private static VkDescriptorPool CreateDescriptorPool(VkDevice device, uint swapchainImageCount, uint textureCount) { VkDescriptorPoolSize[] sizes = new VkDescriptorPoolSize[2]; sizes[0] = new VkDescriptorPoolSize(); sizes[0].descriptorCount = swapchainImageCount * textureCount; sizes[0].type = VkDescriptorType.CombinedImageSampler; sizes[1] = new VkDescriptorPoolSize(); sizes[1].descriptorCount = swapchainImageCount * 1; sizes[1].type = VkDescriptorType.UniformBuffer; VkDescriptorPoolCreateInfo createInfo = VkDescriptorPoolCreateInfo.New(); createInfo.poolSizeCount = 2; fixed(VkDescriptorPoolSize *ptr = sizes) createInfo.pPoolSizes = ptr; createInfo.maxSets = swapchainImageCount; VkDescriptorPool pool = VkDescriptorPool.Null; Assert(vkCreateDescriptorPool(device, &createInfo, null, &pool)); return(pool); }
private VkDescriptorPool CreateDescriptorPool() { VkDescriptorPoolSize *descriptorPoolSizePtr = stackalloc VkDescriptorPoolSize[2] { new VkDescriptorPoolSize { type = VkDescriptorType.UniformBuffer, descriptorCount = 1 }, new VkDescriptorPoolSize { type = VkDescriptorType.CombinedImageSampler, descriptorCount = 1 } }; var createInfo = new VkDescriptorPoolCreateInfo() { sType = VkStructureType.DescriptorPoolCreateInfo, pNext = null, poolSizeCount = 2, pPoolSizes = descriptorPoolSizePtr, maxSets = 2 }; VkDescriptorPool descriptorPool; vkCreateDescriptorPool(Context.Device, &createInfo, null, out descriptorPool).CheckResult(); return(descriptorPool); }
private unsafe PoolInfo CreateNewPool() { uint totalSets = 1000; uint descriptorCount = 256; uint poolSizeCount = MAX_DESCRIPTOR_COUNT; VkDescriptorPoolSize *sizes = stackalloc VkDescriptorPoolSize[(int)poolSizeCount]; for (int i = 0; i < MAX_DESCRIPTOR_COUNT; i++) { sizes[i].type = descriptorTypes[i]; sizes[i].descriptorCount = descriptorCount; } VkDescriptorPoolInlineUniformBlockCreateInfoEXT descriptorPoolInlineUniformBlockCreateInfo = new VkDescriptorPoolInlineUniformBlockCreateInfoEXT { sType = VkStructureType.DescriptorPoolInlineUniformBlockCreateInfoEXT, maxInlineUniformBlockBindings = totalSets }; var poolCI = new VkDescriptorPoolCreateInfo { sType = VkStructureType.DescriptorPoolCreateInfo, flags = VkDescriptorPoolCreateFlags.FreeDescriptorSet, poolSizeCount = poolSizeCount, maxSets = totalSets, pPoolSizes = sizes, pNext = &descriptorPoolInlineUniformBlockCreateInfo }; var descriptorPool = Device.CreateDescriptorPool(ref poolCI); return(new PoolInfo(descriptorPool, totalSets, descriptorCount)); }
public DescriptorPool(Device dev, VkDescriptorPoolCreateFlag flags, uint maxSets, Dictionary <VkDescriptorType, uint> countByType) { unsafe { var pools = stackalloc VkDescriptorPoolSize[countByType.Count]; var i = 0; foreach (var kv in countByType) { pools[i++] = new VkDescriptorPoolSize() { Type = kv.Key, DescriptorCount = kv.Value } } ; Device = dev; var info = new VkDescriptorPoolCreateInfo() { SType = VkStructureType.DescriptorPoolCreateInfo, Flags = flags, MaxSets = maxSets, PNext = IntPtr.Zero, PoolSizeCount = (uint)countByType.Count, PPoolSizes = pools }; Handle = dev.Handle.CreateDescriptorPool(&info, dev.Instance.AllocationCallbacks); } }
private unsafe PoolInfo CreateNewPool() { uint totalSets = 1000; uint descriptorCount = 100; uint poolSizeCount = 7; VkDescriptorPoolSize *sizes = stackalloc VkDescriptorPoolSize[(int)poolSizeCount]; sizes[0].type = VkDescriptorType.UniformBuffer; sizes[0].descriptorCount = descriptorCount; sizes[1].type = VkDescriptorType.SampledImage; sizes[1].descriptorCount = descriptorCount; sizes[2].type = VkDescriptorType.Sampler; sizes[2].descriptorCount = descriptorCount; sizes[3].type = VkDescriptorType.StorageBuffer; sizes[3].descriptorCount = descriptorCount; sizes[4].type = VkDescriptorType.StorageImage; sizes[4].descriptorCount = descriptorCount; sizes[5].type = VkDescriptorType.UniformBufferDynamic; sizes[5].descriptorCount = descriptorCount; sizes[6].type = VkDescriptorType.StorageBufferDynamic; sizes[6].descriptorCount = descriptorCount; VkDescriptorPoolCreateInfo poolCI = VkDescriptorPoolCreateInfo.New(); poolCI.flags = VkDescriptorPoolCreateFlags.FreeDescriptorSet; poolCI.maxSets = totalSets; poolCI.pPoolSizes = sizes; poolCI.poolSizeCount = poolSizeCount; VkResult result = vkCreateDescriptorPool(_gd.Device, ref poolCI, null, out VkDescriptorPool descriptorPool); VulkanUtil.CheckResult(result); return(new PoolInfo(descriptorPool, totalSets, descriptorCount)); }
public VkResourceCache(VkDevice device, VkSamplerState defaultSamplerState) { _device = device; _defaultSamplerState = defaultSamplerState; VkDescriptorPoolSize *sizes = stackalloc VkDescriptorPoolSize[3]; sizes[0].type = VkDescriptorType.UniformBuffer; sizes[0].descriptorCount = 50000; sizes[1].type = VkDescriptorType.SampledImage; sizes[1].descriptorCount = 15000; sizes[2].type = VkDescriptorType.Sampler; sizes[2].descriptorCount = 15000; VkDescriptorPoolCreateInfo descriptorPoolCI = VkDescriptorPoolCreateInfo.New(); descriptorPoolCI.flags = VkDescriptorPoolCreateFlags.FreeDescriptorSet; descriptorPoolCI.maxSets = 15000; descriptorPoolCI.pPoolSizes = sizes; descriptorPoolCI.poolSizeCount = 3; VkResult result = vkCreateDescriptorPool(_device, ref descriptorPoolCI, null, out _descriptorPool); CheckResult(result); }
VkDescriptorSet CreateDescriptorSet(VkDevice device, VkDescriptorSetLayout descriptorSetLayout) { VkDescriptorPool descriptorPool; { // this pool can allocate one uniform descriptor. var info = new VkDescriptorPoolCreateInfo { sType = VkStructureType.DescriptorPoolCreateInfo }; var size = new VkDescriptorPoolSize(VkDescriptorType.UniformBuffer, 1); info.poolSizes = size; info.maxSets = 1; vkAPI.vkCreateDescriptorPool(device, &info, null, &descriptorPool).Check(); info.Free(); } VkDescriptorSet descriptorSet; { var info = new VkDescriptorSetAllocateInfo { sType = VkStructureType.DescriptorSetAllocateInfo }; info.setLayouts = descriptorSetLayout; info.descriptorPool = descriptorPool; vkAPI.vkAllocateDescriptorSets(device, &info, &descriptorSet).Check(); info.Free(); } return(descriptorSet); }
public VkDescriptorPool CreateDescriptorPool(VkDevice device, VkDescriptorPoolSize[] descPoolSize, int maxSets) { var descriptorPoolCreateInfo = new VkDescriptorPoolCreateInfo() { poolSizes = descPoolSize, maxSets = (uint)maxSets, flags = VkDescriptorPoolCreateFlags.VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, }; VulkanAPI.vkCreateDescriptorPool(device, ref descriptorPoolCreateInfo, out m_descriptorPool); return(m_descriptorPool); }
private void PrepareDescriptor(VkDevice device) { // 定数バッファを1つだけ持つものを作る. VkDescriptorPoolSize descriptorPoolSize = new VkDescriptorPoolSize() { descriptorCount = 1, type = VkDescriptorType.VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, }; var descriptorPoolCreateInfo = new VkDescriptorPoolCreateInfo() { poolSizes = new[] { descriptorPoolSize }, maxSets = 1, flags = VkDescriptorPoolCreateFlags.VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, }; VulkanAPI.vkCreateDescriptorPool(device, ref descriptorPoolCreateInfo, out m_descriptorPool); // ディスクリプタセットレイアウトの作成. // 今は定数バッファを1つ持つだけのものを作成. var descriptorLayoutBinding = new VkDescriptorSetLayoutBinding(); descriptorLayoutBinding.binding = 0; descriptorLayoutBinding.descriptorCount = 1; descriptorLayoutBinding.descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; descriptorLayoutBinding.stageFlags = VkShaderStageFlagBits.VK_SHADER_STAGE_VERTEX_BIT; var descriptorSetLayoutCreateInfo = new VkDescriptorSetLayoutCreateInfo(); descriptorSetLayoutCreateInfo.bindings = new[] { descriptorLayoutBinding }; VulkanAPI.vkCreateDescriptorSetLayout(device, ref descriptorSetLayoutCreateInfo, out m_descriptorSetLayout); // ディスクリプタセットを作成. VkDescriptorSet[] descriptorSets; var descriptorSetAllocateInfo = new VkDescriptorSetAllocateInfo(m_descriptorPool, new[] { m_descriptorSetLayout }); VulkanAPI.vkAllocateDescriptorSets(device, ref descriptorSetAllocateInfo, out descriptorSets); m_descriptorSet = descriptorSets[0]; // ディスクリプタを更新. // 定数バッファ1つを持つレイアウトでディスクリプタを作る. VkDescriptorBufferInfo descUniformBufferInfo = new VkDescriptorBufferInfo(); descUniformBufferInfo.buffer = m_uniformBuffer; descUniformBufferInfo.range = Marshal.SizeOf <Transform>(); var descriptor = new VkWriteDescriptorSet(); descriptor.descriptorCount = 1; descriptor.descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; descriptor.pBufferInfo = new[] { descUniformBufferInfo }; descriptor.dstBinding = 0; descriptor.dstSet = m_descriptorSet; VulkanAPI.vkUpdateDescriptorSets(device, new[] { descriptor }, null); }
public static VkDescriptorPoolCreateInfo descriptorPoolCreateInfo( uint poolSizeCount, VkDescriptorPoolSize *pPoolSizes, uint maxSets) { VkDescriptorPoolCreateInfo descriptorPoolInfo = VkDescriptorPoolCreateInfo.New(); descriptorPoolInfo.poolSizeCount = poolSizeCount; descriptorPoolInfo.pPoolSizes = pPoolSizes; descriptorPoolInfo.maxSets = maxSets; return(descriptorPoolInfo); }
void setupDescriptorPool() { // Example uses one ubo VkDescriptorPoolSize poolSizes = Initializers.descriptorPoolSize(VkDescriptorType.UniformBuffer, 1); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( 1, &poolSizes, 2); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
public override void Activate() { if (state != ActivableState.Activated) { VkDescriptorPoolCreateInfo info = VkDescriptorPoolCreateInfo.New(); info.poolSizeCount = (uint)PoolSizes.Count; info.pPoolSizes = PoolSizes.Pin(); info.maxSets = MaxSets; Utils.CheckResult(vkCreateDescriptorPool(Dev.VkDev, ref info, IntPtr.Zero, out handle)); PoolSizes.Unpin(); } base.Activate(); }
void setupDescriptorPool() { FixedArray2<VkDescriptorPoolSize> poolSizes = new FixedArray2<VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VkDescriptorType.UniformBuffer, 2), Initializers.descriptorPoolSize(VkDescriptorType.CombinedImageSampler, 2)); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( poolSizes.Count, &poolSizes.First, 2); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
void setupDescriptorPool() { FixedArray2 <VkDescriptorPoolSize> poolSizes = new FixedArray2 <VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1), Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1)); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( (uint)(poolSizes.Count), &poolSizes.First, 1); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
protected virtual void SetupDescriptorPool(Pipeline pipeline, GraphicsDevice device) { // Example uses one ubo and one combined image sampler FixedArray2 <VkDescriptorPoolSize> poolSizes = new FixedArray2 <VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VkDescriptorType.UniformBuffer, 1), Initializers.descriptorPoolSize(VkDescriptorType.CombinedImageSampler, 1)); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( poolSizes.Count, &poolSizes.First, 1); Util.CheckResult(vkCreateDescriptorPool(device.device, &descriptorPoolInfo, null, out pipeline.descriptorPool)); }
void setupDescriptorPool() { // Example uses one ubo and one combined image sampler FixedArray2 <VkDescriptorPoolSize> poolSizes = new FixedArray2 <VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VkDescriptorType.UniformBuffer, 1), Initializers.descriptorPoolSize(VkDescriptorType.CombinedImageSampler, 1)); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( poolSizes.Count, &poolSizes.First, 1); Util.CheckResult(vkCreateDescriptorPool(Device, &descriptorPoolInfo, null, out descriptorPool)); }
void setupDescriptorPool() { // Example uses one ubo and one image sampler FixedArray3 <VkDescriptorPoolSize> poolSizes = new FixedArray3 <VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1), Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1), Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1)); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( (uint)(poolSizes.Count), &poolSizes.First, 2); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
void CreateDescriptorPool() { var poolSize = new VkDescriptorPoolSize(); poolSize.type = VkDescriptorType.UniformBuffer; poolSize.descriptorCount = 1; var info = new VkDescriptorPoolCreateInfo(); info.poolSizes = new List <VkDescriptorPoolSize> { poolSize }; info.maxSets = 1; descriptorPool = new VkDescriptorPool(device, info); }
void setupDescriptorPool() { // Example uses one ubo and one image sampler FixedArray2 <VkDescriptorPoolSize> poolSizes = new FixedArray2 <VkDescriptorPoolSize>( Initializers.descriptorPoolSize(VkDescriptorType.UniformBuffer, 1), Initializers.descriptorPoolSize(VkDescriptorType.CombinedImageSampler, 1) ); VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( poolSizes.Count, (VkDescriptorPoolSize *)Unsafe.AsPointer(ref poolSizes), 2); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
void setupDescriptorPool() { VkDescriptorPoolSize poolSizes = new VkDescriptorPoolSize() { type = VkDescriptorType.UniformBuffer, descriptorCount = 1 }; VkDescriptorPoolCreateInfo descriptorPoolInfo = VkDescriptorPoolCreateInfo.New(); descriptorPoolInfo.poolSizeCount = 1; descriptorPoolInfo.pPoolSizes = &poolSizes; descriptorPoolInfo.maxSets = 2; Util.CheckResult(vkCreateDescriptorPool(Device, &descriptorPoolInfo, null, out descriptorPool)); }
void setupDescriptorPool() { // Example uses three ubos and one image sampler NativeList <VkDescriptorPoolSize> poolSizes = new NativeList <VkDescriptorPoolSize> { Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 4), Initializers.descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 6) }; VkDescriptorPoolCreateInfo descriptorPoolInfo = Initializers.descriptorPoolCreateInfo( poolSizes.Count, (VkDescriptorPoolSize *)poolSizes.Data, 2); Util.CheckResult(vkCreateDescriptorPool(device, &descriptorPoolInfo, null, out descriptorPool)); }
void setupDescriptorPool() { // Example uses one ubo and one image sampler var poolSizes = new VkDescriptorPoolSize[2]; poolSizes[0].type = VkDescriptorType.UniformBuffer; poolSizes[0].descriptorCount = 1; poolSizes[1].type = VkDescriptorType.CombinedImageSampler; poolSizes[1].descriptorCount = 1; var poolInfo = VkDescriptorPoolCreateInfo.Alloc(); poolInfo[0].poolSizes = poolSizes; poolInfo[0].maxSets = 2; { VkDescriptorPool pool; vkCreateDescriptorPool(device, poolInfo, null, &pool); descriptorPool = pool; } }
void setupDescriptorPool() { // Example uses one ubo and one image sampler var poolSizes = new VkDescriptorPoolSize[] { new VkDescriptorPoolSize(VkDescriptorType.UniformBuffer, 1), new VkDescriptorPoolSize(VkDescriptorType.UniformBufferDynamic, 1), new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler, 1), }; var info = new VkDescriptorPoolCreateInfo(); info.sType = DescriptorPoolCreateInfo; info.poolSizes = poolSizes; info.maxSets = 2; VkDescriptorPool pool; vkCreateDescriptorPool(device, &info, null, &pool); this.descriptorPool = pool; }
void setupDescriptorPool() { // Example uses three ubos and one image sampler var poolSizes = new VkDescriptorPoolSize[2]; poolSizes[0].type = VkDescriptorType.UniformBuffer; poolSizes[0].descriptorCount = 4; poolSizes[1].type = VkDescriptorType.CombinedImageSampler; poolSizes[1].descriptorCount = 6; var descriptorPoolInfo = VkDescriptorPoolCreateInfo.Alloc(); descriptorPoolInfo->poolSizes = poolSizes; descriptorPoolInfo->maxSets = 2; VkDescriptorPool pool; vkCreateDescriptorPool(device, descriptorPoolInfo, null, &pool); this.descriptorPool = pool; Marshal.FreeHGlobal((IntPtr)descriptorPoolInfo); }
protected override unsafe VkDescriptorPool CreateObject() { // No allocator ready to be used, let's create a new one var poolSizes = GraphicsDevice.MaxDescriptorTypeCounts .Select((count, index) => new VkDescriptorPoolSize { type = (VkDescriptorType)index, descriptorCount = count }) .Where(size => size.descriptorCount > 0) .ToArray(); var descriptorPoolCreateInfo = new VkDescriptorPoolCreateInfo { sType = VkStructureType.DescriptorPoolCreateInfo, poolSizeCount = (uint)poolSizes.Length, pPoolSizes = (VkDescriptorPoolSize *)Core.Interop.Fixed(poolSizes), maxSets = GraphicsDevice.MaxDescriptorSetCount, }; vkCreateDescriptorPool(GraphicsDevice.NativeDevice, &descriptorPoolCreateInfo, null, out var descriptorPool); return(descriptorPool); }
public DescriptorPool(Device dev, VkDescriptorPoolCreateFlag flags, uint maxSets, Span <VkDescriptorPoolSize> pools) { unsafe { Device = dev; fixed(VkDescriptorPoolSize *pPools = &pools.DangerousGetPinnableReference()) { var info = new VkDescriptorPoolCreateInfo() { SType = VkStructureType.DescriptorPoolCreateInfo, Flags = flags, MaxSets = maxSets, PNext = IntPtr.Zero, PoolSizeCount = (uint)pools.Length, PPoolSizes = pPools }; Handle = dev.Handle.CreateDescriptorPool(&info, dev.Instance.AllocationCallbacks); } } }
private void CreateDescriptorPool() { VkDescriptorPoolSize *sizes = stackalloc VkDescriptorPoolSize[3]; sizes[0].type = VkDescriptorType.UniformBuffer; sizes[0].descriptorCount = 5000; sizes[1].type = VkDescriptorType.SampledImage; sizes[1].descriptorCount = 5000; sizes[2].type = VkDescriptorType.Sampler; sizes[2].descriptorCount = 5000; VkDescriptorPoolCreateInfo descriptorPoolCI = VkDescriptorPoolCreateInfo.New(); descriptorPoolCI.flags = VkDescriptorPoolCreateFlags.FreeDescriptorSet; descriptorPoolCI.maxSets = 5000; descriptorPoolCI.pPoolSizes = sizes; descriptorPoolCI.poolSizeCount = 3; VkResult result = vkCreateDescriptorPool(_device, ref descriptorPoolCI, null, out _descriptorPool); CheckResult(result); }
void CreateDescriptorPool() { var size1 = new VkDescriptorPoolSize(); size1.type = VkDescriptorType.UniformBuffer; size1.descriptorCount = 1; var size2 = new VkDescriptorPoolSize(); size2.type = VkDescriptorType.CombinedImageSampler; size2.descriptorCount = 1; var poolSizes = new List <VkDescriptorPoolSize> { size1, size2 }; var info = new VkDescriptorPoolCreateInfo(); info.poolSizes = poolSizes; info.maxSets = 1; descriptorPool = new VkDescriptorPool(device, info); }
void CreateDescriptorPool(DescriptorPoolCreateInfo mInfo) { var info = new VkDescriptorPoolCreateInfo(); info.sType = VkStructureType.DescriptorPoolCreateInfo; info.flags = mInfo.flags; info.maxSets = mInfo.maxSets; var poolSizesMarshalled = new NativeArray <VkDescriptorPoolSize>(mInfo.poolSizes); info.poolSizeCount = (uint)poolSizesMarshalled.Count; info.pPoolSizes = poolSizesMarshalled.Address; using (poolSizesMarshalled) { var result = Device.Commands.createDescriptorPool(Device.Native, ref info, Device.Instance.AllocationCallbacks, out descriptorPool); if (result != VkResult.Success) { throw new DescriptorPoolException(string.Format("Error creating descriptor pool: {0}", result)); } } Flags = mInfo.flags; }
public static extern VkResult CreateDescriptorPool( VkDevice device, ref VkDescriptorPoolCreateInfo pCreateInfo, IntPtr pAllocator, out VkDescriptorPool pDescriptorPool );