Loading...
Searching...
No Matches
AmdPinnedBuffers.hpp
Go to the documentation of this file.
1#pragma once
2
38#include <score_plugin_gfx_export.h>
39
40#include <cstddef>
41#include <cstdint>
42
43class QOpenGLContext;
44
45namespace score::gfx::interop
46{
47
50namespace amd_gl_tokens
51{
52constexpr unsigned int EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD = 0x9160;
53constexpr unsigned int BUS_ADDRESSABLE_MEMORY_AMD = 0x9168;
54constexpr unsigned int EXTERNAL_VIRTUAL_MEMORY_AMD = 0x9161;
55constexpr unsigned int EXTERNAL_PHYSICAL_MEMORY_AMD = 0x9162;
56} // namespace amd_gl_tokens
57
59struct SCORE_PLUGIN_GFX_EXPORT AmdPinnedBuffers
60{
61 // -- Presence flags --------------------------------------------------
62
64 bool hasPinnedMemory{};
66 bool hasBusAddressable{};
69 bool hasExternalVirtualMemory{};
72 bool hasExternalPhysicalMemory{};
73
74 // -- Resolved entry points (bus-addressable only) -------------------
75
79 = void (*)(int /*n*/, const unsigned int* /*buffers*/,
80 uint64_t* /*busAddr*/, uint64_t* /*markerAddr*/);
81 FN_MakeBuffersResident makeBuffersResident{};
82
86 = void (*)(unsigned int /*target*/, std::ptrdiff_t /*size*/,
87 uint64_t /*busAddr*/, uint64_t /*markerAddr*/);
88 FN_BufferBusAddress bufferBusAddress{};
89
90 // -- API ------------------------------------------------------------
91
98 bool tryInit(QOpenGLContext* ctx = nullptr) noexcept;
99
103 bool any() const noexcept
104 {
105 return hasPinnedMemory || hasBusAddressable || hasExternalVirtualMemory
106 || hasExternalPhysicalMemory;
107 }
108
122 unsigned int createPinnedBuffer(
123 unsigned int target, std::size_t size_bytes, void* host_ptr,
124 unsigned int usage) noexcept;
125
135 unsigned int createBusAddressableBuffer(
136 std::size_t size_bytes, unsigned int usage, uint64_t* out_busAddr,
137 uint64_t* out_markerAddr) noexcept;
138};
139
140} // namespace score::gfx::interop
Definition AmdPinnedBuffers.hpp:60
void(*)(unsigned int, std::ptrdiff_t, uint64_t, uint64_t) FN_BufferBusAddress
Definition AmdPinnedBuffers.hpp:87
void(*)(int, const unsigned int *, uint64_t *, uint64_t *) FN_MakeBuffersResident
Definition AmdPinnedBuffers.hpp:80