Loading...
Searching...
No Matches
GPUVideoDecoder.hpp
1#pragma once
2
3#include <Gfx/Graph/Node.hpp>
4#include <Gfx/Graph/RenderList.hpp>
5#include <Gfx/Graph/RenderState.hpp>
6#include <Video/VideoInterface.hpp>
7
8extern "C" {
9#include <libavutil/pixdesc.h>
10}
11
12#define SCORE_GFX_VIDEO_UNIFORMS \
13"layout(std140, binding = 0) uniform renderer_t {\n" \
14" mat4 clipSpaceCorrMatrix;\n" \
15" vec2 renderSize;\n" \
16"} renderer;\n" \
17"\n" \
18"layout(std140, binding = 2) uniform material_t {\n" \
19" vec2 scale;\n" \
20" vec2 texSz;\n" \
21"} mat;\n"
22
23namespace score::gfx
24{
25// TODO the "model" nodes should have a first update step so that they
26// can share data across all renderers during a tick
27class VideoNode;
28
43{
44public:
46 virtual ~GPUVideoDecoder();
47
57 [[nodiscard]] virtual std::pair<QShader, QShader> init(RenderList& r) = 0;
58
62 virtual void exec(RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame) = 0;
63
67 void release(RenderList&);
68
75 static QRhiTextureSubresourceUploadDescription
76 createTextureUpload(uint8_t* pixels, int w, int h, int bytesPerPixel, int stride);
77
78 static QString vertexShader() noexcept;
79
80 std::vector<Sampler> samplers;
81};
82
87{
88 static const constexpr auto hashtag_no_filter = R"_(#version 450
89 void main ()
90 {
91 }
92 )_";
93
94 explicit EmptyDecoder() { }
95
96 std::pair<QShader, QShader> init(RenderList& r) override
97 {
98 return score::gfx::makeShaders(r.state, vertexShader(), hashtag_no_filter);
99 }
100
101 void exec(RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame) override { }
102};
103}
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:43
virtual void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame)=0
Decode and upload a video frame to the GPU.
virtual std::pair< QShader, QShader > init(RenderList &r)=0
Initialize a GPUVideoDecoder.
static QRhiTextureSubresourceUploadDescription createTextureUpload(uint8_t *pixels, int w, int h, int bytesPerPixel, int stride)
Utility method to create a QRhiTextureSubresourceUploadDescription.
Definition GPUVideoDecoder.cpp:22
void release(RenderList &)
This method will release all the created samplers and textures.
Definition GPUVideoDecoder.cpp:10
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:89
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
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
STL namespace.
Default decoder when we do not know what to render.
Definition GPUVideoDecoder.hpp:87
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition GPUVideoDecoder.hpp:101
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition GPUVideoDecoder.hpp:96
Stores a sampler and the texture currently associated with it.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:25