Loading...
Searching...
No Matches
RenderedCSFNode.hpp
1#pragma once
2#include <Gfx/Graph/ISFNode.hpp>
3#include <Gfx/Graph/NodeRenderer.hpp>
4
5#include <ossia/detail/small_flat_map.hpp>
6
7namespace score::gfx
8{
9
11{
12 explicit RenderedCSFNode(const ISFNode& node) noexcept;
13
14 virtual ~RenderedCSFNode();
15
16 TextureRenderTarget renderTargetForInput(const Port& p) override;
17
18 void init(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
19 void update(RenderList& renderer, QRhiResourceUpdateBatch& res, Edge* edge) override;
20 void release(RenderList& r) override;
21
22 void runInitialPasses(
23 RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res,
24 Edge& edge) override;
25
26 void runRenderPass(RenderList&, QRhiCommandBuffer& commands, Edge& edge) override;
27
28private:
29 void initComputePass(const TextureRenderTarget& rt, RenderList& renderer, Edge& edge, QRhiResourceUpdateBatch& res);
30 void createComputePipeline(RenderList& renderer);
31 void createGraphicsPass(const TextureRenderTarget& rt, RenderList& renderer, Edge& edge, QRhiResourceUpdateBatch& res);
32 void updateDescriptorSet(RenderList& renderer, Edge& edge);
33 std::vector<Sampler> allSamplers() const noexcept;
34
35 // Image management
36 QRhiTexture::Format getTextureFormat(const QString& format) const noexcept;
37 std::optional<QSize> getImageSize(const isf::csf_image_input&) const noexcept;
38 QSize computeTextureSize(const isf::csf_image_input& img) const noexcept;
39
40 // Buffer management methods
41 int calculateStorageBufferSize(const std::vector<isf::storage_input::layout_field>& layout, int arrayCount) const;
42 QRhiBuffer* createStorageBuffer(RenderList& renderer, const QString& name, const QString& access, int size);
43 void updateStorageBuffers(RenderList& renderer, QRhiResourceUpdateBatch& res);
44 void recreateShaderResourceBindings(RenderList& renderer, QRhiResourceUpdateBatch& res);
45 int getArraySizeFromUI(const QString& bufferName) const;
46
47 ossia::small_flat_map<const Port*, TextureRenderTarget, 2> m_rts;
48
49 struct ComputePass
50 {
51 QRhiComputePipeline* pipeline{};
52 QRhiShaderResourceBindings* srb{};
53 QRhiBuffer* processUBO{};
54 };
55
56 struct GraphicsPass
57 {
58 Pipeline pipeline;
59 QRhiSampler* outputSampler{};
60 MeshBuffers meshBuffers;
61 };
62
63 ossia::small_vector<std::pair<Edge*, ComputePass>, 2> m_computePasses;
64 ossia::small_vector<std::pair<Edge*, GraphicsPass>, 2> m_graphicsPasses;
65
66 ISFNode& n;
67
68 std::vector<Sampler> m_inputSamplers;
69
70 // Storage buffers for compute shaders
71 struct StorageBuffer
72 {
73 QRhiBuffer* buffer{};
74 int size{};
75 int lastKnownSize{}; // For dynamic resizing
76 QString name;
77 QString access; // "read_only", "write_only", "read_write"
78 std::vector<isf::storage_input::layout_field> layout; // For size calculation
79 };
80 std::vector<StorageBuffer> m_storageBuffers;
81
82 // Storage images for compute shaders
83 struct StorageImage
84 {
85 QRhiTexture* texture{};
86 QString name;
87 QString access; // "read_only", "write_only", "read_write"
88 QRhiTexture::Format format{QRhiTexture::RGBA8};
89 };
90 std::vector<StorageImage> m_storageImages;
91
92 QRhiBuffer* m_materialUBO{};
93 int m_materialSize{};
94
95 // Output texture for compute shader results
96 QRhiTexture* m_outputTexture{};
97 QRhiTexture::Format m_outputFormat{QRhiTexture::RGBA8};
98
99 // Compute shader specifics
100 QRhiComputePipeline* m_computePipeline{};
101 QShader m_computeShader;
102 bool m_pipelinesDirty{true};
103};
104
105}
Data model for Interactive Shader Format filters.
Definition ISFNode.hpp:20
Renderer for a given node.
Definition NodeRenderer.hpp:11
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:70
Definition Mesh.hpp:15
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:97
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:52
Definition RenderedCSFNode.hpp:11
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:115