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>
9#include <ossia/detail/small_flat_map.hpp>
11#include <score_plugin_gfx_export.h>
27 QRhiSampler* sampler{};
28 QRhiTexture* texture{};
36 ossia::hash_map<RenderList*, Sampler> samplers;
38 std::vector<float> data;
79 source->
edges.push_back(
this);
80 sink->
edges.push_back(
this);
85 if(
auto it = std::find(source->
edges.begin(), source->
edges.end(),
this);
86 it != source->
edges.end())
87 source->
edges.erase(it);
88 if(
auto it = std::find(sink->
edges.begin(), sink->
edges.end(),
this);
89 it != sink->
edges.end())
90 sink->
edges.erase(it);
102 QRhiGraphicsPipeline* pipeline{};
103 QRhiShaderResourceBindings* srb{};
120 QRhiTexture* texture{};
121 QRhiRenderBuffer* colorRenderBuffer{};
122 QRhiRenderBuffer* depthRenderBuffer{};
123 QRhiRenderPassDescriptor* renderPass{};
124 QRhiRenderTarget* renderTarget{};
126 operator bool()
const noexcept {
return texture !=
nullptr; }
135 delete colorRenderBuffer;
136 colorRenderBuffer =
nullptr;
138 delete depthRenderBuffer;
139 depthRenderBuffer =
nullptr;
142 renderPass =
nullptr;
145 renderTarget =
nullptr;
156 std::vector<QImage> frames;
162SCORE_PLUGIN_GFX_EXPORT
171SCORE_PLUGIN_GFX_EXPORT
173 const RenderState& state, QRhiTexture::Format fmt, QSize sz,
int samples,
bool depth,
174 QRhiTexture::Flags = {});
176SCORE_PLUGIN_GFX_EXPORT
177void replaceBuffer(QRhiShaderResourceBindings&,
int binding, QRhiBuffer* newBuffer);
178SCORE_PLUGIN_GFX_EXPORT
179void replaceSampler(QRhiShaderResourceBindings&,
int binding, QRhiSampler* newSampler);
180SCORE_PLUGIN_GFX_EXPORT
181void replaceTexture(QRhiShaderResourceBindings&,
int binding, QRhiTexture* newTexture);
183SCORE_PLUGIN_GFX_EXPORT
185 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiBuffer* newBuffer);
186SCORE_PLUGIN_GFX_EXPORT
188 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiSampler* newSampler);
189SCORE_PLUGIN_GFX_EXPORT
191 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiTexture* newTexture);
196SCORE_PLUGIN_GFX_EXPORT
198 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler);
203SCORE_PLUGIN_GFX_EXPORT
205 QRhiShaderResourceBindings&, QRhiSampler* sampler, QRhiTexture* newTexture);
210SCORE_PLUGIN_GFX_EXPORT
212 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler,
213 QRhiTexture* newTexture);
218SCORE_PLUGIN_GFX_EXPORT
220 QRhiShaderResourceBindings& srb, QRhiTexture* old_tex, QRhiTexture* new_tex);
224SCORE_PLUGIN_GFX_EXPORT
226 const RenderList& renderer,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
227 QRhiBuffer* materialUBO, std::span<const Sampler> samplers,
228 std::span<QRhiShaderResourceBinding> additionalBindings = {});
233SCORE_PLUGIN_GFX_EXPORT
234Pipeline buildPipeline(
235 const RenderList& renderer,
const Mesh& mesh,
const QShader& vertexS,
236 const QShader& fragmentS,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
237 QRhiBuffer* materialUBO, std::span<const Sampler> samplers,
238 std::span<QRhiShaderResourceBinding> additionalBindings = {});
245SCORE_PLUGIN_GFX_EXPORT
246std::pair<QShader, QShader>
247makeShaders(
const RenderState& v, QString vert, QString frag);
254SCORE_PLUGIN_GFX_EXPORT
255QShader
makeCompute(
const RenderState& v, QString compt);
265 RenderList& renderer,
const std::vector<Port*>& input,
266 ossia::small_vector<Sampler, 8>& samplers);
268 QRhiBuffer* buffer{};
275SCORE_PLUGIN_GFX_EXPORT
281SCORE_PLUGIN_GFX_EXPORT
282QImage
resizeTexture(
const QImage& img,
int min,
int max)
noexcept;
284inline void copyMatrix(
const QMatrix4x4& mat,
float* ptr)
noexcept
286 memcpy(ptr, mat.constData(),
sizeof(
float) * 16);
288inline void copyMatrix(
const QMatrix3x3& mat,
float* ptr)
noexcept
290 memcpy(ptr, mat.constData(),
sizeof(
float) * 9);
296SCORE_PLUGIN_GFX_EXPORT
302SCORE_PLUGIN_GFX_EXPORT
310 QRhiResourceUpdateBatch* ub
317#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
318 ub->updateDynamicBuffer(buf, offset, QByteArray::fromRawData(data, bytesize));
320 ub->updateDynamicBuffer(buf, offset, bytesize, data);
325 QRhiResourceUpdateBatch* ub
331#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
332 ub->updateDynamicBuffer(buf, offset, std::move(b));
334 ub->updateDynamicBuffer(buf, offset, b.size(), b.data());
342 QRhiResourceUpdateBatch* ub
349#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
350 ub->uploadStaticBuffer(buf, offset, QByteArray::fromRawData(data, bytesize));
352 ub->uploadStaticBuffer(buf, offset, bytesize, data);
357 QRhiResourceUpdateBatch* ub
363#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
364 ub->uploadStaticBuffer(buf, offset, std::move(b));
366 ub->uploadStaticBuffer(buf, offset, b.size(), b.data());
370SCORE_PLUGIN_GFX_EXPORT
371std::vector<Sampler> initInputSamplers(
372 const score::gfx::Node& node, RenderList& renderer,
const std::vector<Port*>& ports,
373 ossia::small_flat_map<const Port*, TextureRenderTarget, 2>& m_rts);
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:74
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
QSizeF computeScaleForTexcoordSizing(ScaleMode mode, QSizeF renderSize, QSizeF textureSize)
Compute the scale to apply to a texture rendered to a quad the size of viewport.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:608
void updateDynamicBufferWithStoredData(QRhiResourceUpdateBatch *ub, QRhiBuffer *buf, int offset, int64_t bytesize, const char *data)
Schedule a Dynamic buffer update when we can guarantee the buffer outlives the frame.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:309
QRhiShaderResourceBindings * createDefaultBindings(const RenderList &renderer, const TextureRenderTarget &rt, QRhiBuffer *processUBO, QRhiBuffer *materialUBO, std::span< const Sampler > samplers, std::span< QRhiShaderResourceBinding > additionalBindings)
Create bindings following the score conventions for shaders and materials.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:317
QShader makeCompute(const RenderState &v, QString compute)
Compile a compute shader.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:421
void uploadStaticBufferWithStoredData(QRhiResourceUpdateBatch *ub, QRhiBuffer *buf, int offset, int64_t bytesize, const char *data)
Schedule a Static buffer update when we can guarantee the buffer outlives the frame.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:341
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:558
QSizeF computeScaleForMeshSizing(ScaleMode mode, QSizeF viewport, QSizeF texture)
Compute the scale to apply to a texture so that it fits in a GL viewport.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:568
void replaceSamplerAndTexture(QRhiShaderResourceBindings &srb, QRhiSampler *oldSampler, QRhiSampler *newSampler, QRhiTexture *newTexture)
Replace both sampler and texture in a SRC.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:200
ScaleMode
How to resize a texture to adapt it to a viewport.
Definition Scale.hpp:10
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:394
TextureRenderTarget createRenderTarget(const RenderState &state, QRhiTexture *tex, int samples, bool depth)
Create a render target from a texture.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:10
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:507
Data model for audio data being sent to the GPU.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:35
Utility to represent a shader material following score conventions.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:263
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:74
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:154
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:101
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:53
void * value
Pointer to the corresponding data.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:58
score::gfx::Node * node
Parent node of the port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:55
Types type
Type of the value.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:61
std::vector< Edge * > edges
Edges connected to that port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:67
Flag flags
Optional setting flags.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:64
Global state associated to a rendering context.
Definition RenderState.hpp:35
Stores a sampler and the texture currently associated with it.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:26
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:119