Skip to content

Commit

Permalink
Updates to ensure that changes to maxSlot changes are passed through …
Browse files Browse the repository at this point in the history
…the ViewDependentState.
  • Loading branch information
robertosfield committed Oct 19, 2023
1 parent 073f63d commit fc3d1e5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/vsg/state/ViewDependentState.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace vsg
std::vector<std::pair<dmat4, const SpotLight*>> 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);
Expand Down
2 changes: 2 additions & 0 deletions src/vsg/app/CommandGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

#include <vsg/app/CommandGraph.h>
#include <vsg/app/RenderGraph.h>
#include <vsg/app/View.h>
#include <vsg/state/ViewDependentState.h>
#include <vsg/io/DatabasePager.h>
#include <vsg/ui/ApplicationEvent.h>
#include <vsg/vk/State.h>
Expand Down
17 changes: 13 additions & 4 deletions src/vsg/app/CompileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/core/Exception.h>
#include <vsg/io/Logger.h>
#include <vsg/io/Options.h>
#include <vsg/state/ViewDependentState.h>

using namespace vsg;

Expand Down Expand Up @@ -175,14 +176,22 @@ CompileResult CompileManager::compile(ref_ptr<Object> object, ContextSelectionFu
for (auto& context : compileTraversal->contexts)
{
ref_ptr<View> 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);
}

Expand Down
8 changes: 8 additions & 0 deletions src/vsg/app/CompileTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/vsg/app/RecordAndSubmitTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ VkResult RecordAndSubmitTask::finish(ref_ptr<RecordedCommandBuffers> recordedCom

void vsg::updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> 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)
Expand Down
8 changes: 8 additions & 0 deletions src/vsg/state/ViewDependentState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/vsg/vk/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ ref_ptr<DescriptorSet::Implementation> 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();

Expand Down

0 comments on commit fc3d1e5

Please sign in to comment.