From 701dd6fd00747ffd700c2336dc91329aedf57f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Wed, 11 Sep 2024 06:24:28 +0000 Subject: [PATCH] Replace GPUAdapter::GetProperties() with GPUAdapter::GetInfo() Bug: 335383516 Change-Id: Ic7df2c293555662b41a8ab590cd50dd0b8dc38e1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/193520 Commit-Queue: Fr Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez --- docs/dawn/features/adapter_properties.md | 6 +- include/dawn/native/DawnNative.h | 2 - src/dawn/dawn.json | 30 +-- src/dawn/dawn_wire.json | 1 - .../DawnWireServerAndD3D12BackendFuzzer.cpp | 8 +- .../DawnWireServerAndFrontendFuzzer.cpp | 6 +- .../DawnWireServerAndVulkanBackendFuzzer.cpp | 6 +- .../lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp | 6 +- src/dawn/native/Adapter.cpp | 96 ++------ src/dawn/native/Adapter.h | 3 - src/dawn/native/DawnNative.cpp | 8 - src/dawn/native/PhysicalDevice.h | 2 +- src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp | 6 +- src/dawn/native/d3d11/PhysicalDeviceD3D11.h | 2 +- src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp | 6 +- src/dawn/native/d3d12/PhysicalDeviceD3D12.h | 2 +- src/dawn/native/metal/PhysicalDeviceMTL.h | 2 +- src/dawn/native/metal/PhysicalDeviceMTL.mm | 4 +- src/dawn/native/null/DeviceNull.cpp | 6 +- src/dawn/native/null/DeviceNull.h | 2 +- src/dawn/native/opengl/PhysicalDeviceGL.cpp | 2 +- src/dawn/native/opengl/PhysicalDeviceGL.h | 2 +- src/dawn/native/vulkan/PhysicalDeviceVk.cpp | 6 +- src/dawn/native/vulkan/PhysicalDeviceVk.h | 2 +- src/dawn/samples/DawnInfo.cpp | 30 +-- .../tests/end2end/AdapterCreationTests.cpp | 231 +----------------- .../tests/end2end/AdapterEnumerationTests.cpp | 112 ++++----- .../end2end/AdapterPropertiesD3DTests.cpp | 23 +- .../end2end/AdapterPropertiesVkTests.cpp | 24 +- .../end2end/DeviceInitializationTests.cpp | 50 ++-- .../end2end/MemoryHeapPropertiesTests.cpp | 53 ++-- src/dawn/tests/unittests/ChainUtilsTests.cpp | 16 +- .../unittests/wire/WireInstanceTests.cpp | 31 +-- src/dawn/wire/client/Adapter.cpp | 82 ------- src/dawn/wire/client/Adapter.h | 3 - src/dawn/wire/client/Instance.cpp | 1 - tools/android/BUILD.gn | 1 - 37 files changed, 220 insertions(+), 653 deletions(-) diff --git a/docs/dawn/features/adapter_properties.md b/docs/dawn/features/adapter_properties.md index 006fce7cda9..0889be1e23d 100644 --- a/docs/dawn/features/adapter_properties.md +++ b/docs/dawn/features/adapter_properties.md @@ -4,7 +4,7 @@ `wgpu::FeatureName::AdapterPropertiesMemoryHeaps` allows querying memory heap information from the adapter. -`wgpu::AdapterPropertiesMemoryHeaps` may be chained on `wgpu::AdapterProperties` in a call to `wgpu::Adapter::GetProperties` in order to query information about the memory heaps on that adapter. +`wgpu::AdapterPropertiesMemoryHeaps` may be chained on `wgpu::AdapterInfo` in a call to `wgpu::Adapter::GetInfo` in order to query information about the memory heaps on that adapter. The implementation will write out the number of memory heaps and information about each heap. If `wgpu::FeatureName::AdapterPropertiesMemoryHeaps` is not available, the struct will not be populated. @@ -33,7 +33,7 @@ struct MemoryHeapInfo { `wgpu::FeatureName::AdapterPropertiesD3D` allows querying D3D information from the adapter. -`wgpu::AdapterPropertiesD3D` may be chained on `wgpu::AdapterProperties` in a call to `wgpu::Adapter::GetProperties` in order to query D3D information on that adapter. +`wgpu::AdapterPropertiesD3D` may be chained on `wgpu::AdapterInfo` in a call to `wgpu::Adapter::GetInfo` in order to query D3D information on that adapter. Adds `wgpu::AdapterPropertiesD3D` which is a struct describing the D3D adapter. ``` @@ -46,7 +46,7 @@ struct AdapterPropertiesD3D { `wgpu::FeatureName::AdapterPropertiesVk` allows querying Vulkan information from the adapter. -`wgpu::AdapterPropertiesVk` may be chained on `wgpu::AdapterProperties` in a call to `wgpu::Adapter::GetProperties` in order to query Vulkan information on that adapter. +`wgpu::AdapterPropertiesVk` may be chained on `wgpu::AdapterInfo` in a call to `wgpu::Adapter::GetInfo` in order to query Vulkan information on that adapter. Adds `wgpu::AdapterPropertiesVk` which is a struct describing the Vulkan adapter. ``` diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h index 50e4ccfc06f..61ee84227ba 100644 --- a/include/dawn/native/DawnNative.h +++ b/include/dawn/native/DawnNative.h @@ -93,8 +93,6 @@ class DAWN_NATIVE_EXPORT Adapter { // those in webgpu_cpp.h. Update uses of these methods and remove them. wgpu::Status GetInfo(wgpu::AdapterInfo* info) const; wgpu::Status GetInfo(WGPUAdapterInfo* info) const; - wgpu::Status GetProperties(wgpu::AdapterProperties* properties) const; - wgpu::Status GetProperties(WGPUAdapterProperties* properties) const; std::vector GetSupportedFeatures() const; wgpu::ConvertibleStatus GetLimits(WGPUSupportedLimits* limits) const; diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json index 10a534f56ce..ac8b6c5a50c 100644 --- a/src/dawn/dawn.json +++ b/src/dawn/dawn.json @@ -153,13 +153,6 @@ {"name": "info", "type": "adapter info", "annotation": "*"} ] }, - { - "name": "get properties", - "returns": "status", - "args": [ - {"name": "properties", "type": "adapter properties", "annotation": "*"} - ] - }, { "name": "has feature", "returns": "bool", @@ -236,21 +229,6 @@ {"name": "compatibility mode", "type": "bool", "default": "false", "tags": ["dawn", "emscripten"]} ] }, - "adapter properties": { - "category": "structure", - "extensible": "out", - "members": [ - {"name": "vendor ID", "type": "uint32_t"}, - {"name": "vendor name", "type": "char", "annotation": "const*", "length": "strlen", "default": "nullptr"}, - {"name": "architecture", "type": "char", "annotation": "const*", "length": "strlen", "default": "nullptr"}, - {"name": "device ID", "type": "uint32_t"}, - {"name": "name", "type": "char", "annotation": "const*", "length": "strlen", "default": "nullptr"}, - {"name": "driver description", "type": "char", "annotation": "const*", "length": "strlen", "default": "nullptr"}, - {"name": "adapter type", "type": "adapter type"}, - {"name": "backend type", "type": "backend type"}, - {"name": "compatibility mode", "type": "bool", "default": "false", "tags": ["dawn", "emscripten"]} - ] - }, "adapter type": { "category": "enum", "emscripten_no_enum_table": true, @@ -4866,7 +4844,7 @@ "dawn adapter properties power preference": { "category": "structure", "chained": "out", - "chain roots": ["adapter info", "adapter properties"], + "chain roots": ["adapter info"], "tags": ["dawn"], "members": [ {"name": "power preference", "type": "power preference", "default": "undefined"} @@ -4894,7 +4872,7 @@ "adapter properties memory heaps": { "category": "structure", "chained": "out", - "chain roots": ["adapter info", "adapter properties"], + "chain roots": ["adapter info"], "tags": ["dawn"], "members": [ {"name": "heap count", "type": "size_t"}, @@ -4904,7 +4882,7 @@ "adapter properties D3D": { "category": "structure", "chained": "out", - "chain roots": ["adapter info", "adapter properties"], + "chain roots": ["adapter info"], "tags": ["dawn"], "members": [ {"name": "shader model", "type": "uint32_t"} @@ -4913,7 +4891,7 @@ "adapter properties vk": { "category": "structure", "chained": "out", - "chain roots": ["adapter info", "adapter properties"], + "chain roots": ["adapter info"], "tags": ["dawn"], "members": [ {"name": "driver version", "type": "uint32_t"} diff --git a/src/dawn/dawn_wire.json b/src/dawn/dawn_wire.json index 109893f92b4..6742701cf50 100644 --- a/src/dawn/dawn_wire.json +++ b/src/dawn/dawn_wire.json @@ -221,7 +221,6 @@ "AdapterGetFormatCapabilities", "AdapterGetInfo", "AdapterGetInstance", - "AdapterGetProperties", "AdapterGetLimits", "AdapterHasFeature", "AdapterEnumerateFeatures", diff --git a/src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp index bf3e09e27f5..ad40a45d195 100644 --- a/src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp @@ -39,10 +39,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return DawnWireServerFuzzer::Run( data, size, [](const dawn::native::Adapter& adapter) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - return properties.backendType == wgpu::BackendType::D3D12 && - properties.adapterType == wgpu::AdapterType::CPU; + wgpu::AdapterInfo info; + adapter.GetInfo(&info); + return info.backendType == wgpu::BackendType::D3D12 && + info.adapterType == wgpu::AdapterType::CPU; }, true /* supportsErrorInjection */); } diff --git a/src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp index 780e0760140..33f7e80636b 100644 --- a/src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp @@ -40,9 +40,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return DawnWireServerFuzzer::Run( data, size, [](const dawn::native::Adapter& adapter) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - return properties.backendType == wgpu::BackendType::Null; + wgpu::AdapterInfo info; + adapter.GetInfo(&info); + return info.backendType == wgpu::BackendType::Null; }, false /* supportsErrorInjection */); } diff --git a/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp index 826ba90852d..540e792d0cc 100644 --- a/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp @@ -40,10 +40,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return DawnWireServerFuzzer::Run( data, size, [](const dawn::native::Adapter& adapter) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - return dawn::gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID); + return dawn::gpu_info::IsGoogleSwiftshader(info.vendorID, info.deviceID); }, true /* supportsErrorInjection */); } diff --git a/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp b/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp index e976ce434d9..ba4335fdd8e 100644 --- a/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp +++ b/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp @@ -38,9 +38,9 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { DEFINE_PROTO_FUZZER(const fuzzing::Program& program) { DawnLPMFuzzer::Run(program, [](const dawn::native::Adapter& adapter) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - return dawn::gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID); + return dawn::gpu_info::IsGoogleSwiftshader(info.vendorID, info.deviceID); }); } diff --git a/src/dawn/native/Adapter.cpp b/src/dawn/native/Adapter.cpp index bb0232c5cdd..3cd4906799a 100644 --- a/src/dawn/native/Adapter.cpp +++ b/src/dawn/native/Adapter.cpp @@ -125,55 +125,8 @@ wgpu::Status AdapterBase::APIGetLimits(SupportedLimits* limits) const { wgpu::Status AdapterBase::APIGetInfo(AdapterInfo* info) const { DAWN_ASSERT(info != nullptr); - AdapterProperties properties = {}; - properties.nextInChain = info->nextInChain; - if (GetPropertiesInternal(&properties) == wgpu::Status::Error) { - return wgpu::Status::Error; - } - - // Get lengths, with null terminators. - size_t vendorCLen = mPhysicalDevice->GetVendorName().length() + 1; - size_t architectureCLen = mPhysicalDevice->GetArchitectureName().length() + 1; - size_t deviceCLen = mPhysicalDevice->GetName().length() + 1; - size_t descriptionCLen = mPhysicalDevice->GetDriverDescription().length() + 1; - - // Allocate space for all strings. - char* ptr = new char[vendorCLen + architectureCLen + deviceCLen + descriptionCLen]; - - info->vendor = ptr; - memcpy(ptr, mPhysicalDevice->GetVendorName().c_str(), vendorCLen); - ptr += vendorCLen; - - info->architecture = ptr; - memcpy(ptr, mPhysicalDevice->GetArchitectureName().c_str(), architectureCLen); - ptr += architectureCLen; - - info->device = ptr; - memcpy(ptr, mPhysicalDevice->GetName().c_str(), deviceCLen); - ptr += deviceCLen; - - info->description = ptr; - memcpy(ptr, mPhysicalDevice->GetDriverDescription().c_str(), descriptionCLen); - ptr += descriptionCLen; - - info->backendType = mPhysicalDevice->GetBackendType(); - info->adapterType = mPhysicalDevice->GetAdapterType(); - info->vendorID = mPhysicalDevice->GetVendorId(); - info->deviceID = mPhysicalDevice->GetDeviceId(); - info->compatibilityMode = mFeatureLevel == FeatureLevel::Compatibility; - - return wgpu::Status::Success; -} - -wgpu::Status AdapterBase::APIGetProperties(AdapterProperties* properties) const { - mInstance->EmitDeprecationWarning("GetProperties is deprecated, use GetInfo instead."); - return GetPropertiesInternal(properties); -} - -wgpu::Status AdapterBase::GetPropertiesInternal(AdapterProperties* properties) const { - DAWN_ASSERT(properties != nullptr); - UnpackedPtr unpacked; - if (mInstance->ConsumedError(ValidateAndUnpack(properties), &unpacked)) { + UnpackedPtr unpacked; + if (mInstance->ConsumedError(ValidateAndUnpack(info), &unpacked)) { return wgpu::Status::Error; } @@ -203,36 +156,36 @@ wgpu::Status AdapterBase::GetPropertiesInternal(AdapterProperties* properties) c mPhysicalDevice->PopulateBackendProperties(unpacked); - properties->vendorID = mPhysicalDevice->GetVendorId(); - properties->deviceID = mPhysicalDevice->GetDeviceId(); - properties->adapterType = mPhysicalDevice->GetAdapterType(); - properties->backendType = mPhysicalDevice->GetBackendType(); - properties->compatibilityMode = mFeatureLevel == FeatureLevel::Compatibility; - // Get lengths, with null terminators. - size_t vendorNameCLen = mPhysicalDevice->GetVendorName().length() + 1; + size_t vendorCLen = mPhysicalDevice->GetVendorName().length() + 1; size_t architectureCLen = mPhysicalDevice->GetArchitectureName().length() + 1; - size_t nameCLen = mPhysicalDevice->GetName().length() + 1; - size_t driverDescriptionCLen = mPhysicalDevice->GetDriverDescription().length() + 1; + size_t deviceCLen = mPhysicalDevice->GetName().length() + 1; + size_t descriptionCLen = mPhysicalDevice->GetDriverDescription().length() + 1; // Allocate space for all strings. - char* ptr = new char[vendorNameCLen + architectureCLen + nameCLen + driverDescriptionCLen]; + char* ptr = new char[vendorCLen + architectureCLen + deviceCLen + descriptionCLen]; - properties->vendorName = ptr; - memcpy(ptr, mPhysicalDevice->GetVendorName().c_str(), vendorNameCLen); - ptr += vendorNameCLen; + info->vendor = ptr; + memcpy(ptr, mPhysicalDevice->GetVendorName().c_str(), vendorCLen); + ptr += vendorCLen; - properties->architecture = ptr; + info->architecture = ptr; memcpy(ptr, mPhysicalDevice->GetArchitectureName().c_str(), architectureCLen); ptr += architectureCLen; - properties->name = ptr; - memcpy(ptr, mPhysicalDevice->GetName().c_str(), nameCLen); - ptr += nameCLen; + info->device = ptr; + memcpy(ptr, mPhysicalDevice->GetName().c_str(), deviceCLen); + ptr += deviceCLen; - properties->driverDescription = ptr; - memcpy(ptr, mPhysicalDevice->GetDriverDescription().c_str(), driverDescriptionCLen); - ptr += driverDescriptionCLen; + info->description = ptr; + memcpy(ptr, mPhysicalDevice->GetDriverDescription().c_str(), descriptionCLen); + ptr += descriptionCLen; + + info->backendType = mPhysicalDevice->GetBackendType(); + info->adapterType = mPhysicalDevice->GetAdapterType(); + info->vendorID = mPhysicalDevice->GetVendorId(); + info->deviceID = mPhysicalDevice->GetDeviceId(); + info->compatibilityMode = mFeatureLevel == FeatureLevel::Compatibility; return wgpu::Status::Success; } @@ -242,11 +195,6 @@ void APIAdapterInfoFreeMembers(WGPUAdapterInfo info) { delete[] info.vendor; } -void APIAdapterPropertiesFreeMembers(WGPUAdapterProperties properties) { - // This single delete is enough because everything is a single allocation. - delete[] properties.vendorName; -} - void APIAdapterPropertiesMemoryHeapsFreeMembers( WGPUAdapterPropertiesMemoryHeaps memoryHeapProperties) { delete[] memoryHeapProperties.heapInfo; diff --git a/src/dawn/native/Adapter.h b/src/dawn/native/Adapter.h index ce61708d66c..b0e1b0892e7 100644 --- a/src/dawn/native/Adapter.h +++ b/src/dawn/native/Adapter.h @@ -62,7 +62,6 @@ class AdapterBase : public RefCounted, public WeakRefSupport { InstanceBase* APIGetInstance() const; wgpu::Status APIGetLimits(SupportedLimits* limits) const; wgpu::Status APIGetInfo(AdapterInfo* info) const; - wgpu::Status APIGetProperties(AdapterProperties* properties) const; bool APIHasFeature(wgpu::FeatureName feature) const; size_t APIEnumerateFeatures(wgpu::FeatureName* features) const; void APIRequestDevice(const DeviceDescriptor* descriptor, @@ -93,8 +92,6 @@ class AdapterBase : public RefCounted, public WeakRefSupport { const std::string& GetName() const; private: - wgpu::Status GetPropertiesInternal(AdapterProperties* properties) const; - std::pair, ResultOrError>> CreateDevice( const DeviceDescriptor* rawDescriptor); ResultOrError> CreateDeviceInternal(const DeviceDescriptor* rawDescriptor, diff --git a/src/dawn/native/DawnNative.cpp b/src/dawn/native/DawnNative.cpp index 3b84d988a04..087f62b7f04 100644 --- a/src/dawn/native/DawnNative.cpp +++ b/src/dawn/native/DawnNative.cpp @@ -97,14 +97,6 @@ wgpu::Status Adapter::GetInfo(WGPUAdapterInfo* info) const { return mImpl->APIGetInfo(FromAPI(info)); } -wgpu::Status Adapter::GetProperties(wgpu::AdapterProperties* properties) const { - return GetProperties(reinterpret_cast(properties)); -} - -wgpu::Status Adapter::GetProperties(WGPUAdapterProperties* properties) const { - return mImpl->APIGetProperties(FromAPI(properties)); -} - WGPUAdapter Adapter::Get() const { return ToAPI(mImpl); } diff --git a/src/dawn/native/PhysicalDevice.h b/src/dawn/native/PhysicalDevice.h index dfc5bd4ca2a..cfd2ea17af1 100644 --- a/src/dawn/native/PhysicalDevice.h +++ b/src/dawn/native/PhysicalDevice.h @@ -116,7 +116,7 @@ class PhysicalDeviceBase : public RefCounted { const TogglesState& toggles) const; // Populate backend properties. Ownership of allocations written are owned by the caller. - virtual void PopulateBackendProperties(UnpackedPtr& properties) const = 0; + virtual void PopulateBackendProperties(UnpackedPtr& info) const = 0; // Populate backend format capabilities. Ownership of allocations written are owned by the // caller. diff --git a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp index f2054010ff6..af3decc8fbb 100644 --- a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp +++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp @@ -307,8 +307,8 @@ MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() { return {}; } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const { - if (auto* memoryHeapProperties = properties.Get()) { +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const { + if (auto* memoryHeapProperties = info.Get()) { // https://microsoft.github.io/DirectX-Specs/d3d/D3D12GPUUploadHeaps.html describes // the properties of D3D12 Default/Upload/Readback heaps. The assumption is that these are // roughly how D3D11 allocates memory has well. @@ -336,7 +336,7 @@ void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& p wgpu::HeapProperty::HostUncached | wgpu::HeapProperty::HostCached; } } - if (auto* d3dProperties = properties.Get()) { + if (auto* d3dProperties = info.Get()) { d3dProperties->shaderModel = GetDeviceInfo().shaderModel; } } diff --git a/src/dawn/native/d3d11/PhysicalDeviceD3D11.h b/src/dawn/native/d3d11/PhysicalDeviceD3D11.h index de41bff3d2a..34efdc959f4 100644 --- a/src/dawn/native/d3d11/PhysicalDeviceD3D11.h +++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.h @@ -79,7 +79,7 @@ class PhysicalDevice : public d3d::PhysicalDevice { wgpu::FeatureName feature, const TogglesState& toggles) const override; - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; const bool mIsSharedD3D11Device; ComPtr mD3D11Device; diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp index 80408f8917b..f706dc28390 100644 --- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp +++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp @@ -814,8 +814,8 @@ MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() { return {}; } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const { - if (auto* memoryHeapProperties = properties.Get()) { +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const { + if (auto* memoryHeapProperties = info.Get()) { // https://microsoft.github.io/DirectX-Specs/d3d/D3D12GPUUploadHeaps.html describes // the properties of D3D12 Default/Upload/Readback heaps. if (mDeviceInfo.isUMA) { @@ -849,7 +849,7 @@ void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& p wgpu::HeapProperty::HostUncached | wgpu::HeapProperty::HostCached; } } - if (auto* d3dProperties = properties.Get()) { + if (auto* d3dProperties = info.Get()) { // Report highest supported shader model version, instead of actual applied version. d3dProperties->shaderModel = GetDeviceInfo().highestSupportedShaderModel; } diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.h b/src/dawn/native/d3d12/PhysicalDeviceD3D12.h index 8341a5bc29a..78a3e417e3d 100644 --- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.h +++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.h @@ -84,7 +84,7 @@ class PhysicalDevice : public d3d::PhysicalDevice { MaybeError InitializeDebugLayerFilters(); void CleanUpDebugLayerFilters(); - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; ComPtr mD3d12Device; diff --git a/src/dawn/native/metal/PhysicalDeviceMTL.h b/src/dawn/native/metal/PhysicalDeviceMTL.h index c18c7e30d01..179808aa5b1 100644 --- a/src/dawn/native/metal/PhysicalDeviceMTL.h +++ b/src/dawn/native/metal/PhysicalDeviceMTL.h @@ -72,7 +72,7 @@ class PhysicalDevice : public PhysicalDeviceBase { FeatureValidationResult ValidateFeatureSupportedWithTogglesImpl( wgpu::FeatureName feature, const TogglesState& toggles) const override; - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; NSPRef> mDevice; const bool mMetalValidationEnabled; diff --git a/src/dawn/native/metal/PhysicalDeviceMTL.mm b/src/dawn/native/metal/PhysicalDeviceMTL.mm index 912bed07350..1a8d8aa16cc 100644 --- a/src/dawn/native/metal/PhysicalDeviceMTL.mm +++ b/src/dawn/native/metal/PhysicalDeviceMTL.mm @@ -938,8 +938,8 @@ bool IsGPUCounterSupported(id device, return {}; } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const { - if (auto* memoryHeapProperties = properties.Get()) { +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const { + if (auto* memoryHeapProperties = info.Get()) { if ([*mDevice hasUnifiedMemory]) { auto* heapInfo = new MemoryHeapInfo[1]; memoryHeapProperties->heapCount = 1; diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index ccd42814cab..7949b7c31f2 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp @@ -109,8 +109,8 @@ ResultOrError> PhysicalDevice::CreateDeviceImpl( return Device::Create(adapter, descriptor, deviceToggles, std::move(lostEvent)); } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const { - if (auto* memoryHeapProperties = properties.Get()) { +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const { + if (auto* memoryHeapProperties = info.Get()) { auto* heapInfo = new MemoryHeapInfo[1]; memoryHeapProperties->heapCount = 1; memoryHeapProperties->heapInfo = heapInfo; @@ -119,7 +119,7 @@ void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& p heapInfo[0].properties = wgpu::HeapProperty::DeviceLocal | wgpu::HeapProperty::HostVisible | wgpu::HeapProperty::HostCached; } - if (auto* d3dProperties = properties.Get()) { + if (auto* d3dProperties = info.Get()) { d3dProperties->shaderModel = 0; } } diff --git a/src/dawn/native/null/DeviceNull.h b/src/dawn/native/null/DeviceNull.h index 954ba683a56..0de189a90bb 100644 --- a/src/dawn/native/null/DeviceNull.h +++ b/src/dawn/native/null/DeviceNull.h @@ -217,7 +217,7 @@ class PhysicalDevice : public PhysicalDeviceBase { const TogglesState& deviceToggles, Ref&& lostEvent) override; - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; }; // Helper class so |BindGroup| can allocate memory for its binding data, diff --git a/src/dawn/native/opengl/PhysicalDeviceGL.cpp b/src/dawn/native/opengl/PhysicalDeviceGL.cpp index e1007fab5a9..2020e9c98c6 100644 --- a/src/dawn/native/opengl/PhysicalDeviceGL.cpp +++ b/src/dawn/native/opengl/PhysicalDeviceGL.cpp @@ -477,6 +477,6 @@ FeatureValidationResult PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl( return {}; } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const {} +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const {} } // namespace dawn::native::opengl diff --git a/src/dawn/native/opengl/PhysicalDeviceGL.h b/src/dawn/native/opengl/PhysicalDeviceGL.h index c5c1582fb4d..c6768ab1c28 100644 --- a/src/dawn/native/opengl/PhysicalDeviceGL.h +++ b/src/dawn/native/opengl/PhysicalDeviceGL.h @@ -75,7 +75,7 @@ class PhysicalDevice : public PhysicalDeviceBase { const TogglesState& deviceToggles, Ref&& lostEvent) override; - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; OpenGLFunctions mFunctions; Ref mDisplay; diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp index 23946b240ee..0d35a7d4ee6 100644 --- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp +++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp @@ -1035,8 +1035,8 @@ const AHBFunctions* PhysicalDevice::GetOrLoadAHBFunctions() { #endif // DAWN_PLATFORM_IS(ANDROID) } -void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& properties) const { - if (auto* memoryHeapProperties = properties.Get()) { +void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& info) const { + if (auto* memoryHeapProperties = info.Get()) { size_t count = mDeviceInfo.memoryHeaps.size(); auto* heapInfo = new MemoryHeapInfo[count]; memoryHeapProperties->heapCount = count; @@ -1063,7 +1063,7 @@ void PhysicalDevice::PopulateBackendProperties(UnpackedPtr& p } } } - if (auto* vkProperties = properties.Get()) { + if (auto* vkProperties = info.Get()) { vkProperties->driverVersion = mDeviceInfo.properties.driverVersion; } } diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.h b/src/dawn/native/vulkan/PhysicalDeviceVk.h index 8a09e4f265f..d1065b63419 100644 --- a/src/dawn/native/vulkan/PhysicalDeviceVk.h +++ b/src/dawn/native/vulkan/PhysicalDeviceVk.h @@ -93,7 +93,7 @@ class PhysicalDevice : public PhysicalDeviceBase { bool CheckSemaphoreSupport(DeviceExt deviceExt, VkExternalSemaphoreHandleTypeFlagBits handleType) const; - void PopulateBackendProperties(UnpackedPtr& properties) const override; + void PopulateBackendProperties(UnpackedPtr& info) const override; void PopulateBackendFormatCapabilities( wgpu::TextureFormat format, UnpackedPtr& capabilities) const override; diff --git a/src/dawn/samples/DawnInfo.cpp b/src/dawn/samples/DawnInfo.cpp index 5c1b3032b2a..4ca39d938dd 100644 --- a/src/dawn/samples/DawnInfo.cpp +++ b/src/dawn/samples/DawnInfo.cpp @@ -119,16 +119,16 @@ std::string AsHex(uint32_t val) { return hex.str(); } -std::string AdapterPropertiesToString(const wgpu::AdapterProperties& props) { +std::string AdapterInfoToString(const wgpu::AdapterInfo& info) { std::stringstream out; - out << "VendorID: " << AsHex(props.vendorID) << "\n"; - out << "Vendor: " << props.vendorName << "\n"; - out << "Architecture: " << props.architecture << "\n"; - out << "DeviceID: " << AsHex(props.deviceID) << "\n"; - out << "Name: " << props.name << "\n"; - out << "Driver description: " << props.driverDescription << "\n"; - out << "Adapter Type: " << AdapterTypeToString(props.adapterType) << "\n"; - out << "Backend Type: " << BackendTypeToString(props.backendType) << "\n"; + out << "VendorID: " << AsHex(info.vendorID) << "\n"; + out << "Vendor: " << info.vendor << "\n"; + out << "Architecture: " << info.architecture << "\n"; + out << "DeviceID: " << AsHex(info.deviceID) << "\n"; + out << "Name: " << info.device << "\n"; + out << "Driver description: " << info.description << "\n"; + out << "Adapter Type: " << AdapterTypeToString(info.adapterType) << "\n"; + out << "Backend Type: " << BackendTypeToString(info.backendType) << "\n"; return out.str(); } @@ -221,14 +221,14 @@ std::string LimitsToString(const wgpu::Limits& limits, const std::string& indent return out.str(); } -void DumpAdapterProperties(const wgpu::Adapter& adapter) { +void DumpAdapterInfo(const wgpu::Adapter& adapter) { wgpu::DawnAdapterPropertiesPowerPreference power_props{}; - wgpu::AdapterProperties properties{}; - properties.nextInChain = &power_props; + wgpu::AdapterInfo info{}; + info.nextInChain = &power_props; - adapter.GetProperties(&properties); - std::cout << AdapterPropertiesToString(properties); + adapter.GetInfo(&info); + std::cout << AdapterInfoToString(info); std::cout << "Power: " << PowerPreferenceToString(power_props) << "\n"; std::cout << "\n"; } @@ -262,7 +262,7 @@ void DumpAdapter(const wgpu::Adapter& adapter) { std::cout << "Adapter\n"; std::cout << "=======\n"; - DumpAdapterProperties(adapter); + DumpAdapterInfo(adapter); DumpAdapterFeatures(adapter); DumpAdapterLimits(adapter); } diff --git a/src/dawn/tests/end2end/AdapterCreationTests.cpp b/src/dawn/tests/end2end/AdapterCreationTests.cpp index 3c8125d322c..df281cc877e 100644 --- a/src/dawn/tests/end2end/AdapterCreationTests.cpp +++ b/src/dawn/tests/end2end/AdapterCreationTests.cpp @@ -59,16 +59,14 @@ class AdapterCreationTest : public ::testing::TestWithParamEnumerateAdapters()) { anyAdapterAvailable = true; - wgpu::AdapterProperties properties; - nativeAdapter.GetProperties(&properties); - if (properties.compatibilityMode) { + wgpu::AdapterInfo info; + nativeAdapter.GetInfo(&info); + if (info.compatibilityMode) { continue; } - swiftShaderAvailable |= - gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID); - discreteGPUAvailable |= properties.adapterType == wgpu::AdapterType::DiscreteGPU; - integratedGPUAvailable |= - properties.adapterType == wgpu::AdapterType::IntegratedGPU; + swiftShaderAvailable |= gpu_info::IsGoogleSwiftshader(info.vendorID, info.deviceID); + discreteGPUAvailable |= info.adapterType == wgpu::AdapterType::DiscreteGPU; + integratedGPUAvailable |= info.adapterType == wgpu::AdapterType::IntegratedGPU; } } @@ -180,12 +178,6 @@ TEST_P(AdapterCreationTest, FallbackAdapter) { wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); EXPECT_EQ(adapter != nullptr, swiftShaderAvailable); if (adapter != nullptr) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - - EXPECT_EQ(properties.adapterType, wgpu::AdapterType::CPU); - EXPECT_TRUE(gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID)); - wgpu::AdapterInfo info; adapter.GetInfo(&info); @@ -214,16 +206,12 @@ TEST_P(AdapterCreationTest, PreferHighPerformance) { wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); if (discreteGPUAvailable) { - wgpu::AdapterProperties properties; - wgpu::DawnAdapterPropertiesPowerPreference powerPreferenceProperties; - properties.nextInChain = &powerPreferenceProperties; - adapter.GetProperties(&properties); - EXPECT_EQ(properties.adapterType, wgpu::AdapterType::DiscreteGPU); - EXPECT_EQ(powerPreferenceProperties.powerPreference, options.powerPreference); - wgpu::AdapterInfo info; + wgpu::DawnAdapterPropertiesPowerPreference powerPreferenceProperties; + info.nextInChain = &powerPreferenceProperties; adapter.GetInfo(&info); EXPECT_EQ(info.adapterType, wgpu::AdapterType::DiscreteGPU); + EXPECT_EQ(powerPreferenceProperties.powerPreference, options.powerPreference); } } @@ -247,16 +235,12 @@ TEST_P(AdapterCreationTest, PreferLowPower) { wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); if (integratedGPUAvailable) { - wgpu::AdapterProperties properties; - wgpu::DawnAdapterPropertiesPowerPreference powerPreferenceProperties; - properties.nextInChain = &powerPreferenceProperties; - adapter.GetProperties(&properties); - EXPECT_EQ(properties.adapterType, wgpu::AdapterType::IntegratedGPU); - EXPECT_EQ(powerPreferenceProperties.powerPreference, options.powerPreference); - wgpu::AdapterInfo info; + wgpu::DawnAdapterPropertiesPowerPreference powerPreferenceProperties; + info.nextInChain = &powerPreferenceProperties; adapter.GetInfo(&info); EXPECT_EQ(info.adapterType, wgpu::AdapterType::IntegratedGPU); + EXPECT_EQ(powerPreferenceProperties.powerPreference, options.powerPreference); } } @@ -275,10 +259,6 @@ TEST_P(AdapterCreationTest, Compatibility) { wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - EXPECT_TRUE(properties.compatibilityMode); - wgpu::AdapterInfo info; adapter.GetInfo(&info); EXPECT_TRUE(info.compatibilityMode); @@ -298,10 +278,6 @@ TEST_P(AdapterCreationTest, NonCompatibility) { wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - EXPECT_FALSE(properties.compatibilityMode); - wgpu::AdapterInfo info; adapter.GetInfo(&info); EXPECT_FALSE(info.compatibilityMode); @@ -324,189 +300,6 @@ TEST_P(AdapterCreationTest, GetInstance) { EXPECT_EQ(adapter.GetInstance().Get(), instance.Get()); } -// Test that calling AdapterGetProperties returns separate allocations for strings. -// However, the string contents are equivalent. -TEST_P(AdapterCreationTest, PropertiesUnique) { - wgpu::RequestAdapterOptions options = {}; - - MockCallback cb; - - WGPUAdapter cAdapter = nullptr; - EXPECT_CALL(cb, Call(WGPURequestAdapterStatus_Success, _, nullptr, this)) - .WillOnce(SaveArg<1>(&cAdapter)); - RequestAdapter(instance, &options, cb.Callback(), cb.MakeUserdata(this)); - - wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); - EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - if (!adapter) { - return; - } - - wgpu::AdapterProperties properties1; - wgpu::AdapterProperties properties2; - adapter.GetProperties(&properties1); - adapter.GetProperties(&properties2); - - EXPECT_NE(properties1.vendorName, properties2.vendorName); - EXPECT_STREQ(properties1.vendorName, properties2.vendorName); - EXPECT_NE(properties1.architecture, properties2.architecture); - EXPECT_STREQ(properties1.architecture, properties2.architecture); - EXPECT_NE(properties1.name, properties2.name); - EXPECT_STREQ(properties1.name, properties2.name); - EXPECT_NE(properties1.driverDescription, properties2.driverDescription); - EXPECT_STREQ(properties1.driverDescription, properties2.driverDescription); -} - -// Test move assignment of the adapter properties. -TEST_P(AdapterCreationTest, PropertiesMoveAssign) { - wgpu::RequestAdapterOptions options = {}; - - MockCallback cb; - - WGPUAdapter cAdapter = nullptr; - EXPECT_CALL(cb, Call(WGPURequestAdapterStatus_Success, _, nullptr, this)) - .WillOnce(SaveArg<1>(&cAdapter)); - RequestAdapter(instance, &options, cb.Callback(), cb.MakeUserdata(this)); - - wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); - EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - if (!adapter) { - return; - } - - wgpu::AdapterProperties properties1; - wgpu::AdapterProperties properties2; - adapter.GetProperties(&properties1); - adapter.GetProperties(&properties2); - - uint32_t vendorID = properties1.vendorID; - std::string vendorName = properties1.vendorName; - std::string architecture = properties1.architecture; - uint32_t deviceID = properties1.deviceID; - std::string name = properties1.name; - std::string driverDescription = properties1.driverDescription; - wgpu::AdapterType adapterType = properties1.adapterType; - wgpu::BackendType backendType = properties1.backendType; - bool compatibilityMode = properties1.compatibilityMode; - - properties2 = std::move(properties1); - - // Expect properties2 to have properties1's old contents. - EXPECT_EQ(properties2.vendorID, vendorID); - EXPECT_STREQ(properties2.vendorName, vendorName.c_str()); - EXPECT_STREQ(properties2.architecture, architecture.c_str()); - EXPECT_EQ(properties2.deviceID, deviceID); - EXPECT_STREQ(properties2.name, name.c_str()); - EXPECT_STREQ(properties2.driverDescription, driverDescription.c_str()); - EXPECT_EQ(properties2.adapterType, adapterType); - EXPECT_EQ(properties2.backendType, backendType); - EXPECT_EQ(properties2.compatibilityMode, compatibilityMode); - - // Expect properties1 to be empty. - EXPECT_EQ(properties1.vendorID, 0u); - EXPECT_EQ(properties1.vendorName, nullptr); - EXPECT_EQ(properties1.architecture, nullptr); - EXPECT_EQ(properties1.deviceID, 0u); - EXPECT_EQ(properties1.name, nullptr); - EXPECT_EQ(properties1.driverDescription, nullptr); - EXPECT_EQ(properties1.adapterType, static_cast(0)); - EXPECT_EQ(properties1.backendType, static_cast(0)); - EXPECT_EQ(properties1.compatibilityMode, false); -} - -// Test move construction of the adapter properties. -TEST_P(AdapterCreationTest, PropertiesMoveConstruct) { - wgpu::RequestAdapterOptions options = {}; - - MockCallback cb; - - WGPUAdapter cAdapter = nullptr; - EXPECT_CALL(cb, Call(WGPURequestAdapterStatus_Success, _, nullptr, this)) - .WillOnce(SaveArg<1>(&cAdapter)); - RequestAdapter(instance, &options, cb.Callback(), cb.MakeUserdata(this)); - - wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); - EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - if (!adapter) { - return; - } - - wgpu::AdapterProperties properties1; - adapter.GetProperties(&properties1); - - uint32_t vendorID = properties1.vendorID; - std::string vendorName = properties1.vendorName; - std::string architecture = properties1.architecture; - uint32_t deviceID = properties1.deviceID; - std::string name = properties1.name; - std::string driverDescription = properties1.driverDescription; - wgpu::AdapterType adapterType = properties1.adapterType; - wgpu::BackendType backendType = properties1.backendType; - bool compatibilityMode = properties1.compatibilityMode; - - wgpu::AdapterProperties properties2(std::move(properties1)); - - // Expect properties2 to have properties1's old contents. - EXPECT_EQ(properties2.vendorID, vendorID); - EXPECT_STREQ(properties2.vendorName, vendorName.c_str()); - EXPECT_STREQ(properties2.architecture, architecture.c_str()); - EXPECT_EQ(properties2.deviceID, deviceID); - EXPECT_STREQ(properties2.name, name.c_str()); - EXPECT_STREQ(properties2.driverDescription, driverDescription.c_str()); - EXPECT_EQ(properties2.adapterType, adapterType); - EXPECT_EQ(properties2.backendType, backendType); - EXPECT_EQ(properties2.compatibilityMode, compatibilityMode); - - // Expect properties1 to be empty. - EXPECT_EQ(properties1.vendorID, 0u); - EXPECT_EQ(properties1.vendorName, nullptr); - EXPECT_EQ(properties1.architecture, nullptr); - EXPECT_EQ(properties1.deviceID, 0u); - EXPECT_EQ(properties1.name, nullptr); - EXPECT_EQ(properties1.driverDescription, nullptr); - EXPECT_EQ(properties1.adapterType, static_cast(0)); - EXPECT_EQ(properties1.backendType, static_cast(0)); - EXPECT_EQ(properties1.compatibilityMode, false); -} - -// Test that the adapter properties can outlive the adapter. -TEST_P(AdapterCreationTest, PropertiesOutliveAdapter) { - wgpu::RequestAdapterOptions options = {}; - - MockCallback cb; - - WGPUAdapter cAdapter = nullptr; - EXPECT_CALL(cb, Call(WGPURequestAdapterStatus_Success, _, nullptr, this)) - .WillOnce(SaveArg<1>(&cAdapter)); - RequestAdapter(instance, &options, cb.Callback(), cb.MakeUserdata(this)); - - wgpu::Adapter adapter = wgpu::Adapter::Acquire(cAdapter); - EXPECT_EQ(adapter != nullptr, anyAdapterAvailable); - if (!adapter) { - return; - } - - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); - - // Make a copy of the properties. - std::string vendorName = properties.vendorName; - std::string architecture = properties.architecture; - std::string name = properties.name; - std::string driverDescription = properties.driverDescription; - - // Release the adapter. - adapter = nullptr; - - // Ensure we still read the properties (pointers are still valid). - // Check the values are equal to make sure they haven't been overwritten, - // and to make sure the compiler can't elide no-op pointer reads. - EXPECT_EQ(properties.vendorName, vendorName); - EXPECT_EQ(properties.architecture, architecture); - EXPECT_EQ(properties.name, name); - EXPECT_EQ(properties.driverDescription, driverDescription); -} - // Test that calling AdapterGetInfo returns separate allocations for strings. // However, the string contents are equivalent. TEST_P(AdapterCreationTest, InfoUnique) { diff --git a/src/dawn/tests/end2end/AdapterEnumerationTests.cpp b/src/dawn/tests/end2end/AdapterEnumerationTests.cpp index 1c297f0046f..a8e721be273 100644 --- a/src/dawn/tests/end2end/AdapterEnumerationTests.cpp +++ b/src/dawn/tests/end2end/AdapterEnumerationTests.cpp @@ -68,12 +68,12 @@ TEST_F(AdapterEnumerationTests, OnlyFallback) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan); - EXPECT_EQ(properties.adapterType, wgpu::AdapterType::CPU); - EXPECT_TRUE(gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID)); + EXPECT_EQ(info.backendType, wgpu::BackendType::Vulkan); + EXPECT_EQ(info.adapterType, wgpu::AdapterType::CPU); + EXPECT_TRUE(gpu_info::IsGoogleSwiftshader(info.vendorID, info.deviceID)); } } @@ -86,10 +86,10 @@ TEST_F(AdapterEnumerationTests, OnlyVulkan) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan); + EXPECT_EQ(info.backendType, wgpu::BackendType::Vulkan); } } @@ -102,10 +102,10 @@ TEST_F(AdapterEnumerationTests, OnlyD3D11) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11); + EXPECT_EQ(info.backendType, wgpu::BackendType::D3D11); } } @@ -143,26 +143,26 @@ TEST_F(AdapterEnumerationTests, MatchingDXGIAdapterD3D11) { } ASSERT_EQ(adapters.size(), 1u); - wgpu::AdapterProperties properties; - adapters[0].GetProperties(&properties); - EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11); + wgpu::AdapterInfo info; + adapters[0].GetInfo(&info); + EXPECT_EQ(info.backendType, wgpu::BackendType::D3D11); // Test that enumeration again yields the same adapter device. const auto& adaptersAgain = instance.EnumerateAdapters(&adapterOptions); ASSERT_EQ(adaptersAgain.size(), 1u); - wgpu::AdapterProperties propertiesAgain; - adaptersAgain[0].GetProperties(&propertiesAgain); - - EXPECT_EQ(properties.vendorID, propertiesAgain.vendorID); - EXPECT_STREQ(properties.vendorName, propertiesAgain.vendorName); - EXPECT_STREQ(properties.architecture, propertiesAgain.architecture); - EXPECT_EQ(properties.deviceID, propertiesAgain.deviceID); - EXPECT_STREQ(properties.name, propertiesAgain.name); - EXPECT_STREQ(properties.driverDescription, propertiesAgain.driverDescription); - EXPECT_EQ(properties.adapterType, propertiesAgain.adapterType); - EXPECT_EQ(properties.backendType, propertiesAgain.backendType); - EXPECT_EQ(properties.compatibilityMode, propertiesAgain.compatibilityMode); + wgpu::AdapterInfo infoAgain; + adaptersAgain[0].GetInfo(&infoAgain); + + EXPECT_STREQ(info.vendor, infoAgain.vendor); + EXPECT_STREQ(info.architecture, infoAgain.architecture); + EXPECT_STREQ(info.device, infoAgain.device); + EXPECT_STREQ(info.description, infoAgain.description); + EXPECT_EQ(info.backendType, infoAgain.backendType); + EXPECT_EQ(info.adapterType, infoAgain.adapterType); + EXPECT_EQ(info.vendorID, infoAgain.vendorID); + EXPECT_EQ(info.deviceID, infoAgain.deviceID); + EXPECT_EQ(info.compatibilityMode, infoAgain.compatibilityMode); } } #endif // defined(DAWN_ENABLE_BACKEND_D3D11) @@ -176,10 +176,10 @@ TEST_F(AdapterEnumerationTests, OnlyD3D12) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12); + EXPECT_EQ(info.backendType, wgpu::BackendType::D3D12); } } @@ -217,26 +217,26 @@ TEST_F(AdapterEnumerationTests, MatchingDXGIAdapterD3D12) { } ASSERT_EQ(adapters.size(), 1u); - wgpu::AdapterProperties properties; - adapters[0].GetProperties(&properties); - EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12); + wgpu::AdapterInfo info; + adapters[0].GetInfo(&info); + EXPECT_EQ(info.backendType, wgpu::BackendType::D3D12); // Test that enumeration again yields the same adapter device. const auto& adaptersAgain = instance.EnumerateAdapters(&adapterOptions); ASSERT_EQ(adaptersAgain.size(), 1u); - wgpu::AdapterProperties propertiesAgain; - adaptersAgain[0].GetProperties(&propertiesAgain); - - EXPECT_EQ(properties.vendorID, propertiesAgain.vendorID); - EXPECT_STREQ(properties.vendorName, propertiesAgain.vendorName); - EXPECT_STREQ(properties.architecture, propertiesAgain.architecture); - EXPECT_EQ(properties.deviceID, propertiesAgain.deviceID); - EXPECT_STREQ(properties.name, propertiesAgain.name); - EXPECT_STREQ(properties.driverDescription, propertiesAgain.driverDescription); - EXPECT_EQ(properties.adapterType, propertiesAgain.adapterType); - EXPECT_EQ(properties.backendType, propertiesAgain.backendType); - EXPECT_EQ(properties.compatibilityMode, propertiesAgain.compatibilityMode); + wgpu::AdapterInfo infoAgain; + adaptersAgain[0].GetInfo(&infoAgain); + + EXPECT_STREQ(info.vendor, infoAgain.vendor); + EXPECT_STREQ(info.architecture, infoAgain.architecture); + EXPECT_STREQ(info.device, infoAgain.device); + EXPECT_STREQ(info.description, infoAgain.description); + EXPECT_EQ(info.backendType, infoAgain.backendType); + EXPECT_EQ(info.adapterType, infoAgain.adapterType); + EXPECT_EQ(info.vendorID, infoAgain.vendorID); + EXPECT_EQ(info.deviceID, infoAgain.deviceID); + EXPECT_EQ(info.compatibilityMode, infoAgain.compatibilityMode); } } #endif // defined(DAWN_ENABLE_BACKEND_D3D12) @@ -250,10 +250,10 @@ TEST_F(AdapterEnumerationTests, OnlyMetal) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - EXPECT_EQ(properties.backendType, wgpu::BackendType::Metal); + EXPECT_EQ(info.backendType, wgpu::BackendType::Metal); } } @@ -271,10 +271,10 @@ TEST_F(AdapterEnumerationTests, OneBackendThenTheOther) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); metalAdapterCount = adapters.size(); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - ASSERT_EQ(properties.backendType, wgpu::BackendType::Metal); + ASSERT_EQ(info.backendType, wgpu::BackendType::Metal); } } // Enumerate vulkan adapters. We should only see vulkan adapters. @@ -283,10 +283,10 @@ TEST_F(AdapterEnumerationTests, OneBackendThenTheOther) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - ASSERT_EQ(properties.backendType, wgpu::BackendType::Vulkan); + ASSERT_EQ(info.backendType, wgpu::BackendType::Vulkan); } } @@ -297,10 +297,10 @@ TEST_F(AdapterEnumerationTests, OneBackendThenTheOther) { const auto& adapters = instance.EnumerateAdapters(&adapterOptions); uint32_t metalAdapterCount2 = adapters.size(); for (const auto& adapter : adapters) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - ASSERT_EQ(properties.backendType, wgpu::BackendType::Metal); + ASSERT_EQ(info.backendType, wgpu::BackendType::Metal); } EXPECT_EQ(metalAdapterCount, metalAdapterCount2); } diff --git a/src/dawn/tests/end2end/AdapterPropertiesD3DTests.cpp b/src/dawn/tests/end2end/AdapterPropertiesD3DTests.cpp index 05e409b8310..30ba12fab7d 100644 --- a/src/dawn/tests/end2end/AdapterPropertiesD3DTests.cpp +++ b/src/dawn/tests/end2end/AdapterPropertiesD3DTests.cpp @@ -38,26 +38,15 @@ class AdapterPropertiesD3DTest : public DawnTest {}; // Test that it is possible to query the d3d properties, and it is populated with a valid data. TEST_P(AdapterPropertiesD3DTest, GetD3DProperties) { DAWN_TEST_UNSUPPORTED_IF(!adapter.HasFeature(wgpu::FeatureName::AdapterPropertiesD3D)); - { - wgpu::AdapterProperties properties; - wgpu::AdapterPropertiesD3D d3dProperties; - properties.nextInChain = &d3dProperties; - EXPECT_DEPRECATION_WARNING(adapter.GetProperties(&properties)); + wgpu::AdapterInfo info; + wgpu::AdapterPropertiesD3D d3dProperties; + info.nextInChain = &d3dProperties; - // This is the minimum D3D shader model Dawn supports. - EXPECT_GE(d3dProperties.shaderModel, 50u); - } - { - wgpu::AdapterInfo info; - wgpu::AdapterPropertiesD3D d3dProperties; - info.nextInChain = &d3dProperties; + adapter.GetInfo(&info); - adapter.GetInfo(&info); - - // This is the minimum D3D shader model Dawn supports. - EXPECT_GE(d3dProperties.shaderModel, 50u); - } + // This is the minimum D3D shader model Dawn supports. + EXPECT_GE(d3dProperties.shaderModel, 50u); } DAWN_INSTANTIATE_TEST(AdapterPropertiesD3DTest, diff --git a/src/dawn/tests/end2end/AdapterPropertiesVkTests.cpp b/src/dawn/tests/end2end/AdapterPropertiesVkTests.cpp index 2faa4ed924e..af69930f921 100644 --- a/src/dawn/tests/end2end/AdapterPropertiesVkTests.cpp +++ b/src/dawn/tests/end2end/AdapterPropertiesVkTests.cpp @@ -39,26 +39,14 @@ class AdapterPropertiesVkTest : public DawnTest {}; TEST_P(AdapterPropertiesVkTest, GetVkProperties) { DAWN_TEST_UNSUPPORTED_IF(!adapter.HasFeature(wgpu::FeatureName::AdapterPropertiesVk)); - { - wgpu::AdapterProperties properties; - wgpu::AdapterPropertiesVk vkProperties; - properties.nextInChain = &vkProperties; + wgpu::AdapterInfo info; + wgpu::AdapterPropertiesVk vkProperties; + info.nextInChain = &vkProperties; - EXPECT_DEPRECATION_WARNING(adapter.GetProperties(&properties)); + adapter.GetInfo(&info); - // The driver version should be set to something but it depends on the hardware. - EXPECT_NE(vkProperties.driverVersion, 0u); - } - { - wgpu::AdapterInfo info; - wgpu::AdapterPropertiesVk vkProperties; - info.nextInChain = &vkProperties; - - adapter.GetInfo(&info); - - // The driver version should be set to something but it depends on the hardware. - EXPECT_NE(vkProperties.driverVersion, 0u); - } + // The driver version should be set to something but it depends on the hardware. + EXPECT_NE(vkProperties.driverVersion, 0u); } DAWN_INSTANTIATE_TEST(AdapterPropertiesVkTest, VulkanBackend()); diff --git a/src/dawn/tests/end2end/DeviceInitializationTests.cpp b/src/dawn/tests/end2end/DeviceInitializationTests.cpp index a0e12e2ee9c..f89715e7274 100644 --- a/src/dawn/tests/end2end/DeviceInitializationTests.cpp +++ b/src/dawn/tests/end2end/DeviceInitializationTests.cpp @@ -82,35 +82,34 @@ class DeviceInitializationTest : public testing::Test { // Test that device operations are still valid if the reference to the instance // is dropped. TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) { - // Get properties of all available adapters and then free the instance. + // Get info of all available adapters and then free the instance. // We want to create a device on a fresh instance and adapter each time. - std::vector availableAdapterProperties; + std::vector availableAdapterInfo; { auto instance = std::make_unique(); for (const native::Adapter& adapter : instance->EnumerateAdapters()) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - if (properties.backendType == wgpu::BackendType::Null) { + if (info.backendType == wgpu::BackendType::Null) { continue; } - availableAdapterProperties.push_back(std::move(properties)); + availableAdapterInfo.push_back(std::move(info)); } } - for (const wgpu::AdapterProperties& desiredProperties : availableAdapterProperties) { + for (const wgpu::AdapterInfo& desiredInfo : availableAdapterInfo) { wgpu::Device device; auto instance = std::make_unique(); for (native::Adapter& adapter : instance->EnumerateAdapters()) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - if (properties.deviceID == desiredProperties.deviceID && - properties.vendorID == desiredProperties.vendorID && - properties.adapterType == desiredProperties.adapterType && - properties.backendType == desiredProperties.backendType) { + if (info.deviceID == desiredInfo.deviceID && info.vendorID == desiredInfo.vendorID && + info.adapterType == desiredInfo.adapterType && + info.backendType == desiredInfo.backendType) { // Create the device, destroy the instance, and break out of the loop. device = wgpu::Device::Acquire(adapter.CreateDevice()); instance.reset(); @@ -127,34 +126,33 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) { // Test that it is still possible to create a device from an adapter after the reference to the // instance is dropped. TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) { - // Get properties of all available adapters and then free the instance. + // Get info of all available adapters and then free the instance. // We want to create a device on a fresh instance and adapter each time. - std::vector availableAdapterProperties; + std::vector availableAdapterInfo; { auto instance = std::make_unique(); for (const native::Adapter& adapter : instance->EnumerateAdapters()) { - wgpu::AdapterProperties properties; - adapter.GetProperties(&properties); + wgpu::AdapterInfo info; + adapter.GetInfo(&info); - if (properties.backendType == wgpu::BackendType::Null) { + if (info.backendType == wgpu::BackendType::Null) { continue; } - availableAdapterProperties.push_back(std::move(properties)); + availableAdapterInfo.push_back(std::move(info)); } } - for (const wgpu::AdapterProperties& desiredProperties : availableAdapterProperties) { + for (const wgpu::AdapterInfo& desiredInfo : availableAdapterInfo) { wgpu::Adapter adapter; auto instance = std::make_unique(); for (native::Adapter& nativeAdapter : instance->EnumerateAdapters()) { - wgpu::AdapterProperties properties; - nativeAdapter.GetProperties(&properties); + wgpu::AdapterInfo info; + nativeAdapter.GetInfo(&info); - if (properties.deviceID == desiredProperties.deviceID && - properties.vendorID == desiredProperties.vendorID && - properties.adapterType == desiredProperties.adapterType && - properties.backendType == desiredProperties.backendType) { + if (info.deviceID == desiredInfo.deviceID && info.vendorID == desiredInfo.vendorID && + info.adapterType == desiredInfo.adapterType && + info.backendType == desiredInfo.backendType) { // Save the adapter, and reset the instance. adapter = wgpu::Adapter(nativeAdapter.Get()); instance.reset(); diff --git a/src/dawn/tests/end2end/MemoryHeapPropertiesTests.cpp b/src/dawn/tests/end2end/MemoryHeapPropertiesTests.cpp index d855c881d0f..421eaf00967 100644 --- a/src/dawn/tests/end2end/MemoryHeapPropertiesTests.cpp +++ b/src/dawn/tests/end2end/MemoryHeapPropertiesTests.cpp @@ -32,27 +32,7 @@ namespace dawn { namespace { -class MemoryHeapPropertiesTest : public DawnTest { - protected: - void CheckMemoryHeapProperties(const wgpu::AdapterPropertiesMemoryHeaps& memoryHeapProperties) { - EXPECT_GT(memoryHeapProperties.heapCount, 0u); - for (size_t i = 0; i < memoryHeapProperties.heapCount; ++i) { - // Check the heap is non-zero in size. - EXPECT_GT(memoryHeapProperties.heapInfo[i].size, 0ull); - - constexpr wgpu::HeapProperty kValidProps = - wgpu::HeapProperty::DeviceLocal | wgpu::HeapProperty::HostVisible | - wgpu::HeapProperty::HostCoherent | wgpu::HeapProperty::HostUncached | - wgpu::HeapProperty::HostCached; - - // Check the heap properties only contain the set of valid enums. - EXPECT_EQ(memoryHeapProperties.heapInfo[i].properties & ~kValidProps, 0u); - - // Check the heap properties have at least one bit. - EXPECT_NE(uint32_t(memoryHeapProperties.heapInfo[i].properties), 0u); - } - } -}; +class MemoryHeapPropertiesTest : public DawnTest {}; // TODO(dawn:2257) test that is is invalid to request AdapterPropertiesMemoryHeaps if the // feature is not available. @@ -60,21 +40,26 @@ class MemoryHeapPropertiesTest : public DawnTest { // Test that it is possible to query the memory, and it is populated with valid enums. TEST_P(MemoryHeapPropertiesTest, GetMemoryHeapProperties) { DAWN_TEST_UNSUPPORTED_IF(!adapter.HasFeature(wgpu::FeatureName::AdapterPropertiesMemoryHeaps)); - { - wgpu::AdapterProperties properties; - wgpu::AdapterPropertiesMemoryHeaps memoryHeapProperties; - properties.nextInChain = &memoryHeapProperties; + wgpu::AdapterInfo info; + wgpu::AdapterPropertiesMemoryHeaps memoryHeapProperties; + info.nextInChain = &memoryHeapProperties; - EXPECT_DEPRECATION_WARNING(adapter.GetProperties(&properties)); - CheckMemoryHeapProperties(memoryHeapProperties); - } - { - wgpu::AdapterInfo info; - wgpu::AdapterPropertiesMemoryHeaps memoryHeapProperties; - info.nextInChain = &memoryHeapProperties; + adapter.GetInfo(&info); + EXPECT_GT(memoryHeapProperties.heapCount, 0u); + for (size_t i = 0; i < memoryHeapProperties.heapCount; ++i) { + // Check the heap is non-zero in size. + EXPECT_GT(memoryHeapProperties.heapInfo[i].size, 0ull); + + constexpr wgpu::HeapProperty kValidProps = + wgpu::HeapProperty::DeviceLocal | wgpu::HeapProperty::HostVisible | + wgpu::HeapProperty::HostCoherent | wgpu::HeapProperty::HostUncached | + wgpu::HeapProperty::HostCached; + + // Check the heap properties only contain the set of valid enums. + EXPECT_EQ(memoryHeapProperties.heapInfo[i].properties & ~kValidProps, 0u); - adapter.GetInfo(&info); - CheckMemoryHeapProperties(memoryHeapProperties); + // Check the heap properties have at least one bit. + EXPECT_NE(uint32_t(memoryHeapProperties.heapInfo[i].properties), 0u); } } diff --git a/src/dawn/tests/unittests/ChainUtilsTests.cpp b/src/dawn/tests/unittests/ChainUtilsTests.cpp index 594b198e129..1d3029d8e15 100644 --- a/src/dawn/tests/unittests/ChainUtilsTests.cpp +++ b/src/dawn/tests/unittests/ChainUtilsTests.cpp @@ -102,11 +102,11 @@ TEST(ChainUtilsTests, ValidateAndUnpack) { // Nominal unpacking valid descriptors should return the expected descriptors in the unpacked type. TEST(ChainUtilsTests, ValidateAndUnpackOut) { - // DawnAdapterPropertiesPowerPreference is a valid extension for AdapterProperties. - AdapterProperties properties; + // DawnAdapterPropertiesPowerPreference is a valid extension for AdapterInfo. + AdapterInfo info; DawnAdapterPropertiesPowerPreference chain; - properties.nextInChain = &chain; - auto unpacked = ValidateAndUnpack(&properties).AcquireSuccess(); + info.nextInChain = &chain; + auto unpacked = ValidateAndUnpack(&info).AcquireSuccess(); auto ext = unpacked.Get(); EXPECT_EQ(ext, &chain); @@ -128,13 +128,13 @@ TEST(ChainUtilsTests, ValidateAndUnpackDuplicate) { // Duplicate valid extensions cause an error. TEST(ChainUtilsTests, ValidateAndUnpackOutDuplicate) { - // DawnAdapterPropertiesPowerPreference is a valid extension for AdapterProperties. - AdapterProperties properties; + // DawnAdapterPropertiesPowerPreference is a valid extension for AdapterInfo. + AdapterInfo info; DawnAdapterPropertiesPowerPreference chain1; DawnAdapterPropertiesPowerPreference chain2; - properties.nextInChain = &chain1; + info.nextInChain = &chain1; chain1.nextInChain = &chain2; - EXPECT_THAT(ValidateAndUnpack(&properties).AcquireError()->GetFormattedMessage(), + EXPECT_THAT(ValidateAndUnpack(&info).AcquireError()->GetFormattedMessage(), HasSubstr("Duplicate")); } diff --git a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp index 69b7283c423..8b97d85596a 100644 --- a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp @@ -188,17 +188,6 @@ TEST_P(WireInstanceTests, RequestAdapterSuccess) { EXPECT_EQ(info.vendorID, fakeInfo.vendorID); EXPECT_EQ(info.deviceID, fakeInfo.deviceID); - WGPUAdapterProperties properties = {}; - wgpuAdapterGetProperties(adapter, &properties); - EXPECT_EQ(properties.vendorID, fakeInfo.vendorID); - EXPECT_STREQ(properties.vendorName, fakeInfo.vendor); - EXPECT_STREQ(properties.architecture, fakeInfo.architecture); - EXPECT_EQ(properties.deviceID, fakeInfo.deviceID); - EXPECT_STREQ(properties.name, fakeInfo.device); - EXPECT_STREQ(properties.driverDescription, fakeInfo.description); - EXPECT_EQ(properties.backendType, fakeInfo.backendType); - EXPECT_EQ(properties.adapterType, fakeInfo.adapterType); - WGPUSupportedLimits limits = {}; EXPECT_EQ(wgpuAdapterGetLimits(adapter, &limits), WGPUStatus_Success); EXPECT_EQ(limits.limits.maxTextureDimension1D, @@ -321,17 +310,17 @@ TEST_P(WireInstanceTests, RequestAdapterPassesChainedProperties) { ExpectWireCallbacksWhen([&](auto& mockCb) { EXPECT_CALL(mockCb, Call(WGPURequestAdapterStatus_Success, NotNull(), nullptr, nullptr)) .WillOnce(WithArg<1>(Invoke([&](WGPUAdapter adapter) { - // Request properties without a chained struct. + // Request info without a chained struct. // It should be nullptr. - WGPUAdapterProperties properties = {}; - wgpuAdapterGetProperties(adapter, &properties); - EXPECT_EQ(properties.nextInChain, nullptr); + WGPUAdapterInfo info = {}; + wgpuAdapterGetInfo(adapter, &info); + EXPECT_EQ(info.nextInChain, nullptr); // Request the memory heap properties. WGPUAdapterPropertiesMemoryHeaps memoryHeapProperties = {}; memoryHeapProperties.chain.sType = WGPUSType_AdapterPropertiesMemoryHeaps; - properties.nextInChain = &memoryHeapProperties.chain; - wgpuAdapterGetProperties(adapter, &properties); + info.nextInChain = &memoryHeapProperties.chain; + wgpuAdapterGetInfo(adapter, &info); // Expect everything matches the fake properties returned by the server. EXPECT_EQ(memoryHeapProperties.heapCount, fakeMemoryHeapProperties.heapCount); @@ -345,16 +334,16 @@ TEST_P(WireInstanceTests, RequestAdapterPassesChainedProperties) { // Get the D3D properties. WGPUAdapterPropertiesD3D d3dProperties = {}; d3dProperties.chain.sType = WGPUSType_AdapterPropertiesD3D; - properties.nextInChain = &d3dProperties.chain; - wgpuAdapterGetProperties(adapter, &properties); + info.nextInChain = &d3dProperties.chain; + wgpuAdapterGetInfo(adapter, &info); // Expect them to match. EXPECT_EQ(d3dProperties.shaderModel, fakeD3DProperties.shaderModel); // Get the Vulkan properties. WGPUAdapterPropertiesVk vkProperties = {}; vkProperties.chain.sType = WGPUSType_AdapterPropertiesVk; - properties.nextInChain = &vkProperties.chain; - wgpuAdapterGetProperties(adapter, &properties); + info.nextInChain = &vkProperties.chain; + wgpuAdapterGetInfo(adapter, &info); // Expect them to match. EXPECT_EQ(vkProperties.driverVersion, fakeVkProperties.driverVersion); }))); diff --git a/src/dawn/wire/client/Adapter.cpp b/src/dawn/wire/client/Adapter.cpp index 46e97910bfb..02b2fdac4de 100644 --- a/src/dawn/wire/client/Adapter.cpp +++ b/src/dawn/wire/client/Adapter.cpp @@ -196,19 +196,6 @@ void Adapter::SetInfo(const WGPUAdapterInfo* info) { } } -void Adapter::SetProperties(const WGPUAdapterInfo* info) { - mProperties.nextInChain = nullptr; - mProperties.vendorID = info->vendorID; - mProperties.vendorName = info->vendor; - mProperties.architecture = info->architecture; - mProperties.deviceID = info->deviceID; - mProperties.name = info->device; - mProperties.driverDescription = info->description; - mProperties.adapterType = info->adapterType; - mProperties.backendType = info->backendType; - mProperties.compatibilityMode = info->compatibilityMode; -} - WGPUStatus Adapter::GetInfo(WGPUAdapterInfo* info) const { // Loop through the chained struct. WGPUChainedStructOut* chain = info->nextInChain; @@ -272,69 +259,6 @@ WGPUStatus Adapter::GetInfo(WGPUAdapterInfo* info) const { return WGPUStatus_Success; } -WGPUStatus Adapter::GetProperties(WGPUAdapterProperties* properties) const { - // Loop through the chained struct. - WGPUChainedStructOut* chain = properties->nextInChain; - while (chain != nullptr) { - switch (chain->sType) { - case WGPUSType_AdapterPropertiesMemoryHeaps: { - // Copy `mMemoryHeapInfo` into a new allocation. - auto* memoryHeapProperties = - reinterpret_cast(chain); - size_t heapCount = mMemoryHeapInfo.size(); - auto* heapInfo = new WGPUMemoryHeapInfo[heapCount]; - memcpy(heapInfo, mMemoryHeapInfo.data(), sizeof(WGPUMemoryHeapInfo) * heapCount); - // Write out the pointer and count to the heap properties out-struct. - memoryHeapProperties->heapCount = heapCount; - memoryHeapProperties->heapInfo = heapInfo; - break; - } - case WGPUSType_AdapterPropertiesD3D: { - auto* d3dProperties = reinterpret_cast(chain); - d3dProperties->shaderModel = mD3DProperties.shaderModel; - break; - } - case WGPUSType_AdapterPropertiesVk: { - auto* vkProperties = reinterpret_cast(chain); - vkProperties->driverVersion = mVkProperties.driverVersion; - break; - } - default: - break; - } - chain = chain->next; - } - - *properties = mProperties; - - // Get lengths, with null terminators. - size_t vendorNameCLen = strlen(mProperties.vendorName) + 1; - size_t architectureCLen = strlen(mProperties.architecture) + 1; - size_t nameCLen = strlen(mProperties.name) + 1; - size_t driverDescriptionCLen = strlen(mProperties.driverDescription) + 1; - - // Allocate space for all strings. - char* ptr = new char[vendorNameCLen + architectureCLen + nameCLen + driverDescriptionCLen]; - - properties->vendorName = ptr; - memcpy(ptr, mProperties.vendorName, vendorNameCLen); - ptr += vendorNameCLen; - - properties->architecture = ptr; - memcpy(ptr, mProperties.architecture, architectureCLen); - ptr += architectureCLen; - - properties->name = ptr; - memcpy(ptr, mProperties.name, nameCLen); - ptr += nameCLen; - - properties->driverDescription = ptr; - memcpy(ptr, mProperties.driverDescription, driverDescriptionCLen); - ptr += driverDescriptionCLen; - - return WGPUStatus_Success; -} - void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor, WGPURequestDeviceCallback callback, void* userdata) { @@ -452,12 +376,6 @@ DAWN_WIRE_EXPORT void wgpuDawnWireClientAdapterInfoFreeMembers(WGPUAdapterInfo i delete[] info.vendor; } -DAWN_WIRE_EXPORT void wgpuDawnWireClientAdapterPropertiesFreeMembers( - WGPUAdapterProperties properties) { - // This single delete is enough because everything is a single allocation. - delete[] properties.vendorName; -} - DAWN_WIRE_EXPORT void wgpuDawnWireClientAdapterPropertiesMemoryHeapsFreeMembers( WGPUAdapterPropertiesMemoryHeaps memoryHeapProperties) { delete[] memoryHeapProperties.heapInfo; diff --git a/src/dawn/wire/client/Adapter.h b/src/dawn/wire/client/Adapter.h index 7e2a98b8606..34b903a8aa0 100644 --- a/src/dawn/wire/client/Adapter.h +++ b/src/dawn/wire/client/Adapter.h @@ -50,9 +50,7 @@ class Adapter final : public ObjectWithEventsBase { void SetLimits(const WGPUSupportedLimits* limits); void SetFeatures(const WGPUFeatureName* features, uint32_t featuresCount); void SetInfo(const WGPUAdapterInfo* info); - void SetProperties(const WGPUAdapterInfo* info); WGPUStatus GetInfo(WGPUAdapterInfo* info) const; - WGPUStatus GetProperties(WGPUAdapterProperties* properties) const; void RequestDevice(const WGPUDeviceDescriptor* descriptor, WGPURequestDeviceCallback callback, void* userdata); @@ -69,7 +67,6 @@ class Adapter final : public ObjectWithEventsBase { private: LimitsAndFeatures mLimitsAndFeatures; - WGPUAdapterProperties mProperties; WGPUAdapterInfo mInfo; std::vector mMemoryHeapInfo; WGPUAdapterPropertiesD3D mD3DProperties; diff --git a/src/dawn/wire/client/Instance.cpp b/src/dawn/wire/client/Instance.cpp index f0bcf39c465..a9dece8012d 100644 --- a/src/dawn/wire/client/Instance.cpp +++ b/src/dawn/wire/client/Instance.cpp @@ -77,7 +77,6 @@ class RequestAdapterEvent : public TrackedEvent { } if (status == WGPURequestAdapterStatus_Success) { mAdapter->SetInfo(info); - mAdapter->SetProperties(info); mAdapter->SetLimits(limits); mAdapter->SetFeatures(features, featuresCount); } diff --git a/tools/android/BUILD.gn b/tools/android/BUILD.gn index 7ba2620ee18..a9b454a79fe 100644 --- a/tools/android/BUILD.gn +++ b/tools/android/BUILD.gn @@ -43,7 +43,6 @@ dawn_json_generator("kotlin_gen") { outputs = [ "java/android/dawn/Adapter.kt", "java/android/dawn/AdapterInfo.kt", - "java/android/dawn/AdapterProperties.kt", "java/android/dawn/AdapterType.kt", "java/android/dawn/AddressMode.kt", "java/android/dawn/AsyncHelpers.kt",