Rename "extension" to "feature"

This CL renames "extension" to "feature" to follow WebGPU. It still
supports both. A future Chromium CL will pick this change, then all
"extension" occurrences will be removed.

Change-Id: I070e32d7ae042f9b846df01f200b39f6741a0a14
Bug: dawn:1149
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65664
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
This commit is contained in:
François Beaufort 2021-10-04 11:30:02 +00:00 committed by Dawn LUCI CQ
parent bf8c40b4f1
commit 3f689a4c5a
61 changed files with 565 additions and 547 deletions

View File

@ -1021,6 +1021,7 @@
"category": "structure", "category": "structure",
"extensible": false, "extensible": false,
"tags": ["dawn"], "tags": ["dawn"],
"_comment": "TODO(dawn:1149): remove 'invalid extension' once it's no longer used.",
"members": [ "members": [
{"name": "device ID", "type": "uint32_t"}, {"name": "device ID", "type": "uint32_t"},
{"name": "vendor ID", "type": "uint32_t"}, {"name": "vendor ID", "type": "uint32_t"},
@ -1033,6 +1034,7 @@
{"name": "multi planar formats", "type": "bool", "default": "false"}, {"name": "multi planar formats", "type": "bool", "default": "false"},
{"name": "depth clamping", "type": "bool", "default": "false"}, {"name": "depth clamping", "type": "bool", "default": "false"},
{"name": "invalid extension", "type": "bool", "default": "false"}, {"name": "invalid extension", "type": "bool", "default": "false"},
{"name": "invalid feature", "type": "bool", "default": "false"},
{"name": "dawn internal usages", "type": "bool", "default": "false"}, {"name": "dawn internal usages", "type": "bool", "default": "false"},
{"name": "limits", "type": "supported limits"} {"name": "limits", "type": "supported limits"}
] ]

View File

