rhi: vulkan: expose the instance in the nativeHandles query
Mainly for completeness, but it has practical uses: someone retrieving a QRhi instance from somewhere should be able to tell the QVulkanInstance, and so the VkInstance, used by that QRhi without resorting to investigating other objects (e.g. retrieving the instance from the QWindow). This provides symmetry to other 3D APIs and QRhi backends where just a single QRhi instance is sufficient to get the MTLDevice, ID3D11Device/Context, etc. i.e. all that is needed to work with the 3D API directly. Change-Id: I5a8b9871a543ea648c76b868bf6ff7be5f2098f2 Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>bb10
parent
1cd35cff4d
commit
afe0bf0914
|
|
@ -86,9 +86,12 @@ struct Q_GUI_EXPORT QRhiVulkanNativeHandles : public QRhiNativeHandles
|
|||
VkDevice dev = VK_NULL_HANDLE;
|
||||
quint32 gfxQueueFamilyIdx = 0;
|
||||
quint32 gfxQueueIdx = 0;
|
||||
VkQueue gfxQueue = VK_NULL_HANDLE;
|
||||
// and optionally, the mem allocator
|
||||
void *vmemAllocator = nullptr;
|
||||
|
||||
// only for querying (rhi->nativeHandles())
|
||||
VkQueue gfxQueue = VK_NULL_HANDLE;
|
||||
QVulkanInstance *inst = nullptr;
|
||||
};
|
||||
|
||||
struct Q_GUI_EXPORT QRhiVulkanCommandBufferNativeHandles : public QRhiNativeHandles
|
||||
|
|
|
|||
|
|
@ -225,6 +225,13 @@ QT_BEGIN_NAMESPACE
|
|||
Graphics queue index.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QRhiVulkanNativeHandles::vmemAllocator
|
||||
|
||||
Relevant only when importing an existing memory allocator object,
|
||||
leave it set to \nullptr otherwise.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QRhiVulkanNativeHandles::gfxQueue
|
||||
|
||||
|
|
@ -233,10 +240,10 @@ QT_BEGIN_NAMESPACE
|
|||
*/
|
||||
|
||||
/*!
|
||||
\variable QRhiVulkanNativeHandles::vmemAllocator
|
||||
\variable QRhiVulkanNativeHandles::inst
|
||||
|
||||
Relevant only when importing an existing memory allocator object,
|
||||
leave it set to \nullptr otherwise.
|
||||
Output only, not used by QRhi::create(), only set by the
|
||||
QRhi::nativeHandles() accessor. The QVulkanInstance used by the QRhi.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -819,6 +826,7 @@ bool QRhiVulkan::create(QRhi::Flags flags)
|
|||
nativeHandlesStruct.gfxQueueIdx = gfxQueueIdx;
|
||||
nativeHandlesStruct.gfxQueue = gfxQueue;
|
||||
nativeHandlesStruct.vmemAllocator = allocator;
|
||||
nativeHandlesStruct.inst = inst;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -487,6 +487,8 @@ void tst_QRhi::nativeHandles()
|
|||
case QRhi::Vulkan:
|
||||
{
|
||||
const QRhiVulkanNativeHandles *vkHandles = static_cast<const QRhiVulkanNativeHandles *>(rhiHandles);
|
||||
QVERIFY(vkHandles->inst);
|
||||
QCOMPARE(vkHandles->inst, &vulkanInstance);
|
||||
QVERIFY(vkHandles->physDev);
|
||||
QVERIFY(vkHandles->dev);
|
||||
QVERIFY(vkHandles->gfxQueue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue