Loading...
Searching...
No Matches
HostPinnedRing.hpp
Go to the documentation of this file.
1#pragma once
2
40
41#include <score_plugin_gfx_export.h>
42
43#include <cstddef>
44#include <cstdint>
45#include <memory>
46
47class QRhi;
48class QRhiTexture;
49class QRhiResourceUpdateBatch;
50
51namespace score::gfx::interop
52{
53
56enum class HostPinnedRingBackend : uint8_t
57{
58 None = 0,
59 Dvp,
60 AmdPinned,
63};
64
66SCORE_PLUGIN_GFX_EXPORT const char*
67hostPinnedBackendName(HostPinnedRingBackend) noexcept;
68
70enum class HostPinnedDirection : uint8_t
71{
74};
75
80struct SCORE_PLUGIN_GFX_EXPORT HostPinnedSlot
81{
82 void* host{};
83 std::size_t size{};
84 std::size_t stride{};
85 void* backendOpaque{};
88 bool cudaRegistered{};
89};
90
92{
93 QRhi* rhi{};
95 HostPinnedDirection direction{HostPinnedDirection::CaptureToTexture};
98 VideoPixelFormat format{VideoPixelFormat::BGRA8};
99 uint32_t width{};
100 uint32_t height{};
101 uint32_t stride{0};
102 uint32_t slotCount{2};
103 const char* debugName{"score-host-pinned-ring"};
104};
105
120class SCORE_PLUGIN_GFX_EXPORT HostPinnedRing
121{
122public:
123 HostPinnedRing() noexcept;
125
126 HostPinnedRing(const HostPinnedRing&) = delete;
127 HostPinnedRing& operator=(const HostPinnedRing&) = delete;
128 HostPinnedRing(HostPinnedRing&&) noexcept;
129 HostPinnedRing& operator=(HostPinnedRing&&) noexcept;
130
135 bool create(const HostPinnedRingConfig& cfg);
136
150 void destroy() noexcept;
151
152 bool valid() const noexcept;
153 HostPinnedRingBackend backend() const noexcept;
154 std::size_t slotCount() const noexcept;
155
157 HostPinnedSlot& slot(std::size_t i) noexcept;
158 const HostPinnedSlot& slot(std::size_t i) const noexcept;
159
188 void bindCudaDestination(
189 QRhiTexture* dst, void* cuda_ctx, void* cuda_array) noexcept;
190
204 bool uploadSlotToTexture(std::size_t i, QRhiTexture* dst,
205 QRhiResourceUpdateBatch* batch = nullptr);
206
220 bool downloadTextureToSlot(QRhiTexture* src, std::size_t i,
221 QRhiResourceUpdateBatch* batch = nullptr);
222
227 bool slotReady(std::size_t i) const noexcept;
228
233 void resetSlotReady(std::size_t i) noexcept;
234
237 std::size_t writeIndex() const noexcept;
238 std::size_t advance() noexcept;
239
240private:
241 struct Impl;
242 std::unique_ptr<Impl> m_impl;
243};
244
245} // namespace score::gfx::interop
Runtime probe of which GPU interop mechanisms are available on this system.
HostPinnedDirection
Definition HostPinnedRing.hpp:71
HostPinnedRingBackend
Definition HostPinnedRing.hpp:57
Vendor-neutral pixel format vocabulary + descriptive metadata.
VideoPixelFormat
Definition VideoPixelFormat.hpp:229
Definition HostPinnedRing.hpp:121
Definition GpuCapabilities.hpp:106
Definition HostPinnedRing.cpp:134
Definition HostPinnedRing.hpp:92
VideoPixelFormat format
Definition HostPinnedRing.hpp:98
uint32_t stride
Definition HostPinnedRing.hpp:101
const GpuCapabilities * caps
Definition HostPinnedRing.hpp:94
Definition HostPinnedRing.hpp:81