From 476693ae501a3a39851858ded2bd430d4c811104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Tue, 19 Nov 2024 09:26:50 +0000 Subject: [PATCH] webgpu.h: Remove EnumerateFeatures() Now that GetFeatures() has been added, we can safely remove the deprecated EnumerateFeatures(). Bug: 368672123 Change-Id: Ia8a4b377ff9b41219543f3a1071aacfe05d07998 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/215514 Reviewed-by: Kai Ninomiya Commit-Queue: Fr Reviewed-by: Corentin Wallez --- src/dawn/dawn.json | 16 -------------- src/dawn/dawn_wire.json | 2 -- src/dawn/native/Adapter.cpp | 4 ---- src/dawn/native/Adapter.h | 1 - src/dawn/native/Device.cpp | 4 ---- src/dawn/native/Device.h | 1 - src/dawn/native/Features.cpp | 11 ---------- src/dawn/native/Features.h | 3 --- .../unittests/native/DeviceCreationTests.cpp | 21 +++---------------- .../ShaderModuleValidationTests.cpp | 8 ++++--- src/dawn/wire/client/Adapter.cpp | 4 ---- src/dawn/wire/client/Adapter.h | 1 - src/dawn/wire/client/Device.cpp | 4 ---- src/dawn/wire/client/Device.h | 1 - src/dawn/wire/client/LimitsAndFeatures.cpp | 10 --------- src/dawn/wire/client/LimitsAndFeatures.h | 1 - third_party/emdawnwebgpu/library_webgpu.js | 2 +- 17 files changed, 9 insertions(+), 85 deletions(-) diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json index 5450df5cebc..d719a2c8a1f 100644 --- a/src/dawn/dawn.json +++ b/src/dawn/dawn.json @@ -154,14 +154,6 @@ {"name": "feature", "type": "feature name"} ] }, - { - "name": "enumerate features", - "tags": ["deprecated"], - "returns": "size_t", - "args": [ - {"name": "features", "type": "feature name", "annotation": "*"} - ] - }, { "name": "get features", "returns": "void", @@ -1566,14 +1558,6 @@ {"name": "feature", "type": "feature name"} ] }, - { - "name": "enumerate features", - "tags": ["deprecated"], - "returns": "size_t", - "args": [ - {"name": "features", "type": "feature name", "annotation": "*"} - ] - }, { "name": "get features", "returns": "void", diff --git a/src/dawn/dawn_wire.json b/src/dawn/dawn_wire.json index f95a1ca1512..ba541a99eb3 100644 --- a/src/dawn/dawn_wire.json +++ b/src/dawn/dawn_wire.json @@ -224,7 +224,6 @@ "AdapterGetInstance", "AdapterGetLimits", "AdapterHasFeature", - "AdapterEnumerateFeatures", "AdapterRequestDevice", "AdapterRequestDeviceF", "AdapterRequestDevice2", @@ -248,7 +247,6 @@ "DeviceGetFeatures", "DeviceGetLimits", "DeviceHasFeature", - "DeviceEnumerateFeatures", "DevicePopErrorScope", "DevicePopErrorScopeF", "DevicePopErrorScope2", diff --git a/src/dawn/native/Adapter.cpp b/src/dawn/native/Adapter.cpp index be0cca35caf..c2f0e705024 100644 --- a/src/dawn/native/Adapter.cpp +++ b/src/dawn/native/Adapter.cpp @@ -224,10 +224,6 @@ bool AdapterBase::APIHasFeature(wgpu::FeatureName feature) const { return mSupportedFeatures.IsEnabled(feature); } -size_t AdapterBase::APIEnumerateFeatures(wgpu::FeatureName* features) const { - return mSupportedFeatures.EnumerateFeatures(features); -} - void AdapterBase::APIGetFeatures(wgpu::SupportedFeatures* features) const { this->APIGetFeatures(reinterpret_cast(features)); } diff --git a/src/dawn/native/Adapter.h b/src/dawn/native/Adapter.h index 28b5bcf9622..bcf4a06c3ca 100644 --- a/src/dawn/native/Adapter.h +++ b/src/dawn/native/Adapter.h @@ -63,7 +63,6 @@ class AdapterBase : public RefCounted, public WeakRefSupport { wgpu::Status APIGetLimits(SupportedLimits* limits) const; wgpu::Status APIGetInfo(AdapterInfo* info) const; bool APIHasFeature(wgpu::FeatureName feature) const; - size_t APIEnumerateFeatures(wgpu::FeatureName* features) const; void APIGetFeatures(SupportedFeatures* features) const; void APIGetFeatures(wgpu::SupportedFeatures* features) const; void APIRequestDevice(const DeviceDescriptor* descriptor, diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index eea04ac5a9f..423889c6701 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp @@ -2009,10 +2009,6 @@ bool DeviceBase::APIHasFeature(wgpu::FeatureName feature) const { return mEnabledFeatures.IsEnabled(feature); } -size_t DeviceBase::APIEnumerateFeatures(wgpu::FeatureName* features) const { - return mEnabledFeatures.EnumerateFeatures(features); -} - void DeviceBase::APIGetFeatures(wgpu::SupportedFeatures* features) const { this->APIGetFeatures(reinterpret_cast(features)); } diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h index 4f9b3278c70..2b0708f5c37 100644 --- a/src/dawn/native/Device.h +++ b/src/dawn/native/Device.h @@ -288,7 +288,6 @@ class DeviceBase : public ErrorSink, public RefCountedWithExternalCount FeaturesSet::GetEnabledFeatureNames() const { std::vector enabledFeatureNames(featuresBitSet.count()); diff --git a/src/dawn/native/Features.h b/src/dawn/native/Features.h index d97d0b5328f..915b13731da 100644 --- a/src/dawn/native/Features.h +++ b/src/dawn/native/Features.h @@ -56,9 +56,6 @@ struct FeaturesSet { void EnableFeature(wgpu::FeatureName feature); bool IsEnabled(Feature feature) const; bool IsEnabled(wgpu::FeatureName feature) const; - // Returns |count|, the number of features. Writes out all |count| values if |features| is - // non-null. - size_t EnumerateFeatures(wgpu::FeatureName* features) const; std::vector GetEnabledFeatureNames() const; void ToSupportedFeatures(SupportedFeatures* supportedFeatures) const; }; diff --git a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp index cc62cd08456..1c598732098 100644 --- a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp +++ b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp @@ -164,15 +164,10 @@ TEST_F(DeviceCreationTest, CreateDeviceRequiringExperimentalFeatures) { wgpu::Device device = unsafeAdapter.CreateDevice(&deviceDescriptor); EXPECT_NE(device, nullptr); - ASSERT_EQ(1u, device.EnumerateFeatures(nullptr)); - wgpu::FeatureName enabledFeature; - device.EnumerateFeatures(&enabledFeature); - EXPECT_EQ(enabledFeature, featureName); - wgpu::SupportedFeatures supportedFeatures; device.GetFeatures(&supportedFeatures); ASSERT_EQ(1u, supportedFeatures.featureCount); - EXPECT_EQ(enabledFeature, supportedFeatures.features[0]); + EXPECT_EQ(featureName, supportedFeatures.features[0]); } // Test creating device with AllowUnsafeApis enabled in device toggle descriptor will @@ -189,15 +184,10 @@ TEST_F(DeviceCreationTest, CreateDeviceRequiringExperimentalFeatures) { wgpu::Device device = adapter.CreateDevice(&deviceDescriptor); EXPECT_NE(device, nullptr); - ASSERT_EQ(1u, device.EnumerateFeatures(nullptr)); - wgpu::FeatureName enabledFeature; - device.EnumerateFeatures(&enabledFeature); - EXPECT_EQ(enabledFeature, featureName); - wgpu::SupportedFeatures supportedFeatures; device.GetFeatures(&supportedFeatures); ASSERT_EQ(1u, supportedFeatures.featureCount); - EXPECT_EQ(enabledFeature, supportedFeatures.features[0]); + EXPECT_EQ(featureName, supportedFeatures.features[0]); } // Test on adapter with AllowUnsafeApis disabled. @@ -205,15 +195,10 @@ TEST_F(DeviceCreationTest, CreateDeviceRequiringExperimentalFeatures) { wgpu::Device device = unsafeAdapter.CreateDevice(&deviceDescriptor); EXPECT_NE(device, nullptr); - ASSERT_EQ(1u, device.EnumerateFeatures(nullptr)); - wgpu::FeatureName enabledFeature; - device.EnumerateFeatures(&enabledFeature); - EXPECT_EQ(enabledFeature, featureName); - wgpu::SupportedFeatures supportedFeatures; device.GetFeatures(&supportedFeatures); ASSERT_EQ(1u, supportedFeatures.featureCount); - EXPECT_EQ(enabledFeature, supportedFeatures.features[0]); + EXPECT_EQ(featureName, supportedFeatures.features[0]); } } diff --git a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp index 9400ecae60e..3b59c80d526 100644 --- a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp @@ -791,9 +791,11 @@ class ShaderModuleExtensionValidationTestBase : public ValidationTest { std::vector GetAllFeatures() { std::vector requiredFeatures; - const size_t featureCount = adapter.EnumerateFeatures(nullptr); - requiredFeatures.resize(featureCount); - adapter.EnumerateFeatures(requiredFeatures.data()); + wgpu::SupportedFeatures supportedFeatures; + adapter.GetFeatures(&supportedFeatures); + for (uint32_t i = 0; i < supportedFeatures.featureCount; ++i) { + requiredFeatures.push_back(supportedFeatures.features[i]); + } return requiredFeatures; } }; diff --git a/src/dawn/wire/client/Adapter.cpp b/src/dawn/wire/client/Adapter.cpp index 2547eac31d3..9dfa04b07c9 100644 --- a/src/dawn/wire/client/Adapter.cpp +++ b/src/dawn/wire/client/Adapter.cpp @@ -150,10 +150,6 @@ bool Adapter::HasFeature(WGPUFeatureName feature) const { return mLimitsAndFeatures.HasFeature(feature); } -size_t Adapter::EnumerateFeatures(WGPUFeatureName* features) const { - return mLimitsAndFeatures.EnumerateFeatures(features); -} - void Adapter::GetFeatures(WGPUSupportedFeatures* features) const { mLimitsAndFeatures.ToSupportedFeatures(features); } diff --git a/src/dawn/wire/client/Adapter.h b/src/dawn/wire/client/Adapter.h index c21d7f21a68..cfdebfdcf5f 100644 --- a/src/dawn/wire/client/Adapter.h +++ b/src/dawn/wire/client/Adapter.h @@ -47,7 +47,6 @@ class Adapter final : public ObjectWithEventsBase { WGPUStatus GetLimits(WGPUSupportedLimits* limits) const; bool HasFeature(WGPUFeatureName feature) const; - size_t EnumerateFeatures(WGPUFeatureName* features) const; void SetLimits(const WGPUSupportedLimits* limits); void SetFeatures(const WGPUFeatureName* features, uint32_t featuresCount); void SetInfo(const WGPUAdapterInfo* info); diff --git a/src/dawn/wire/client/Device.cpp b/src/dawn/wire/client/Device.cpp index ddf4befa140..3883cb2dcbc 100644 --- a/src/dawn/wire/client/Device.cpp +++ b/src/dawn/wire/client/Device.cpp @@ -337,10 +337,6 @@ bool Device::HasFeature(WGPUFeatureName feature) const { return mLimitsAndFeatures.HasFeature(feature); } -size_t Device::EnumerateFeatures(WGPUFeatureName* features) const { - return mLimitsAndFeatures.EnumerateFeatures(features); -} - void Device::GetFeatures(WGPUSupportedFeatures* features) const { mLimitsAndFeatures.ToSupportedFeatures(features); } diff --git a/src/dawn/wire/client/Device.h b/src/dawn/wire/client/Device.h index edc7c68fbac..15f0e0319c5 100644 --- a/src/dawn/wire/client/Device.h +++ b/src/dawn/wire/client/Device.h @@ -97,7 +97,6 @@ class Device final : public RefCountedWithExternalCount { WGPUStatus GetLimits(WGPUSupportedLimits* limits) const; bool HasFeature(WGPUFeatureName feature) const; - size_t EnumerateFeatures(WGPUFeatureName* features) const; void GetFeatures(WGPUSupportedFeatures* features) const; WGPUStatus GetAdapterInfo(WGPUAdapterInfo* info) const; WGPUAdapter GetAdapter() const; diff --git a/src/dawn/wire/client/LimitsAndFeatures.cpp b/src/dawn/wire/client/LimitsAndFeatures.cpp index 803480aca1d..790fb8c4176 100644 --- a/src/dawn/wire/client/LimitsAndFeatures.cpp +++ b/src/dawn/wire/client/LimitsAndFeatures.cpp @@ -74,16 +74,6 @@ bool LimitsAndFeatures::HasFeature(WGPUFeatureName feature) const { return mFeatures.contains(feature); } -size_t LimitsAndFeatures::EnumerateFeatures(WGPUFeatureName* features) const { - if (features != nullptr) { - for (WGPUFeatureName f : mFeatures) { - *features = f; - ++features; - } - } - return mFeatures.size(); -} - void LimitsAndFeatures::ToSupportedFeatures(WGPUSupportedFeatures* supportedFeatures) const { if (!supportedFeatures) { return; diff --git a/src/dawn/wire/client/LimitsAndFeatures.h b/src/dawn/wire/client/LimitsAndFeatures.h index 4c4933f58eb..30344076464 100644 --- a/src/dawn/wire/client/LimitsAndFeatures.h +++ b/src/dawn/wire/client/LimitsAndFeatures.h @@ -41,7 +41,6 @@ class LimitsAndFeatures { WGPUStatus GetLimits(WGPUSupportedLimits* limits) const; bool HasFeature(WGPUFeatureName feature) const; - size_t EnumerateFeatures(WGPUFeatureName* features) const; void ToSupportedFeatures(WGPUSupportedFeatures* supportedFeatures) const; void SetLimits(const WGPUSupportedLimits* limits); diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js index e406c1833ba..83907097e49 100644 --- a/third_party/emdawnwebgpu/library_webgpu.js +++ b/third_party/emdawnwebgpu/library_webgpu.js @@ -2484,7 +2484,7 @@ var LibraryWebGPU = { // -------------------------------------------------------------------------- }; -// Inverted index used by EnumerateFeatures/HasFeature +// Inverted index used by GetFeatures/HasFeature LibraryWebGPU.$WebGPU.FeatureNameString2Enum = {}; for (var value in LibraryWebGPU.$WebGPU.FeatureName) { LibraryWebGPU.$WebGPU.FeatureNameString2Enum[LibraryWebGPU.$WebGPU.FeatureName[value]] = value;