From 042cd97884bb86dfd0bedaa63480d99846ab06bb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 12 Jan 2021 13:02:13 +0100 Subject: rhi: Expose device name, type, and IDs ...to the extent it is sensible. We have to make compromises still, meaning some fields will only be applicable with certain APIs. Most of this is already shown upon QRhi::create() as info debug prints, when enabled. Now expose it all through the QRhi API as well. This is useful for printing in qtdiag, and, while it should be avoided as much as possible, to make decisions about disabling 3D rendering features depending on the driver and GPU in use. Change-Id: Iebe1e192965c928b82a094d1c7c50ddf4b38b9a2 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhimetal.mm | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/gui/rhi/qrhimetal.mm') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 9e0655ef06..5a1183b8ef 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -372,7 +372,30 @@ bool QRhiMetal::create(QRhi::Flags flags) return false; } - qCDebug(QRHI_LOG_INFO, "Metal device: %s", qPrintable(QString::fromNSString([d->dev name]))); + const QString deviceName = QString::fromNSString([d->dev name]); + qCDebug(QRHI_LOG_INFO, "Metal device: %s", qPrintable(deviceName)); + driverInfoStruct.deviceName = deviceName.toUtf8(); + driverInfoStruct.deviceId = [d->dev registryID]; +#ifdef Q_OS_IOS + driverInfoStruct.deviceType = QRhiDriverInfo::IntegratedDevice; +#else + if (@available(macOS 10.15, *)) { + const MTLDeviceLocation deviceLocation = [d->dev location]; + switch (deviceLocation) { + case MTLDeviceLocationBuiltIn: + driverInfoStruct.deviceType = QRhiDriverInfo::IntegratedDevice; + break; + case MTLDeviceLocationSlot: + driverInfoStruct.deviceType = QRhiDriverInfo::DiscreteDevice; + break; + case MTLDeviceLocationExternal: + driverInfoStruct.deviceType = QRhiDriverInfo::ExternalDevice; + break; + default: + break; + } + } +#endif if (importedCmdQueue) [d->cmdQueue retain]; @@ -615,6 +638,11 @@ const QRhiNativeHandles *QRhiMetal::nativeHandles() return &nativeHandlesStruct; } +QRhiDriverInfo QRhiMetal::driverInfo() const +{ + return driverInfoStruct; +} + void QRhiMetal::sendVMemStatsToProfiler() { // nothing to do here -- cgit v1.2.3