Loading...
Searching...
No Matches
SimpleRenderedISFNode.hpp
1#pragma once
2
3#include <Gfx/Graph/ISFNode.hpp>
4#include <Gfx/Graph/IsfBindingsBuilder.hpp>
5#include <Gfx/Graph/NodeRenderer.hpp>
6#include <Gfx/Graph/RenderedISFUtils.hpp>
7
8#include <ossia/detail/small_flat_map.hpp>
9
10namespace score::gfx
11{
12// Used for the simple case of a single, non-persistent pass (the most common case)
13
14struct SCORE_PLUGIN_GFX_TEST_EXPORT SimpleRenderedISFNode : score::gfx::NodeRenderer
15{
16 SimpleRenderedISFNode(const ISFNode& node) noexcept;
17
18 virtual ~SimpleRenderedISFNode();
19
20 void updateInputTexture(const Port& input, QRhiTexture* tex, QRhiTexture* depthTex = nullptr) override;
21 void updateInputSamplerFilter(const Port& input, const RenderTargetSpecs& spec) override;
22 QRhiTexture* textureForOutput(const Port& output) override;
23
24 void init(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
25 void update(RenderList& renderer, QRhiResourceUpdateBatch& res, Edge* edge) override;
26 void release(RenderList& r) override;
27
28 void initState(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
29 void releaseState(RenderList& r) override;
30 void addOutputPass(RenderList& renderer, Edge& edge, QRhiResourceUpdateBatch& res) override;
31 void removeOutputPass(RenderList& renderer, Edge& edge) override;
32 bool hasOutputPassForEdge(Edge& edge) const override;
33 void addInputEdge(RenderList& renderer, Edge& edge, QRhiResourceUpdateBatch& res) override;
34 void removeInputEdge(RenderList& renderer, Edge& edge) override;
35
36 void runInitialPasses(
37 RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res,
38 Edge& edge) override;
39
40 void runRenderPass(RenderList&, QRhiCommandBuffer& commands, Edge& edge) override;
41
42 QRhiGraphicsPipeline::CompareOp depthCompare() const noexcept override;
43 bool followsRenderSize() const noexcept override;
44
45private:
46 void initPass(
47 const TextureRenderTarget& rt, RenderList& renderer, Edge& edge,
48 QRhiResourceUpdateBatch& res);
49 void initMRTPass(RenderList& renderer, QRhiResourceUpdateBatch& res);
52 QSize declaredOutputSize(const RenderList& renderer) const;
53 void initMRTBlitPasses(RenderList& renderer, QRhiResourceUpdateBatch& res);
54 void initMRTBlitPass(RenderList& renderer, QRhiResourceUpdateBatch& res, Edge& edge);
55
56 std::vector<Sampler> allSamplers() const noexcept;
57
58 ossia::small_vector<std::pair<Edge*, Pass>, 2> m_passes;
59
60 ISFNode& n;
61
62 std::vector<Sampler> m_inputSamplers;
63 std::vector<int> m_storageImageSamplers;
64 std::vector<Sampler> m_audioSamplers;
65 ossia::small_flat_map<Edge*, QRhiSampler*, 4> m_blitSamplersByEdge;
66 // Nearest sampler of the depth OUTPUT the colour copies carry
67 // (initMRTBlitPass); only made for a shader whose depth travels.
68 QRhiSampler* m_depthCopySampler{};
69
70 const Mesh* m_mesh{};
71 MeshBuffers m_meshBuffer{};
72
73 QRhiBuffer* m_materialUBO{};
74 int m_materialSize{};
75
76 std::optional<AudioTextureUpload> m_audioTex;
77
78 // MRT: internally-owned render target with multiple attachments
79 TextureRenderTarget m_mrtRenderTarget;
80 bool m_hasMRT{false};
83 QSize m_declaredOutputSize;
84 // update() runs once per downstream sink; once-per-frame work is keyed
85 // on the RenderList frame counter instead of bools reset in update().
86 int64_t m_lastMRTRenderFrame{-1};
87 int64_t m_lastStorageSwapFrame{-1};
88 int64_t m_frameIndexFrame{-1};
89
90 // Graphics-visible storage buffers / images (see IsfBindingsBuilder).
92
93 // Cached number of bindings consumed by storage resources (recorded in
94 // initState so that runtime buffer rebinds can reuse the same layout).
95 int m_firstStorageBinding{-1};
96 int m_firstSamplerBinding{3};
97};
98}
Definition ISFNode.hpp:39
Renderer for a given node.
Definition NodeRenderer.hpp:11
List of nodes to be rendered to an output.
Definition RenderList.hpp:36
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
void updateInputSamplerFilter(std::span< Sampler > samplers, const score::gfx::Node &node, const Port &input, const RenderTargetSpecs &spec)
Give the sampler initInputSamplers() created for input, one of node's input ports,...
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:2213
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:236
Aggregate of all graphics-visible storage resources for a node.
Definition IsfBindingsBuilder.hpp:143
Definition Mesh.hpp:95
Data model for meshes.
Definition Mesh.hpp:196
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:215
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:71
Definition SimpleRenderedISFNode.hpp:15
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:307