5#if defined(Q_OS_WIN) && defined(QGC_HAS_GST_D3D11_GPU_PATH)
9#include <gst/d3d11/gstd3d11.h>
17namespace GstD3D11ContextBridge {
20GstD3DContextBridgeCommon::BridgeState s_state;
22GstObject* createDevice(
const QLoggingCategory& cat)
27 qCWarning(cat) <<
"QRhi D3D11 snapshot missing ID3D11Device*";
34 ID3D11DeviceContext* immediate =
nullptr;
35 dev->GetImmediateContext(&immediate);
37 ID3D11Multithread* multithread =
nullptr;
38 if (SUCCEEDED(immediate->QueryInterface(__uuidof(ID3D11Multithread),
reinterpret_cast<void**
>(&multithread))) &&
40 multithread->SetMultithreadProtected(TRUE);
41 multithread->Release();
47 GstD3D11Device* device = gst_d3d11_device_new_wrapped(dev);
49 qCWarning(cat) <<
"gst_d3d11_device_new_wrapped failed";
54 GstD3DContextBridgeCommon::logAdapterMatch(expectedLuid, device, cat,
"D3D11");
55 return GST_OBJECT(device);
58GstContext* makeContext(GstObject* device)
61 return gst_d3d11_context_new(GST_D3D11_DEVICE_CAST(device));
64const GstD3DContextBridgeCommon::BridgeOps s_ops = {
65 "D3D11", GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE, &GstD3D11BridgeLog, int(QRhi::D3D11), &createDevice, &makeContext,
68struct D3D11BridgeRegistrar
70 D3D11BridgeRegistrar() { GstD3DContextBridgeCommon::registerBridge(GstD3D11BridgeLog(), &handleSyncMessage, &reset); }
73static D3D11BridgeRegistrar s_d3d11BridgeRegistrar;
79 return GstD3DContextBridgeCommon::prime(s_state, s_ops);
82GstD3D11Device* currentDevice()
84 return GST_D3D11_DEVICE_CAST(GstD3DContextBridgeCommon::currentDevice(s_state));
87GstBusSyncReply handleSyncMessage(GstMessage* message)
89 return GstD3DContextBridgeCommon::handleSyncMessage(s_state, s_ops, message);
92bool answerContextQuery(GstQuery* query)
94 return GstD3DContextBridgeCommon::answerContextQuery(s_state, s_ops, query);
99 GstD3DContextBridgeCommon::reset(s_state, s_ops);
#define QGC_LOGGING_CATEGORY(name, categoryStr)
DeviceSnapshot & deviceSnapshot() noexcept
Returns the global snapshot. Atomic fields make individual reads thread-safe.
std::atomic< void * > d3d11Device
ID3D11Device* (Windows only)
std::atomic< qint64 > adapterLuid
Composed (high<<32)|low LUID, 0 if unknown.