3 #include <Gfx/Graph/Mesh.hpp>
4 #include <Gfx/Graph/RenderState.hpp>
5 #include <Gfx/Graph/Scale.hpp>
6 #include <Gfx/Graph/Uniforms.hpp>
8 #include <ossia/detail/hash_map.hpp>
10 #include <score_plugin_gfx_export.h>
24 QRhiSampler* sampler{};
25 QRhiTexture* texture{};
33 ossia::hash_map<RenderList*, Sampler> samplers;
35 std::vector<float> data;
38 int rectUniformOffset{};
69 source->
edges.push_back(
this);
70 sink->
edges.push_back(
this);
75 if(
auto it = std::find(source->
edges.begin(), source->
edges.end(),
this);
76 it != source->
edges.end())
77 source->
edges.erase(it);
78 if(
auto it = std::find(sink->
edges.begin(), sink->
edges.end(),
this);
79 it != sink->
edges.end())
80 sink->
edges.erase(it);
92 QRhiGraphicsPipeline* pipeline{};
93 QRhiShaderResourceBindings* srb{};
110 QRhiTexture* texture{};
111 QRhiRenderBuffer* colorRenderBuffer{};
112 QRhiRenderBuffer* depthRenderBuffer{};
113 QRhiRenderPassDescriptor* renderPass{};
114 QRhiRenderTarget* renderTarget{};
116 operator bool()
const noexcept {
return texture !=
nullptr; }
125 delete colorRenderBuffer;
126 colorRenderBuffer =
nullptr;
128 delete depthRenderBuffer;
129 depthRenderBuffer =
nullptr;
132 renderPass =
nullptr;
135 renderTarget =
nullptr;
146 std::vector<QImage> frames;
152 SCORE_PLUGIN_GFX_EXPORT
161 SCORE_PLUGIN_GFX_EXPORT
163 const RenderState& state, QRhiTexture::Format fmt, QSize sz,
int samples,
164 QRhiTexture::Flags = {});
166 SCORE_PLUGIN_GFX_EXPORT
167 void replaceBuffer(QRhiShaderResourceBindings&,
int binding, QRhiBuffer* newBuffer);
168 SCORE_PLUGIN_GFX_EXPORT
169 void replaceSampler(QRhiShaderResourceBindings&,
int binding, QRhiSampler* newSampler);
170 SCORE_PLUGIN_GFX_EXPORT
171 void replaceTexture(QRhiShaderResourceBindings&,
int binding, QRhiTexture* newTexture);
173 SCORE_PLUGIN_GFX_EXPORT
175 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiBuffer* newBuffer);
176 SCORE_PLUGIN_GFX_EXPORT
178 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiSampler* newSampler);
179 SCORE_PLUGIN_GFX_EXPORT
181 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiTexture* newTexture);
186 SCORE_PLUGIN_GFX_EXPORT
188 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler);
193 SCORE_PLUGIN_GFX_EXPORT
195 QRhiShaderResourceBindings&, QRhiSampler* sampler, QRhiTexture* newTexture);
200 SCORE_PLUGIN_GFX_EXPORT
202 QRhiShaderResourceBindings& srb, QRhiTexture* old_tex, QRhiTexture* new_tex);
206 SCORE_PLUGIN_GFX_EXPORT
208 const RenderList& renderer,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
209 QRhiBuffer* materialUBO,
const std::vector<Sampler>& samplers);
214 SCORE_PLUGIN_GFX_EXPORT
215 Pipeline buildPipeline(
216 const RenderList& renderer,
const Mesh& mesh,
const QShader& vertexS,
217 const QShader& fragmentS,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
218 QRhiBuffer* materialUBO,
const std::vector<Sampler>& samplers);
225 SCORE_PLUGIN_GFX_EXPORT
226 std::pair<QShader, QShader>
227 makeShaders(
const RenderState& v, QString vert, QString frag);
234 SCORE_PLUGIN_GFX_EXPORT
235 QShader
makeCompute(
const RenderState& v, QString compt);
245 RenderList& renderer,
const std::vector<Port*>& input,
246 std::vector<Sampler>& samplers);
248 QRhiBuffer* buffer{};
255 SCORE_PLUGIN_GFX_EXPORT
261 SCORE_PLUGIN_GFX_EXPORT
262 QImage
resizeTexture(
const QImage& img,
int min,
int max) noexcept;
264 inline void copyMatrix(
const QMatrix4x4& mat,
float* ptr) noexcept
266 memcpy(ptr, mat.constData(),
sizeof(
float) * 16);
268 inline void copyMatrix(
const QMatrix3x3& mat,
float* ptr) noexcept
270 memcpy(ptr, mat.constData(),
sizeof(
float) * 9);
276 SCORE_PLUGIN_GFX_EXPORT
Root data model for visual nodes.
Definition: score-plugin-gfx/Gfx/Graph/Node.hpp:60
List of nodes to be rendered to an output.
Definition: RenderList.hpp:19
TreeNode< DeviceExplorerNode > Node
Definition: DeviceNode.hpp:74
Graphics rendering pipeline for ossia score.
Definition: PreviewWidget.hpp:12
QRhiShaderResourceBindings * createDefaultBindings(const RenderList &renderer, const TextureRenderTarget &rt, QRhiBuffer *processUBO, QRhiBuffer *materialUBO, const std::vector< Sampler > &samplers)
Create bindings following the score conventions for shaders and materials.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:265
QShader makeCompute(const RenderState &v, QString compute)
Compile a compute shader.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:358
QImage resizeTexture(const QImage &img, int min, int max) noexcept
Resize a texture to fit within GPU limits.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:495
TextureRenderTarget createRenderTarget(const RenderState &state, QRhiTexture *tex, int samples)
Create a render target from a texture.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:10
ScaleMode
How to resize a texture to adapt it to a viewport.
Definition: Scale.hpp:10
QSizeF computeScale(ScaleMode mode, QSizeF viewport, QSizeF texture)
Comput the scale to apply to a texture so that it fits in a GL viewport.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:505
std::pair< QShader, QShader > makeShaders(const RenderState &v, QString vert, QString frag)
Get a pair of compiled vertex / fragment shaders from GLSL 4.5 sources.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:334
QSize resizeTextureSize(QSize sz, int min, int max) noexcept
Resize the size of a texture to fit within GPU limits.
Definition: score-plugin-gfx/Gfx/Graph/Utils.cpp:444
Data model for audio data being sent to the GPU.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:32
Utility to represent a shader material following score conventions.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:243
Connection between two score::gfx::Port.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:64
Image data and metadata.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:144
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:91
Port of a score::gfx::Node.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:46
void * value
Pointer to the corresponding data.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:51
score::gfx::Node * node
Parent node of the port.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:48
Types type
Type of the value.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:54
std::vector< Edge * > edges
Edges connected to that port.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:57
Global state associated to a rendering context.
Definition: RenderState.hpp:31
Stores a sampler and the texture currently associated with it.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:23
Useful abstraction for storing all the data related to a render target.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:109