@ -94,7 +94,7 @@ This is also useful to be able to compare objects by pointers like `BindGroupLay
### Format Tables ### Format Tables
The frontend has a `Format` structure that represent all the information that are known about a particular WebGPU format for this Device based on the enabled extensions. The frontend has a `Format` structure that represent all the information that are known about a particular WebGPU format for this Device based on the enabled features.
Formats are precomputed at device initialization and can be queried from a WebGPU format either assuming the format is a valid enum, or in a safe manner that doesn't do this assumption. Formats are precomputed at device initialization and can be queried from a WebGPU format either assuming the format is a valid enum, or in a safe manner that doesn't do this assumption.
A reference to these formats can be stored persistently as they have the same lifetime as the `Device`. A reference to these formats can be stored persistently as they have the same lifetime as the `Device`.

View File

@ -1,6 +1,6 @@
# Dawn Internal Usages # Dawn Internal Usages
The `dawn-internal-usages` extension allows adding additional usage which affects how a texture is allocated, but does not affect frontend validation. The `dawn-internal-usages` feature allows adding additional usage which affects how a texture is allocated, but does not affect frontend validation.
One use case for this is so that Chromium can use an internal copyTextureToTexture command to implement copies from a WebGPU texture-backed canvas to other Web platform primitives when the swapchain texture was not explicitly created with CopySrc usage in Javascript. One use case for this is so that Chromium can use an internal copyTextureToTexture command to implement copies from a WebGPU texture-backed canvas to other Web platform primitives when the swapchain texture was not explicitly created with CopySrc usage in Javascript.

View File

@ -21,7 +21,7 @@ namespace dawn_native {
AdapterBase::AdapterBase(InstanceBase* instance, wgpu::BackendType backend) AdapterBase::AdapterBase(InstanceBase* instance, wgpu::BackendType backend)
: mInstance(instance), mBackend(backend) { : mInstance(instance), mBackend(backend) {
GetDefaultLimits(&mLimits.v1); GetDefaultLimits(&mLimits.v1);
mSupportedExtensions.EnableExtension(Extension::DawnInternalUsages); mSupportedFeatures.EnableFeature(Feature::DawnInternalUsages);
} }
wgpu::BackendType AdapterBase::GetBackendType() const { wgpu::BackendType AdapterBase::GetBackendType() const {
@ -44,18 +44,18 @@ namespace dawn_native {
return mInstance; return mInstance;
} }
ExtensionsSet AdapterBase::GetSupportedExtensions() const { FeaturesSet AdapterBase::GetSupportedFeatures() const {
return mSupportedExtensions; return mSupportedFeatures;
} }
bool AdapterBase::SupportsAllRequestedExtensions( bool AdapterBase::SupportsAllRequestedFeatures(
const std::vector<const char*>& requestedExtensions) const { const std::vector<const char*>& requestedFeatures) const {
for (const char* extensionStr : requestedExtensions) { for (const char* featureStr : requestedFeatures) {
Extension extensionEnum = mInstance->ExtensionNameToEnum(extensionStr); Feature featureEnum = mInstance->FeatureNameToEnum(featureStr);
if (extensionEnum == Extension::InvalidEnum) { if (featureEnum == Feature::InvalidEnum) {
return false; return false;
} }
if (!mSupportedExtensions.IsEnabled(extensionEnum)) { if (!mSupportedFeatures.IsEnabled(featureEnum)) {
return false; return false;
} }
} }
@ -67,8 +67,8 @@ namespace dawn_native {
adapterProperties.deviceID = mPCIInfo.deviceId; adapterProperties.deviceID = mPCIInfo.deviceId;
adapterProperties.vendorID = mPCIInfo.vendorId; adapterProperties.vendorID = mPCIInfo.vendorId;
mSupportedExtensions.InitializeDeviceProperties(&adapterProperties); mSupportedFeatures.InitializeDeviceProperties(&adapterProperties);
// This is OK for now because there are no limit extension structs. // This is OK for now because there are no limit feature structs.
// If we add additional structs, the caller will need to provide memory // If we add additional structs, the caller will need to provide memory
// to store them (ex. by calling GetLimits directly instead). Currently, // to store them (ex. by calling GetLimits directly instead). Currently,
// we keep this function as it's only used internally in Chromium to // we keep this function as it's only used internally in Chromium to
@ -121,13 +121,21 @@ namespace dawn_native {
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result, MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
const DeviceDescriptor* descriptor) { const DeviceDescriptor* descriptor) {
if (descriptor != nullptr) { if (descriptor != nullptr) {
// TODO(dawn:1149): remove once requiredExtensions is no longer used.
for (const char* extensionStr : descriptor->requiredExtensions) { for (const char* extensionStr : descriptor->requiredExtensions) {
Extension extensionEnum = mInstance->ExtensionNameToEnum(extensionStr); Feature extensionEnum = mInstance->FeatureNameToEnum(extensionStr);
DAWN_INVALID_IF(extensionEnum == Extension::InvalidEnum, DAWN_INVALID_IF(extensionEnum == Feature::InvalidEnum,
"Requested feature %s is unknown.", extensionStr); "Requested feature %s is unknown.", extensionStr);
DAWN_INVALID_IF(!mSupportedExtensions.IsEnabled(extensionEnum), DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(extensionEnum),
"Requested feature %s is disabled.", extensionStr); "Requested feature %s is disabled.", extensionStr);
} }
for (const char* featureStr : descriptor->requiredFeatures) {
Feature featureEnum = mInstance->FeatureNameToEnum(featureStr);
DAWN_INVALID_IF(featureEnum == Feature::InvalidEnum,
"Requested feature %s is unknown.", featureStr);
DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(featureEnum),
"Requested feature %s is disabled.", featureStr);
}
} }
if (descriptor != nullptr && descriptor->requiredLimits != nullptr) { if (descriptor != nullptr && descriptor->requiredLimits != nullptr) {

View File

@ -18,7 +18,7 @@
#include "dawn_native/DawnNative.h" #include "dawn_native/DawnNative.h"
#include "dawn_native/Error.h" #include "dawn_native/Error.h"
#include "dawn_native/Extensions.h" #include "dawn_native/Features.h"
#include "dawn_native/Limits.h" #include "dawn_native/Limits.h"
#include "dawn_native/dawn_platform.h" #include "dawn_native/dawn_platform.h"
@ -47,9 +47,8 @@ namespace dawn_native {
void ResetInternalDeviceForTesting(); void ResetInternalDeviceForTesting();
ExtensionsSet GetSupportedExtensions() const; FeaturesSet GetSupportedFeatures() const;
bool SupportsAllRequestedExtensions( bool SupportsAllRequestedFeatures(const std::vector<const char*>& requestedFeatures) const;
const std::vector<const char*>& requestedExtensions) const;
WGPUDeviceProperties GetAdapterProperties() const; WGPUDeviceProperties GetAdapterProperties() const;
bool GetLimits(SupportedLimits* limits) const; bool GetLimits(SupportedLimits* limits) const;
@ -62,7 +61,7 @@ namespace dawn_native {
PCIInfo mPCIInfo = {}; PCIInfo mPCIInfo = {};
wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown; wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown;
std::string mDriverDescription; std::string mDriverDescription;
ExtensionsSet mSupportedExtensions; FeaturesSet mSupportedFeatures;
private: private:
virtual ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) = 0; virtual ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) = 0;

View File

@ -248,10 +248,10 @@ source_set("dawn_native_sources") {
"ErrorInjector.h", "ErrorInjector.h",
"ErrorScope.cpp", "ErrorScope.cpp",
"ErrorScope.h", "ErrorScope.h",
"Extensions.cpp",
"Extensions.h",
"ExternalTexture.cpp", "ExternalTexture.cpp",
"ExternalTexture.h", "ExternalTexture.h",
"Features.cpp",
"Features.h",
"Format.cpp", "Format.cpp",
"Format.h", "Format.h",
"Forward.h", "Forward.h",

View File

@ -94,8 +94,8 @@ target_sources(dawn_native PRIVATE
"ErrorInjector.h" "ErrorInjector.h"
"ErrorScope.cpp" "ErrorScope.cpp"
"ErrorScope.h" "ErrorScope.h"
"Extensions.cpp" "Features.cpp"
"Extensions.h" "Features.h"
"ExternalTexture.cpp" "ExternalTexture.cpp"
"ExternalTexture.h" "ExternalTexture.h"
"IndirectDrawMetadata.cpp" "IndirectDrawMetadata.cpp"

View File

@ -100,9 +100,14 @@ namespace dawn_native {
return mImpl->GetPCIInfo(); return mImpl->GetPCIInfo();
} }
// TODO(dawn:1149): remove once GetSupportedExtensions() is no longer used.
std::vector<const char*> Adapter::GetSupportedExtensions() const { std::vector<const char*> Adapter::GetSupportedExtensions() const {
ExtensionsSet supportedExtensionsSet = mImpl->GetSupportedExtensions(); return GetSupportedFeatures();
return supportedExtensionsSet.GetEnabledExtensionNames(); }
std::vector<const char*> Adapter::GetSupportedFeatures() const {
FeaturesSet supportedFeaturesSet = mImpl->GetSupportedFeatures();
return supportedFeaturesSet.GetEnabledFeatureNames();
} }
WGPUDeviceProperties Adapter::GetAdapterProperties() const { WGPUDeviceProperties Adapter::GetAdapterProperties() const {

View File

@ -176,7 +176,7 @@ namespace dawn_native {
: mInstance(adapter->GetInstance()), mAdapter(adapter), mNextPipelineCompatibilityToken(1) { : mInstance(adapter->GetInstance()), mAdapter(adapter), mNextPipelineCompatibilityToken(1) {
if (descriptor != nullptr) { if (descriptor != nullptr) {
ApplyToggleOverrides(descriptor); ApplyToggleOverrides(descriptor);
ApplyExtensions(descriptor); ApplyFeatures(descriptor);
} }
if (descriptor != nullptr && descriptor->requiredLimits != nullptr) { if (descriptor != nullptr && descriptor->requiredLimits != nullptr) {
@ -1049,20 +1049,26 @@ namespace dawn_native {
return result.Detach(); return result.Detach();
} }
void DeviceBase::ApplyExtensions(const DeviceDescriptor* deviceDescriptor) { void DeviceBase::ApplyFeatures(const DeviceDescriptor* deviceDescriptor) {
ASSERT(deviceDescriptor); ASSERT(deviceDescriptor);
ASSERT(GetAdapter()->SupportsAllRequestedExtensions(deviceDescriptor->requiredExtensions)); // TODO(dawn:1149): remove once requiredExtensions is no longer used.
ASSERT(GetAdapter()->SupportsAllRequestedFeatures(deviceDescriptor->requiredExtensions));
ASSERT(GetAdapter()->SupportsAllRequestedFeatures(deviceDescriptor->requiredFeatures));
mEnabledExtensions = GetAdapter()->GetInstance()->ExtensionNamesToExtensionsSet( // TODO(dawn:1149): remove once requiredExtensions is no longer used.
mEnabledExtensions = GetAdapter()->GetInstance()->FeatureNamesToFeaturesSet(
deviceDescriptor->requiredExtensions); deviceDescriptor->requiredExtensions);
mEnabledFeatures = GetAdapter()->GetInstance()->FeatureNamesToFeaturesSet(
deviceDescriptor->requiredFeatures);
} }
std::vector<const char*> DeviceBase::GetEnabledExtensions() const { std::vector<const char*> DeviceBase::GetEnabledFeatures() const {
return mEnabledExtensions.GetEnabledExtensionNames(); return mEnabledFeatures.GetEnabledFeatureNames();
} }
bool DeviceBase::IsExtensionEnabled(Extension extension) const { bool DeviceBase::IsFeatureEnabled(Feature feature) const {
return mEnabledExtensions.IsEnabled(extension); // TODO(dawn:1149): remove mEnabledExtensions once it is no longer used.
return mEnabledFeatures.IsEnabled(feature) || mEnabledExtensions.IsEnabled(feature);
} }
bool DeviceBase::IsValidationEnabled() const { bool DeviceBase::IsValidationEnabled() const {

View File

@ -17,7 +17,7 @@
#include "dawn_native/Commands.h" #include "dawn_native/Commands.h"
#include "dawn_native/Error.h" #include "dawn_native/Error.h"
#include "dawn_native/Extensions.h" #include "dawn_native/Features.h"
#include "dawn_native/Format.h" #include "dawn_native/Format.h"
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/Limits.h" #include "dawn_native/Limits.h"
@ -300,9 +300,9 @@ namespace dawn_native {
bool IsLost() const; bool IsLost() const;
std::mutex* GetObjectListMutex(ObjectType type); std::mutex* GetObjectListMutex(ObjectType type);
std::vector<const char*> GetEnabledExtensions() const; std::vector<const char*> GetEnabledFeatures() const;
std::vector<const char*> GetTogglesUsed() const; std::vector<const char*> GetTogglesUsed() const;
bool IsExtensionEnabled(Extension extension) const; bool IsFeatureEnabled(Feature feature) const;
bool IsToggleEnabled(Toggle toggle) const; bool IsToggleEnabled(Toggle toggle) const;
bool IsValidationEnabled() const; bool IsValidationEnabled() const;
bool IsRobustnessEnabled() const; bool IsRobustnessEnabled() const;
@ -423,7 +423,7 @@ namespace dawn_native {
void* userdata); void* userdata);
void ApplyToggleOverrides(const DeviceDescriptor* deviceDescriptor); void ApplyToggleOverrides(const DeviceDescriptor* deviceDescriptor);
void ApplyExtensions(const DeviceDescriptor* deviceDescriptor); void ApplyFeatures(const DeviceDescriptor* deviceDescriptor);
void SetDefaultToggles(); void SetDefaultToggles();
@ -510,7 +510,8 @@ namespace dawn_native {
std::atomic_uint64_t mNextPipelineCompatibilityToken; std::atomic_uint64_t mNextPipelineCompatibilityToken;
CombinedLimits mLimits; CombinedLimits mLimits;
ExtensionsSet mEnabledExtensions; FeaturesSet mEnabledExtensions;
FeaturesSet mEnabledFeatures;
std::unique_ptr<InternalPipelineStore> mInternalPipelineStore; std::unique_ptr<InternalPipelineStore> mInternalPipelineStore;

View File

@ -1,164 +0,0 @@
// Copyright 2019 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.
#include <array>
#include "common/Assert.h"
#include "common/BitSetIterator.h"
#include "dawn_native/Extensions.h"
namespace dawn_native {
namespace {
struct ExtensionEnumAndInfo {
Extension extension;
ExtensionInfo info;
bool WGPUDeviceProperties::*memberInWGPUDeviceProperties;
};
using ExtensionEnumAndInfoList =
std::array<ExtensionEnumAndInfo, static_cast<size_t>(Extension::EnumCount)>;
static constexpr ExtensionEnumAndInfoList kExtensionNameAndInfoList = {
{{Extension::TextureCompressionBC,
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
&WGPUDeviceProperties::textureCompressionBC},
{Extension::TextureCompressionETC2,
{"texture-compression-etc2",
"Support Ericsson Texture Compressed (ETC2/EAC) texture "
"formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
&WGPUDeviceProperties::textureCompressionETC2},
{Extension::TextureCompressionASTC,
{"texture-compression-astc",
"Support Adaptable Scalable Texture Compressed (ASTC) "
"texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
&WGPUDeviceProperties::textureCompressionASTC},
{Extension::ShaderFloat16,
{"shader_float16",
"Support 16bit float arithmetic and declarations in uniform and storage buffers",
"https://bugs.chromium.org/p/dawn/issues/detail?id=426"},
&WGPUDeviceProperties::shaderFloat16},
{Extension::PipelineStatisticsQuery,
{"pipeline_statistics_query", "Support Pipeline Statistics Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"},
&WGPUDeviceProperties::pipelineStatisticsQuery},
{Extension::TimestampQuery,
{"timestamp_query", "Support Timestamp Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"},
&WGPUDeviceProperties::timestampQuery},
{Extension::MultiPlanarFormats,
{"multiplanar_formats",
"Import and use multi-planar texture formats with per plane views",
"https://bugs.chromium.org/p/dawn/issues/detail?id=551"},
&WGPUDeviceProperties::multiPlanarFormats},
{Extension::DepthClamping,
{"depth_clamping", "Clamp depth to [0, 1] in NDC space instead of clipping",
"https://bugs.chromium.org/p/dawn/issues/detail?id=716"},
&WGPUDeviceProperties::depthClamping},
{Extension::DawnInternalUsages,
{"dawn-internal-usages",
"Add internal usages to resources to affect how the texture is allocated, but not "
"frontend validation. Other internal commands may access this usage.",
"https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/extensions/"
"dawn_internal_usages.md"},
&WGPUDeviceProperties::dawnInternalUsages}}};
} // anonymous namespace
void ExtensionsSet::EnableExtension(Extension extension) {
ASSERT(extension != Extension::InvalidEnum);
const size_t extensionIndex = static_cast<size_t>(extension);
extensionsBitSet.set(extensionIndex);
}
bool ExtensionsSet::IsEnabled(Extension extension) const {
ASSERT(extension != Extension::InvalidEnum);
const size_t extensionIndex = static_cast<size_t>(extension);
return extensionsBitSet[extensionIndex];
}
std::vector<const char*> ExtensionsSet::GetEnabledExtensionNames() const {
std::vector<const char*> enabledExtensionNames(extensionsBitSet.count());
uint32_t index = 0;
for (uint32_t i : IterateBitSet(extensionsBitSet)) {
const char* extensionName = ExtensionEnumToName(static_cast<Extension>(i));
enabledExtensionNames[index] = extensionName;
++index;
}
return enabledExtensionNames;
}
void ExtensionsSet::InitializeDeviceProperties(WGPUDeviceProperties* properties) const {
ASSERT(properties != nullptr);
for (uint32_t i : IterateBitSet(extensionsBitSet)) {
properties->*(kExtensionNameAndInfoList[i].memberInWGPUDeviceProperties) = true;
}
}
const char* ExtensionEnumToName(Extension extension) {
ASSERT(extension != Extension::InvalidEnum);
const ExtensionEnumAndInfo& extensionNameAndInfo =
kExtensionNameAndInfoList[static_cast<size_t>(extension)];
ASSERT(extensionNameAndInfo.extension == extension);
return extensionNameAndInfo.info.name;
}
ExtensionsInfo::ExtensionsInfo() {
for (size_t index = 0; index < kExtensionNameAndInfoList.size(); ++index) {
const ExtensionEnumAndInfo& extensionNameAndInfo = kExtensionNameAndInfoList[index];
ASSERT(index == static_cast<size_t>(extensionNameAndInfo.extension));
mExtensionNameToEnumMap[extensionNameAndInfo.info.name] =
extensionNameAndInfo.extension;
}
}
const ExtensionInfo* ExtensionsInfo::GetExtensionInfo(const char* extensionName) const {
ASSERT(extensionName);
const auto& iter = mExtensionNameToEnumMap.find(extensionName);
if (iter != mExtensionNameToEnumMap.cend()) {
return &kExtensionNameAndInfoList[static_cast<size_t>(iter->second)].info;
}
return nullptr;
}
Extension ExtensionsInfo::ExtensionNameToEnum(const char* extensionName) const {
ASSERT(extensionName);
const auto& iter = mExtensionNameToEnumMap.find(extensionName);
if (iter != mExtensionNameToEnumMap.cend()) {
return kExtensionNameAndInfoList[static_cast<size_t>(iter->second)].extension;
}
return Extension::InvalidEnum;
}
ExtensionsSet ExtensionsInfo::ExtensionNamesToExtensionsSet(
const std::vector<const char*>& requiredExtensions) const {
ExtensionsSet extensionsSet;
for (const char* extensionName : requiredExtensions) {
Extension extensionEnum = ExtensionNameToEnum(extensionName);
ASSERT(extensionEnum != Extension::InvalidEnum);
extensionsSet.EnableExtension(extensionEnum);
}
return extensionsSet;
}
} // namespace dawn_native

View File

@ -1,74 +0,0 @@
// Copyright 2019 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.
#ifndef DAWNNATIVE_EXTENSIONS_H_
#define DAWNNATIVE_EXTENSIONS_H_
#include <bitset>
#include <unordered_map>
#include <vector>
#include "dawn_native/DawnNative.h"
namespace dawn_native {
enum class Extension {
TextureCompressionBC,
TextureCompressionETC2,
TextureCompressionASTC,
ShaderFloat16,
PipelineStatisticsQuery,
TimestampQuery,
MultiPlanarFormats,
DepthClamping,
// Dawn-specific
DawnInternalUsages,
EnumCount,
InvalidEnum = EnumCount,
ExtensionMin = TextureCompressionBC,
};
// A wrapper of the bitset to store if an extension is enabled or not. This wrapper provides the
// convenience to convert the enums of enum class Extension to the indices of a bitset.
struct ExtensionsSet {
std::bitset<static_cast<size_t>(Extension::EnumCount)> extensionsBitSet;
void EnableExtension(Extension extension);
bool IsEnabled(Extension extension) const;
std::vector<const char*> GetEnabledExtensionNames() const;
void InitializeDeviceProperties(WGPUDeviceProperties* properties) const;
};
const char* ExtensionEnumToName(Extension extension);
class ExtensionsInfo {
public:
ExtensionsInfo();
// Used to query the details of an extension. Return nullptr if extensionName is not a valid
// name of an extension supported in Dawn
const ExtensionInfo* GetExtensionInfo(const char* extensionName) const;
Extension ExtensionNameToEnum(const char* extensionName) const;
ExtensionsSet ExtensionNamesToExtensionsSet(
const std::vector<const char*>& requiredExtensions) const;
private:
std::unordered_map<std::string, Extension> mExtensionNameToEnumMap;
};
} // namespace dawn_native
#endif // DAWNNATIVE_EXTENSIONS_H_

View File

@ -0,0 +1,163 @@
// Copyright 2019 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.
#include <array>
#include "common/Assert.h"
#include "common/BitSetIterator.h"
#include "dawn_native/Features.h"
namespace dawn_native {
namespace {
struct FeatureEnumAndInfo {
Feature feature;
FeatureInfo info;
bool WGPUDeviceProperties::*memberInWGPUDeviceProperties;
};
using FeatureEnumAndInfoList =
std::array<FeatureEnumAndInfo, static_cast<size_t>(Feature::EnumCount)>;
static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {
{{Feature::TextureCompressionBC,
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
&WGPUDeviceProperties::textureCompressionBC},
{Feature::TextureCompressionETC2,
{"texture-compression-etc2",
"Support Ericsson Texture Compressed (ETC2/EAC) texture "
"formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
&WGPUDeviceProperties::textureCompressionETC2},
{Feature::TextureCompressionASTC,
{"texture-compression-astc",
"Support Adaptable Scalable Texture Compressed (ASTC) "
"texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
&WGPUDeviceProperties::textureCompressionASTC},
{Feature::ShaderFloat16,
{"shader_float16",
"Support 16bit float arithmetic and declarations in uniform and storage buffers",
"https://bugs.chromium.org/p/dawn/issues/detail?id=426"},
&WGPUDeviceProperties::shaderFloat16},
{Feature::PipelineStatisticsQuery,
{"pipeline_statistics_query", "Support Pipeline Statistics Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"},
&WGPUDeviceProperties::pipelineStatisticsQuery},
{Feature::TimestampQuery,
{"timestamp_query", "Support Timestamp Query",
"https://bugs.chromium.org/p/dawn/issues/detail?id=434"},
&WGPUDeviceProperties::timestampQuery},
{Feature::DepthClamping,
{"depth_clamping", "Clamp depth to [0, 1] in NDC space instead of clipping",
"https://bugs.chromium.org/p/dawn/issues/detail?id=716"},
&WGPUDeviceProperties::depthClamping},
{Feature::DawnInternalUsages,
{"dawn-internal-usages",
"Add internal usages to resources to affect how the texture is allocated, but not "
"frontend validation. Other internal commands may access this usage.",
"https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/features/"
"dawn_internal_usages.md"},
&WGPUDeviceProperties::dawnInternalUsages},
{Feature::MultiPlanarFormats,
{"multiplanar_formats",
"Import and use multi-planar texture formats with per plane views",
"https://bugs.chromium.org/p/dawn/issues/detail?id=551"},
&WGPUDeviceProperties::multiPlanarFormats}}};
} // anonymous namespace
void FeaturesSet::EnableFeature(Feature feature) {
ASSERT(feature != Feature::InvalidEnum);
const size_t featureIndex = static_cast<size_t>(feature);
featuresBitSet.set(featureIndex);
}
bool FeaturesSet::IsEnabled(Feature feature) const {
ASSERT(feature != Feature::InvalidEnum);
const size_t featureIndex = static_cast<size_t>(feature);
return featuresBitSet[featureIndex];
}
std::vector<const char*> FeaturesSet::GetEnabledFeatureNames() const {
std::vector<const char*> enabledFeatureNames(featuresBitSet.count());
uint32_t index = 0;
for (uint32_t i : IterateBitSet(featuresBitSet)) {
const char* featureName = FeatureEnumToName(static_cast<Feature>(i));
enabledFeatureNames[index] = featureName;
++index;
}
return enabledFeatureNames;
}
void FeaturesSet::InitializeDeviceProperties(WGPUDeviceProperties* properties) const {
ASSERT(properties != nullptr);
for (uint32_t i : IterateBitSet(featuresBitSet)) {
properties->*(kFeatureNameAndInfoList[i].memberInWGPUDeviceProperties) = true;
}
}
const char* FeatureEnumToName(Feature feature) {
ASSERT(feature != Feature::InvalidEnum);
const FeatureEnumAndInfo& featureNameAndInfo =
kFeatureNameAndInfoList[static_cast<size_t>(feature)];
ASSERT(featureNameAndInfo.feature == feature);
return featureNameAndInfo.info.name;
}
FeaturesInfo::FeaturesInfo() {
for (size_t index = 0; index < kFeatureNameAndInfoList.size(); ++index) {
const FeatureEnumAndInfo& featureNameAndInfo = kFeatureNameAndInfoList[index];
ASSERT(index == static_cast<size_t>(featureNameAndInfo.feature));
mFeatureNameToEnumMap[featureNameAndInfo.info.name] = featureNameAndInfo.feature;
}
}
const FeatureInfo* FeaturesInfo::GetFeatureInfo(const char* featureName) const {
ASSERT(featureName);
const auto& iter = mFeatureNameToEnumMap.find(featureName);
if (iter != mFeatureNameToEnumMap.cend()) {
return &kFeatureNameAndInfoList[static_cast<size_t>(iter->second)].info;
}
return nullptr;
}
Feature FeaturesInfo::FeatureNameToEnum(const char* featureName) const {
ASSERT(featureName);
const auto& iter = mFeatureNameToEnumMap.find(featureName);
if (iter != mFeatureNameToEnumMap.cend()) {
return kFeatureNameAndInfoList[static_cast<size_t>(iter->second)].feature;
}
return Feature::InvalidEnum;
}
FeaturesSet FeaturesInfo::FeatureNamesToFeaturesSet(
const std::vector<const char*>& requiredFeatures) const {
FeaturesSet featuresSet;
for (const char* featureName : requiredFeatures) {
Feature featureEnum = FeatureNameToEnum(featureName);
ASSERT(featureEnum != Feature::InvalidEnum);
featuresSet.EnableFeature(featureEnum);
}
return featuresSet;
}
} // namespace dawn_native

View File

@ -0,0 +1,74 @@
// Copyright 2019 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.
#ifndef DAWNNATIVE_FEATURES_H_
#define DAWNNATIVE_FEATURES_H_
#include <bitset>
#include <unordered_map>
#include <vector>
#include "dawn_native/DawnNative.h"
namespace dawn_native {
enum class Feature {
TextureCompressionBC,
TextureCompressionETC2,
TextureCompressionASTC,
ShaderFloat16,
PipelineStatisticsQuery,
TimestampQuery,
DepthClamping,
// Dawn-specific
DawnInternalUsages,
MultiPlanarFormats,
EnumCount,
InvalidEnum = EnumCount,
FeatureMin = TextureCompressionBC,
};
// A wrapper of the bitset to store if an feature is enabled or not. This wrapper provides the
// convenience to convert the enums of enum class Feature to the indices of a bitset.
struct FeaturesSet {
std::bitset<static_cast<size_t>(Feature::EnumCount)> featuresBitSet;
void EnableFeature(Feature feature);
bool IsEnabled(Feature feature) const;
std::vector<const char*> GetEnabledFeatureNames() const;
void InitializeDeviceProperties(WGPUDeviceProperties* properties) const;
};
const char* FeatureEnumToName(Feature feature);
class FeaturesInfo {
public:
FeaturesInfo();
// Used to query the details of an feature. Return nullptr if featureName is not a valid
// name of an feature supported in Dawn
const FeatureInfo* GetFeatureInfo(const char* featureName) const;
Feature FeatureNameToEnum(const char* featureName) const;
FeaturesSet FeatureNamesToFeaturesSet(
const std::vector<const char*>& requiredFeatures) const;
private:
std::unordered_map<std::string, Feature> mFeatureNameToEnumMap;
};
} // namespace dawn_native
#endif // DAWNNATIVE_FEATURES_H_

View File

@ -16,7 +16,7 @@
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
#include "dawn_native/EnumMaskIterator.h" #include "dawn_native/EnumMaskIterator.h"
#include "dawn_native/Extensions.h" #include "dawn_native/Features.h"
#include "dawn_native/Texture.h" #include "dawn_native/Texture.h"
#include <bitset> #include <bitset>
@ -122,7 +122,7 @@ namespace dawn_native {
// Implementation details of the format table of the DeviceBase // Implementation details of the format table of the DeviceBase
// For the enum for formats are packed but this might change when we have a broader extension // For the enum for formats are packed but this might change when we have a broader feature
// mechanism for webgpu.h. Formats start at 1 because 0 is the undefined format. // mechanism for webgpu.h. Formats start at 1 because 0 is the undefined format.
size_t ComputeFormatIndex(wgpu::TextureFormat format) { size_t ComputeFormatIndex(wgpu::TextureFormat format) {
// This takes advantage of overflows to make the index of TextureFormat::Undefined outside // This takes advantage of overflows to make the index of TextureFormat::Undefined outside
@ -340,7 +340,7 @@ namespace dawn_native {
// TODO(dawn:690): Implement Depth24UnormStencil8, Depth32FloatStencil8. // TODO(dawn:690): Implement Depth24UnormStencil8, Depth32FloatStencil8.
// BC compressed formats // BC compressed formats
bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC); bool isBCFormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionBC);
AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported, 4);
AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported, 4);
AddCompressedFormat(wgpu::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported, 1); AddCompressedFormat(wgpu::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported, 1);
@ -357,7 +357,7 @@ namespace dawn_native {
AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported, 4);
// ETC2/EAC compressed formats // ETC2/EAC compressed formats
bool isETC2FormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionETC2); bool isETC2FormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionETC2);
AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8Unorm, 8, 4, 4, isETC2FormatSupported, 3); AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8Unorm, 8, 4, 4, isETC2FormatSupported, 3);
AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8UnormSrgb, 8, 4, 4, isETC2FormatSupported, 3); AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8UnormSrgb, 8, 4, 4, isETC2FormatSupported, 3);
AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1Unorm, 8, 4, 4, isETC2FormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1Unorm, 8, 4, 4, isETC2FormatSupported, 4);
@ -370,7 +370,7 @@ namespace dawn_native {
AddCompressedFormat(wgpu::TextureFormat::EACRG11Snorm, 16, 4, 4, isETC2FormatSupported, 2); AddCompressedFormat(wgpu::TextureFormat::EACRG11Snorm, 16, 4, 4, isETC2FormatSupported, 2);
// ASTC compressed formats // ASTC compressed formats
bool isASTCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionASTC); bool isASTCFormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionASTC);
AddCompressedFormat(wgpu::TextureFormat::ASTC4x4Unorm, 16, 4, 4, isASTCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::ASTC4x4Unorm, 16, 4, 4, isASTCFormatSupported, 4);
AddCompressedFormat(wgpu::TextureFormat::ASTC4x4UnormSrgb, 16, 4, 4, isASTCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::ASTC4x4UnormSrgb, 16, 4, 4, isASTCFormatSupported, 4);
AddCompressedFormat(wgpu::TextureFormat::ASTC5x4Unorm, 16, 5, 4, isASTCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::ASTC5x4Unorm, 16, 5, 4, isASTCFormatSupported, 4);
@ -401,7 +401,7 @@ namespace dawn_native {
AddCompressedFormat(wgpu::TextureFormat::ASTC12x12UnormSrgb, 16, 12, 12, isASTCFormatSupported, 4); AddCompressedFormat(wgpu::TextureFormat::ASTC12x12UnormSrgb, 16, 12, 12, isASTCFormatSupported, 4);
// multi-planar formats // multi-planar formats
const bool isMultiPlanarFormatSupported = device->IsExtensionEnabled(Extension::MultiPlanarFormats); const bool isMultiPlanarFormatSupported = device->IsFeatureEnabled(Feature::MultiPlanarFormats);
AddMultiAspectFormat(wgpu::TextureFormat::R8BG8Biplanar420Unorm, Aspect::Plane0 | Aspect::Plane1, AddMultiAspectFormat(wgpu::TextureFormat::R8BG8Biplanar420Unorm, Aspect::Plane0 | Aspect::Plane1,
wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm, false, isMultiPlanarFormatSupported, 3); wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm, false, isMultiPlanarFormatSupported, 3);

View File

@ -105,17 +105,17 @@ namespace dawn_native {
return mTogglesInfo.ToggleNameToEnum(toggleName); return mTogglesInfo.ToggleNameToEnum(toggleName);
} }
const ExtensionInfo* InstanceBase::GetExtensionInfo(const char* extensionName) { const FeatureInfo* InstanceBase::GetFeatureInfo(const char* featureName) {
return mExtensionsInfo.GetExtensionInfo(extensionName); return mFeaturesInfo.GetFeatureInfo(featureName);
} }
Extension InstanceBase::ExtensionNameToEnum(const char* extensionName) { Feature InstanceBase::FeatureNameToEnum(const char* featureName) {
return mExtensionsInfo.ExtensionNameToEnum(extensionName); return mFeaturesInfo.FeatureNameToEnum(featureName);
} }
ExtensionsSet InstanceBase::ExtensionNamesToExtensionsSet( FeaturesSet InstanceBase::FeatureNamesToFeaturesSet(
const std::vector<const char*>& requiredExtensions) { const std::vector<const char*>& requiredFeatures) {
return mExtensionsInfo.ExtensionNamesToExtensionsSet(requiredExtensions); return mFeaturesInfo.FeatureNamesToFeaturesSet(requiredFeatures);
} }
const std::vector<std::unique_ptr<AdapterBase>>& InstanceBase::GetAdapters() const { const std::vector<std::unique_ptr<AdapterBase>>& InstanceBase::GetAdapters() const {

View File

@ -18,7 +18,7 @@
#include "common/RefCounted.h" #include "common/RefCounted.h"
#include "dawn_native/Adapter.h" #include "dawn_native/Adapter.h"
#include "dawn_native/BackendConnection.h" #include "dawn_native/BackendConnection.h"
#include "dawn_native/Extensions.h" #include "dawn_native/Features.h"
#include "dawn_native/Toggles.h" #include "dawn_native/Toggles.h"
#include "dawn_native/dawn_platform.h" #include "dawn_native/dawn_platform.h"
@ -55,12 +55,11 @@ namespace dawn_native {
const ToggleInfo* GetToggleInfo(const char* toggleName); const ToggleInfo* GetToggleInfo(const char* toggleName);
Toggle ToggleNameToEnum(const char* toggleName); Toggle ToggleNameToEnum(const char* toggleName);
// Used to query the details of an extension. Return nullptr if extensionName is not a valid // Used to query the details of an feature. Return nullptr if featureName is not a valid
// name of an extension supported in Dawn. // name of an feature supported in Dawn.
const ExtensionInfo* GetExtensionInfo(const char* extensionName); const FeatureInfo* GetFeatureInfo(const char* featureName);
Extension ExtensionNameToEnum(const char* extensionName); Feature FeatureNameToEnum(const char* featureName);
ExtensionsSet ExtensionNamesToExtensionsSet( FeaturesSet FeatureNamesToFeaturesSet(const std::vector<const char*>& requiredFeatures);
const std::vector<const char*>& requiredExtensions);
bool IsBackendValidationEnabled() const; bool IsBackendValidationEnabled() const;
void SetBackendValidationLevel(BackendValidationLevel level); void SetBackendValidationLevel(BackendValidationLevel level);
@ -104,7 +103,7 @@ namespace dawn_native {
std::vector<std::unique_ptr<BackendConnection>> mBackends; std::vector<std::unique_ptr<BackendConnection>> mBackends;
std::vector<std::unique_ptr<AdapterBase>> mAdapters; std::vector<std::unique_ptr<AdapterBase>> mAdapters;
ExtensionsInfo mExtensionsInfo; FeaturesInfo mFeaturesInfo;
TogglesInfo mTogglesInfo; TogglesInfo mTogglesInfo;
#if defined(DAWN_USE_X11) #if defined(DAWN_USE_X11)

View File

@ -15,7 +15,7 @@
#include "dawn_native/QuerySet.h" #include "dawn_native/QuerySet.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
#include "dawn_native/Extensions.h" #include "dawn_native/Features.h"
#include "dawn_native/ObjectType_autogen.h" #include "dawn_native/ObjectType_autogen.h"
#include "dawn_native/ValidationUtils_autogen.h" #include "dawn_native/ValidationUtils_autogen.h"
@ -63,8 +63,8 @@ namespace dawn_native {
"fully implemented"); "fully implemented");
DAWN_INVALID_IF( DAWN_INVALID_IF(
!device->IsExtensionEnabled(Extension::PipelineStatisticsQuery), !device->IsFeatureEnabled(Feature::PipelineStatisticsQuery),
"Pipeline statistics query set created without the extension being enabled."); "Pipeline statistics query set created without the feature being enabled.");
DAWN_INVALID_IF(descriptor->pipelineStatisticsCount == 0, DAWN_INVALID_IF(descriptor->pipelineStatisticsCount == 0,
"Pipeline statistics query set created with 0 statistics."); "Pipeline statistics query set created with 0 statistics.");
@ -85,8 +85,8 @@ namespace dawn_native {
"Timestamp queries are disallowed because they may expose precise " "Timestamp queries are disallowed because they may expose precise "
"timing information."); "timing information.");
DAWN_INVALID_IF(!device->IsExtensionEnabled(Extension::TimestampQuery), DAWN_INVALID_IF(!device->IsFeatureEnabled(Feature::TimestampQuery),
"Timestamp query set created without the extension being enabled."); "Timestamp query set created without the feature being enabled.");
DAWN_INVALID_IF(descriptor->pipelineStatisticsCount != 0, DAWN_INVALID_IF(descriptor->pipelineStatisticsCount != 0,
"Pipeline statistics specified for a query of type %s.", "Pipeline statistics specified for a query of type %s.",

View File

@ -240,7 +240,7 @@ namespace dawn_native {
wgpu::SType::PrimitiveDepthClampingState)); wgpu::SType::PrimitiveDepthClampingState));
const PrimitiveDepthClampingState* clampInfo = nullptr; const PrimitiveDepthClampingState* clampInfo = nullptr;
FindInChain(descriptor->nextInChain, &clampInfo); FindInChain(descriptor->nextInChain, &clampInfo);
if (clampInfo && !device->IsExtensionEnabled(Extension::DepthClamping)) { if (clampInfo && !device->IsFeatureEnabled(Feature::DepthClamping)) {
return DAWN_VALIDATION_ERROR("The depth clamping feature is not supported"); return DAWN_VALIDATION_ERROR("The depth clamping feature is not supported");
} }
DAWN_TRY(ValidatePrimitiveTopology(descriptor->topology)); DAWN_TRY(ValidatePrimitiveTopology(descriptor->topology));

View File

@ -273,9 +273,9 @@ namespace dawn_native {
DAWN_INVALID_IF(descriptor->dimension == wgpu::TextureDimension::e1D, DAWN_INVALID_IF(descriptor->dimension == wgpu::TextureDimension::e1D,
"1D textures aren't supported (yet)."); "1D textures aren't supported (yet).");
DAWN_INVALID_IF(internalUsageDesc != nullptr && DAWN_INVALID_IF(
!device->IsExtensionEnabled(Extension::DawnInternalUsages), internalUsageDesc != nullptr && !device->IsFeatureEnabled(Feature::DawnInternalUsages),
"The dawn-internal-usages feature is not enabled"); "The dawn-internal-usages feature is not enabled");
const Format* format; const Format* format;
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format)); DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format));
@ -434,7 +434,7 @@ namespace dawn_native {
} }
// WebGPU only supports sample counts of 1 and 4. We could expand to more based on // WebGPU only supports sample counts of 1 and 4. We could expand to more based on
// platform support, but it would probably be an extension. // platform support, but it would probably be a feature.
bool IsValidSampleCount(uint32_t sampleCount) { bool IsValidSampleCount(uint32_t sampleCount) {
switch (sampleCount) { switch (sampleCount) {
case 1: case 1:

View File

@ -104,7 +104,7 @@ namespace dawn_native { namespace d3d12 {
mDriverDescription = o.str(); mDriverDescription = o.str();
} }
InitializeSupportedExtensions(); InitializeSupportedFeatures();
return {}; return {};
} }
@ -130,13 +130,13 @@ namespace dawn_native { namespace d3d12 {
return true; return true;
} }
void Adapter::InitializeSupportedExtensions() { void Adapter::InitializeSupportedFeatures() {
if (AreTimestampQueriesSupported()) { if (AreTimestampQueriesSupported()) {
mSupportedExtensions.EnableExtension(Extension::TimestampQuery); mSupportedFeatures.EnableFeature(Feature::TimestampQuery);
} }
mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC); mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery); mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery);
mSupportedExtensions.EnableExtension(Extension::MultiPlanarFormats); mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
} }
MaybeError Adapter::InitializeDebugLayerFilters() { MaybeError Adapter::InitializeDebugLayerFilters() {

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace d3d12 {
bool AreTimestampQueriesSupported() const; bool AreTimestampQueriesSupported() const;
void InitializeSupportedExtensions(); void InitializeSupportedFeatures();
MaybeError InitializeDebugLayerFilters(); MaybeError InitializeDebugLayerFilters();
void CleanUpDebugLayerFilters(); void CleanUpDebugLayerFilters();

View File

@ -73,7 +73,7 @@ namespace dawn_native { namespace d3d12 {
CheckHRESULT(mD3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue)), CheckHRESULT(mD3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue)),
"D3D12 create command queue")); "D3D12 create command queue"));
if (IsExtensionEnabled(Extension::TimestampQuery)) { if (IsFeatureEnabled(Feature::TimestampQuery)) {
// Get GPU timestamp counter frequency (in ticks/second). This fails if the specified // Get GPU timestamp counter frequency (in ticks/second). This fails if the specified
// command queue doesn't support timestamps. D3D12_COMMAND_LIST_TYPE_DIRECT queues // command queue doesn't support timestamps. D3D12_COMMAND_LIST_TYPE_DIRECT queues
// always support timestamps except where there are bugs in Windows container and vGPU // always support timestamps except where there are bugs in Windows container and vGPU
@ -203,7 +203,7 @@ namespace dawn_native { namespace d3d12 {
MaybeError Device::ApplyUseDxcToggle() { MaybeError Device::ApplyUseDxcToggle() {
if (!ToBackend(GetAdapter())->GetBackend()->GetFunctions()->IsDXCAvailable()) { if (!ToBackend(GetAdapter())->GetBackend()->GetFunctions()->IsDXCAvailable()) {
ForceSetToggle(Toggle::UseDXC, false); ForceSetToggle(Toggle::UseDXC, false);
} else if (IsExtensionEnabled(Extension::ShaderFloat16)) { } else if (IsFeatureEnabled(Feature::ShaderFloat16)) {
// Currently we can only use DXC to compile HLSL shaders using float16. // Currently we can only use DXC to compile HLSL shaders using float16.
ForceSetToggle(Toggle::UseDXC, true); ForceSetToggle(Toggle::UseDXC, true);
} }

View File

@ -116,7 +116,7 @@ namespace dawn_native { namespace d3d12 {
// DXC inputs // DXC inputs
uint64_t dxcVersion; uint64_t dxcVersion;
const D3D12DeviceInfo* deviceInfo; const D3D12DeviceInfo* deviceInfo;
bool hasShaderFloat16Extension; bool hasShaderFloat16Feature;
static ResultOrError<ShaderCompilationRequest> Create( static ResultOrError<ShaderCompilationRequest> Create(
const char* entryPointName, const char* entryPointName,
@ -192,8 +192,7 @@ namespace dawn_native { namespace d3d12 {
request.fxcVersion = compiler == Compiler::FXC ? GetD3DCompilerVersion() : 0; request.fxcVersion = compiler == Compiler::FXC ? GetD3DCompilerVersion() : 0;
request.dxcVersion = compiler == Compiler::DXC ? dxcVersion : 0; request.dxcVersion = compiler == Compiler::DXC ? dxcVersion : 0;
request.deviceInfo = &device->GetDeviceInfo(); request.deviceInfo = &device->GetDeviceInfo();
request.hasShaderFloat16Extension = request.hasShaderFloat16Feature = device->IsFeatureEnabled(Feature::ShaderFloat16);
device->IsExtensionEnabled(Extension::ShaderFloat16);
return std::move(request); return std::move(request);
} }
@ -240,7 +239,7 @@ namespace dawn_native { namespace d3d12 {
stream << " isRobustnessEnabled=" << isRobustnessEnabled; stream << " isRobustnessEnabled=" << isRobustnessEnabled;
stream << " fxcVersion=" << fxcVersion; stream << " fxcVersion=" << fxcVersion;
stream << " dxcVersion=" << dxcVersion; stream << " dxcVersion=" << dxcVersion;
stream << " hasShaderFloat16Extension=" << hasShaderFloat16Extension; stream << " hasShaderFloat16Feature=" << hasShaderFloat16Feature;
stream << ")"; stream << ")";
stream << "\n"; stream << "\n";
@ -314,7 +313,7 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY_ASSIGN(entryPointW, ConvertStringToWstring(request.entryPointName)); DAWN_TRY_ASSIGN(entryPointW, ConvertStringToWstring(request.entryPointName));
std::vector<const wchar_t*> arguments = std::vector<const wchar_t*> arguments =
GetDXCArguments(request.compileFlags, request.hasShaderFloat16Extension); GetDXCArguments(request.compileFlags, request.hasShaderFloat16Feature);
ComPtr<IDxcOperationResult> result; ComPtr<IDxcOperationResult> result;
DAWN_TRY(CheckHRESULT( DAWN_TRY(CheckHRESULT(

View File

@ -264,7 +264,7 @@ namespace dawn_native { namespace metal {
mDriverDescription = mDriverDescription =
"Metal driver on " + std::string(systemName) + [osVersion UTF8String]; "Metal driver on " + std::string(systemName) + [osVersion UTF8String];
InitializeSupportedExtensions(); InitializeSupportedFeatures();
} }
// AdapterBase Implementation // AdapterBase Implementation
@ -278,10 +278,10 @@ namespace dawn_native { namespace metal {
return Device::Create(this, mDevice, descriptor); return Device::Create(this, mDevice, descriptor);
} }
void InitializeSupportedExtensions() { void InitializeSupportedFeatures() {
#if defined(DAWN_PLATFORM_MACOS) #if defined(DAWN_PLATFORM_MACOS)
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC); mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
} }
#endif #endif
@ -291,7 +291,7 @@ namespace dawn_native { namespace metal {
{MTLCommonCounterVertexInvocations, MTLCommonCounterClipperInvocations, {MTLCommonCounterVertexInvocations, MTLCommonCounterClipperInvocations,
MTLCommonCounterClipperPrimitivesOut, MTLCommonCounterFragmentInvocations, MTLCommonCounterClipperPrimitivesOut, MTLCommonCounterFragmentInvocations,
MTLCommonCounterComputeKernelInvocations})) { MTLCommonCounterComputeKernelInvocations})) {
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery); mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery);
} }
if (IsGPUCounterSupported(*mDevice, MTLCommonCounterSetTimestamp, if (IsGPUCounterSupported(*mDevice, MTLCommonCounterSetTimestamp,
@ -306,13 +306,13 @@ namespace dawn_native { namespace metal {
enableTimestampQuery &= !IsMacOSVersionAtLeast(11); enableTimestampQuery &= !IsMacOSVersionAtLeast(11);
#endif #endif
if (enableTimestampQuery) { if (enableTimestampQuery) {
mSupportedExtensions.EnableExtension(Extension::TimestampQuery); mSupportedFeatures.EnableFeature(Feature::TimestampQuery);
} }
} }
} }
if (@available(macOS 10.11, iOS 11.0, *)) { if (@available(macOS 10.11, iOS 11.0, *)) {
mSupportedExtensions.EnableExtension(Extension::DepthClamping); mSupportedFeatures.EnableFeature(Feature::DepthClamping);
} }
} }

View File

@ -134,7 +134,7 @@ namespace dawn_native { namespace metal {
DAWN_TRY(mCommandContext.PrepareNextCommandBuffer(*mCommandQueue)); DAWN_TRY(mCommandContext.PrepareNextCommandBuffer(*mCommandQueue));
if (IsExtensionEnabled(Extension::TimestampQuery)) { if (IsFeatureEnabled(Feature::TimestampQuery)) {
// Make a best guess of timestamp period based on device vendor info, and converge it to // Make a best guess of timestamp period based on device vendor info, and converge it to
// an accurate value by the following calculations. // an accurate value by the following calculations.
mTimestampPeriod = mTimestampPeriod =
@ -312,8 +312,8 @@ namespace dawn_native { namespace metal {
MaybeError Device::TickImpl() { MaybeError Device::TickImpl() {
DAWN_TRY(SubmitPendingCommandBuffer()); DAWN_TRY(SubmitPendingCommandBuffer());
// Just run timestamp period calculation when timestamp extension is enabled. // Just run timestamp period calculation when timestamp feature is enabled.
if (IsExtensionEnabled(Extension::TimestampQuery)) { if (IsFeatureEnabled(Feature::TimestampQuery)) {
if (@available(macos 10.15, iOS 14.0, *)) { if (@available(macos 10.15, iOS 14.0, *)) {
UpdateTimestampPeriod(GetMTLDevice(), mKalmanInfo.get(), &mCpuTimestamp, UpdateTimestampPeriod(GetMTLDevice(), mKalmanInfo.get(), &mCpuTimestamp,
&mGpuTimestamp, &mTimestampPeriod); &mGpuTimestamp, &mTimestampPeriod);

View File

@ -28,8 +28,8 @@ namespace dawn_native { namespace null {
mPCIInfo.name = "Null backend"; mPCIInfo.name = "Null backend";
mAdapterType = wgpu::AdapterType::CPU; mAdapterType = wgpu::AdapterType::CPU;
// Enable all extensions by default for the convenience of tests. // Enable all features by default for the convenience of tests.
mSupportedExtensions.extensionsBitSet.set(); mSupportedFeatures.featuresBitSet.set();
} }
Adapter::~Adapter() = default; Adapter::~Adapter() = default;
@ -38,9 +38,9 @@ namespace dawn_native { namespace null {
return false; return false;
} }
// Used for the tests that intend to use an adapter without all extensions enabled. // Used for the tests that intend to use an adapter without all features enabled.
void Adapter::SetSupportedExtensions(const std::vector<const char*>& requiredExtensions) { void Adapter::SetSupportedFeatures(const std::vector<const char*>& requiredFeatures) {
mSupportedExtensions = GetInstance()->ExtensionNamesToExtensionsSet(requiredExtensions); mSupportedFeatures = GetInstance()->FeatureNamesToFeaturesSet(requiredFeatures);
} }
ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) { ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) {

View File

@ -173,8 +173,8 @@ namespace dawn_native { namespace null {
// AdapterBase Implementation // AdapterBase Implementation
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;
// Used for the tests that intend to use an adapter without all extensions enabled. // Used for the tests that intend to use an adapter without all features enabled.
void SetSupportedExtensions(const std::vector<const char*>& requiredExtensions); void SetSupportedFeatures(const std::vector<const char*>& requiredFeatures);
private: private:
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override; ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override;

View File

@ -187,7 +187,7 @@ namespace dawn_native { namespace opengl {
mAdapterType = wgpu::AdapterType::CPU; mAdapterType = wgpu::AdapterType::CPU;
} }
InitializeSupportedExtensions(); InitializeSupportedFeatures();
return {}; return {};
} }
@ -209,7 +209,7 @@ namespace dawn_native { namespace opengl {
return Device::Create(this, descriptor, mFunctions); return Device::Create(this, descriptor, mFunctions);
} }
void InitializeSupportedExtensions() { void InitializeSupportedFeatures() {
// TextureCompressionBC // TextureCompressionBC
{ {
// BC1, BC2 and BC3 are not supported in OpenGL or OpenGL ES core features. // BC1, BC2 and BC3 are not supported in OpenGL or OpenGL ES core features.
@ -249,8 +249,7 @@ namespace dawn_native { namespace opengl {
if (supportsS3TC && (supportsTextureSRGB || supportsS3TCSRGB) && supportsRGTC && if (supportsS3TC && (supportsTextureSRGB || supportsS3TCSRGB) && supportsRGTC &&
supportsBPTC) { supportsBPTC) {
mSupportedExtensions.EnableExtension( mSupportedFeatures.EnableFeature(dawn_native::Feature::TextureCompressionBC);
dawn_native::Extension::TextureCompressionBC);
} }
} }
} }

View File

@ -53,7 +53,7 @@ namespace dawn_native { namespace vulkan {
"Vulkan driver version: " + std::to_string(mDeviceInfo.properties.driverVersion); "Vulkan driver version: " + std::to_string(mDeviceInfo.properties.driverVersion);
} }
InitializeSupportedExtensions(); InitializeSupportedFeatures();
mPCIInfo.deviceId = mDeviceInfo.properties.deviceID; mPCIInfo.deviceId = mDeviceInfo.properties.deviceID;
mPCIInfo.vendorId = mDeviceInfo.properties.vendorID; mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
@ -257,29 +257,29 @@ namespace dawn_native { namespace vulkan {
mBackend->GetFunctions()); mBackend->GetFunctions());
} }
void Adapter::InitializeSupportedExtensions() { void Adapter::InitializeSupportedFeatures() {
if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) { if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC); mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
} }
if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) { if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::TextureCompressionETC2); mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2);
} }
if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) { if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::TextureCompressionASTC); mSupportedFeatures.EnableFeature(Feature::TextureCompressionASTC);
} }
if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) { if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery); mSupportedFeatures.EnableFeature(Feature::PipelineStatisticsQuery);
} }
if (mDeviceInfo.features.depthClamp == VK_TRUE) { if (mDeviceInfo.features.depthClamp == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::DepthClamping); mSupportedFeatures.EnableFeature(Feature::DepthClamping);
} }
if (mDeviceInfo.properties.limits.timestampComputeAndGraphics == VK_TRUE) { if (mDeviceInfo.properties.limits.timestampComputeAndGraphics == VK_TRUE) {
mSupportedExtensions.EnableExtension(Extension::TimestampQuery); mSupportedFeatures.EnableFeature(Feature::TimestampQuery);
} }
} }

View File

@ -41,7 +41,7 @@ namespace dawn_native { namespace vulkan {
private: private:
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override; ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override;
MaybeError CheckCoreWebGPUSupport(); MaybeError CheckCoreWebGPUSupport();
void InitializeSupportedExtensions(); void InitializeSupportedFeatures();
VkPhysicalDevice mPhysicalDevice; VkPhysicalDevice mPhysicalDevice;
Backend* mBackend; Backend* mBackend;

View File

@ -348,31 +348,31 @@ namespace dawn_native { namespace vulkan {
usedKnobs.features.samplerAnisotropy = VK_TRUE; usedKnobs.features.samplerAnisotropy = VK_TRUE;
} }
if (IsExtensionEnabled(Extension::TextureCompressionBC)) { if (IsFeatureEnabled(Feature::TextureCompressionBC)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionBC == ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionBC ==
VK_TRUE); VK_TRUE);
usedKnobs.features.textureCompressionBC = VK_TRUE; usedKnobs.features.textureCompressionBC = VK_TRUE;
} }
if (IsExtensionEnabled(Extension::TextureCompressionETC2)) { if (IsFeatureEnabled(Feature::TextureCompressionETC2)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionETC2 == ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionETC2 ==
VK_TRUE); VK_TRUE);
usedKnobs.features.textureCompressionETC2 = VK_TRUE; usedKnobs.features.textureCompressionETC2 = VK_TRUE;
} }
if (IsExtensionEnabled(Extension::TextureCompressionASTC)) { if (IsFeatureEnabled(Feature::TextureCompressionASTC)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionASTC_LDR == ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionASTC_LDR ==
VK_TRUE); VK_TRUE);
usedKnobs.features.textureCompressionASTC_LDR = VK_TRUE; usedKnobs.features.textureCompressionASTC_LDR = VK_TRUE;
} }
if (IsExtensionEnabled(Extension::PipelineStatisticsQuery)) { if (IsFeatureEnabled(Feature::PipelineStatisticsQuery)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery == ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery ==
VK_TRUE); VK_TRUE);
usedKnobs.features.pipelineStatisticsQuery = VK_TRUE; usedKnobs.features.pipelineStatisticsQuery = VK_TRUE;
} }
if (IsExtensionEnabled(Extension::ShaderFloat16)) { if (IsFeatureEnabled(Feature::ShaderFloat16)) {
const VulkanDeviceInfo& deviceInfo = ToBackend(GetAdapter())->GetDeviceInfo(); const VulkanDeviceInfo& deviceInfo = ToBackend(GetAdapter())->GetDeviceInfo();
ASSERT(deviceInfo.HasExt(DeviceExt::ShaderFloat16Int8) && ASSERT(deviceInfo.HasExt(DeviceExt::ShaderFloat16Int8) &&
deviceInfo.shaderFloat16Int8Features.shaderFloat16 == VK_TRUE && deviceInfo.shaderFloat16Int8Features.shaderFloat16 == VK_TRUE &&
@ -390,7 +390,7 @@ namespace dawn_native { namespace vulkan {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES); VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES);
} }
if (IsExtensionEnabled(Extension::DepthClamping)) { if (IsFeatureEnabled(Feature::DepthClamping)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.depthClamp == VK_TRUE); ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.depthClamp == VK_TRUE);
usedKnobs.features.depthClamp = VK_TRUE; usedKnobs.features.depthClamp = VK_TRUE;
} }

View File

@ -106,20 +106,20 @@ namespace wgpu { namespace binding {
interop::Promise<interop::Interface<interop::GPUDevice>> promise(env); interop::Promise<interop::Interface<interop::GPUDevice>> promise(env);
if (descriptor.has_value()) { if (descriptor.has_value()) {
// See src/dawn_native/Extensions.cpp for feature <-> extension mappings. // See src/dawn_native/Features.cpp for enum <-> string mappings.
for (auto required : descriptor->requiredFeatures) { for (auto required : descriptor->requiredFeatures) {
switch (required) { switch (required) {
case interop::GPUFeatureName::kDepthClamping: case interop::GPUFeatureName::kDepthClamping:
desc.requiredExtensions.emplace_back("depth_clamping"); desc.requiredFeatures.emplace_back("depth_clamping");
continue; continue;
case interop::GPUFeatureName::kPipelineStatisticsQuery: case interop::GPUFeatureName::kPipelineStatisticsQuery:
desc.requiredExtensions.emplace_back("pipeline_statistics_query"); desc.requiredFeatures.emplace_back("pipeline_statistics_query");
continue; continue;
case interop::GPUFeatureName::kTextureCompressionBc: case interop::GPUFeatureName::kTextureCompressionBc:
desc.requiredExtensions.emplace_back("texture_compression_bc"); desc.requiredFeatures.emplace_back("texture_compression_bc");
continue; continue;
case interop::GPUFeatureName::kTimestampQuery: case interop::GPUFeatureName::kTimestampQuery:
desc.requiredExtensions.emplace_back("timestamp_query"); desc.requiredFeatures.emplace_back("timestamp_query");
continue; continue;
case interop::GPUFeatureName::kDepth24UnormStencil8: case interop::GPUFeatureName::kDepth24UnormStencil8:
case interop::GPUFeatureName::kDepth32FloatStencil8: case interop::GPUFeatureName::kDepth32FloatStencil8:

View File

@ -63,7 +63,9 @@ namespace dawn_native {
// An optional parameter of Adapter::CreateDevice() to send additional information when creating // An optional parameter of Adapter::CreateDevice() to send additional information when creating
// a Device. For example, we can use it to enable a workaround, optimization or feature. // a Device. For example, we can use it to enable a workaround, optimization or feature.
struct DAWN_NATIVE_EXPORT DeviceDescriptor { struct DAWN_NATIVE_EXPORT DeviceDescriptor {
// TODO(dawn:1149): remove once requiredExtensions is no longer used.
std::vector<const char*> requiredExtensions; std::vector<const char*> requiredExtensions;
std::vector<const char*> requiredFeatures;
std::vector<const char*> forceEnabledToggles; std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles; std::vector<const char*> forceDisabledToggles;
@ -79,10 +81,10 @@ namespace dawn_native {
const char* url; const char* url;
}; };
// A struct to record the information of an extension. An extension is a GPU feature that is not // A struct to record the information of a feature. A feature is a GPU feature that is not
// required to be supported by all Dawn backends and can only be used when it is enabled on the // required to be supported by all Dawn backends and can only be used when it is enabled on the
// creation of device. // creation of device.
using ExtensionInfo = ToggleInfo; using FeatureInfo = ToggleInfo;
// An adapter is an object that represent on possibility of creating devices in the system. // An adapter is an object that represent on possibility of creating devices in the system.
// Most of the time it will represent a combination of a physical GPU and an API. Not that the // Most of the time it will represent a combination of a physical GPU and an API. Not that the
@ -109,6 +111,7 @@ namespace dawn_native {
void GetProperties(wgpu::AdapterProperties* properties) const; void GetProperties(wgpu::AdapterProperties* properties) const;
std::vector<const char*> GetSupportedExtensions() const; std::vector<const char*> GetSupportedExtensions() const;
std::vector<const char*> GetSupportedFeatures() const;
WGPUDeviceProperties GetAdapterProperties() const; WGPUDeviceProperties GetAdapterProperties() const;
bool GetLimits(WGPUSupportedLimits* limits) const; bool GetLimits(WGPUSupportedLimits* limits) const;

View File

@ -162,7 +162,7 @@ test("dawn_unittests") {
"unittests/EnumClassBitmasksTests.cpp", "unittests/EnumClassBitmasksTests.cpp",
"unittests/EnumMaskIteratorTests.cpp", "unittests/EnumMaskIteratorTests.cpp",
"unittests/ErrorTests.cpp", "unittests/ErrorTests.cpp",
"unittests/ExtensionTests.cpp", "unittests/FeatureTests.cpp",
"unittests/GPUInfoTests.cpp", "unittests/GPUInfoTests.cpp",
"unittests/GetProcAddressTests.cpp", "unittests/GetProcAddressTests.cpp",
"unittests/ITypArrayTests.cpp", "unittests/ITypArrayTests.cpp",

View File

@ -854,7 +854,7 @@ dawn_native::Adapter DawnTestBase::GetAdapter() const {
return mBackendAdapter; return mBackendAdapter;
} }
std::vector<const char*> DawnTestBase::GetRequiredExtensions() { std::vector<const char*> DawnTestBase::GetRequiredFeatures() {
return {}; return {};
} }
@ -862,15 +862,15 @@ const wgpu::AdapterProperties& DawnTestBase::GetAdapterProperties() const {
return mParam.adapterProperties; return mParam.adapterProperties;
} }
bool DawnTestBase::SupportsExtensions(const std::vector<const char*>& extensions) { bool DawnTestBase::SupportsFeatures(const std::vector<const char*>& features) {
ASSERT(mBackendAdapter); ASSERT(mBackendAdapter);
std::set<std::string> supportedExtensionsSet; std::set<std::string> supportedFeaturesSet;
for (const char* supportedExtensionName : mBackendAdapter.GetSupportedExtensions()) { for (const char* supportedFeatureName : mBackendAdapter.GetSupportedFeatures()) {
supportedExtensionsSet.insert(supportedExtensionName); supportedFeaturesSet.insert(supportedFeatureName);
} }
for (const char* extensionName : extensions) { for (const char* featureName : features) {
if (supportedExtensionsSet.find(extensionName) == supportedExtensionsSet.end()) { if (supportedFeaturesSet.find(featureName) == supportedFeaturesSet.end()) {
return false; return false;
} }
} }
@ -912,7 +912,7 @@ void DawnTestBase::SetUp() {
dawn_native::DeviceDescriptor deviceDescriptor = {}; dawn_native::DeviceDescriptor deviceDescriptor = {};
deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds; deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds;
deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds; deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds;
deviceDescriptor.requiredExtensions = GetRequiredExtensions(); deviceDescriptor.requiredFeatures = GetRequiredFeatures();
// Disabled disallowing unsafe APIs so we can test them. // Disabled disallowing unsafe APIs so we can test them.
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");

View File

@ -475,13 +475,13 @@ class DawnTestBase {
void FlushWire(); void FlushWire();
void WaitForAllOperations(); void WaitForAllOperations();
bool SupportsExtensions(const std::vector<const char*>& extensions); bool SupportsFeatures(const std::vector<const char*>& features);
// Called in SetUp() to get the extensions required to be enabled in the tests. The tests must // Called in SetUp() to get the features required to be enabled in the tests. The tests must
// check if the required extensions are supported by the adapter in this function and guarantee // check if the required features are supported by the adapter in this function and guarantee
// the returned extensions are all supported by the adapter. The tests may provide different // the returned features are all supported by the adapter. The tests may provide different
// code path to handle the situation when not all extensions are supported. // code path to handle the situation when not all features are supported.
virtual std::vector<const char*> GetRequiredExtensions(); virtual std::vector<const char*> GetRequiredFeatures();
const wgpu::AdapterProperties& GetAdapterProperties() const; const wgpu::AdapterProperties& GetAdapterProperties() const;
@ -568,7 +568,7 @@ class DawnTestBase {
} \ } \
} while (0) } while (0)
// Skip a test which requires an extension or a toggle to be present / not present or some WIP // Skip a test which requires a feature or a toggle to be present / not present or some WIP
// features. // features.
#define DAWN_TEST_UNSUPPORTED_IF(condition) \ #define DAWN_TEST_UNSUPPORTED_IF(condition) \
DAWN_SKIP_TEST_IF_BASE(condition, "unsupported", condition) DAWN_SKIP_TEST_IF_BASE(condition, "unsupported", condition)

View File

@ -46,12 +46,12 @@ namespace {
class BufferZeroInitTest : public DawnTest { class BufferZeroInitTest : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredExtensions = {}; std::vector<const char*> requiredFeatures = {};
if (SupportsExtensions({"timestamp_query"})) { if (SupportsFeatures({"timestamp_query"})) {
requiredExtensions.push_back("timestamp_query"); requiredFeatures.push_back("timestamp_query");
} }
return requiredExtensions; return requiredFeatures;
} }
public: public:
@ -1314,8 +1314,8 @@ TEST_P(BufferZeroInitTest, ResolveQuerySet) {
// without any copy commands on Metal on AMD GPU. // without any copy commands on Metal on AMD GPU.
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsAMD()); DAWN_SUPPRESS_TEST_IF(IsMetal() && IsAMD());
// Skip if timestamp extension is not supported on device // Skip if timestamp feature is not supported on device
DAWN_TEST_UNSUPPORTED_IF(!SupportsExtensions({"timestamp_query"})); DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"timestamp_query"}));
// crbug.com/dawn/940: Does not work on Mac 11.0+. Backend validation changed. // crbug.com/dawn/940: Does not work on Mac 11.0+. Backend validation changed.
DAWN_TEST_UNSUPPORTED_IF(IsMacOS() && !IsMacOS(10)); DAWN_TEST_UNSUPPORTED_IF(IsMacOS() && !IsMacOS(10));

View File

@ -40,19 +40,17 @@ namespace {
class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> { class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
const wgpu::TextureFormat format = GetParam().mTextureFormat; const wgpu::TextureFormat format = GetParam().mTextureFormat;
if (utils::IsBCTextureFormat(format) && SupportsExtensions({"texture_compression_bc"})) { if (utils::IsBCTextureFormat(format) && SupportsFeatures({"texture_compression_bc"})) {
mIsFormatSupported = true; mIsFormatSupported = true;
return {"texture_compression_bc"}; return {"texture_compression_bc"};
} }
if (utils::IsETC2TextureFormat(format) && if (utils::IsETC2TextureFormat(format) && SupportsFeatures({"texture-compression-etc2"})) {
SupportsExtensions({"texture-compression-etc2"})) {
mIsFormatSupported = true; mIsFormatSupported = true;
return {"texture-compression-etc2"}; return {"texture-compression-etc2"};
} }
if (utils::IsASTCTextureFormat(format) && if (utils::IsASTCTextureFormat(format) && SupportsFeatures({"texture-compression-astc"})) {
SupportsExtensions({"texture-compression-astc"})) {
mIsFormatSupported = true; mIsFormatSupported = true;
return {"texture-compression-astc"}; return {"texture-compression-astc"};
} }
@ -1151,14 +1149,14 @@ DAWN_INSTANTIATE_TEST_P(CompressedTextureFormatTest,
// Suite of regression tests that target specific compression types. // Suite of regression tests that target specific compression types.
class CompressedTextureFormatSpecificTest : public DawnTest { class CompressedTextureFormatSpecificTest : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsExtensions({"texture_compression_bc"}); mIsBCFormatSupported = SupportsFeatures({"texture_compression_bc"});
std::vector<const char*> extensions; std::vector<const char*> features;
if (mIsBCFormatSupported) { if (mIsBCFormatSupported) {
extensions.emplace_back("texture_compression_bc"); features.emplace_back("texture_compression_bc");
} }
return extensions; return features;
} }
bool IsBCFormatSupported() const { bool IsBCFormatSupported() const {

View File

@ -331,7 +331,7 @@ namespace {
class CopyTests_T2T : public CopyTests, public DawnTestWithParams<CopyTestsParams> { class CopyTests_T2T : public CopyTests, public DawnTestWithParams<CopyTestsParams> {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {"dawn-internal-usages"};
} }

View File

@ -29,7 +29,7 @@ namespace {
class D3D12ResourceTestBase : public DawnTest { class D3D12ResourceTestBase : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {"dawn-internal-usages"};
} }

View File

@ -68,8 +68,8 @@ namespace {
mD3d11Device = std::move(d3d11Device); mD3d11Device = std::move(d3d11Device);
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
mIsMultiPlanarFormatsSupported = SupportsExtensions({"multiplanar_formats"}); mIsMultiPlanarFormatsSupported = SupportsFeatures({"multiplanar_formats"});
if (!mIsMultiPlanarFormatsSupported) { if (!mIsMultiPlanarFormatsSupported) {
return {}; return {};
} }

View File

@ -75,9 +75,9 @@ namespace {
protected: protected:
constexpr static uint32_t kSize = 128; constexpr static uint32_t kSize = 128;
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
if (GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && if (GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
SupportsExtensions({"texture_compression_bc"})) { SupportsFeatures({"texture_compression_bc"})) {
return {"texture_compression_bc"}; return {"texture_compression_bc"};
} }
return {}; return {};
@ -85,7 +85,7 @@ namespace {
void Run() { void Run() {
DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
!SupportsExtensions({"texture_compression_bc"})); !SupportsFeatures({"texture_compression_bc"}));
// TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support // TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support
// reading from Snorm textures. // reading from Snorm textures.
@ -129,7 +129,7 @@ namespace {
GetParam().mAspect == wgpu::TextureAspect::DepthOnly && GetParam().mAspect == wgpu::TextureAspect::DepthOnly &&
IsOpenGL() && IsLinux()); IsOpenGL() && IsLinux());
// GL may support the extension, but reading data back is not implemented. // GL may support the feature, but reading data back is not implemented.
DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
(IsOpenGL() || IsOpenGLES())); (IsOpenGL() || IsOpenGLES()));

View File

@ -24,7 +24,7 @@ class DepthClampingTest : public DawnTest {
protected: protected:
void SetUp() override { void SetUp() override {
DawnTest::SetUp(); DawnTest::SetUp();
DAWN_TEST_UNSUPPORTED_IF(!SupportsExtensions({"depth_clamping"})); DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"depth_clamping"}));
wgpu::TextureDescriptor renderTargetDescriptor; wgpu::TextureDescriptor renderTargetDescriptor;
renderTargetDescriptor.size = {kRTSize, kRTSize}; renderTargetDescriptor.size = {kRTSize, kRTSize};
@ -67,12 +67,12 @@ class DepthClampingTest : public DawnTest {
})"); })");
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredExtensions = {}; std::vector<const char*> requiredFeatures = {};
if (SupportsExtensions({"depth_clamping"})) { if (SupportsFeatures({"depth_clamping"})) {
requiredExtensions.push_back("depth_clamping"); requiredFeatures.push_back("depth_clamping");
} }
return requiredExtensions; return requiredFeatures;
} }
struct TestSpec { struct TestSpec {

View File

@ -453,17 +453,17 @@ class PipelineStatisticsQueryTests : public QueryTests {
void SetUp() override { void SetUp() override {
DawnTest::SetUp(); DawnTest::SetUp();
// Skip all tests if pipeline statistics extension is not supported // Skip all tests if pipeline statistics feature is not supported
DAWN_TEST_UNSUPPORTED_IF(!SupportsExtensions({"pipeline_statistics_query"})); DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"pipeline_statistics_query"}));
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredExtensions = {}; std::vector<const char*> requiredFeatures = {};
if (SupportsExtensions({"pipeline_statistics_query"})) { if (SupportsFeatures({"pipeline_statistics_query"})) {
requiredExtensions.push_back("pipeline_statistics_query"); requiredFeatures.push_back("pipeline_statistics_query");
} }
return requiredExtensions; return requiredFeatures;
} }
wgpu::QuerySet CreateQuerySetForPipelineStatistics( wgpu::QuerySet CreateQuerySetForPipelineStatistics(
@ -522,16 +522,16 @@ class TimestampQueryTests : public QueryTests {
void SetUp() override { void SetUp() override {
DawnTest::SetUp(); DawnTest::SetUp();
// Skip all tests if timestamp extension is not supported // Skip all tests if timestamp feature is not supported
DAWN_TEST_UNSUPPORTED_IF(!SupportsExtensions({"timestamp_query"})); DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"timestamp_query"}));
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredExtensions = {}; std::vector<const char*> requiredFeatures = {};
if (SupportsExtensions({"timestamp_query"})) { if (SupportsFeatures({"timestamp_query"})) {
requiredExtensions.push_back("timestamp_query"); requiredFeatures.push_back("timestamp_query");
} }
return requiredExtensions; return requiredFeatures;
} }
wgpu::QuerySet CreateQuerySetForTimestamp(uint32_t queryCount) { wgpu::QuerySet CreateQuerySetForTimestamp(uint32_t queryCount) {

View File

@ -19,8 +19,8 @@
class ShaderFloat16Tests : public DawnTest { class ShaderFloat16Tests : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
mIsShaderFloat16Supported = SupportsExtensions({"shader_float16"}); mIsShaderFloat16Supported = SupportsFeatures({"shader_float16"});
if (!mIsShaderFloat16Supported) { if (!mIsShaderFloat16Supported) {
return {}; return {};
} }

View File

@ -1719,8 +1719,8 @@ class CompressedTextureZeroInitTest : public TextureZeroInitTest {
DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported()); DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported());
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsExtensions({"texture_compression_bc"}); mIsBCFormatSupported = SupportsFeatures({"texture_compression_bc"});
if (!mIsBCFormatSupported) { if (!mIsBCFormatSupported) {
return {}; return {};
} }

View File

@ -1,81 +0,0 @@
// Copyright 2019 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.
#include <gtest/gtest.h>
#include "dawn_native/Extensions.h"
#include "dawn_native/Instance.h"
#include "dawn_native/null/DeviceNull.h"
class ExtensionTests : public testing::Test {
public:
ExtensionTests()
: testing::Test(),
mInstanceBase(dawn_native::InstanceBase::Create()),
mAdapterBase(mInstanceBase.Get()) {
}
std::vector<const char*> GetAllExtensionNames() {
std::vector<const char*> allExtensionNames(kTotalExtensionsCount);
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
allExtensionNames[i] = ExtensionEnumToName(static_cast<dawn_native::Extension>(i));
}
return allExtensionNames;
}
static constexpr size_t kTotalExtensionsCount =
static_cast<size_t>(dawn_native::Extension::EnumCount);
protected:
Ref<dawn_native::InstanceBase> mInstanceBase;
dawn_native::null::Adapter mAdapterBase;
};
// Test the creation of a device will fail if the requested extension is not supported on the
// Adapter.
TEST_F(ExtensionTests, AdapterWithRequiredExtensionDisabled) {
const std::vector<const char*> kAllExtensionNames = GetAllExtensionNames();
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
dawn_native::Extension notSupportedExtension = static_cast<dawn_native::Extension>(i);
std::vector<const char*> extensionNamesWithoutOne = kAllExtensionNames;
extensionNamesWithoutOne.erase(extensionNamesWithoutOne.begin() + i);
mAdapterBase.SetSupportedExtensions(extensionNamesWithoutOne);
dawn_native::Adapter adapterWithoutExtension(&mAdapterBase);
dawn_native::DeviceDescriptor deviceDescriptor;
const char* extensionName = ExtensionEnumToName(notSupportedExtension);
deviceDescriptor.requiredExtensions = std::vector<const char*>(1, extensionName);
WGPUDevice deviceWithExtension = adapterWithoutExtension.CreateDevice(&deviceDescriptor);
ASSERT_EQ(nullptr, deviceWithExtension);
}
}
// Test Device.GetEnabledExtensions() can return the names of the enabled extensions correctly.
TEST_F(ExtensionTests, GetEnabledExtensions) {
dawn_native::Adapter adapter(&mAdapterBase);
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
dawn_native::Extension extension = static_cast<dawn_native::Extension>(i);
const char* extensionName = ExtensionEnumToName(extension);
dawn_native::DeviceDescriptor deviceDescriptor;
deviceDescriptor.requiredExtensions = {extensionName};
dawn_native::DeviceBase* deviceBase =
reinterpret_cast<dawn_native::DeviceBase*>(adapter.CreateDevice(&deviceDescriptor));
std::vector<const char*> enabledExtensions = deviceBase->GetEnabledExtensions();
ASSERT_EQ(1u, enabledExtensions.size());
ASSERT_EQ(0, std::strcmp(extensionName, enabledExtensions[0]));
}
}

View File

@ -0,0 +1,81 @@
// Copyright 2019 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.
#include <gtest/gtest.h>
#include "dawn_native/Features.h"
#include "dawn_native/Instance.h"
#include "dawn_native/null/DeviceNull.h"
class FeatureTests : public testing::Test {
public:
FeatureTests()
: testing::Test(),
mInstanceBase(dawn_native::InstanceBase::Create()),
mAdapterBase(mInstanceBase.Get()) {
}
std::vector<const char*> GetAllFeatureNames() {
std::vector<const char*> allFeatureNames(kTotalFeaturesCount);
for (size_t i = 0; i < kTotalFeaturesCount; ++i) {
allFeatureNames[i] = FeatureEnumToName(static_cast<dawn_native::Feature>(i));
}
return allFeatureNames;
}
static constexpr size_t kTotalFeaturesCount =
static_cast<size_t>(dawn_native::Feature::EnumCount);
protected:
Ref<dawn_native::InstanceBase> mInstanceBase;
dawn_native::null::Adapter mAdapterBase;
};
// Test the creation of a device will fail if the requested feature is not supported on the
// Adapter.
TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
const std::vector<const char*> kAllFeatureNames = GetAllFeatureNames();
for (size_t i = 0; i < kTotalFeaturesCount; ++i) {
dawn_native::Feature notSupportedFeature = static_cast<dawn_native::Feature>(i);
std::vector<const char*> featureNamesWithoutOne = kAllFeatureNames;
featureNamesWithoutOne.erase(featureNamesWithoutOne.begin() + i);
mAdapterBase.SetSupportedFeatures(featureNamesWithoutOne);
dawn_native::Adapter adapterWithoutFeature(&mAdapterBase);
dawn_native::DeviceDescriptor deviceDescriptor;
const char* featureName = FeatureEnumToName(notSupportedFeature);
deviceDescriptor.requiredFeatures = std::vector<const char*>(1, featureName);
WGPUDevice deviceWithFeature = adapterWithoutFeature.CreateDevice(&deviceDescriptor);
ASSERT_EQ(nullptr, deviceWithFeature);
}
}
// Test Device.GetEnabledFeatures() can return the names of the enabled features correctly.
TEST_F(FeatureTests, GetEnabledFeatures) {
dawn_native::Adapter adapter(&mAdapterBase);
for (size_t i = 0; i < kTotalFeaturesCount; ++i) {
dawn_native::Feature feature = static_cast<dawn_native::Feature>(i);
const char* featureName = FeatureEnumToName(feature);
dawn_native::DeviceDescriptor deviceDescriptor;
deviceDescriptor.requiredFeatures = {featureName};
dawn_native::DeviceBase* deviceBase =
reinterpret_cast<dawn_native::DeviceBase*>(adapter.CreateDevice(&deviceDescriptor));
std::vector<const char*> enabledFeatures = deviceBase->GetEnabledFeatures();
ASSERT_EQ(1u, enabledFeatures.size());
ASSERT_EQ(0, std::strcmp(featureName, enabledFeatures[0]));
}
}

View File

@ -2047,8 +2047,8 @@ class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"texture_compression_bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture_compression_bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -18,8 +18,8 @@
class TextureInternalUsageValidationDisabledTest : public ValidationTest {}; class TextureInternalUsageValidationDisabledTest : public ValidationTest {};
// Test that using the extension is an error if it is not enabled // Test that using the feature is an error if it is not enabled
TEST_F(TextureInternalUsageValidationDisabledTest, RequiresExtension) { TEST_F(TextureInternalUsageValidationDisabledTest, RequiresFeature) {
wgpu::TextureDescriptor textureDesc = {}; wgpu::TextureDescriptor textureDesc = {};
textureDesc.size = {1, 1}; textureDesc.size = {1, 1};
textureDesc.usage = wgpu::TextureUsage::CopySrc; textureDesc.usage = wgpu::TextureUsage::CopySrc;
@ -31,7 +31,7 @@ TEST_F(TextureInternalUsageValidationDisabledTest, RequiresExtension) {
wgpu::DawnTextureInternalUsageDescriptor internalDesc = {}; wgpu::DawnTextureInternalUsageDescriptor internalDesc = {};
textureDesc.nextInChain = &internalDesc; textureDesc.nextInChain = &internalDesc;
// Error with chained extension struct. // Error with chained feature struct.
ASSERT_DEVICE_ERROR(device.CreateTexture(&textureDesc)); ASSERT_DEVICE_ERROR(device.CreateTexture(&textureDesc));
// Also does not work with various internal usages. // Also does not work with various internal usages.
@ -45,7 +45,7 @@ TEST_F(TextureInternalUsageValidationDisabledTest, RequiresExtension) {
class TextureInternalUsageValidationTest : public ValidationTest { class TextureInternalUsageValidationTest : public ValidationTest {
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions.push_back("dawn-internal-usages"); descriptor.requiredFeatures.push_back("dawn-internal-usages");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -36,12 +36,12 @@ class QuerySetValidationTest : public ValidationTest {
} }
}; };
// Test creating query set without extensions // Test creating query set without features
TEST_F(QuerySetValidationTest, CreationWithoutExtensions) { TEST_F(QuerySetValidationTest, CreationWithoutFeatures) {
// Creating a query set for occlusion queries succeeds without any extensions enabled. // Creating a query set for occlusion queries succeeds without any features enabled.
CreateQuerySet(device, wgpu::QueryType::Occlusion, 1); CreateQuerySet(device, wgpu::QueryType::Occlusion, 1);
// Creating a query set for other types of queries fails without extensions enabled. // Creating a query set for other types of queries fails without features enabled.
ASSERT_DEVICE_ERROR(CreateQuerySet(device, wgpu::QueryType::PipelineStatistics, 1, ASSERT_DEVICE_ERROR(CreateQuerySet(device, wgpu::QueryType::PipelineStatistics, 1,
{wgpu::PipelineStatisticName::VertexShaderInvocations})); {wgpu::PipelineStatisticName::VertexShaderInvocations}));
ASSERT_DEVICE_ERROR(CreateQuerySet(device, wgpu::QueryType::Timestamp, 1)); ASSERT_DEVICE_ERROR(CreateQuerySet(device, wgpu::QueryType::Timestamp, 1));
@ -226,13 +226,13 @@ class TimestampQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions.push_back("timestamp_query"); descriptor.requiredFeatures.push_back("timestamp_query");
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
// Test creating query set with only the timestamp extension enabled. // Test creating query set with only the timestamp feature enabled.
TEST_F(TimestampQueryValidationTest, Creation) { TEST_F(TimestampQueryValidationTest, Creation) {
// Creating a query set for occlusion queries succeeds. // Creating a query set for occlusion queries succeeds.
CreateQuerySet(device, wgpu::QueryType::Occlusion, 1); CreateQuerySet(device, wgpu::QueryType::Occlusion, 1);
@ -430,7 +430,7 @@ class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions.push_back("pipeline_statistics_query"); descriptor.requiredFeatures.push_back("pipeline_statistics_query");
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing // TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
// unsafe APIs to test it. // unsafe APIs to test it.
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
@ -438,7 +438,7 @@ class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
} }
}; };
// Test creating query set with only the pipeline statistics extension enabled. // Test creating query set with only the pipeline statistics feature enabled.
TEST_F(PipelineStatisticsQueryValidationTest, Creation) { TEST_F(PipelineStatisticsQueryValidationTest, Creation) {
// Creating a query set for occlusion queries succeeds. // Creating a query set for occlusion queries succeeds.
CreateQuerySet(device, wgpu::QueryType::Occlusion, 1); CreateQuerySet(device, wgpu::QueryType::Occlusion, 1);

View File

@ -558,8 +558,8 @@ namespace {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"texture_compression_bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture_compression_bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -782,7 +782,7 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
} }
// Test that specifying a clampDepth value results in an error if the feature is not enabled. // Test that specifying a clampDepth value results in an error if the feature is not enabled.
TEST_F(RenderPipelineValidationTest, ClampDepthWithoutExtension) { TEST_F(RenderPipelineValidationTest, ClampDepthWithoutFeature) {
{ {
utils::ComboRenderPipelineDescriptor descriptor; utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule; descriptor.vertex.module = vsModule;
@ -1125,12 +1125,12 @@ class DepthClampingValidationTest : public RenderPipelineValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"depth_clamping"}; descriptor.requiredFeatures = {"depth_clamping"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
// Tests that specifying a clampDepth value succeeds if the extension is enabled. // Tests that specifying a clampDepth value succeeds if the feature is enabled.
TEST_F(DepthClampingValidationTest, Success) { TEST_F(DepthClampingValidationTest, Success) {
{ {
utils::ComboRenderPipelineDescriptor descriptor; utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -533,9 +533,9 @@ namespace {
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
// Test that the creation of a texture with BC format will fail when the extension // Test that the creation of a texture with BC format will fail when the feature
// textureCompressionBC is not enabled. // textureCompressionBC is not enabled.
TEST_F(TextureValidationTest, UseBCFormatWithoutEnablingExtension) { TEST_F(TextureValidationTest, UseBCFormatWithoutEnablingFeature) {
for (wgpu::TextureFormat format : utils::kBCFormats) { for (wgpu::TextureFormat format : utils::kBCFormats) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
@ -543,9 +543,9 @@ namespace {
} }
} }
// Test that the creation of a texture with ETC2 format will fail when the extension // Test that the creation of a texture with ETC2 format will fail when the feature
// textureCompressionETC2 is not enabled. // textureCompressionETC2 is not enabled.
TEST_F(TextureValidationTest, UseETC2FormatWithoutEnablingExtension) { TEST_F(TextureValidationTest, UseETC2FormatWithoutEnablingFeature) {
for (wgpu::TextureFormat format : utils::kETC2Formats) { for (wgpu::TextureFormat format : utils::kETC2Formats) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
@ -553,9 +553,9 @@ namespace {
} }
} }
// Test that the creation of a texture with ASTC format will fail when the extension // Test that the creation of a texture with ASTC format will fail when the feature
// textureCompressionASTC is not enabled. // textureCompressionASTC is not enabled.
TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingExtension) { TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingFeature) {
for (wgpu::TextureFormat format : utils::kASTCFormats) { for (wgpu::TextureFormat format : utils::kASTCFormats) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
@ -569,8 +569,8 @@ namespace {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"texture_compression_bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture_compression_bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -110,8 +110,8 @@ class UnsafeQueryAPIValidationTest : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions.push_back("pipeline_statistics_query"); descriptor.requiredFeatures.push_back("pipeline_statistics_query");
descriptor.requiredExtensions.push_back("timestamp_query"); descriptor.requiredFeatures.push_back("timestamp_query");
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -22,7 +22,7 @@ namespace {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"multiplanar_formats"}; descriptor.requiredFeatures = {"multiplanar_formats"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -26,8 +26,8 @@ class D3D12ResourceHeapTests : public DawnTest {
DAWN_TEST_UNSUPPORTED_IF(UsesWire()); DAWN_TEST_UNSUPPORTED_IF(UsesWire());
} }
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsExtensions({"texture_compression_bc"}); mIsBCFormatSupported = SupportsFeatures({"texture_compression_bc"});
if (!mIsBCFormatSupported) { if (!mIsBCFormatSupported) {
return {}; return {};
} }

View File

@ -115,7 +115,7 @@ namespace {
class EGLImageTestBase : public DawnTest { class EGLImageTestBase : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {"dawn-internal-usages"};
} }

View File

@ -34,7 +34,7 @@ namespace dawn_native { namespace vulkan {
class VulkanImageWrappingTestBase : public DawnTest { class VulkanImageWrappingTestBase : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {"dawn-internal-usages"};
} }

View File

@ -31,7 +31,7 @@ namespace dawn_native { namespace vulkan {
class VulkanImageWrappingTestBase : public DawnTest { class VulkanImageWrappingTestBase : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredExtensions() override { std::vector<const char*> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {"dawn-internal-usages"};
} }