Remove deprecated DawnNative Adapter getters.

Bug: dawn:824
Change-Id: I4e73598ccd8eb5ce85c8a0ed86629daef4b575c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75584
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2022-01-11 09:30:34 +00:00 committed by Dawn LUCI CQ
parent 98b6b73ac0
commit f07477a1ce
14 changed files with 62 additions and 139 deletions

View File

@ -33,14 +33,12 @@ namespace dawn_native {
InitializeSupportedFeaturesImpl(),
"gathering supported features for \"%s\" - \"%s\" (vendorId=%#06x deviceId=%#06x "
"backend=%s type=%s)",
mPCIInfo.name, mDriverDescription, mPCIInfo.vendorId, mPCIInfo.deviceId, mBackend,
mAdapterType);
mName, mDriverDescription, mVendorId, mDeviceId, mBackend, mAdapterType);
DAWN_TRY_CONTEXT(
InitializeSupportedLimitsImpl(&mLimits),
"gathering supported limits for \"%s\" - \"%s\" (vendorId=%#06x deviceId=%#06x "
"backend=%s type=%s)",
mPCIInfo.name, mDriverDescription, mPCIInfo.vendorId, mPCIInfo.deviceId, mBackend,
mAdapterType);
mName, mDriverDescription, mVendorId, mDeviceId, mBackend, mAdapterType);
// Enforce internal Dawn constants.
mLimits.v1.maxVertexBufferArrayStride =
@ -77,9 +75,9 @@ namespace dawn_native {
}
void AdapterBase::APIGetProperties(AdapterProperties* properties) const {
properties->vendorID = mPCIInfo.vendorId;
properties->deviceID = mPCIInfo.deviceId;
properties->name = mPCIInfo.name.c_str();
properties->vendorID = mVendorId;
properties->deviceID = mDeviceId;
properties->name = mName.c_str();
properties->driverDescription = mDriverDescription.c_str();
properties->adapterType = mAdapterType;
properties->backendType = mBackend;
@ -125,22 +123,18 @@ namespace dawn_native {
callback(status, ToAPI(device.Detach()), nullptr, userdata);
}
uint32_t AdapterBase::GetVendorId() const {
return mVendorId;
}
uint32_t AdapterBase::GetDeviceId() const {
return mDeviceId;
}
wgpu::BackendType AdapterBase::GetBackendType() const {
return mBackend;
}
wgpu::AdapterType AdapterBase::GetAdapterType() const {
return mAdapterType;
}
const std::string& AdapterBase::GetDriverDescription() const {
return mDriverDescription;
}
const PCIInfo& AdapterBase::GetPCIInfo() const {
return mPCIInfo;
}
InstanceBase* AdapterBase::GetInstance() const {
return mInstance;
}
@ -161,8 +155,8 @@ namespace dawn_native {
WGPUDeviceProperties AdapterBase::GetAdapterProperties() const {
WGPUDeviceProperties adapterProperties = {};
adapterProperties.deviceID = mPCIInfo.deviceId;
adapterProperties.vendorID = mPCIInfo.vendorId;
adapterProperties.deviceID = mDeviceId;
adapterProperties.vendorID = mVendorId;
adapterProperties.adapterType = static_cast<WGPUAdapterType>(mAdapterType);
mSupportedFeatures.InitializeDeviceProperties(&adapterProperties);

View File

@ -47,10 +47,9 @@ namespace dawn_native {
void* userdata);
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
uint32_t GetVendorId() const;
uint32_t GetDeviceId() const;
wgpu::BackendType GetBackendType() const;
wgpu::AdapterType GetAdapterType() const;
const std::string& GetDriverDescription() const;
const PCIInfo& GetPCIInfo() const;
InstanceBase* GetInstance() const;
void ResetInternalDeviceForTesting();
@ -67,7 +66,9 @@ namespace dawn_native {
virtual bool SupportsExternalImages() const = 0;
protected:
PCIInfo mPCIInfo = {};
uint32_t mVendorId = 0xFFFFFFFF;
uint32_t mDeviceId = 0xFFFFFFFF;
std::string mName;
wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown;
std::string mDriverDescription;
FeaturesSet mSupportedFeatures;

View File

@ -86,56 +86,11 @@ namespace dawn_native {
Adapter& Adapter::operator=(const Adapter& other) = default;
void Adapter::GetProperties(wgpu::AdapterProperties* properties) const {
properties->backendType = mImpl->GetBackendType();
properties->adapterType = mImpl->GetAdapterType();
properties->driverDescription = mImpl->GetDriverDescription().c_str();
properties->deviceID = mImpl->GetPCIInfo().deviceId;
properties->vendorID = mImpl->GetPCIInfo().vendorId;
properties->name = mImpl->GetPCIInfo().name.c_str();
GetProperties(reinterpret_cast<WGPUAdapterProperties*>(properties));
}
void Adapter::GetProperties(WGPUAdapterProperties* properties) const {
GetProperties(reinterpret_cast<wgpu::AdapterProperties*>(properties));
}
BackendType Adapter::GetBackendType() const {
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;
case wgpu::BackendType::OpenGLES:
return BackendType::OpenGLES;
case wgpu::BackendType::D3D11:
case wgpu::BackendType::WebGPU:
break;
}
UNREACHABLE();
}
DeviceType Adapter::GetDeviceType() const {
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;
}
UNREACHABLE();
}
const PCIInfo& Adapter::GetPCIInfo() const {
return mImpl->GetPCIInfo();
mImpl->APIGetProperties(FromAPI(properties));
}
WGPUAdapter Adapter::Get() const {

View File

@ -76,9 +76,9 @@ namespace dawn_native::d3d12 {
DXGI_ADAPTER_DESC1 adapterDesc;
mHardwareAdapter->GetDesc1(&adapterDesc);
mPCIInfo.deviceId = adapterDesc.DeviceId;
mPCIInfo.vendorId = adapterDesc.VendorId;
mPCIInfo.name = WCharToUTF8(adapterDesc.Description);
mDeviceId = adapterDesc.DeviceId;
mVendorId = adapterDesc.VendorId;
mName = WCharToUTF8(adapterDesc.Description);
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));

View File

@ -54,7 +54,7 @@ namespace dawn_native::d3d12 {
// with RENDER_PASS_TIER_1 available, so fall back to a software emulated render
// pass on these platforms.
if (featureOptions5.RenderPassesTier < D3D12_RENDER_PASS_TIER_1 ||
!gpu_info::IsIntel(adapter.GetPCIInfo().vendorId)) {
!gpu_info::IsIntel(adapter.GetVendorId())) {
info.supportsRenderPass = true;
}
}

View File

@ -584,15 +584,16 @@ namespace dawn_native::d3d12 {
// By default use the maximum shader-visible heap size allowed.
SetToggle(Toggle::UseD3D12SmallShaderVisibleHeapForTesting, false);
PCIInfo pciInfo = GetAdapter()->GetPCIInfo();
uint32_t deviceId = GetAdapter()->GetDeviceId();
uint32_t vendorId = GetAdapter()->GetVendorId();
// Currently this workaround is only needed on Intel Gen9 and Gen9.5 GPUs.
// See http://crbug.com/1161355 for more information.
if (gpu_info::IsIntel(pciInfo.vendorId) &&
(gpu_info::IsSkylake(pciInfo.deviceId) || gpu_info::IsKabylake(pciInfo.deviceId) ||
gpu_info::IsCoffeelake(pciInfo.deviceId))) {
if (gpu_info::IsIntel(vendorId) &&
(gpu_info::IsSkylake(deviceId) || gpu_info::IsKabylake(deviceId) ||
gpu_info::IsCoffeelake(deviceId))) {
constexpr gpu_info::D3DDriverVersion kFirstDriverVersionWithFix = {30, 0, 100, 9864};
if (gpu_info::CompareD3DDriverVersion(pciInfo.vendorId,
if (gpu_info::CompareD3DDriverVersion(vendorId,
ToBackend(GetAdapter())->GetDriverVersion(),
kFirstDriverVersionWithFix) < 0) {
SetToggle(

View File

@ -243,12 +243,12 @@ namespace dawn_native::metal {
public:
Adapter(InstanceBase* instance, id<MTLDevice> device)
: AdapterBase(instance, wgpu::BackendType::Metal), mDevice(device) {
mPCIInfo.name = std::string([[*mDevice name] UTF8String]);
mName = std::string([[*mDevice name] UTF8String]);
PCIIDs ids;
if (!instance->ConsumedError(GetDevicePCIInfo(device, &ids))) {
mPCIInfo.vendorId = ids.vendorId;
mPCIInfo.deviceId = ids.deviceId;
mVendorId = ids.vendorId;
mDeviceId = ids.deviceId;
}
#if defined(DAWN_PLATFORM_IOS)
@ -311,7 +311,7 @@ namespace dawn_native::metal {
// fails to call without any copy commands on MTLBlitCommandEncoder. This issue
// has been fixed on macOS 11.0. See crbug.com/dawn/545
enableTimestampQuery &=
!(gpu_info::IsAMD(GetPCIInfo().vendorId) && IsMacOSVersionAtLeast(11));
!(gpu_info::IsAMD(mVendorId) && IsMacOSVersionAtLeast(11));
#endif
if (enableTimestampQuery) {

View File

@ -137,8 +137,7 @@ namespace dawn_native::metal {
if (IsFeatureEnabled(Feature::TimestampQuery)) {
// Make a best guess of timestamp period based on device vendor info, and converge it to
// an accurate value by the following calculations.
mTimestampPeriod =
gpu_info::IsIntel(GetAdapter()->GetPCIInfo().vendorId) ? 83.333f : 1.0f;
mTimestampPeriod = gpu_info::IsIntel(GetAdapter()->GetVendorId()) ? 83.333f : 1.0f;
// Initialize kalman filter parameters
mKalmanInfo = std::make_unique<KalmanInfo>();
@ -199,27 +198,28 @@ namespace dawn_native::metal {
// TODO(crbug.com/dawn/846): tighten this workaround when the driver bug is fixed.
SetToggle(Toggle::AlwaysResolveIntoZeroLevelAndLayer, true);
const PCIInfo& pciInfo = GetAdapter()->GetPCIInfo();
uint32_t deviceId = GetAdapter()->GetDeviceId();
uint32_t vendorId = GetAdapter()->GetVendorId();
// TODO(crbug.com/dawn/847): Use MTLStorageModeShared instead of MTLStorageModePrivate when
// creating MTLCounterSampleBuffer in QuerySet on Intel platforms, otherwise it fails to
// create the buffer. Change to use MTLStorageModePrivate when the bug is fixed.
if (@available(macOS 10.15, iOS 14.0, *)) {
bool useSharedMode = gpu_info::IsIntel(pciInfo.vendorId);
bool useSharedMode = gpu_info::IsIntel(vendorId);
SetToggle(Toggle::MetalUseSharedModeForCounterSampleBuffer, useSharedMode);
}
// TODO(crbug.com/dawn/1071): r8unorm and rg8unorm textures with multiple mip levels don't
// clear properly on Intel Macs.
if (gpu_info::IsIntel(pciInfo.vendorId)) {
if (gpu_info::IsIntel(vendorId)) {
SetToggle(Toggle::DisableR8RG8Mipmaps, true);
}
// On some Intel GPU vertex only render pipeline get wrong depth result if no fragment
// shader provided. Create a dummy fragment shader module to work around this issue.
if (gpu_info::IsIntel(this->GetAdapter()->GetPCIInfo().vendorId)) {
if (gpu_info::IsIntel(vendorId)) {
bool useDummyFragmentShader = true;
if (gpu_info::IsSkylake(this->GetAdapter()->GetPCIInfo().deviceId)) {
if (gpu_info::IsSkylake(deviceId)) {
useDummyFragmentShader = false;
}
SetToggle(Toggle::UseDummyFragmentInVertexOnlyPipeline, useDummyFragmentShader);

View File

@ -25,7 +25,9 @@ namespace dawn_native::null {
// Implementation of pre-Device objects: the null adapter, null backend connection and Connect()
Adapter::Adapter(InstanceBase* instance) : AdapterBase(instance, wgpu::BackendType::Null) {
mPCIInfo.name = "Null backend";
mVendorId = 0;
mDeviceId = 0;
mName = "Null backend";
mAdapterType = wgpu::AdapterType::CPU;
MaybeError err = Initialize();
ASSERT(err.IsSuccess());

View File

@ -186,16 +186,16 @@ namespace dawn_native::opengl {
}
mFunctions.Enable(GL_SAMPLE_MASK);
mPCIInfo.name = reinterpret_cast<const char*>(mFunctions.GetString(GL_RENDERER));
mName = reinterpret_cast<const char*>(mFunctions.GetString(GL_RENDERER));
// Workaroud to find vendor id from vendor name
const char* vendor = reinterpret_cast<const char*>(mFunctions.GetString(GL_VENDOR));
mPCIInfo.vendorId = GetVendorIdFromVendors(vendor);
mVendorId = GetVendorIdFromVendors(vendor);
mDriverDescription = std::string("OpenGL version ") +
reinterpret_cast<const char*>(mFunctions.GetString(GL_VERSION));
if (mPCIInfo.name.find("SwiftShader") != std::string::npos) {
if (mName.find("SwiftShader") != std::string::npos) {
mAdapterType = wgpu::AdapterType::CPU;
}

View File

@ -65,9 +65,9 @@ namespace dawn_native::vulkan {
"Vulkan driver version: " + std::to_string(mDeviceInfo.properties.driverVersion);
}
mPCIInfo.deviceId = mDeviceInfo.properties.deviceID;
mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
mPCIInfo.name = mDeviceInfo.properties.deviceName;
mDeviceId = mDeviceInfo.properties.deviceID;
mVendorId = mDeviceInfo.properties.vendorID;
mName = mDeviceInfo.properties.deviceName;
switch (mDeviceInfo.properties.deviceType) {
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:

View File

@ -33,31 +33,6 @@ namespace wgpu {
namespace dawn_native {
// DEPRECATED: use WGPUAdapterProperties instead.
struct PCIInfo {
uint32_t deviceId = 0;
uint32_t vendorId = 0;
std::string name;
};
// DEPRECATED: use WGPUBackendType instead.
enum class BackendType {
D3D12,
Metal,
Null,
OpenGL,
OpenGLES,
Vulkan,
};
// DEPRECATED: use WGPUAdapterType instead.
enum class DeviceType {
DiscreteGPU,
IntegratedGPU,
CPU,
Unknown,
};
class InstanceBase;
class AdapterBase;
@ -100,11 +75,6 @@ namespace dawn_native {
Adapter(const Adapter& other);
Adapter& operator=(const Adapter& other);
// DEPRECATED: use GetProperties instead.
BackendType GetBackendType() const;
DeviceType GetDeviceType() const;
const PCIInfo& GetPCIInfo() const;
// Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in
// dawn.json
void GetProperties(wgpu::AdapterProperties* properties) const;

View File

@ -323,11 +323,11 @@ void DawnTestEnvironment::ParseArgs(int argc, char** argv) {
std::string type;
while (std::getline(ss, type, ',')) {
if (strcmp(type.c_str(), "discrete") == 0) {
mDevicePreferences.push_back(dawn_native::DeviceType::DiscreteGPU);
mDevicePreferences.push_back(wgpu::AdapterType::DiscreteGPU);
} else if (strcmp(type.c_str(), "integrated") == 0) {
mDevicePreferences.push_back(dawn_native::DeviceType::IntegratedGPU);
mDevicePreferences.push_back(wgpu::AdapterType::IntegratedGPU);
} else if (strcmp(type.c_str(), "cpu") == 0) {
mDevicePreferences.push_back(dawn_native::DeviceType::CPU);
mDevicePreferences.push_back(wgpu::AdapterType::CPU);
} else {
dawn::ErrorLog() << "Invalid device type preference: " << type;
UNREACHABLE();
@ -474,14 +474,14 @@ GLFWwindow* DawnTestEnvironment::GetOpenGLESWindow() const {
void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::Instance* instance) {
// Get the first available preferred device type.
dawn_native::DeviceType preferredDeviceType = static_cast<dawn_native::DeviceType>(-1);
wgpu::AdapterType preferredDeviceType = static_cast<wgpu::AdapterType>(-1);
bool hasDevicePreference = false;
for (dawn_native::DeviceType devicePreference : mDevicePreferences) {
for (wgpu::AdapterType devicePreference : mDevicePreferences) {
for (const dawn_native::Adapter& adapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
if (adapter.GetDeviceType() == devicePreference) {
if (properties.adapterType == devicePreference) {
preferredDeviceType = devicePreference;
hasDevicePreference = true;
break;
@ -517,12 +517,12 @@ void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::In
selected &=
// The device type doesn't match the first available preferred type for that
// backend, if present.
(adapter.GetDeviceType() == preferredDeviceType) ||
(properties.adapterType == preferredDeviceType) ||
// Always select Unknown OpenGL adapters if we don't want a CPU adapter.
// OpenGL will usually be unknown because we can't query the device type.
// If we ever have Swiftshader GL (unlikely), we could set the DeviceType properly.
(preferredDeviceType != dawn_native::DeviceType::CPU &&
adapter.GetDeviceType() == dawn_native::DeviceType::Unknown &&
(preferredDeviceType != wgpu::AdapterType::CPU &&
properties.adapterType == wgpu::AdapterType::Unknown &&
(properties.backendType == wgpu::BackendType::OpenGL ||
properties.backendType == wgpu::BackendType::OpenGLES)) ||
// Always select the Null backend. There are few tests on this backend, and they run

View File

@ -261,7 +261,7 @@ class DawnTestEnvironment : public testing::Environment {
ToggleParser mToggleParser;
std::vector<dawn_native::DeviceType> mDevicePreferences;
std::vector<wgpu::AdapterType> mDevicePreferences;
std::vector<TestAdapterProperties> mAdapterProperties;
std::unique_ptr<utils::PlatformDebugLogger> mPlatformDebugLogger;