Skip to content

Commit

Permalink
gfx: add a way for render nodes to have a parent renderer, to allow s…
Browse files Browse the repository at this point in the history
…ynchronized multi-viewport
  • Loading branch information
jcelerier committed Feb 19, 2025
1 parent fa1ac55 commit 4cb34d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugins/score-plugin-gfx/Gfx/GfxContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ void GfxContext::recompute_graph()

for(auto& outputs : m_graph->renderLists())
{
if(auto conf = outputs->output.configuration(); conf.manualRenderingRate)
auto conf = outputs->output.configuration();
if(conf.manualRenderingRate)
{
int id = startTimer(*conf.manualRenderingRate, Qt::PreciseTimer);
m_manualTimers[id] = &outputs->output;
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,25 @@ void Graph::createAllRenderLists(GraphicsApi graphicsApi)
m_renderers.clear();
m_outputs.clear();

ossia::flat_set<OutputNode*> parent_nodes;
for(auto node : m_nodes)
{
if(auto out = dynamic_cast<OutputNode*>(node))
{
m_outputs.push_back(out);
if(auto ptr = out->configuration().parent)
parent_nodes.insert(ptr);
}
}

// For multi-viewport renders
for(auto node : parent_nodes)
{
if(!ossia::contains(m_outputs, node))
{
m_outputs.push_back(node);
}
}

m_renderers.reserve(ossia::max(16, std::ssize(m_outputs)));

Expand Down
1 change: 1 addition & 0 deletions src/plugins/score-plugin-gfx/Gfx/Graph/OutputNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SCORE_PLUGIN_GFX_EXPORT OutputNode : public score::gfx::Node
// rate (given in milliseconds)
std::optional<double> manualRenderingRate;
bool outputNeedsRenderPass{};
OutputNode* parent{};
};

virtual Configuration configuration() const noexcept = 0;
Expand Down

0 comments on commit 4cb34d2

Please sign in to comment.