From 1d0b7a615b6e94facd0e6b7f5807ab416e71c6fa Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Thu, 29 Jan 2026 23:43:54 +0100 Subject: [PATCH] descriptor fixed --- examples/VulkanAnimation/main.cpp | 21 +++++++++++++-------- examples/VulkanTriangle/main.cpp | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/VulkanAnimation/main.cpp b/examples/VulkanAnimation/main.cpp index 9238e88..e9e71d0 100644 --- a/examples/VulkanAnimation/main.cpp +++ b/examples/VulkanAnimation/main.cpp @@ -16,15 +16,15 @@ int main() { This must be called before any vulkan related things. Things like VkDevice are static members of the VulkanDevice class. */ - VulkanDevice::CreateDevice(); + VulkanDevice::CreateDevice(); Raygenspv::CreateShader(); Closesthitspv::CreateShader(); Misspv::CreateShader(); - DescriptorLayoutVulkan::Init(); - PipelineRTVulkan::Init(); - DescriptorPool<1, Raygenspv, Closesthitspv, Misspv> pool; - pool.setsCount = 2; - pool.BuildPool(0); + std::array layouts {{Raygenspv::layout, Raygenspv::layout, Raygenspv::layout}}; + PipelineRTVulkan::Init(layouts); + DescriptorPool pool; + pool.sets.resize(3); + pool.BuildPool(DescriptorPool::GetPoolSizes(), layouts); WindowVulkan window(1280, 720, "HelloVulkan"); @@ -41,12 +41,13 @@ int main() { RenderingElement3DVulkan& el = RenderingElement3DVulkan::elements.emplace_back(triangleMesh); MatrixRowMajor transform = MatrixRowMajor::Identity(); std::memcpy(el.instance.transform.matrix, transform.m, sizeof(transform.m)); - RenderingElement3DVulkan::tlases.resize(2); + RenderingElement3DVulkan::tlases.resize(3); window.SetPipelineRT(); - window.descriptorsRt = pool.sets; RenderingElement3DVulkan::BuildTLAS(cmd, 0); + RenderingElement3DVulkan::BuildTLAS(cmd, 1); + RenderingElement3DVulkan::BuildTLAS(cmd, 2); VkDescriptorImageInfo imageInfo = { .imageView = window.imageViews[0], .imageLayout = VK_IMAGE_LAYOUT_GENERAL @@ -79,6 +80,7 @@ int main() { } }; vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr); + window.descriptorsRt = {pool.sets[0]}; /* FinishInit executes all commands recorded to StartInit. @@ -87,6 +89,7 @@ int main() { window.FinishInit(); EventListener updateListener(&window.onRender, [&](VkCommandBuffer cmd){ + std::cout << window.currentBuffer << std::endl; RenderingElement3DVulkan::BuildTLAS(cmd, window.currentBuffer); VkDescriptorImageInfo imageInfo = { .imageView = window.imageViews[window.currentBuffer], @@ -120,6 +123,8 @@ int main() { } }; vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr); + + window.descriptorsRt[0] = pool.sets[window.currentBuffer]; }); window.Render(); diff --git a/examples/VulkanTriangle/main.cpp b/examples/VulkanTriangle/main.cpp index 5013de4..b5451ba 100644 --- a/examples/VulkanTriangle/main.cpp +++ b/examples/VulkanTriangle/main.cpp @@ -20,7 +20,7 @@ int main() { Raygenspv::CreateShader(); Closesthitspv::CreateShader(); Misspv::CreateShader(); - std::array layouts {{Raygenspv::layout, Closesthitspv::layout, Misspv::layout}}; + std::array layouts {{Raygenspv::layout}}; PipelineRTVulkan::Init(layouts); DescriptorPool pool; pool.sets.resize(1);