Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public VkFence(VkGraphicsDevice gd, bool signaled)
        {
            _gd = gd;
            VkFenceCreateInfo fenceCI = VkFenceCreateInfo.New();

            fenceCI.flags = signaled ? VkFenceCreateFlags.Signaled : VkFenceCreateFlags.None;
            VkResult result = vkCreateFence(_gd.Device, ref fenceCI, null, out _fence);

            VulkanUtil.CheckResult(result);
        }
        public unsafe DescriptorAllocationToken Allocate(DescriptorResourceCounts counts, VkDescriptorSetLayout setLayout)
        {
            VkDescriptorPool            pool = GetPool(counts);
            VkDescriptorSetAllocateInfo dsAI = VkDescriptorSetAllocateInfo.New();

            dsAI.descriptorSetCount = 1;
            dsAI.pSetLayouts        = &setLayout;
            dsAI.descriptorPool     = pool;
            VkResult result = vkAllocateDescriptorSets(_gd.Device, ref dsAI, out VkDescriptorSet set);

            VulkanUtil.CheckResult(result);

            return(new DescriptorAllocationToken(set, pool));
        }