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;
76 source->
edges.push_back(
this);
77 sink->
edges.push_back(
this);
82 if(
auto it = std::find(source->
edges.begin(), source->
edges.end(),
this);
83 it != source->
edges.end())
84 source->
edges.erase(it);
85 if(
auto it = std::find(sink->
edges.begin(), sink->
edges.end(),
this);
86 it != sink->
edges.end())
87 sink->
edges.erase(it);
99 QRhiGraphicsPipeline* pipeline{};
100 QRhiShaderResourceBindings* srb{};
117 QRhiTexture* texture{};
118 QRhiRenderBuffer* colorRenderBuffer{};
119 QRhiRenderBuffer* depthRenderBuffer{};
120 QRhiRenderPassDescriptor* renderPass{};
121 QRhiRenderTarget* renderTarget{};
123 operator bool()
const noexcept {
return texture !=
nullptr; }
132 delete colorRenderBuffer;
133 colorRenderBuffer =
nullptr;
135 delete depthRenderBuffer;
136 depthRenderBuffer =
nullptr;
139 renderPass =
nullptr;
142 renderTarget =
nullptr;
153 std::vector<QImage> frames;
159SCORE_PLUGIN_GFX_EXPORT
168SCORE_PLUGIN_GFX_EXPORT
170 const RenderState& state, QRhiTexture::Format fmt, QSize sz,
int samples,
bool depth,
171 QRhiTexture::Flags = {});
173SCORE_PLUGIN_GFX_EXPORT
174void replaceBuffer(QRhiShaderResourceBindings&,
int binding, QRhiBuffer* newBuffer);
175SCORE_PLUGIN_GFX_EXPORT
176void replaceSampler(QRhiShaderResourceBindings&,
int binding, QRhiSampler* newSampler);
177SCORE_PLUGIN_GFX_EXPORT
178void replaceTexture(QRhiShaderResourceBindings&,
int binding, QRhiTexture* newTexture);
180SCORE_PLUGIN_GFX_EXPORT
182 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiBuffer* newBuffer);
183SCORE_PLUGIN_GFX_EXPORT
185 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiSampler* newSampler);
186SCORE_PLUGIN_GFX_EXPORT
188 std::vector<QRhiShaderResourceBinding>&,
int binding, QRhiTexture* newTexture);
193SCORE_PLUGIN_GFX_EXPORT
195 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler);
200SCORE_PLUGIN_GFX_EXPORT
202 QRhiShaderResourceBindings&, QRhiSampler* sampler, QRhiTexture* newTexture);
207SCORE_PLUGIN_GFX_EXPORT
209 QRhiShaderResourceBindings&, QRhiSampler* oldSampler, QRhiSampler* newSampler,
210 QRhiTexture* newTexture);
215SCORE_PLUGIN_GFX_EXPORT
217 QRhiShaderResourceBindings& srb, QRhiTexture* old_tex, QRhiTexture* new_tex);
221SCORE_PLUGIN_GFX_EXPORT
223 const RenderList& renderer,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
224 QRhiBuffer* materialUBO, std::span<const Sampler> samplers,
225 std::span<QRhiShaderResourceBinding> additionalBindings = {});
230SCORE_PLUGIN_GFX_EXPORT
231Pipeline buildPipeline(
232 const RenderList& renderer,
const Mesh& mesh,
const QShader& vertexS,
233 const QShader& fragmentS,
const TextureRenderTarget& rt, QRhiBuffer* processUBO,
234 QRhiBuffer* materialUBO, std::span<const Sampler> samplers,
235 std::span<QRhiShaderResourceBinding> additionalBindings = {});
242SCORE_PLUGIN_GFX_EXPORT
243std::pair<QShader, QShader>
244makeShaders(
const RenderState& v, QString vert, QString frag);
251SCORE_PLUGIN_GFX_EXPORT
252QShader
makeCompute(
const RenderState& v, QString compt);
262 RenderList& renderer,
const std::vector<Port*>& input,
263 ossia::small_vector<Sampler, 8>& samplers);
265 QRhiBuffer* buffer{};
272SCORE_PLUGIN_GFX_EXPORT
278SCORE_PLUGIN_GFX_EXPORT
279QImage
resizeTexture(
const QImage& img,
int min,
int max)
noexcept;
281inline void copyMatrix(
const QMatrix4x4& mat,
float* ptr)
noexcept
283 memcpy(ptr, mat.constData(),
sizeof(
float) * 16);
285inline void copyMatrix(
const QMatrix3x3& mat,
float* ptr)
noexcept
287 memcpy(ptr, mat.constData(),
sizeof(
float) * 9);
293SCORE_PLUGIN_GFX_EXPORT
299SCORE_PLUGIN_GFX_EXPORT
307 QRhiResourceUpdateBatch* ub
314#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
315 ub->updateDynamicBuffer(buf, offset, QByteArray::fromRawData(data, bytesize));
317 ub->updateDynamicBuffer(buf, offset, bytesize, data);
322 QRhiResourceUpdateBatch* ub
328#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
329 ub->updateDynamicBuffer(buf, offset, std::move(b));
331 ub->updateDynamicBuffer(buf, offset, b.size(), b.data());
339 QRhiResourceUpdateBatch* ub
346#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
347 ub->uploadStaticBuffer(buf, offset, QByteArray::fromRawData(data, bytesize));
349 ub->uploadStaticBuffer(buf, offset, bytesize, data);
354 QRhiResourceUpdateBatch* ub
360#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
361 ub->uploadStaticBuffer(buf, offset, std::move(b));
363 ub->uploadStaticBuffer(buf, offset, b.size(), b.data());
367SCORE_PLUGIN_GFX_EXPORT
368std::vector<Sampler> initInputSamplers(
369 const score::gfx::Node& node, RenderList& renderer,
const std::vector<Port*>& ports,
370 ossia::small_flat_map<const Port*, TextureRenderTarget, 2>& m_rts);
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:75
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:306
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:338
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:260
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:71
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:151
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:98
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: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:116