Loading...
Searching...
No Matches
GpuCapabilities.hpp
Go to the documentation of this file.
1#pragma once
2
38#include <score_plugin_gfx_export.h>
39
40#include <cstdint>
41
42class QRhi;
43
44namespace score::gfx::interop
45{
46
49enum class GpuVendor : uint8_t
50{
51 Unknown = 0,
54 Amd,
55 Apple,
56 Intel,
57 Other,
58};
59
63enum class HostOs : uint8_t
64{
65 Linux = 0,
66 Windows,
67 MacOS,
68 Other,
69};
70
75enum class QRhiBackendKind : uint8_t
76{
77 Unknown = 0,
78 OpenGL,
79 Vulkan,
80 D3D11,
81 D3D12,
82 Metal,
83 Null,
84};
85
90{
94 bool pinnedMemory{};
97 constexpr bool any() const noexcept
98 {
100 || pinnedMemory;
101 }
102};
103
105struct SCORE_PLUGIN_GFX_EXPORT GpuCapabilities
106{
107 // -- Identity --------------------------------------------------------
108 GpuVendor vendor{GpuVendor::Unknown};
109 HostOs os{HostOs::Other};
110 QRhiBackendKind backend{QRhiBackendKind::Unknown};
111
113 char rendererName[128]{};
114
117 char driverVersion[64]{};
118
119 // -- NVIDIA DVP ------------------------------------------------------
120
122 bool dvpLoaded{};
124 bool dvpHaveGl{};
126 bool dvpHaveD3D11{};
128 bool dvpHaveCuda{};
129
130 // -- CUDA driver API ------------------------------------------------
131
134 bool cudaLoaded{};
138 bool cudaVmmSupported{};
141 bool nvidiaPeermem{};
142
143 // -- AMD GL ----------------------------------------------------------
144
147
148 // -- Vulkan ----------------------------------------------------------
149
152 bool vkExternalMemorySupported{};
153
154 // -- Apple -----------------------------------------------------------
155
158 bool metalSupported{};
159
160 // -- Convenience capability helpers ----------------------------------
161
163 constexpr bool hasTier0() const noexcept
164 {
165 return (cudaVmmSupported && nvidiaPeermem) || amd.busAddressable;
166 }
167
169 constexpr bool hasTier1Dvp() const noexcept
170 {
171 return dvpLoaded && (dvpHaveGl || dvpHaveD3D11 || dvpHaveCuda);
172 }
173
181 constexpr bool rulesOutNvidiaPaths() const noexcept
182 {
183 return vendor == GpuVendor::Amd || vendor == GpuVendor::Intel
184 || vendor == GpuVendor::Apple;
185 }
186
188 constexpr bool hasTier2AmdPinned() const noexcept
189 {
190 return amd.externalVirtualMemory || amd.externalPhysicalMemory
191 || amd.pinnedMemory;
192 }
193};
194
200SCORE_PLUGIN_GFX_EXPORT
201GpuCapabilities probeContextFree();
202
206SCORE_PLUGIN_GFX_EXPORT
207void probeFromQRhi(GpuCapabilities& caps, QRhi* rhi) noexcept;
208
215SCORE_PLUGIN_GFX_EXPORT
216void probeGlExtensions(GpuCapabilities& caps) noexcept;
217
221SCORE_PLUGIN_GFX_EXPORT
222void probeGlExtensions(GpuCapabilities& caps, QRhi* rhi) noexcept;
223
226SCORE_PLUGIN_GFX_EXPORT
227const char* gpuVendorName(GpuVendor v) noexcept;
228SCORE_PLUGIN_GFX_EXPORT
229const char* qrhiBackendName(QRhiBackendKind b) noexcept;
230
231} // namespace score::gfx::interop
QRhiBackendKind
Definition GpuCapabilities.hpp:76
HostOs
Definition GpuCapabilities.hpp:64
GpuVendor
Definition GpuCapabilities.hpp:50
Definition GpuCapabilities.hpp:90
bool externalVirtualMemory
Definition GpuCapabilities.hpp:92
bool externalPhysicalMemory
Definition GpuCapabilities.hpp:93
bool pinnedMemory
Definition GpuCapabilities.hpp:94
constexpr bool any() const noexcept
Definition GpuCapabilities.hpp:97
bool busAddressable
Definition GpuCapabilities.hpp:91
Definition GpuCapabilities.hpp:106
constexpr bool hasTier1Dvp() const noexcept
Definition GpuCapabilities.hpp:169
constexpr bool rulesOutNvidiaPaths() const noexcept
Definition GpuCapabilities.hpp:181
constexpr bool hasTier0() const noexcept
Definition GpuCapabilities.hpp:163
constexpr bool hasTier2AmdPinned() const noexcept
Definition GpuCapabilities.hpp:188