GPU RGBA -> p216, as ONE texture holding the whole framestore. More...
Detailed Description
GPU RGBA -> p216, as ONE texture holding the whole framestore.
P216Encoder produces the same bytes in two plane textures, which is the right shape for a consumer that wants planes. A consumer that wants the framestore – NDI's p_data, a capture card's frame buffer – then has to concatenate them, because a QRhi readback lands in its own allocation per plane. At 1080p that is 8.3 MB of memcpy per frame for nothing.
P216's two planes are the same size: 2*width bytes per row, height rows each. So the whole framestore is exactly an RGBA8 texture of (width/2) x (2*height) – luma rows on top, interleaved chroma below – and one readback of it IS the framestore, in order, ready to send.
It is UYVYEncoder's trick (an RGBA8 target at half width whose texels are the wire bytes) applied one dimension further. The cost is that the shader writes bytes rather than samples: each RGBA8 texel carries two 16-bit values, little endian, which is what both P216 and every consumer of it expect.
Requires width % 2 == 0. Feed an RGBA16F source texture if the extra bits should mean anything; from an 8-bit scene this produces valid P216 whose values are 8-bit quantities scaled into 16-bit words.
Public Member Functions | |
| void | init (QRhi &rhi, const RenderState &state, QRhiTexture *inputRGBA, int width, int height, const QString &colorConversion) override |
| void | exec (QRhi &rhi, QRhiCommandBuffer &cb) override |
| int | planeCount () const override |
| Number of readback planes (1 for UYVY, 2 for NV12, 3 for I420). | |
| const QRhiReadbackResult & | readback (int) const override |
| Get the readback result for a given plane. Valid after endOffscreenFrame. | |
| QRhiTexture * | outputTexture () const noexcept override |
| void | setReadbackEnabled (bool e) noexcept override |
| void | release () override |
| Release all GPU resources. | |
Static Public Attributes | |
| static constexpr const char * | frag |
Static Public Attributes inherited from score::gfx::GPUVideoEncoder | |
| static constexpr const char * | vertex_shader |
| static constexpr const char * | rgb_to_yuv_glsl |
| static constexpr const char * | y_flip_glsl |
| Fragment shader Y-flip: on GL, flip v_texcoord.y. On Metal/HLSL, no flip. | |
Member Function Documentation
◆ exec()
|
inlineoverridevirtual |
Execute the conversion pass. Call inside beginOffscreenFrame/endOffscreenFrame. Renders the conversion shader and schedules GPU->CPU readback(s).
Implements score::gfx::GPUVideoEncoder.
◆ init()
|
inlineoverridevirtual |
Create render targets, textures, samplers, and the graphics pipeline.
- Parameters
-
rhi The QRhi instance. state The render state (for shader compilation). inputRGBA The scene RGBA texture to read from. width Source width in pixels. height Source height in pixels. colorConversion GLSL code from colorMatrixOut() defining convert_from_rgb(). If empty, defaults to BT.709 full range.
Implements score::gfx::GPUVideoEncoder.
◆ outputTexture()
|
inlineoverridevirtualnoexcept |
The single output texture (RGBA8, format-dependent dimensions) for single-plane encoders, so vendor-neutral code (CpuStagedVideoOutput's DVP download) can copy it straight to sysmem instead of using readback(). Default nullptr (multi-plane encoders) => callers must use readback().
Reimplemented from score::gfx::GPUVideoEncoder.
◆ planeCount()
|
inlineoverridevirtual |
Number of readback planes (1 for UYVY, 2 for NV12, 3 for I420).
Implements score::gfx::GPUVideoEncoder.
◆ readback()
|
inlineoverridevirtual |
Get the readback result for a given plane. Valid after endOffscreenFrame.
Implements score::gfx::GPUVideoEncoder.
◆ release()
|
inlineoverridevirtual |
Release all GPU resources.
Implements score::gfx::GPUVideoEncoder.
◆ setReadbackEnabled()
|
inlineoverridevirtualnoexcept |
Enable/disable the GPU->CPU readback scheduled in exec(). Default enabled (readback runs). Disable when a GPU-direct download reads outputTexture() directly, so exec() doesn't also pay the readback (no double transfer).
Reimplemented from score::gfx::GPUVideoEncoder.
The documentation for this struct was generated from the following file:
Static Public Attributes inherited from