From efef0e4b1fc4138d6424e526cc67a4c1aecab2a3 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Fri, 10 May 2019 02:18:49 +0000 Subject: [PATCH] Detect integrated device type on Intel iGPUs. Fix to prevent incorrectly reporting the device type. BUG=dawn:144 Change-Id: Ie1956d908b20649787aef785cd29f0f63f524431 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6980 Reviewed-by: Kai Ninomiya Commit-Queue: Bryan Bernhart --- src/common/Constants.h | 7 +++++++ src/dawn_native/d3d12/AdapterD3D12.cpp | 20 ++++++++++++++++++-- src/tests/DawnTest.cpp | 7 ------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/common/Constants.h b/src/common/Constants.h index 7641502b84..7aa9039415 100644 --- a/src/common/Constants.h +++ b/src/common/Constants.h @@ -38,4 +38,11 @@ static constexpr uint32_t kTextureRowPitchAlignment = 256u; static constexpr float kLodMin = 0.0; static constexpr float kLodMax = 1000.0; +static constexpr uint32_t kVendorID_AMD = 0x1002; +static constexpr uint32_t kVendorID_ARM = 0x13B5; +static constexpr uint32_t kVendorID_ImgTec = 0x1010; +static constexpr uint32_t kVendorID_Intel = 0x8086; +static constexpr uint32_t kVendorID_Nvidia = 0x10DE; +static constexpr uint32_t kVendorID_Qualcomm = 0x5143; + #endif // COMMON_CONSTANTS_H_ diff --git a/src/dawn_native/d3d12/AdapterD3D12.cpp b/src/dawn_native/d3d12/AdapterD3D12.cpp index a5df7e477a..16fc617f93 100644 --- a/src/dawn_native/d3d12/AdapterD3D12.cpp +++ b/src/dawn_native/d3d12/AdapterD3D12.cpp @@ -14,6 +14,7 @@ #include "dawn_native/d3d12/AdapterD3D12.h" +#include "common/Constants.h" #include "dawn_native/d3d12/BackendD3D12.h" #include "dawn_native/d3d12/DeviceD3D12.h" #include "dawn_native/d3d12/PlatformFunctions.h" @@ -46,8 +47,23 @@ namespace dawn_native { namespace d3d12 { if (adapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) { mDeviceType = DeviceType::CPU; } else { - // TODO(cwallez@chromium.org): properly detect integrated vs. discrete. - mDeviceType = DeviceType::DiscreteGPU; + // Using DXGI_ADAPTER_DESC1 approach to determine integrated vs dedicated is + // vendor-specific. + switch (mPCIInfo.vendorId) { + case kVendorID_Intel: { + // On Intel GPUs, dedicated video memory is always set to 128MB when the GPU is + // integrated. + static constexpr uint64_t kDedicatedVideoMemory = 128 * 1024 * 1024; + mDeviceType = (adapterDesc.DedicatedVideoMemory == kDedicatedVideoMemory) + ? DeviceType::IntegratedGPU + : DeviceType::DiscreteGPU; + break; + } + default: + // TODO: Support additional GPU vendors. + mDeviceType = DeviceType::Unknown; + break; + } } std::wstring_convert>> converter( diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index 1d3c8ff376..b0f423b9cd 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -78,13 +78,6 @@ namespace { size_t slot; }; - constexpr uint32_t kVendorID_AMD = 0x1002; - constexpr uint32_t kVendorID_ARM = 0x13B5; - constexpr uint32_t kVendorID_ImgTec = 0x1010; - constexpr uint32_t kVendorID_Intel = 0x8086; - constexpr uint32_t kVendorID_Nvidia = 0x10DE; - constexpr uint32_t kVendorID_Qualcomm = 0x5143; - DawnTestEnvironment* gTestEnv = nullptr; } // namespace