/// <summary> /// Create a new descriptor type binding /// </summary> /// <param name="key">key for this descriptor set</param> /// <param name="layout">what type of data does this descriptor set have?</param> public virtual void InsertKey( string key, API.DescriptorLayout layout ) { if (_handle.ContainsKey(key)) { return; } if (layout == null) { _handle[key] = new DescriptorObject(); return; } var pool = new API.DescriptorPool(layout, 1); _handle[key] = new DescriptorObject { Layout = layout, Pool = pool, Set = new API.DescriptorSet(pool), StagingBuffers = new API.Buffer[layout.Bindings.Count], Buffers = new API.Buffer[layout.Bindings.Count], Images = new API.Image[layout.Bindings.Count], ImageViews = new API.ImageView[layout.Bindings.Count], Samplers = new API.Sampler[layout.Bindings.Count], CommandBuffer = new API.CommandBuffer[layout.Bindings.Count] }; }
public unsafe DescriptorPool(DescriptorLayout layout, uint maxSets) { _device = layout.Device; _layout = layout; _maxSets = maxSets; var poolSizes = new List <VkDescriptorPoolSize>(); foreach (var binding in layout.Bindings) { var poolSizeIndex = poolSizes.FindIndex( p => p.type == binding.DescriptorType ); if (poolSizeIndex == -1) { poolSizes.Add(new VkDescriptorPoolSize { type = binding.DescriptorType, descriptorCount = binding.DescriptorCounts }); } else { poolSizes[poolSizeIndex] = new VkDescriptorPoolSize { type = binding.DescriptorType, descriptorCount = ( poolSizes[poolSizeIndex].descriptorCount + binding.DescriptorCounts ) }; } } var vulkanPoolSizes = new NativeList <VkDescriptorPoolSize>(); foreach (var p in poolSizes) { vulkanPoolSizes.Add(p); } var createInfo = new VkDescriptorPoolCreateInfo { sType = VkStructureType.DescriptorPoolCreateInfo, maxSets = maxSets, poolSizeCount = vulkanPoolSizes.Count, pPoolSizes = (VkDescriptorPoolSize *)vulkanPoolSizes.Data.ToPointer() }; VkDescriptorPool descriptorPool; if (VulkanNative.vkCreateDescriptorPool( _device.Handle, &createInfo, null, &descriptorPool ) != VkResult.Success) { throw new Exception("failed to create descriptor pool"); } _handle = descriptorPool; }