From fc3d1e5ea5645efa7de12c58fff5ab38abf67d88 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 19 Oct 2023 18:17:01 +0100 Subject: [PATCH] Updates to ensure that changes to maxSlot changes are passed through the ViewDependentState. --- include/vsg/state/ViewDependentState.h | 1 + src/vsg/app/CommandGraph.cpp | 2 ++ src/vsg/app/CompileManager.cpp | 17 +++++++++++++---- src/vsg/app/CompileTraversal.cpp | 8 ++++++++ src/vsg/app/RecordAndSubmitTask.cpp | 2 +- src/vsg/state/ViewDependentState.cpp | 8 ++++++++ src/vsg/vk/Context.cpp | 5 +++++ 7 files changed, 38 insertions(+), 5 deletions(-) diff --git a/include/vsg/state/ViewDependentState.h b/include/vsg/state/ViewDependentState.h index 7e674d977..7b0840d39 100644 --- a/include/vsg/state/ViewDependentState.h +++ b/include/vsg/state/ViewDependentState.h @@ -124,6 +124,7 @@ namespace vsg std::vector> spotLights; virtual void init(ResourceRequirements& requirements); + virtual void update(ResourceRequirements& requirements); virtual void clear(); virtual void bindDescriptorSets(CommandBuffer& commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet); diff --git a/src/vsg/app/CommandGraph.cpp b/src/vsg/app/CommandGraph.cpp index ab45b646c..b12812119 100644 --- a/src/vsg/app/CommandGraph.cpp +++ b/src/vsg/app/CommandGraph.cpp @@ -12,6 +12,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include +#include +#include #include #include #include diff --git a/src/vsg/app/CompileManager.cpp b/src/vsg/app/CompileManager.cpp index 4127bbe9e..f52cfd70c 100644 --- a/src/vsg/app/CompileManager.cpp +++ b/src/vsg/app/CompileManager.cpp @@ -16,6 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include using namespace vsg; @@ -175,14 +176,22 @@ CompileResult CompileManager::compile(ref_ptr object, ContextSelectionFu for (auto& context : compileTraversal->contexts) { ref_ptr view = context->view; - if (view && !viewDetailsStack.empty()) + + if (view) { - if (auto itr = result.views.find(view.get()); itr == result.views.end()) + if (view->viewDependentState) { - result.views[view] = viewDetailsStack.top(); + view->viewDependentState->update(requirements); } - } + if (!viewDetailsStack.empty()) + { + if (auto itr = result.views.find(view.get()); itr == result.views.end()) + { + result.views[view] = viewDetailsStack.top(); + } + } + } context->reserve(requirements); } diff --git a/src/vsg/app/CompileTraversal.cpp b/src/vsg/app/CompileTraversal.cpp index ad38fe6d0..fa1826998 100644 --- a/src/vsg/app/CompileTraversal.cpp +++ b/src/vsg/app/CompileTraversal.cpp @@ -275,6 +275,14 @@ void CompileTraversal::apply(CommandGraph& commandGraph) } }; + for(auto& context : contexts) + { + if (context->resourceRequirements.maxSlot > commandGraph.maxSlot) + { + commandGraph.maxSlot = context->resourceRequirements.maxSlot; + } + } + if (commandGraph.framebuffer) { traverseRenderedSubgraph(commandGraph.framebuffer->getRenderPass(), commandGraph.framebuffer->extent2D()); diff --git a/src/vsg/app/RecordAndSubmitTask.cpp b/src/vsg/app/RecordAndSubmitTask.cpp index 538696ba4..039aaabbd 100644 --- a/src/vsg/app/RecordAndSubmitTask.cpp +++ b/src/vsg/app/RecordAndSubmitTask.cpp @@ -202,7 +202,7 @@ VkResult RecordAndSubmitTask::finish(ref_ptr recordedCom void vsg::updateTasks(RecordAndSubmitTasks& tasks, ref_ptr compileManager, const CompileResult& compileResult) { - //info("vsg::updateTasks(RecordAndSubmitTasks& tasks..) "); + //info("vsg::updateTasks(RecordAndSubmitTasks& tasks..) compileResult.maxSlot = ", compileResult.maxSlot); if (compileResult.earlyDynamicData || compileResult.lateDynamicData) { for (auto& task : tasks) diff --git a/src/vsg/state/ViewDependentState.cpp b/src/vsg/state/ViewDependentState.cpp index 853b72743..c25d32f7b 100644 --- a/src/vsg/state/ViewDependentState.cpp +++ b/src/vsg/state/ViewDependentState.cpp @@ -365,6 +365,14 @@ void ViewDependentState::init(ResourceRequirements& requirements) } } +void ViewDependentState::update(ResourceRequirements& requirements) +{ + if (preRenderCommandGraph && requirements.maxSlot > preRenderCommandGraph->maxSlot) + { + preRenderCommandGraph->maxSlot = requirements.maxSlot; + } +} + void ViewDependentState::compile(Context& context) { descriptorSet->compile(context); diff --git a/src/vsg/vk/Context.cpp b/src/vsg/vk/Context.cpp index f4184cf59..47646470d 100644 --- a/src/vsg/vk/Context.cpp +++ b/src/vsg/vk/Context.cpp @@ -205,6 +205,11 @@ ref_ptr Context::allocateDescriptorSet(Descriptor void Context::reserve(const ResourceRequirements& requirements) { + if (requirements.maxSlot > resourceRequirements.maxSlot) + { + resourceRequirements.maxSlot = requirements.maxSlot; + } + auto maxSets = requirements.computeNumDescriptorSets(); auto descriptorPoolSizes = requirements.computeDescriptorPoolSizes();