diff --git a/examples/VulkanTriangle/main.cpp b/examples/VulkanTriangle/main.cpp index f10af52..67a29d4 100644 --- a/examples/VulkanTriangle/main.cpp +++ b/examples/VulkanTriangle/main.cpp @@ -15,7 +15,10 @@ int main() { */ VulkanDevice::CreateDevice(); Raygenspv::CreateShader(); - + DescriptorPool<1, Raygenspv> pool; + pool.setsCount = 1; + pool.BuildPool(0); + WindowVulkan window(1280, 720, "HelloVulkan"); /* diff --git a/interfaces/Crafter.Graphics-DescriptorSetVulkan.cppm b/interfaces/Crafter.Graphics-DescriptorSetVulkan.cppm index c4077c5..e976026 100644 --- a/interfaces/Crafter.Graphics-DescriptorSetVulkan.cppm +++ b/interfaces/Crafter.Graphics-DescriptorSetVulkan.cppm @@ -40,6 +40,7 @@ export namespace Crafter { public: inline static Event onDescriptorRefresh; inline static std::uint32_t setIndex = 0; + inline static std::uint32_t setsCount = 0; inline static std::vector sets; inline static VkDescriptorPool descriptorPool[PoolCount] = { VK_NULL_HANDLE }; @@ -116,19 +117,19 @@ export namespace Crafter { public: static void BuildPool(std::uint32_t poolIndex) { if(descriptorPool[poolIndex] != VK_NULL_HANDLE) { - vkDestroyDescriptorPool(VulkanDevice::device, descriptorPool, nullptr); + vkDestroyDescriptorPool(VulkanDevice::device, descriptorPool[poolIndex], nullptr); } std::array poolSizes = GetPoolSizes(); for(VkDescriptorPoolSize& size : poolSizes) { - size.descriptorCount *= sets.size(); + size.descriptorCount *= setsCount; } VkDescriptorPoolCreateInfo descriptorPoolInfo { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, + .maxSets = static_cast(setsCount), .poolSizeCount = uniqueDescriptorCount, - .pPoolSizes = poolSizes.data(), - .maxSets = sets.size() + .pPoolSizes = poolSizes.data() }; VulkanDevice::CheckVkResult(vkCreateDescriptorPool(VulkanDevice::device, &descriptorPoolInfo, nullptr, &descriptorPool[poolIndex])); @@ -141,8 +142,8 @@ export namespace Crafter { constexpr std::array setLayoutBindingsMesh = GetDescriptorSet(); VkDescriptorSetLayoutCreateInfo descriptorLayoutInfoMesh = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - .pBindings = setLayoutBindingsMesh.data(), - .bindingCount = Shaders::descriptorCount + .bindingCount = Shaders::descriptorCount, + .pBindings = setLayoutBindingsMesh.data() }; VulkanDevice::CheckVkResult(vkCreateDescriptorSetLayout(VulkanDevice::device, &descriptorLayoutInfoMesh, nullptr, &descriptorSetLayout[shaderIndex++])); }(), @@ -151,10 +152,11 @@ export namespace Crafter { VkDescriptorSetAllocateInfo allocInfo { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, .descriptorPool = descriptorPool[poolIndex], + .descriptorSetCount = setsCount, .pSetLayouts = descriptorSetLayout, - .descriptorSetCount = sets.size() }; + sets.resize(setsCount); VulkanDevice::CheckVkResult(vkAllocateDescriptorSets(VulkanDevice::device, &allocInfo, sets.data())); setIndex = 0;