descriptor fixed

This commit is contained in:
Jorijn van der Graaf 2026-01-29 23:43:54 +01:00
commit 1d0b7a615b
2 changed files with 14 additions and 9 deletions

View file

@ -16,15 +16,15 @@ int main() {
This must be called before any vulkan related things. This must be called before any vulkan related things.
Things like VkDevice are static members of the VulkanDevice class. Things like VkDevice are static members of the VulkanDevice class.
*/ */
VulkanDevice::CreateDevice(); VulkanDevice::CreateDevice();
Raygenspv::CreateShader(); Raygenspv::CreateShader();
Closesthitspv::CreateShader(); Closesthitspv::CreateShader();
Misspv::CreateShader(); Misspv::CreateShader();
DescriptorLayoutVulkan<Raygenspv, Closesthitspv, Misspv>::Init(); std::array<VkDescriptorSetLayout, 3> layouts {{Raygenspv::layout, Raygenspv::layout, Raygenspv::layout}};
PipelineRTVulkan<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>::Init(); PipelineRTVulkan<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>::Init(layouts);
DescriptorPool<1, Raygenspv, Closesthitspv, Misspv> pool; DescriptorPool pool;
pool.setsCount = 2; pool.sets.resize(3);
pool.BuildPool(0); pool.BuildPool(DescriptorPool::GetPoolSizes<Raygenspv, Raygenspv, Raygenspv>(), layouts);
WindowVulkan window(1280, 720, "HelloVulkan"); WindowVulkan window(1280, 720, "HelloVulkan");
@ -41,12 +41,13 @@ int main() {
RenderingElement3DVulkan& el = RenderingElement3DVulkan::elements.emplace_back(triangleMesh); RenderingElement3DVulkan& el = RenderingElement3DVulkan::elements.emplace_back(triangleMesh);
MatrixRowMajor<float, 4, 3, 1> transform = MatrixRowMajor<float, 4, 3, 1>::Identity(); MatrixRowMajor<float, 4, 3, 1> transform = MatrixRowMajor<float, 4, 3, 1>::Identity();
std::memcpy(el.instance.transform.matrix, transform.m, sizeof(transform.m)); std::memcpy(el.instance.transform.matrix, transform.m, sizeof(transform.m));
RenderingElement3DVulkan::tlases.resize(2); RenderingElement3DVulkan::tlases.resize(3);
window.SetPipelineRT<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>(); window.SetPipelineRT<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>();
window.descriptorsRt = pool.sets;
RenderingElement3DVulkan::BuildTLAS(cmd, 0); RenderingElement3DVulkan::BuildTLAS(cmd, 0);
RenderingElement3DVulkan::BuildTLAS(cmd, 1);
RenderingElement3DVulkan::BuildTLAS(cmd, 2);
VkDescriptorImageInfo imageInfo = { VkDescriptorImageInfo imageInfo = {
.imageView = window.imageViews[0], .imageView = window.imageViews[0],
.imageLayout = VK_IMAGE_LAYOUT_GENERAL .imageLayout = VK_IMAGE_LAYOUT_GENERAL
@ -79,6 +80,7 @@ int main() {
} }
}; };
vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr); vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr);
window.descriptorsRt = {pool.sets[0]};
/* /*
FinishInit executes all commands recorded to StartInit. FinishInit executes all commands recorded to StartInit.
@ -87,6 +89,7 @@ int main() {
window.FinishInit(); window.FinishInit();
EventListener<VkCommandBuffer> updateListener(&window.onRender, [&](VkCommandBuffer cmd){ EventListener<VkCommandBuffer> updateListener(&window.onRender, [&](VkCommandBuffer cmd){
std::cout << window.currentBuffer << std::endl;
RenderingElement3DVulkan::BuildTLAS(cmd, window.currentBuffer); RenderingElement3DVulkan::BuildTLAS(cmd, window.currentBuffer);
VkDescriptorImageInfo imageInfo = { VkDescriptorImageInfo imageInfo = {
.imageView = window.imageViews[window.currentBuffer], .imageView = window.imageViews[window.currentBuffer],
@ -120,6 +123,8 @@ int main() {
} }
}; };
vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr); vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr);
window.descriptorsRt[0] = pool.sets[window.currentBuffer];
}); });
window.Render(); window.Render();

View file

@ -20,7 +20,7 @@ int main() {
Raygenspv::CreateShader(); Raygenspv::CreateShader();
Closesthitspv::CreateShader(); Closesthitspv::CreateShader();
Misspv::CreateShader(); Misspv::CreateShader();
std::array<VkDescriptorSetLayout, 3> layouts {{Raygenspv::layout, Closesthitspv::layout, Misspv::layout}}; std::array<VkDescriptorSetLayout, 1> layouts {{Raygenspv::layout}};
PipelineRTVulkan<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>::Init(layouts); PipelineRTVulkan<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>::Init(layouts);
DescriptorPool pool; DescriptorPool pool;
pool.sets.resize(1); pool.sets.resize(1);