Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/vsg/app/CompileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace vsg

// forward declare
class RecordAndSubmitTask;
class Viewer;

/// CompileResult struct encapsulates the results of compile traversal.
/// Used to help guide further operations done with the compiled subgraph.
Expand All @@ -36,7 +37,7 @@ namespace vsg

void reset();
void add(const CompileResult& cr);
bool requiresViewerUpdate() const;
bool requiresViewerUpdate(const Viewer* viewer = nullptr) const;
};

/// ResourceScavenger provides a mechanism for releasing and reusing unused resources when allocation of required GPU memory fails.
Expand Down
9 changes: 8 additions & 1 deletion include/vsg/vk/Slots.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ namespace vsg
return view > state ? view : state;
}

void merge(const Slots& rhs)
/// update this Slots object to hold the maximum state and view value of this and rhs Slots objects.
void update(const Slots& rhs)
{
if (rhs.state > state) state = rhs.state;
if (rhs.view > view) view = rhs.view;
}

/// return true if this Slots object is less that rhs Slots object and needs to be updated by calling this Slots::merge(rhs).
bool requiresUpdate(const Slots& rhs) const
{
return rhs.state > state || rhs.view > view;
}
};

} // namespace vsg
16 changes: 14 additions & 2 deletions src/vsg/app/CompileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CompileResult::add(const CompileResult& cr)
result = cr.result;
}

maxSlots.merge(cr.maxSlots);
maxSlots.update(cr.maxSlots);

if (!containsPagedLOD) containsPagedLOD = cr.containsPagedLOD;

Expand All @@ -57,7 +57,7 @@ void CompileResult::add(const CompileResult& cr)
dynamicData.add(cr.dynamicData);
}

bool CompileResult::requiresViewerUpdate() const
bool CompileResult::requiresViewerUpdate(const Viewer* viewer) const
{
if (result == VK_INCOMPLETE) return false;

Expand All @@ -67,6 +67,18 @@ bool CompileResult::requiresViewerUpdate() const
{
if (!binDetails.indices.empty() || !binDetails.bins.empty()) return true;
}

if (viewer)
{
for (const auto& task : viewer->recordAndSubmitTasks)
{
for (const auto& commandGraph : task->commandGraphs)
{
if (commandGraph->maxSlots.requiresUpdate(maxSlots)) return true;
}
}
}

return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/vsg/app/CompileTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void CompileTraversal::apply(CommandGraph& commandGraph)

for (const auto& context : contexts)
{
commandGraph.maxSlots.merge(context->resourceRequirements.maxSlots);
commandGraph.maxSlots.update(context->resourceRequirements.maxSlots);
}

commandGraph.traverse(*this);
Expand All @@ -339,7 +339,7 @@ void CompileTraversal::apply(SecondaryCommandGraph& secondaryCommandGraph)

for (auto& context : contexts)
{
secondaryCommandGraph.maxSlots.merge(context->resourceRequirements.maxSlots);
secondaryCommandGraph.maxSlots.update(context->resourceRequirements.maxSlots);

// save previous states to be restored after traversal
auto previousRenderPass = context->renderPass;
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 @@ -306,7 +306,7 @@ void vsg::updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> compi
{
for (const auto& commandGraph : task->commandGraphs)
{
commandGraph->maxSlots.merge(compileResult.maxSlots);
commandGraph->maxSlots.update(compileResult.maxSlots);
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/vsg/app/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,17 +794,22 @@ void Viewer::update()
{
CPU_INSTRUMENTATION_L1_NC(instrumentation, "Viewer update", COLOR_UPDATE);

CompileResult cr;

// merge any updates from the DatabasePager
for (const auto& task : recordAndSubmitTasks)
{
if (task->databasePager)
{
CompileResult cr;
task->databasePager->updateSceneGraph(_frameStamp, cr);
if (cr.requiresViewerUpdate()) updateViewer(*this, cr);
}
}

if (cr.requiresViewerUpdate(this))
{
updateViewer(*this, cr);
}

// run update operations
updateOperations->run();

Expand Down
2 changes: 1 addition & 1 deletion src/vsg/state/ViewDependentState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void ViewDependentState::update(ResourceRequirements& requirements)
{
if (preRenderCommandGraph)
{
preRenderCommandGraph->maxSlots.merge(requirements.maxSlots);
preRenderCommandGraph->maxSlots.update(requirements.maxSlots);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vsg/vk/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ VkResult Context::reserve(ResourceRequirements& requirements)

if (deviceMemoryBufferPools->compileTraversalUseReserve) result = deviceMemoryBufferPools->reserve(requirements);

resourceRequirements.maxSlots.merge(requirements.maxSlots);
resourceRequirements.maxSlots.update(requirements.maxSlots);

descriptorPools->reserve(requirements);

Expand Down
2 changes: 1 addition & 1 deletion src/vsg/vk/ResourceRequirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ DescriptorPoolSizes ResourceRequirements::computeDescriptorPoolSizes() const

void ResourceRequirements::apply(const ResourceHints& resourceHints)
{
maxSlots.merge(resourceHints.maxSlots);
maxSlots.update(resourceHints.maxSlots);

if (!resourceHints.descriptorPoolSizes.empty() || resourceHints.numDescriptorSets > 0)
{
Expand Down
Loading