-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes it much easier to add new features. A few minor changes: - names are changed from hyphen-case to snake_case - make the features set a typed bitset Change-Id: Ia5fff4c96421878952d676c56ab42c8719b27478 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/147820 Reviewed-by: Loko Kung <[email protected]> Auto-Submit: Austin Eng <[email protected]> Kokoro: Kokoro <[email protected]> Commit-Queue: Austin Eng <[email protected]>
- Loading branch information
Showing
24 changed files
with
262 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Dawn Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
{% set namespace_name = Name(metadata.native_namespace) %} | ||
{% set DIR = namespace_name.concatcase().upper() %} | ||
#ifndef {{DIR}}_FEATURES_AUTOGEN_H_ | ||
#define {{DIR}}_FEATURES_AUTOGEN_H_ | ||
|
||
#include "dawn/native/dawn_platform.h" | ||
#include "dawn/native/DawnNative.h" | ||
#include "dawn/common/ityp_array.h" | ||
|
||
namespace dawn::native { | ||
|
||
enum class Feature { | ||
{% for enum in types["feature name"].values if enum.valid %} | ||
{{as_cppEnum(enum.name)}}, | ||
{% endfor %} | ||
InvalidEnum, | ||
}; | ||
|
||
template<> | ||
struct EnumCount<Feature> { | ||
{% set counter = namespace(value = 0) %} | ||
{% for enum in types["feature name"].values if enum.valid -%} | ||
{% set counter.value = counter.value + 1 %} | ||
{% endfor %} | ||
static constexpr uint32_t value = {{counter.value}}; | ||
}; | ||
|
||
} // namespace dawn::native | ||
|
||
#endif // {{DIR}}_FEATURES_AUTOGEN_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2023 The Dawn Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace dawn::native { | ||
|
||
wgpu::FeatureName ToAPI(Feature feature) { | ||
switch (feature) { | ||
{% for enum in types["feature name"].values if enum.valid %} | ||
case Feature::{{as_cppEnum(enum.name)}}: | ||
return wgpu::FeatureName::{{as_cppEnum(enum.name)}}; | ||
{% endfor %} | ||
case Feature::InvalidEnum: | ||
UNREACHABLE(); | ||
} | ||
} | ||
|
||
Feature FromAPI(wgpu::FeatureName feature) { | ||
switch (feature) { | ||
{% for enum in types["feature name"].values %} | ||
case wgpu::FeatureName::{{as_cppEnum(enum.name)}}: | ||
{% if enum.valid %} | ||
return Feature::{{as_cppEnum(enum.name)}}; | ||
{% else %} | ||
return Feature::InvalidEnum; | ||
{% endif %} | ||
{% endfor %} | ||
default: | ||
return Feature::InvalidEnum; | ||
} | ||
} | ||
|
||
static constexpr bool FeatureInfoIsDefined(Feature feature) { | ||
for (const auto& info : kFeatureInfo) { | ||
if (info.feature == feature) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
static constexpr ityp::array<Feature, FeatureInfo, kEnumCount<Feature>> InitializeFeatureEnumAndInfoList() { | ||
constexpr size_t kInfoCount = sizeof(kFeatureInfo) / sizeof(kFeatureInfo[0]); | ||
ityp::array<Feature, FeatureInfo, kEnumCount<Feature>> list{}; | ||
{% for enum in types["feature name"].values if enum.valid %} | ||
{ | ||
static_assert(FeatureInfoIsDefined(Feature::{{as_cppEnum(enum.name)}}), | ||
"Please define feature info for {{as_cppEnum(enum.name)}} in Features.cpp"); | ||
for (size_t i = 0; i < kInfoCount; ++i) { | ||
if (kFeatureInfo[i].feature == Feature::{{as_cppEnum(enum.name)}}) { | ||
list[Feature::{{as_cppEnum(enum.name)}}] = { | ||
"{{enum.name.snake_case()}}", | ||
kFeatureInfo[i].info.description, | ||
kFeatureInfo[i].info.url, | ||
kFeatureInfo[i].info.featureState, | ||
}; | ||
} | ||
} | ||
} | ||
{% endfor %} | ||
return list; | ||
} | ||
|
||
const ityp::array<Feature, FeatureInfo, kEnumCount<Feature>> kFeatureNameAndInfoList = InitializeFeatureEnumAndInfoList(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.