Loading...
Searching...
No Matches
RdmaVideoOutput.hpp
Go to the documentation of this file.
1#pragma once
2
35#include <Gfx/Graph/encoders/ComputeEncoder.hpp>
37#include <Gfx/Graph/interop/CudaInterop.h>
41#include <score_plugin_gfx_export.h>
42
43#include <cstdint>
44#include <functional>
45#include <memory>
46
47class QRhi;
48class QRhiCommandBuffer;
49class QRhiTexture;
50
51namespace score::gfx
52{
53struct RenderState;
54}
55
56namespace score::gfx::interop
57{
58
59// VendorDmaRegistrar (the per-slot pin/unpin hooks supplied by the vendor
60// adapter) lives in VendorDmaRegistrar.hpp, shared with CpuStagedVideoOutput.
61
63{
64 QRhi* rhi{};
65 const score::gfx::RenderState* state{};
66 QRhiTexture* sourceTexture{};
67 int width{};
68 int height{};
69 std::uint32_t frameByteSize{};
70 int slotCount{2};
73 const char* debugName{"score-gpu-direct-output"};
74
77 std::function<std::unique_ptr<score::gfx::ComputeEncoder>()> encoderFactory;
78
82
85};
86
94class SCORE_PLUGIN_GFX_EXPORT RdmaVideoOutput
95{
96public:
97 RdmaVideoOutput() = default;
99
100 RdmaVideoOutput(const RdmaVideoOutput&) = delete;
101 RdmaVideoOutput& operator=(const RdmaVideoOutput&) = delete;
102
111 bool init(const RdmaVideoOutputConfig& cfg);
112
113 void release();
114
115 bool valid() const noexcept { return m_ring.valid(); }
116 std::size_t slotCount() const noexcept { return m_ring.slotCount(); }
117
121 void encodeFrame(QRhiCommandBuffer& cb);
122
134 void* prepareNextFrame();
135
138 void advance();
139
143 std::uint64_t lostFrames() const noexcept { return m_lostFrames; }
144
145private:
146 void reportLostFrame(const char* stage);
147
148 RdmaVideoOutputConfig m_cfg{};
149 CudaInteropContextHandle m_cudaCtx{};
150 ImportedGpuBufferRing m_ring;
151 std::unique_ptr<InteropFence> m_fence;
152 ComputeRingDispatcher m_dispatcher;
155 std::vector<void*> m_bounce;
156 std::vector<bool> m_pinned;
157 std::uint64_t m_fenceValue{0};
158 std::uint64_t m_lostFrames{0};
159};
160
161} // namespace score::gfx::interop
Bundles a ImportedGpuBufferRing + per-slot ComputeEncoder + InteropFence into the per-frame "encode +...
Backend-uniform N-slot exportable GPU buffer ring for vendor P2P.
Backend-uniform fence between QRhi command-buffer + CUDA stream.
Vendor-supplied pin / unpin callbacks shared by the GPU-direct and host-staged output helpers.
Generic GPU-direct output. Vendor-neutral.
Definition RdmaVideoOutput.hpp:95
std::uint64_t lostFrames() const noexcept
Definition RdmaVideoOutput.hpp:143
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Global state associated to a rendering context.
Definition RenderState.hpp:37
Definition RdmaVideoOutput.hpp:63
const char * debugName
Definition RdmaVideoOutput.hpp:73
std::function< std::unique_ptr< score::gfx::ComputeEncoder >()> encoderFactory
Definition RdmaVideoOutput.hpp:77
QString colorConversion
Definition RdmaVideoOutput.hpp:81
VendorDmaRegistrar registrar
Vendor-supplied pin / unpin callbacks. Must both be non-null.
Definition RdmaVideoOutput.hpp:84
Definition VendorDmaRegistrar.hpp:41