Skip to content

Commit

Permalink
webgpu.h: Remove EnumerateFeatures()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Fr <[email protected]>
Reviewed-by: Corentin Wallez <[email protected]>
  • Loading branch information
beaufortfrancois authored and Dawn LUCI CQ committed Nov 19, 2024
1 parent 70eab84 commit 476693a
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 85 deletions.
16 changes: 0 additions & 16 deletions src/dawn/dawn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions src/dawn/dawn_wire.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@
"AdapterGetInstance",
"AdapterGetLimits",
"AdapterHasFeature",
"AdapterEnumerateFeatures",
"AdapterRequestDevice",
"AdapterRequestDeviceF",
"AdapterRequestDevice2",
Expand All @@ -248,7 +247,6 @@
"DeviceGetFeatures",
"DeviceGetLimits",
"DeviceHasFeature",
"DeviceEnumerateFeatures",
"DevicePopErrorScope",
"DevicePopErrorScopeF",
"DevicePopErrorScope2",
Expand Down
4 changes: 0 additions & 4 deletions src/dawn/native/Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportedFeatures*>(features));
}
Expand Down
1 change: 0 additions & 1 deletion src/dawn/native/Adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class AdapterBase : public RefCounted, public WeakRefSupport<AdapterBase> {
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,
Expand Down
4 changes: 0 additions & 4 deletions src/dawn/native/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportedFeatures*>(features));
}
Expand Down
1 change: 0 additions & 1 deletion src/dawn/native/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class DeviceBase : public ErrorSink, public RefCountedWithExternalCount<RefCount
AHardwareBufferProperties* properties);
wgpu::Status APIGetLimits(SupportedLimits* limits) const;
bool APIHasFeature(wgpu::FeatureName feature) const;
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
void APIGetFeatures(wgpu::SupportedFeatures* features) const;
void APIGetFeatures(SupportedFeatures* features) const;
wgpu::Status APIGetAdapterInfo(AdapterInfo* adapterInfo) const;
Expand Down
11 changes: 0 additions & 11 deletions src/dawn/native/Features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,6 @@ bool FeaturesSet::IsEnabled(wgpu::FeatureName feature) const {
return f != Feature::InvalidEnum && IsEnabled(f);
}

size_t FeaturesSet::EnumerateFeatures(wgpu::FeatureName* features) const {
for (Feature f : IterateBitSet(featuresBitSet)) {
wgpu::FeatureName feature = ToAPI(f);
if (features != nullptr) {
*features = feature;
features += 1;
}
}
return featuresBitSet.count();
}

std::vector<const char*> FeaturesSet::GetEnabledFeatureNames() const {
std::vector<const char*> enabledFeatureNames(featuresBitSet.count());

Expand Down
3 changes: 0 additions & 3 deletions src/dawn/native/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*> GetEnabledFeatureNames() const;
void ToSupportedFeatures(SupportedFeatures* supportedFeatures) const;
};
Expand Down
21 changes: 3 additions & 18 deletions src/dawn/tests/unittests/native/DeviceCreationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -189,31 +184,21 @@ 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.
{
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]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,11 @@ class ShaderModuleExtensionValidationTestBase : public ValidationTest {

std::vector<wgpu::FeatureName> GetAllFeatures() {
std::vector<wgpu::FeatureName> 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;
}
};
Expand Down
4 changes: 0 additions & 4 deletions src/dawn/wire/client/Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/dawn/wire/client/Adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/dawn/wire/client/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/dawn/wire/client/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class Device final : public RefCountedWithExternalCount<ObjectWithEventsBase> {

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;
Expand Down
10 changes: 0 additions & 10 deletions src/dawn/wire/client/LimitsAndFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/dawn/wire/client/LimitsAndFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion third_party/emdawnwebgpu/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 476693a

Please sign in to comment.