Loading...
Searching...
No Matches
InvertYRenderer.hpp
1#pragma once
2
3#include <Gfx/Graph/NodeRenderer.hpp>
4#include <Gfx/Graph/OutputNode.hpp>
5namespace Gfx
6{
7
8class SCORE_PLUGIN_GFX_EXPORT InvertYRenderer final
10{
11public:
12 explicit InvertYRenderer(
14 QRhiReadbackResult& readback);
15
18
19 QShader m_vertexS, m_fragmentS;
20
21 std::vector<score::gfx::Sampler> m_samplers;
22
24
26
27 // m_inputTarget is a SNAPSHOT of the owning output node's render target,
28 // taken in createRenderer() and refreshed in init(). The output node can
29 // replace both the QRhiTextureRenderTarget and the QRhiRenderPassDescriptor
30 // behind our back — BackgroundNode::resize() `deleteLater()`s them and
31 // installs fresh ones — and when the resize takes the fast path
32 // (RenderList::resizeSwapchainSizedTargets) the re-init is deferred to the
33 // next render frame. Anything reading the snapshot in that window (an
34 // incremental edge add: Graph::createAllMissingPasses ->
35 // RenderList::renderTargetForOutput -> here -> addOutputPass's
36 // renderPass->serializedFormat()) dereferences freed memory. Re-adopt the
37 // node's LIVE target on every query: the output node is the authority, and
38 // this is the same rule init() applies.
40 renderTargetForInput(const score::gfx::Port& p) override
41 {
42 if(auto* out = dynamic_cast<const score::gfx::OutputNode*>(&this->node))
43 {
44 auto cur = out->currentRenderTarget();
45 if(cur.renderTarget && cur.renderPass)
46 m_inputTarget = cur;
47 }
48 return m_inputTarget;
49 }
50
51 void finishFrame(
52 score::gfx::RenderList& renderer, QRhiCommandBuffer& cb,
53 QRhiResourceUpdateBatch*& res) override;
54
55 void init(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res) override;
56 void update(
57 score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res,
58 score::gfx::Edge* edge) override;
59 void release(score::gfx::RenderList&) override;
60
61 void updateReadback(QRhiReadbackResult& rb) { m_readback = &rb; }
62
63private:
64 QRhiReadbackResult* m_readback{};
65};
66
68{
69public:
72
73 QShader m_vertexS, m_fragmentS;
74
75 std::array<score::gfx::Sampler, 1> m_samplers;
78
79 // When the output is a swap chain, the render target must be re-queried for
80 // every frame (QRhiSwapChain::currentFrameRenderTarget: "the value must not
81 // be cached and reused between frames"). Null for offscreen outputs.
82 QRhiSwapChain* m_swapChain{};
83
84
87 const score::gfx::Node& parent, QRhiSwapChain* swapChain = nullptr);
89
90 score::gfx::TextureRenderTarget renderTargetForInput(const score::gfx::Port& p) override;
91
92 void init(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res) override;
93 void update(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res, score::gfx::Edge* edge) override;
94 void release(score::gfx::RenderList&) override;
95
96 void runRenderPass(score::gfx::RenderList&, QRhiCommandBuffer& commands, score::gfx::Edge& e) override;
97
98 void finishFrame(
99 score::gfx::RenderList& renderer, QRhiCommandBuffer& cb,
100 QRhiResourceUpdateBatch*& res) override;
101};
102
103class SCORE_PLUGIN_GFX_EXPORT BasicRenderer : public score::gfx::OutputNodeRenderer
104{
105public:
107
108 score::gfx::TextureRenderTarget renderTargetForInput(const score::gfx::Port& p) override;
111
112 void init(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res) override;
113 void update(score::gfx::RenderList& renderer, QRhiResourceUpdateBatch& res, score::gfx::Edge* edge) override;
114 void runRenderPass(score::gfx::RenderList&, QRhiCommandBuffer& commands, score::gfx::Edge& e) override;
115 void release(score::gfx::RenderList&) override;
116};
117
118}
Definition InvertYRenderer.hpp:104
Definition InvertYRenderer.hpp:10
Definition InvertYRenderer.hpp:68
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:74
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:54
Definition OutputNode.hpp:36
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Binds the rendering pipeline to ossia processes.
Definition AssetTable.cpp:7
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103
Definition Mesh.hpp:94
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:132
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:82
Global state associated to a rendering context.
Definition RenderState.hpp:37
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:152