rhi: Map DXGI_ADAPTER_FLAG_SOFTWARE onto the driverInfo's CpuDevice

Fixes: QTBUG-116756
Change-Id: I6218ea3f59716873853b8bf83b18e0a799eedcc3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
bb10
Laszlo Agocs 2023-09-06 14:54:07 +02:00
parent 5994e94fd1
commit 737dd95950
5 changed files with 29 additions and 18 deletions

View File

@ -8419,9 +8419,11 @@ const char *QRhi::backendName() const
/*!
\enum QRhiDriverInfo::DeviceType
Specifies the graphics device's type, when the information is available. In
practice this is only applicable with Vulkan and Metal. With others the
value will always be UnknownDevice.
Specifies the graphics device's type, when the information is available.
In practice this is only applicable with Vulkan and Metal. With Direct 3D
11 and 12, using an adapter with the software flag set leads to the value
\c CpuDevice. Otherwise, and with OpenGL, the value is always UnknownDevice.
\value UnknownDevice
\value IntegratedDevice

View File

@ -247,9 +247,7 @@ bool QRhiD3D11::create(QRhi::Flags flags)
if (!activeAdapter && (requestedAdapterIndex < 0 || requestedAdapterIndex == adapterIndex)) {
activeAdapter = adapter;
adapterLuid = desc.AdapterLuid;
driverInfoStruct.deviceName = name.toUtf8();
driverInfoStruct.deviceId = desc.DeviceId;
driverInfoStruct.vendorId = desc.VendorId;
QRhiD3D::fillDriverInfo(&driverInfoStruct, desc);
qCDebug(QRHI_LOG_INFO, " using this adapter");
} else {
adapter->Release();
@ -330,12 +328,14 @@ bool QRhiD3D11::create(QRhi::Flags flags)
if (SUCCEEDED(dev->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void **>(&dxgiDev)))) {
IDXGIAdapter *adapter = nullptr;
if (SUCCEEDED(dxgiDev->GetAdapter(&adapter))) {
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
adapterLuid = desc.AdapterLuid;
driverInfoStruct.deviceName = QString::fromUtf16(reinterpret_cast<char16_t *>(desc.Description)).toUtf8();
driverInfoStruct.deviceId = desc.DeviceId;
driverInfoStruct.vendorId = desc.VendorId;
IDXGIAdapter1 *adapter1 = nullptr;
if (SUCCEEDED(adapter->QueryInterface(__uuidof(IDXGIAdapter1), reinterpret_cast<void **>(&adapter1)))) {
DXGI_ADAPTER_DESC1 desc;
adapter1->GetDesc1(&desc);
adapterLuid = desc.AdapterLuid;
QRhiD3D::fillDriverInfo(&driverInfoStruct, desc);
adapter1->Release();
}
adapter->Release();
}
dxgiDev->Release();

View File

@ -254,9 +254,7 @@ bool QRhiD3D12::create(QRhi::Flags flags)
if (!activeAdapter && (requestedAdapterIndex < 0 || requestedAdapterIndex == adapterIndex)) {
activeAdapter = adapter;
adapterLuid = desc.AdapterLuid;
driverInfoStruct.deviceName = name.toUtf8();
driverInfoStruct.deviceId = desc.DeviceId;
driverInfoStruct.vendorId = desc.VendorId;
QRhiD3D::fillDriverInfo(&driverInfoStruct, desc);
qCDebug(QRHI_LOG_INFO, " using this adapter");
} else {
adapter->Release();
@ -290,9 +288,7 @@ bool QRhiD3D12::create(QRhi::Flags flags)
if (desc.AdapterLuid.LowPart == adapterLuid.LowPart
&& desc.AdapterLuid.HighPart == adapterLuid.HighPart)
{
driverInfoStruct.deviceName = QString::fromUtf16(reinterpret_cast<char16_t *>(desc.Description)).toUtf8();
driverInfoStruct.deviceId = desc.DeviceId;
driverInfoStruct.vendorId = desc.VendorId;
QRhiD3D::fillDriverInfo(&driverInfoStruct, desc);
break;
}
}

View File

@ -155,6 +155,16 @@ std::pair<IDxcCompiler *, IDxcLibrary *> createDxcCompiler()
}
#endif
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc)
{
const QString name = QString::fromUtf16(reinterpret_cast<const char16_t *>(desc.Description));
info->deviceName = name.toUtf8();
info->deviceId = desc.DeviceId;
info->vendorId = desc.VendorId;
info->deviceType = (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) ? QRhiDriverInfo::CpuDevice
: QRhiDriverInfo::UnknownDevice;
}
} // namespace
QT_END_NAMESPACE

View File

@ -17,6 +17,7 @@
#include <QtCore/private/qsystemlibrary_p.h>
#include <QtCore/private/qsystemerror_p.h>
#include <rhi/qrhi.h>
#include <QtGui/qwindow.h>
@ -45,6 +46,8 @@ IDCompositionDevice *createDirectCompositionDevice();
std::pair<IDxcCompiler *, IDxcLibrary *> createDxcCompiler();
#endif
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc);
} // namespace
QT_END_NAMESPACE