Loading...
Searching...
No Matches
ImportedGpuBufferRing.hpp
Go to the documentation of this file.
1#pragma once
2
35#include <Gfx/Graph/interop/CudaInterop.h>
36#include <score_plugin_gfx_export.h>
37
38#include <QtGui/private/qrhi_p.h>
39
40#include <cstdint>
41#include <vector>
42
43namespace score::gfx::interop
44{
45
50{
51 QRhiBuffer* qrhiBuffer{};
52 CudaInteropResourceHandle cudaHandle{};
53 void* gpuDevicePtr{};
58};
59
61{
62 QRhi* rhi{};
63 CudaInteropContextHandle cudaCtx{};
64 std::uint32_t bufferSize{};
65 int slotCount{2};
66 const char* debugName{"score-gpu-ring"};
67
79 bool glRegisterOnly{false};
80};
81
102class SCORE_PLUGIN_GFX_EXPORT ImportedGpuBufferRing
103{
104public:
105 ImportedGpuBufferRing() = default;
107
109 ImportedGpuBufferRing& operator=(const ImportedGpuBufferRing&) = delete;
111 ImportedGpuBufferRing& operator=(ImportedGpuBufferRing&&) = delete;
112
120 bool create(const ImportedGpuBufferRingConfig& cfg);
121
123 void destroy();
124
125 bool valid() const noexcept { return !m_slots.empty(); }
126 std::size_t slotCount() const noexcept { return m_slots.size(); }
127
128 GpuRingBufferSlot& slot(std::size_t i) noexcept { return m_slots[i]; }
129 const GpuRingBufferSlot& slot(std::size_t i) const noexcept { return m_slots[i]; }
130
131 std::size_t writeIndex() const noexcept { return m_writeIndex; }
133 std::size_t advance() noexcept;
134
135private:
137 std::vector<GpuRingBufferSlot> m_slots;
138 std::size_t m_writeIndex{};
139
140 bool createD3D11();
141 bool createOpenGL();
142 bool createVulkanStub();
143 bool createD3D12Stub();
144};
145
146} // namespace score::gfx::interop
Vendor-neutral helper that allocates + manages the slot ring.
Definition ImportedGpuBufferRing.hpp:103
One slot of the ring. Lifetime owned by ImportedGpuBufferRing.
Definition ImportedGpuBufferRing.hpp:50
void * gpuDevicePtr
Definition ImportedGpuBufferRing.hpp:53
CudaInteropResourceHandle cudaHandle
Bridge handle for cleanup.
Definition ImportedGpuBufferRing.hpp:52
QRhiBuffer * qrhiBuffer
QRhi-owned UAV / Storage buffer.
Definition ImportedGpuBufferRing.hpp:51
void * nativeVkBuffer
Definition ImportedGpuBufferRing.hpp:57
Definition ImportedGpuBufferRing.hpp:61
bool glRegisterOnly
Definition ImportedGpuBufferRing.hpp:79
CudaInteropContextHandle cudaCtx
Caller-owned, must be inited.
Definition ImportedGpuBufferRing.hpp:63