Пример #1
0
        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);
        }
Пример #2
0
        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));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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();
        }
Пример #6
0
        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));
        }
Пример #7
0
        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);
        }