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 int getArraySizeFromUI(const QString& bufferName) const;
45
46 ossia::small_flat_map<const Port*, TextureRenderTarget, 2> m_rts;
47
48 struct ComputePass
49 {
50 QRhiComputePipeline* pipeline{};
51 QRhiShaderResourceBindings* srb{};
52 QRhiBuffer* processUBO{};
53 };
54
55 struct GraphicsPass
56 {
57 Pipeline pipeline;
58 QRhiSampler* outputSampler{};
59 MeshBuffers meshBuffers;
60 };
61
62 ossia::small_vector<std::pair<Edge*, ComputePass>, 2> m_computePasses;
63 ossia::small_vector<std::pair<Edge*, GraphicsPass>, 2> m_graphicsPasses;
64
65 ISFNode& n;
66
67 std::vector<Sampler> m_inputSamplers;
68
69 // Storage buffers for compute shaders
70 struct StorageBuffer
71 {
72 QRhiBuffer* buffer{};
73 int size{};
74 int lastKnownSize{}; // For dynamic resizing
75 QString name;
76 QString access; // "read_only", "write_only", "read_write"
77 std::vector<isf::storage_input::layout_field> layout; // For size calculation
78 };
79 std::vector<StorageBuffer> m_storageBuffers;
80
81 // Storage images for compute shaders
82 struct StorageImage
83 {
84 QRhiTexture* texture{};
85 QString name;
86 QString access; // "read_only", "write_only", "read_write"
87 QRhiTexture::Format format{QRhiTexture::RGBA8};
88 };
89 std::vector<StorageImage> m_storageImages;
90
91 QRhiBuffer* m_materialUBO{};
92 int m_materialSize{};
93
94 // Output texture for compute shader results
95 QRhiTexture* m_outputTexture{};
96 QRhiTexture::Format m_outputFormat{QRhiTexture::RGBA8};
97
98 // Compute shader specifics
99 QRhiComputePipeline* m_computePipeline{};
100 QShader m_computeShader;
101 bool m_pipelinesDirty{true};
102};
103
104}
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