diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-24 16:34:53 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-29 10:17:25 +0200 |
commit | 9c39dd56283c74d28254c0b01f2edddb66919c08 (patch) | |
tree | 6427f5e5abe4747b4ab7f164d8a182a5ef634c38 /src/quick/scenegraph/qsgrhisupport.cpp | |
parent | a2c0fc9e87d84aee77b45705a092f86e4cd96ad8 (diff) |
Make it possible to specify an adapter or physical device only
As required by OpenXR.
While we are at it, make the API a bit more type safe.
Change-Id: I3c6152feeb71359056830ab02d35f8cb258722c0
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index e8edbeac57..891beb0d90 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -605,9 +605,15 @@ QRhi *QSGRhiSupport::createRhi(QQuickWindow *window, QOffscreenSurface *offscree importDev.physDev = reinterpret_cast<VkPhysicalDevice>(customDevD->u.deviceObjects.physicalDevice); importDev.dev = reinterpret_cast<VkDevice>(customDevD->u.deviceObjects.device); importDev.gfxQueueFamilyIdx = customDevD->u.deviceObjects.queueFamilyIndex; + importDev.gfxQueueIdx = customDevD->u.deviceObjects.queueIndex; qCDebug(QSG_LOG_INFO, "Using existing native Vulkan physical device %p device %p graphics queue family index %d", importDev.physDev, importDev.dev, importDev.gfxQueueFamilyIdx); rhi = QRhi::create(backend, &rhiParams, flags, &importDev); + } else if (customDevD->type == QQuickGraphicsDevicePrivate::Type::PhysicalDevice) { + QRhiVulkanNativeHandles importDev; + importDev.physDev = reinterpret_cast<VkPhysicalDevice>(customDevD->u.physicalDevice.physicalDevice); + qCDebug(QSG_LOG_INFO, "Using existing native Vulkan physical device %p", importDev.physDev); + rhi = QRhi::create(backend, &rhiParams, flags, &importDev); } else { rhi = QRhi::create(backend, &rhiParams, flags); } @@ -628,6 +634,14 @@ QRhi *QSGRhiSupport::createRhi(QQuickWindow *window, QOffscreenSurface *offscree qCDebug(QSG_LOG_INFO, "Using existing native D3D11 device %p and context %p", importDev.dev, importDev.context); rhi = QRhi::create(backend, &rhiParams, flags, &importDev); + } else if (customDevD->type == QQuickGraphicsDevicePrivate::Type::Adapter) { + QRhiD3D11NativeHandles importDev; + importDev.adapterLuidLow = customDevD->u.adapter.luidLow; + importDev.adapterLuidHigh = customDevD->u.adapter.luidHigh; + importDev.featureLevel = customDevD->u.adapter.featureLevel; + qCDebug(QSG_LOG_INFO, "Using D3D11 adapter LUID %u, %d and feature level %d", + importDev.adapterLuidLow, importDev.adapterLuidHigh, importDev.featureLevel); + rhi = QRhi::create(backend, &rhiParams, flags, &importDev); } else { rhi = QRhi::create(backend, &rhiParams, flags); } @@ -638,8 +652,8 @@ QRhi *QSGRhiSupport::createRhi(QQuickWindow *window, QOffscreenSurface *offscree QRhiMetalInitParams rhiParams; if (customDevD->type == QQuickGraphicsDevicePrivate::Type::DeviceAndCommandQueue) { QRhiMetalNativeHandles importDev; - importDev.dev = customDevD->u.deviceAndCommandQueue.device; - importDev.cmdQueue = customDevD->u.deviceAndCommandQueue.cmdQueue; + importDev.dev = (MTLDevice *) customDevD->u.deviceAndCommandQueue.device; + importDev.cmdQueue = (MTLCommandQueue *) customDevD->u.deviceAndCommandQueue.cmdQueue; qCDebug(QSG_LOG_INFO, "Using existing native Metal device %p and command queue %p", importDev.dev, importDev.cmdQueue); rhi = QRhi::create(backend, &rhiParams, flags, &importDev); |