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>
26 QRhiSampler* sampler{};
27 QRhiTexture* texture{};
35 ossia::hash_map<RenderList*, Sampler> samplers;
37 std::vector<float> data;
40 int rectUniformOffset{};
71 source->
edges.push_back(
this);
72 sink->
edges.push_back(
this);
77 if(
auto it = std::find(source->
edges.begin(), source->
edges.end(),
this);
78 it != source->
edges.end())
79 source->
edges.erase(it);
80 if(
auto it = std::find(sink->
edges.begin(), sink->
edges.end(),
this);
81 it != sink->
edges.end())
82 sink->
edges.erase(it);
94 QRhiGraphicsPipeline* pipeline{};
95 QRhiShaderResourceBindings* srb{};
112 QRhiTexture* texture{};
113 QRhiRenderBuffer* colorRenderBuffer{};
114 QRhiRenderBuffer* depthRenderBuffer{};
115 QRhiRenderPassDescriptor* renderPass{};
116 QRhiRenderTarget* renderTarget{};
118 operator bool()
const noexcept {
return texture !=
nullptr; }
127 delete colorRenderBuffer;
128 colorRenderBuffer =
nullptr;
130 delete depthRenderBuffer;
131 depthRenderBuffer =
nullptr;
134 renderPass =
nullptr;
137 renderTarget =
nullptr;
148 std::vector<QImage> frames;
154SCORE_PLUGIN_GFX_EXPORT
163SCORE_PLUGIN_GFX_EXPORT
165 const RenderState& state, QRhiTexture::Format fmt, QSize sz,
int samples,
166 QRhiTexture::Flags = {});
168SCORE_PLUGIN_GFX_EXPORT
169void replaceBuffer(QRhiShaderResourceBindings&,
int binding, QRhiBuffer* newBuffer);
170SCORE_PLUGIN_GFX_EXPORT
171void replaceSampler(QRhiShaderResourceBindings&,
int binding, QRhiSampler* newSampler);
172SCORE_PLUGIN_GFX_EXPORT
173void replaceTexture(QRhiShaderResourceBindings&,
int binding, QRhiTexture* newTexture);
175SCORE_PLUGIN_GFX_EXPORT
177 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiBuffer* newBuffer);
178SCORE_PLUGIN_GFX_EXPORT
180 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiSampler* newSampler);
181SCORE_PLUGIN_GFX_EXPORT
183 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiTexture* newTexture);
188SCORE_PLUGIN_GFX_EXPORT
190 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler);
195SCORE_PLUGIN_GFX_EXPORT
197 QRhiShaderResourceBindings&, QRhiSampler* sampler, QRhiTexture* newTexture);
202SCORE_PLUGIN_GFX_EXPORT
204 QRhiShaderResourceBindings& srb, QRhiTexture* old_tex, QRhiTexture* new_tex);
208SCORE_PLUGIN_GFX_EXPORT
210 const RenderList& renderer,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
211 QRhiBuffer* materialUBO,
const std::vector<Sampler>& samplers,
212 std::span<QRhiShaderResourceBinding> additionalBindings = {});
217SCORE_PLUGIN_GFX_EXPORT
218Pipeline buildPipeline(
219 const RenderList& renderer,
const Mesh& mesh,
const QShader& vertexS,
220 const QShader& fragmentS,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
221 QRhiBuffer* materialUBO,
const std::vector<Sampler>& samplers,
222 std::span<QRhiShaderResourceBinding> additionalBindings = {});
229SCORE_PLUGIN_GFX_EXPORT
230std::pair<QShader, QShader>
231makeShaders(
const RenderState& v, QString vert, QString frag);
238SCORE_PLUGIN_GFX_EXPORT
239QShader
makeCompute(
const RenderState& v, QString compt);
249 RenderList& renderer,
const std::vector<Port*>& input,
250 std::vector<Sampler>& samplers);
252 QRhiBuffer* buffer{};
259SCORE_PLUGIN_GFX_EXPORT
265SCORE_PLUGIN_GFX_EXPORT
266QImage
resizeTexture(
const QImage& img,
int min,
int max)
noexcept;
268inline void copyMatrix(
const QMatrix4x4& mat,
float* ptr)
noexcept
270 memcpy(ptr, mat.constData(),
sizeof(
float) * 16);
272inline void copyMatrix(
const QMatrix3x3& mat,
float* ptr)
noexcept
274 memcpy(ptr, mat.constData(),
sizeof(
float) * 9);
280SCORE_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 Filter/PreviewWidget.hpp:12
QShader makeCompute(const RenderState &v, QString compute)
Compile a compute shader.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:369
QRhiShaderResourceBindings * createDefaultBindings(const RenderList &renderer, const TextureRenderTarget &rt, QRhiBuffer *processUBO, QRhiBuffer *materialUBO, const std::vector< Sampler > &samplers, std::span< QRhiShaderResourceBinding > additionalBindings)
Create bindings following the score conventions for shaders and materials.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:265
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:506
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:516
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:342
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:455
Data model for audio data being sent to the GPU.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:34
Utility to represent a shader material following score conventions.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:247
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:66
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:146
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:93
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:48
void * value
Pointer to the corresponding data.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:53
score::gfx::Node * node
Parent node of the port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:50
Types type
Type of the value.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:56
std::vector< Edge * > edges
Edges connected to that port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:59
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:25
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:111