Add WGPUAdapterProperties and expose it in DawnNative

The dawn_native::Adapter::GetPCIInfo/GetBackendType/GetDeviceType
methods are now deprecated in favor of a method returning a webgpu.h
AdapterProperties structure. Deprecated function are still available to
avoid breaking Chromium or Skia compilation.

This reduces the difference between dawn.json and webgpu.h

BUG=dawn:160

Change-Id: Ib68fe1c4d1d87676c01c212c91f80fdd26056c56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2020-01-10 13:28:18 +00:00
committed by Commit Bot service account
parent 5fc2c82c11
commit f12c9dba6d
27 changed files with 237 additions and 143 deletions

View File

@@ -44,12 +44,44 @@ namespace dawn_native {
mImpl = nullptr;
}
void Adapter::GetProperties(wgpu::AdapterProperties* properties) const {
properties->backendType = mImpl->GetBackendType();
properties->adapterType = mImpl->GetAdapterType();
properties->deviceID = mImpl->GetPCIInfo().deviceId;
properties->vendorID = mImpl->GetPCIInfo().vendorId;
properties->name = mImpl->GetPCIInfo().name.c_str();
}
BackendType Adapter::GetBackendType() const {
return mImpl->GetBackendType();
switch (mImpl->GetBackendType()) {
case wgpu::BackendType::D3D12:
return BackendType::D3D12;
case wgpu::BackendType::Metal:
return BackendType::Metal;
case wgpu::BackendType::Null:
return BackendType::Null;
case wgpu::BackendType::OpenGL:
return BackendType::OpenGL;
case wgpu::BackendType::Vulkan:
return BackendType::Vulkan;
default:
UNREACHABLE();
return BackendType::Null;
}
}
DeviceType Adapter::GetDeviceType() const {
return mImpl->GetDeviceType();
switch (mImpl->GetAdapterType()) {
case wgpu::AdapterType::DiscreteGPU:
return DeviceType::DiscreteGPU;
case wgpu::AdapterType::IntegratedGPU:
return DeviceType::IntegratedGPU;
case wgpu::AdapterType::CPU:
return DeviceType::CPU;
case wgpu::AdapterType::Unknown:
return DeviceType::Unknown;
}
}
const PCIInfo& Adapter::GetPCIInfo() const {
@@ -75,7 +107,8 @@ namespace dawn_native {
// AdapterDiscoverOptionsBase
AdapterDiscoveryOptionsBase::AdapterDiscoveryOptionsBase(BackendType type) : backendType(type) {
AdapterDiscoveryOptionsBase::AdapterDiscoveryOptionsBase(WGPUBackendType type)
: backendType(type) {
}
// Instance