Skip to content

Commit

Permalink
[isf] Send an initial clear to multipass textures as some drivers ini…
Browse files Browse the repository at this point in the history
…t with garbage
  • Loading branch information
jcelerier committed Apr 3, 2024
1 parent 32f5438 commit 92b1fbb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
30 changes: 30 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Graph/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,35 @@ void ProcessNode::process(Message&& msg)
p++;
}
}
}

QDebug operator<<(QDebug s, const score::gfx::gfx_input& v)
{
struct
{
QDebug& s;
void operator()(ossia::monostate) { s << "monostate"; }
void operator()(const ossia::value& v)
{
s << "value:" << ossia::value_to_pretty_string(v);
}
void operator()(const ossia::audio_vector& v)
{
s << "audio: " << v.size() << "channels";
}
void operator()(const ossia::mesh_list_ptr& v) { s << "meshlist"; }
void operator()(const ossia::transform3d& v) { s << "transform3d"; }
} print{s};
ossia::visit(print, std::move(v));
return s;
}
QDebug operator<<(QDebug s, const std::vector<score::gfx::gfx_input>& v)
{
s << "[";
for(const auto& m : v)
{
s << m << " ; ";
}
s << "]";
return s;
}
3 changes: 3 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Graph/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,6 @@ class SCORE_PLUGIN_GFX_EXPORT NodeModel : public score::gfx::ProcessNode
friend class GenericNodeRenderer;
};
}

// QDebug operator<<(QDebug, const score::gfx::gfx_input&);
QDebug operator<<(QDebug, const std::vector<score::gfx::gfx_input>&);
12 changes: 8 additions & 4 deletions src/plugins/score-plugin-gfx/Gfx/Graph/RenderedISFNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void storeTextureRectUniform(char* buffer, int& cur_pos, QSize texSize)
RenderedISFNode::~RenderedISFNode() { }
PassOutput RenderedISFNode::initPassSampler(
ISFNode& n, const isf::pass& pass, RenderList& renderer, int& cur_pos,
QSize mainTexSize)
QSize mainTexSize, QRhiResourceUpdateBatch& res)
{
QRhi& rhi = *renderer.state.rhi;
// In all the other cases we create a custom render target
Expand All @@ -41,9 +41,12 @@ PassOutput RenderedISFNode::initPassSampler(
? mainTexSize
: n.computeTextureSize(pass, mainTexSize);

QImage clear_texture(texSize, QImage::Format_ARGB32);
clear_texture.fill(0);
auto tex = rhi.newTexture(fmt, texSize, 1, QRhiTexture::RenderTarget);
tex->setName("ISFNode::initPassSamplers::tex");
SCORE_ASSERT(tex->create());
res.uploadTexture(tex, clear_texture);

if(!pass.target.empty())
{
Expand All @@ -59,6 +62,7 @@ PassOutput RenderedISFNode::initPassSampler(
auto tex2 = rhi.newTexture(fmt, texSize, 1, QRhiTexture::RenderTarget);
tex2->setName("ISFNode::initPassSamplers::tex2");
SCORE_ASSERT(tex2->create());
res.uploadTexture(tex2, clear_texture);

return PersistSampler{sampler, tex, tex2};
}
Expand Down Expand Up @@ -365,7 +369,7 @@ std::pair<Pass, Pass> RenderedISFNode::createPass(

void RenderedISFNode::initPasses(
const TextureRenderTarget& rt, RenderList& renderer, Edge& edge, int& cur_pos,
QSize mainTexSize)
QSize mainTexSize, QRhiResourceUpdateBatch& res)
{
Passes passes;

Expand All @@ -384,7 +388,7 @@ void RenderedISFNode::initPasses(
else
{
passes.samplers.push_back(
initPassSampler(n, pass, renderer, cur_pos, mainTexSize));
initPassSampler(n, pass, renderer, cur_pos, mainTexSize, res));
}
}

Expand Down Expand Up @@ -462,7 +466,7 @@ void RenderedISFNode::init(RenderList& renderer, QRhiResourceUpdateBatch& res)
auto rt = renderer.renderTargetForOutput(*edge);
if(rt.renderTarget)
{
initPasses(rt, renderer, *edge, cur_pos, renderer.state.renderSize);
initPasses(rt, renderer, *edge, cur_pos, renderer.state.renderSize, res);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/score-plugin-gfx/Gfx/Graph/RenderedISFNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ struct RenderedISFNode : score::gfx::NodeRenderer
const TextureRenderTarget& target);
void initPasses(
const TextureRenderTarget& rt, RenderList& renderer, Edge& edge, int& cur_pos,
QSize mainTexSize);
QSize mainTexSize, QRhiResourceUpdateBatch& res);

PassOutput initPassSampler(
ISFNode& n, const isf::pass& pass, RenderList& renderer, int& cur_pos,
QSize mainTexSize);
QSize mainTexSize, QRhiResourceUpdateBatch& res);

struct Passes
{
Expand Down

0 comments on commit 92b1fbb

Please sign in to comment.