mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-08 07:33:33 +00:00
Add Adapter::GetDeviceType() (integrate vs. discrete vs. CPU)
BUG=chromium:852089 Change-Id: Ia447448392e09c5d604ae038b4758776ed3e66ee Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5180 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
bff933affc
commit
2ec74dcc3f
@ -26,6 +26,10 @@ namespace dawn_native {
|
|||||||
return mBackend;
|
return mBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceType AdapterBase::GetDeviceType() const {
|
||||||
|
return mDeviceType;
|
||||||
|
}
|
||||||
|
|
||||||
const PCIInfo& AdapterBase::GetPCIInfo() const {
|
const PCIInfo& AdapterBase::GetPCIInfo() const {
|
||||||
return mPCIInfo;
|
return mPCIInfo;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ namespace dawn_native {
|
|||||||
virtual ~AdapterBase() = default;
|
virtual ~AdapterBase() = default;
|
||||||
|
|
||||||
BackendType GetBackendType() const;
|
BackendType GetBackendType() const;
|
||||||
|
DeviceType GetDeviceType() const;
|
||||||
const PCIInfo& GetPCIInfo() const;
|
const PCIInfo& GetPCIInfo() const;
|
||||||
InstanceBase* GetInstance() const;
|
InstanceBase* GetInstance() const;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
PCIInfo mPCIInfo = {};
|
PCIInfo mPCIInfo = {};
|
||||||
|
DeviceType mDeviceType = DeviceType::Unknown;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ResultOrError<DeviceBase*> CreateDeviceImpl() = 0;
|
virtual ResultOrError<DeviceBase*> CreateDeviceImpl() = 0;
|
||||||
|
@ -41,6 +41,10 @@ namespace dawn_native {
|
|||||||
return mImpl->GetBackendType();
|
return mImpl->GetBackendType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceType Adapter::GetDeviceType() const {
|
||||||
|
return mImpl->GetDeviceType();
|
||||||
|
}
|
||||||
|
|
||||||
const PCIInfo& Adapter::GetPCIInfo() const {
|
const PCIInfo& Adapter::GetPCIInfo() const {
|
||||||
return mImpl->GetPCIInfo();
|
return mImpl->GetPCIInfo();
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,13 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mPCIInfo.deviceId = adapterDesc.DeviceId;
|
mPCIInfo.deviceId = adapterDesc.DeviceId;
|
||||||
mPCIInfo.vendorId = adapterDesc.VendorId;
|
mPCIInfo.vendorId = adapterDesc.VendorId;
|
||||||
|
|
||||||
|
if (adapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
|
||||||
|
mDeviceType = DeviceType::CPU;
|
||||||
|
} else {
|
||||||
|
// TODO(cwallez@chromium.org): properly detect integrated vs. discrete.
|
||||||
|
mDeviceType = DeviceType::DiscreteGPU;
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring_convert<DeletableFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> converter(
|
std::wstring_convert<DeletableFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> converter(
|
||||||
"Error converting");
|
"Error converting");
|
||||||
mPCIInfo.name = converter.to_bytes(adapterDesc.Description);
|
mPCIInfo.name = converter.to_bytes(adapterDesc.Description);
|
||||||
|
@ -129,6 +129,12 @@ namespace dawn_native { namespace metal {
|
|||||||
mPCIInfo.deviceId = GetEntryProperty(entry, CFSTR("device-id"));
|
mPCIInfo.deviceId = GetEntryProperty(entry, CFSTR("device-id"));
|
||||||
IOObjectRelease(entry);
|
IOObjectRelease(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([device isLowPower]) {
|
||||||
|
mDeviceType = DeviceType::IntegratedGPU;
|
||||||
|
} else {
|
||||||
|
mDeviceType = DeviceType::DiscreteGPU;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Adapter() override {
|
~Adapter() override {
|
||||||
|
@ -28,6 +28,7 @@ namespace dawn_native { namespace null {
|
|||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance) : AdapterBase(instance, BackendType::Null) {
|
Adapter(InstanceBase* instance) : AdapterBase(instance, BackendType::Null) {
|
||||||
mPCIInfo.name = "Null backend";
|
mPCIInfo.name = "Null backend";
|
||||||
|
mDeviceType = DeviceType::CPU;
|
||||||
}
|
}
|
||||||
virtual ~Adapter() = default;
|
virtual ~Adapter() = default;
|
||||||
|
|
||||||
|
@ -44,6 +44,21 @@ namespace dawn_native { namespace vulkan {
|
|||||||
mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
|
mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
|
||||||
mPCIInfo.name = mDeviceInfo.properties.deviceName;
|
mPCIInfo.name = mDeviceInfo.properties.deviceName;
|
||||||
|
|
||||||
|
switch (mDeviceInfo.properties.deviceType) {
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||||
|
mDeviceType = DeviceType::IntegratedGPU;
|
||||||
|
break;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||||
|
mDeviceType = DeviceType::DiscreteGPU;
|
||||||
|
break;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||||
|
mDeviceType = DeviceType::CPU;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mDeviceType = DeviceType::Unknown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,13 @@ namespace dawn_native {
|
|||||||
Vulkan,
|
Vulkan,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class DeviceType {
|
||||||
|
DiscreteGPU,
|
||||||
|
IntegratedGPU,
|
||||||
|
CPU,
|
||||||
|
Unknown,
|
||||||
|
};
|
||||||
|
|
||||||
class InstanceBase;
|
class InstanceBase;
|
||||||
class AdapterBase;
|
class AdapterBase;
|
||||||
|
|
||||||
@ -53,6 +60,7 @@ namespace dawn_native {
|
|||||||
~Adapter();
|
~Adapter();
|
||||||
|
|
||||||
BackendType GetBackendType() const;
|
BackendType GetBackendType() const;
|
||||||
|
DeviceType GetDeviceType() const;
|
||||||
const PCIInfo& GetPCIInfo() const;
|
const PCIInfo& GetPCIInfo() const;
|
||||||
|
|
||||||
explicit operator bool() const;
|
explicit operator bool() const;
|
||||||
|
@ -52,6 +52,21 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* DeviceTypeName(dawn_native::DeviceType type) {
|
||||||
|
switch (type) {
|
||||||
|
case dawn_native::DeviceType::DiscreteGPU:
|
||||||
|
return "Discrete GPU";
|
||||||
|
case dawn_native::DeviceType::IntegratedGPU:
|
||||||
|
return "Integrated GPU";
|
||||||
|
case dawn_native::DeviceType::CPU:
|
||||||
|
return "CPU";
|
||||||
|
case dawn_native::DeviceType::Unknown:
|
||||||
|
return "Unknown";
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct MapReadUserdata {
|
struct MapReadUserdata {
|
||||||
DawnTest* test;
|
DawnTest* test;
|
||||||
size_t slot;
|
size_t slot;
|
||||||
@ -130,7 +145,9 @@ void DawnTestEnvironment::SetUp() {
|
|||||||
deviceId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
deviceId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
||||||
<< pci.deviceId;
|
<< pci.deviceId;
|
||||||
|
|
||||||
std::cout << " - \"" << pci.name << "\" on " << ParamName(adapter.GetBackendType()) << "\n";
|
std::cout << " - \"" << pci.name << "\"\n";
|
||||||
|
std::cout << " type: " << DeviceTypeName(adapter.GetDeviceType())
|
||||||
|
<< ", backend: " << ParamName(adapter.GetBackendType()) << "\n";
|
||||||
std::cout << " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
std::cout << " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user