コード例 #1
0
ファイル: ImagePooled.cs プロジェクト: Equinox-/CSharpVulkan
        public ImagePooled(Device dev, VkFormat format, VkImageType type, VkExtent3D size, uint mipLevels,
                           uint arrayLayers, VkImageTiling tiling, VkSampleCountFlag samples, VkImageUsageFlag usage,
                           VkImageCreateFlag flags, VkSharingMode sharing = VkSharingMode.Exclusive, uint[] sharedQueueFamily = null) :
            base(dev, format, type, size, mipLevels, arrayLayers, tiling, samples, usage, flags, sharing,
                 sharedQueueFamily)
        {
            var memReq  = MemoryRequirements;
            var memType = memReq.FindMemoryType(dev.PhysicalDevice);

            Memory = dev.MemoryPool.Allocate(memType, DeviceMemoryPools.Pool.TexturePool, memReq.TypeRequirements.Size);
            BindMemory(Memory.BackingMemory, Memory.Offset);
        }
コード例 #2
0
        public PooledMemoryBuffer(Device dev, VkBufferUsageFlag usage, VkBufferCreateFlag flags, MemoryRequirements req,
                                  ulong size, params uint[] sharedQueueFamilies) :
            base(dev, usage, flags, size, sharedQueueFamilies)
        {
            var pool = Size >= DeviceMemoryPools.BlockSizeForPool(DeviceMemoryPools.Pool.LargeBufferPool)
                ? DeviceMemoryPools.Pool.LargeBufferPool
                : DeviceMemoryPools.Pool.SmallBufferPool;
            var reqs = MemoryRequirements.Union(MemoryRequirements, req);
            var type = reqs.FindMemoryType(PhysicalDevice);

            _memory = Device.MemoryPool.Allocate(type, pool, reqs.TypeRequirements.Size);
            BindMemory(_memory.BackingMemory, _memory.Offset);
        }
コード例 #3
0
 protected override void Free()
 {
     base.Free();
     _memory.Free();
     _memory = default(DeviceMemoryPools.MemoryHandle);
 }