Update tests to use wgpu::DeviceDescriptor
Bug: dawn:160
Change-Id: I2fce45c5cc6f9e95054ad5fa42acfeb42ad787c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72062
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp
index 86a6bb4..03afef2 100644
--- a/src/dawn_native/DawnNative.cpp
+++ b/src/dawn_native/DawnNative.cpp
@@ -168,6 +168,10 @@
return ToAPI(mImpl->APICreateDevice(&desc));
}
+ WGPUDevice Adapter::CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor) {
+ return CreateDevice(reinterpret_cast<const WGPUDeviceDescriptor*>(deviceDescriptor));
+ }
+
WGPUDevice Adapter::CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor) {
return ToAPI(mImpl->APICreateDevice(FromAPI(deviceDescriptor)));
}
@@ -179,6 +183,20 @@
mImpl->APIRequestDevice(&desc, callback, userdata);
}
+ void Adapter::RequestDevice(const wgpu::DeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata) {
+ mImpl->APIRequestDevice(reinterpret_cast<const DeviceDescriptor*>(descriptor), callback,
+ userdata);
+ }
+
+ void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata) {
+ mImpl->APIRequestDevice(reinterpret_cast<const DeviceDescriptor*>(descriptor), callback,
+ userdata);
+ }
+
void Adapter::ResetInternalDeviceForTesting() {
mImpl->ResetInternalDeviceForTesting();
}
diff --git a/src/dawn_node/binding/GPUAdapter.cpp b/src/dawn_node/binding/GPUAdapter.cpp
index c9a6edb..4b4def5 100644
--- a/src/dawn_node/binding/GPUAdapter.cpp
+++ b/src/dawn_node/binding/GPUAdapter.cpp
@@ -168,23 +168,24 @@
interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevice(
Napi::Env env,
interop::GPUDeviceDescriptor descriptor) {
- dawn_native::DawnDeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in.
+ wgpu::DeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in.
interop::Promise<interop::Interface<interop::GPUDevice>> promise(env, PROMISE_INFO);
+ std::vector<wgpu::FeatureName> requiredFeatures;
// See src/dawn_native/Features.cpp for enum <-> string mappings.
for (auto required : descriptor.requiredFeatures) {
switch (required) {
case interop::GPUFeatureName::kDepthClamping:
- desc.requiredFeatures.emplace_back("depth-clamping");
+ requiredFeatures.emplace_back(wgpu::FeatureName::DepthClamping);
continue;
case interop::GPUFeatureName::kPipelineStatisticsQuery:
- desc.requiredFeatures.emplace_back("pipeline-statistics-query");
+ requiredFeatures.emplace_back(wgpu::FeatureName::PipelineStatisticsQuery);
continue;
case interop::GPUFeatureName::kTextureCompressionBc:
- desc.requiredFeatures.emplace_back("texture-compression-bc");
+ requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionBC);
continue;
case interop::GPUFeatureName::kTimestampQuery:
- desc.requiredFeatures.emplace_back("timestamp-query");
+ requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery);
continue;
case interop::GPUFeatureName::kDepth24UnormStencil8:
case interop::GPUFeatureName::kDepth32FloatStencil8:
@@ -194,24 +195,36 @@
}
// Propogate enabled/disabled dawn features
- // Note: DawnDeviceDescriptor::forceEnabledToggles and forceDisabledToggles are vectors of
- // 'const char*', so we make sure the parsed strings survive the CreateDevice() call by
- // storing them on the stack.
+ // Note: DawnDeviceTogglesDescriptor::forceEnabledToggles and forceDisabledToggles are
+ // vectors of 'const char*', so we make sure the parsed strings survive the CreateDevice()
+ // call by storing them on the stack.
std::vector<std::string> enabledToggles;
std::vector<std::string> disabledToggles;
+ std::vector<const char*> forceEnabledToggles;
+ std::vector<const char*> forceDisabledToggles;
if (auto values = flags_.Get("enable-dawn-features")) {
enabledToggles = Split(*values, ',');
for (auto& t : enabledToggles) {
- desc.forceEnabledToggles.emplace_back(t.c_str());
+ forceEnabledToggles.emplace_back(t.c_str());
}
}
if (auto values = flags_.Get("disable-dawn-features")) {
disabledToggles = Split(*values, ',');
for (auto& t : disabledToggles) {
- desc.forceDisabledToggles.emplace_back(t.c_str());
+ forceDisabledToggles.emplace_back(t.c_str());
}
}
+ desc.requiredFeaturesCount = requiredFeatures.size();
+ desc.requiredFeatures = requiredFeatures.data();
+
+ wgpu::DawnDeviceTogglesDescriptor togglesDesc = {};
+ desc.nextInChain = &togglesDesc;
+ togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
+ togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
+ togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
+ togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
+
auto wgpu_device = adapter_.CreateDevice(&desc);
if (wgpu_device) {
promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device));
diff --git a/src/include/dawn_native/DawnNative.h b/src/include/dawn_native/DawnNative.h
index fb2bd78..79f6fa7 100644
--- a/src/include/dawn_native/DawnNative.h
+++ b/src/include/dawn_native/DawnNative.h
@@ -28,6 +28,7 @@
namespace wgpu {
struct AdapterProperties;
+ struct DeviceDescriptor;
}
namespace dawn_native {
@@ -123,11 +124,18 @@
// Create a device on this adapter. On an error, nullptr is returned.
WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor);
+ WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
void RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback,
void* userdata);
+ void RequestDevice(const wgpu::DeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata);
+ void RequestDevice(const WGPUDeviceDescriptor* descriptor,
+ WGPURequestDeviceCallback callback,
+ void* userdata);
// Returns the underlying WGPUAdapter object.
WGPUAdapter Get() const;
diff --git a/src/tests/DawnNativeTest.cpp b/src/tests/DawnNativeTest.cpp
index 0e47053..20d7146 100644
--- a/src/tests/DawnNativeTest.cpp
+++ b/src/tests/DawnNativeTest.cpp
@@ -70,8 +70,13 @@
WGPUDevice DawnNativeTest::CreateTestDevice() {
// Disabled disallowing unsafe APIs so we can test them.
- dawn_native::DawnDeviceDescriptor deviceDescriptor;
- deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
+ wgpu::DeviceDescriptor deviceDescriptor = {};
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
+ deviceDescriptor.nextInChain = &togglesDesc;
+
+ const char* toggle = "disallow_unsafe_apis";
+ togglesDesc.forceDisabledToggles = &toggle;
+ togglesDesc.forceDisabledTogglesCount = 1;
return adapter.CreateDevice(&deviceDescriptor);
}
diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp
index 490b2ca..2955e30 100644
--- a/src/tests/DawnTest.cpp
+++ b/src/tests/DawnTest.cpp
@@ -37,6 +37,7 @@
#include <regex>
#include <sstream>
#include <unordered_map>
+#include <unordered_set>
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
# include "GLFW/glfw3.h"
@@ -856,7 +857,7 @@
return mBackendAdapter;
}
-std::vector<const char*> DawnTestBase::GetRequiredFeatures() {
+std::vector<wgpu::FeatureName> DawnTestBase::GetRequiredFeatures() {
return {};
}
@@ -875,19 +876,25 @@
return *reinterpret_cast<wgpu::SupportedLimits*>(&supportedLimits);
}
-bool DawnTestBase::SupportsFeatures(const std::vector<const char*>& features) {
+bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& features) {
ASSERT(mBackendAdapter);
- std::set<std::string> supportedFeaturesSet;
- for (const char* supportedFeatureName : mBackendAdapter.GetSupportedFeatures()) {
- supportedFeaturesSet.insert(supportedFeatureName);
+ std::vector<wgpu::FeatureName> supportedFeatures;
+ uint32_t count =
+ dawn_native::GetProcs().adapterEnumerateFeatures(mBackendAdapter.Get(), nullptr);
+ supportedFeatures.resize(count);
+ dawn_native::GetProcs().adapterEnumerateFeatures(
+ mBackendAdapter.Get(), reinterpret_cast<WGPUFeatureName*>(&supportedFeatures[0]));
+
+ std::unordered_set<wgpu::FeatureName> supportedSet;
+ for (wgpu::FeatureName f : supportedFeatures) {
+ supportedSet.insert(f);
}
- for (const char* featureName : features) {
- if (supportedFeaturesSet.find(featureName) == supportedFeaturesSet.end()) {
+ for (wgpu::FeatureName f : features) {
+ if (supportedSet.count(f) == 0) {
return false;
}
}
-
return true;
}
@@ -922,33 +929,45 @@
for (const char* forceDisabledWorkaround : mParam.forceDisabledWorkarounds) {
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceDisabledWorkaround) != nullptr);
}
- dawn_native::DawnDeviceDescriptor deviceDescriptor = {};
- deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds;
- deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds;
- deviceDescriptor.requiredFeatures = GetRequiredFeatures();
+
+ std::vector<const char*> forceEnabledToggles = mParam.forceEnabledWorkarounds;
+ std::vector<const char*> forceDisabledToggles = mParam.forceDisabledWorkarounds;
+
+ std::vector<wgpu::FeatureName> requiredFeatures = GetRequiredFeatures();
wgpu::SupportedLimits supportedLimits;
mBackendAdapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits));
wgpu::RequiredLimits requiredLimits = GetRequiredLimits(supportedLimits);
- deviceDescriptor.requiredLimits = reinterpret_cast<WGPURequiredLimits*>(&requiredLimits);
// Disabled disallowing unsafe APIs so we can test them.
- deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
+ forceDisabledToggles.push_back("disallow_unsafe_apis");
for (const std::string& toggle : gTestEnv->GetEnabledToggles()) {
const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr);
- deviceDescriptor.forceEnabledToggles.push_back(info->name);
+ forceEnabledToggles.push_back(info->name);
}
for (const std::string& toggle : gTestEnv->GetDisabledToggles()) {
const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr);
- deviceDescriptor.forceDisabledToggles.push_back(info->name);
+ forceDisabledToggles.push_back(info->name);
}
+ wgpu::DeviceDescriptor deviceDescriptor = {};
+ deviceDescriptor.requiredLimits = &requiredLimits;
+ deviceDescriptor.requiredFeatures = requiredFeatures.data();
+ deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();
+
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
+ deviceDescriptor.nextInChain = &togglesDesc;
+ togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
+ togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
+ togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
+ togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
+
std::tie(device, backendDevice) =
mWireHelper->RegisterDevice(mBackendAdapter.CreateDevice(&deviceDescriptor));
ASSERT_NE(nullptr, backendDevice);
diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h
index c38d6ee..8f96aff 100644
--- a/src/tests/DawnTest.h
+++ b/src/tests/DawnTest.h
@@ -509,13 +509,13 @@
void FlushWire();
void WaitForAllOperations();
- bool SupportsFeatures(const std::vector<const char*>& features);
+ bool SupportsFeatures(const std::vector<wgpu::FeatureName>& features);
// Called in SetUp() to get the features required to be enabled in the tests. The tests must
// check if the required features are supported by the adapter in this function and guarantee
// the returned features are all supported by the adapter. The tests may provide different
// code path to handle the situation when not all features are supported.
- virtual std::vector<const char*> GetRequiredFeatures();
+ virtual std::vector<wgpu::FeatureName> GetRequiredFeatures();
virtual wgpu::RequiredLimits GetRequiredLimits(const wgpu::SupportedLimits&);
diff --git a/src/tests/end2end/BufferZeroInitTests.cpp b/src/tests/end2end/BufferZeroInitTests.cpp
index 63df6b8..76f51fe 100644
--- a/src/tests/end2end/BufferZeroInitTests.cpp
+++ b/src/tests/end2end/BufferZeroInitTests.cpp
@@ -46,10 +46,10 @@
class BufferZeroInitTest : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- std::vector<const char*> requiredFeatures = {};
- if (SupportsFeatures({"timestamp-query"})) {
- requiredFeatures.push_back("timestamp-query");
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> requiredFeatures = {};
+ if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
+ requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
}
return requiredFeatures;
}
@@ -1316,7 +1316,7 @@
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsAMD());
// Skip if timestamp feature is not supported on device
- DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"timestamp-query"}));
+ DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::TimestampQuery}));
// crbug.com/dawn/940: Does not work on Mac 11.0+. Backend validation changed.
DAWN_TEST_UNSUPPORTED_IF(IsMacOS() && !IsMacOS(10));
diff --git a/src/tests/end2end/CompressedTextureFormatTests.cpp b/src/tests/end2end/CompressedTextureFormatTests.cpp
index 70b90a2..69f5a7a 100644
--- a/src/tests/end2end/CompressedTextureFormatTests.cpp
+++ b/src/tests/end2end/CompressedTextureFormatTests.cpp
@@ -40,19 +40,22 @@
class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
const wgpu::TextureFormat format = GetParam().mTextureFormat;
- if (utils::IsBCTextureFormat(format) && SupportsFeatures({"texture-compression-bc"})) {
+ if (utils::IsBCTextureFormat(format) &&
+ SupportsFeatures({wgpu::FeatureName::TextureCompressionBC})) {
mIsFormatSupported = true;
- return {"texture-compression-bc"};
+ return {wgpu::FeatureName::TextureCompressionBC};
}
- if (utils::IsETC2TextureFormat(format) && SupportsFeatures({"texture-compression-etc2"})) {
+ if (utils::IsETC2TextureFormat(format) &&
+ SupportsFeatures({wgpu::FeatureName::TextureCompressionETC2})) {
mIsFormatSupported = true;
- return {"texture-compression-etc2"};
+ return {wgpu::FeatureName::TextureCompressionETC2};
}
- if (utils::IsASTCTextureFormat(format) && SupportsFeatures({"texture-compression-astc"})) {
+ if (utils::IsASTCTextureFormat(format) &&
+ SupportsFeatures({wgpu::FeatureName::TextureCompressionASTC})) {
mIsFormatSupported = true;
- return {"texture-compression-astc"};
+ return {wgpu::FeatureName::TextureCompressionASTC};
}
return {};
}
@@ -1149,12 +1152,12 @@
// Suite of regression tests that target specific compression types.
class CompressedTextureFormatSpecificTest : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"});
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
- std::vector<const char*> features;
+ std::vector<wgpu::FeatureName> features;
if (mIsBCFormatSupported) {
- features.emplace_back("texture-compression-bc");
+ features.emplace_back(wgpu::FeatureName::TextureCompressionBC);
}
return features;
}
diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp
index 9e7aae1..1907ffd 100644
--- a/src/tests/end2end/CopyTests.cpp
+++ b/src/tests/end2end/CopyTests.cpp
@@ -331,8 +331,8 @@
class CopyTests_T2T : public CopyTests, public DawnTestWithParams<CopyTestsParams> {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- return {"dawn-internal-usages"};
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ return {wgpu::FeatureName::DawnInternalUsages};
}
void DoTest(const TextureSpec& srcSpec,
diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
index 3c1ffd0..34f7a58 100644
--- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp
+++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
@@ -29,8 +29,8 @@
class D3D12ResourceTestBase : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- return {"dawn-internal-usages"};
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ return {wgpu::FeatureName::DawnInternalUsages};
}
public:
diff --git a/src/tests/end2end/DeviceInitializationTests.cpp b/src/tests/end2end/DeviceInitializationTests.cpp
index e379300..0eb1795 100644
--- a/src/tests/end2end/DeviceInitializationTests.cpp
+++ b/src/tests/end2end/DeviceInitializationTests.cpp
@@ -61,8 +61,7 @@
properties.adapterType == desiredProperties.adapterType &&
properties.backendType == desiredProperties.backendType) {
// Create the device, destroy the instance, and break out of the loop.
- dawn_native::DawnDeviceDescriptor deviceDescriptor = {};
- device = wgpu::Device::Acquire(adapter.CreateDevice(&deviceDescriptor));
+ device = wgpu::Device::Acquire(adapter.CreateDevice());
instance.reset();
break;
}
diff --git a/src/tests/end2end/NonzeroTextureCreationTests.cpp b/src/tests/end2end/NonzeroTextureCreationTests.cpp
index 63c1a39..957fe02 100644
--- a/src/tests/end2end/NonzeroTextureCreationTests.cpp
+++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp
@@ -75,17 +75,17 @@
protected:
constexpr static uint32_t kSize = 128;
- std::vector<const char*> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
if (GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
- SupportsFeatures({"texture-compression-bc"})) {
- return {"texture-compression-bc"};
+ SupportsFeatures({wgpu::FeatureName::TextureCompressionBC})) {
+ return {wgpu::FeatureName::TextureCompressionBC};
}
return {};
}
void Run() {
DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
- !SupportsFeatures({"texture-compression-bc"}));
+ !SupportsFeatures({wgpu::FeatureName::TextureCompressionBC}));
// TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support
// reading from Snorm textures.
diff --git a/src/tests/end2end/PrimitiveStateTests.cpp b/src/tests/end2end/PrimitiveStateTests.cpp
index 5bf00b7..4741b91 100644
--- a/src/tests/end2end/PrimitiveStateTests.cpp
+++ b/src/tests/end2end/PrimitiveStateTests.cpp
@@ -24,7 +24,7 @@
protected:
void SetUp() override {
DawnTest::SetUp();
- DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"depth-clamping"}));
+ DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::DepthClamping}));
wgpu::TextureDescriptor renderTargetDescriptor;
renderTargetDescriptor.size = {kRTSize, kRTSize};
@@ -67,10 +67,10 @@
})");
}
- std::vector<const char*> GetRequiredFeatures() override {
- std::vector<const char*> requiredFeatures = {};
- if (SupportsFeatures({"depth-clamping"})) {
- requiredFeatures.push_back("depth-clamping");
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> requiredFeatures = {};
+ if (SupportsFeatures({wgpu::FeatureName::DepthClamping})) {
+ requiredFeatures.push_back(wgpu::FeatureName::DepthClamping);
}
return requiredFeatures;
}
diff --git a/src/tests/end2end/QueryTests.cpp b/src/tests/end2end/QueryTests.cpp
index 6a6708d..57e6624 100644
--- a/src/tests/end2end/QueryTests.cpp
+++ b/src/tests/end2end/QueryTests.cpp
@@ -454,13 +454,13 @@
DawnTest::SetUp();
// Skip all tests if pipeline statistics feature is not supported
- DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"pipeline-statistics-query"}));
+ DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::PipelineStatisticsQuery}));
}
- std::vector<const char*> GetRequiredFeatures() override {
- std::vector<const char*> requiredFeatures = {};
- if (SupportsFeatures({"pipeline-statistics-query"})) {
- requiredFeatures.push_back("pipeline-statistics-query");
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> requiredFeatures = {};
+ if (SupportsFeatures({wgpu::FeatureName::PipelineStatisticsQuery})) {
+ requiredFeatures.push_back(wgpu::FeatureName::PipelineStatisticsQuery);
}
return requiredFeatures;
@@ -523,13 +523,13 @@
DawnTest::SetUp();
// Skip all tests if timestamp feature is not supported
- DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({"timestamp-query"}));
+ DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::TimestampQuery}));
}
- std::vector<const char*> GetRequiredFeatures() override {
- std::vector<const char*> requiredFeatures = {};
- if (SupportsFeatures({"timestamp-query"})) {
- requiredFeatures.push_back("timestamp-query");
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> requiredFeatures = {};
+ if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
+ requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
}
return requiredFeatures;
}
diff --git a/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp b/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp
index ccc07ce..c31a322 100644
--- a/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp
+++ b/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp
@@ -34,19 +34,19 @@
uint32_t stencilRefValue;
};
- std::vector<const char*> GetRequiredFeatures() override {
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
switch (GetParam().mTextureFormat) {
case wgpu::TextureFormat::Depth24UnormStencil8:
- if (SupportsFeatures({"depth24unorm-stencil8"})) {
+ if (SupportsFeatures({wgpu::FeatureName::Depth24UnormStencil8})) {
mIsFormatSupported = true;
- return {"depth24unorm-stencil8"};
+ return {wgpu::FeatureName::Depth24UnormStencil8};
}
return {};
case wgpu::TextureFormat::Depth32FloatStencil8:
- if (SupportsFeatures({"depth32float-stencil8"})) {
+ if (SupportsFeatures({wgpu::FeatureName::Depth32FloatStencil8})) {
mIsFormatSupported = true;
- return {"depth32float-stencil8"};
+ return {wgpu::FeatureName::Depth32FloatStencil8};
}
return {};
diff --git a/src/tests/end2end/ShaderFloat16Tests.cpp b/src/tests/end2end/ShaderFloat16Tests.cpp
index f284070..e059c9f 100644
--- a/src/tests/end2end/ShaderFloat16Tests.cpp
+++ b/src/tests/end2end/ShaderFloat16Tests.cpp
@@ -19,13 +19,13 @@
class ShaderFloat16Tests : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- mIsShaderFloat16Supported = SupportsFeatures({"shader-float16"});
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ mIsShaderFloat16Supported = SupportsFeatures({wgpu::FeatureName::DawnShaderFloat16});
if (!mIsShaderFloat16Supported) {
return {};
}
- return {"shader-float16"};
+ return {wgpu::FeatureName::DawnShaderFloat16};
}
bool IsShaderFloat16Supported() const {
diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp
index 55f7b53..98c69c5 100644
--- a/src/tests/end2end/TextureZeroInitTests.cpp
+++ b/src/tests/end2end/TextureZeroInitTests.cpp
@@ -1719,13 +1719,13 @@
DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported());
}
- std::vector<const char*> GetRequiredFeatures() override {
- mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"});
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
if (!mIsBCFormatSupported) {
return {};
}
- return {"texture-compression-bc"};
+ return {wgpu::FeatureName::TextureCompressionBC};
}
bool IsBCFormatSupported() const {
diff --git a/src/tests/end2end/VideoViewsTests.cpp b/src/tests/end2end/VideoViewsTests.cpp
index b640ea0..2b07ba0 100644
--- a/src/tests/end2end/VideoViewsTests.cpp
+++ b/src/tests/end2end/VideoViewsTests.cpp
@@ -45,13 +45,13 @@
DawnTest::TearDown();
}
-std::vector<const char*> VideoViewsTests::GetRequiredFeatures() {
- std::vector<const char*> requiredFeatures = {};
- mIsMultiPlanarFormatsSupported = SupportsFeatures({"multiplanar-formats"});
+std::vector<wgpu::FeatureName> VideoViewsTests::GetRequiredFeatures() {
+ std::vector<wgpu::FeatureName> requiredFeatures = {};
+ mIsMultiPlanarFormatsSupported = SupportsFeatures({wgpu::FeatureName::DawnMultiPlanarFormats});
if (mIsMultiPlanarFormatsSupported) {
- requiredFeatures.push_back("multiplanar-formats");
+ requiredFeatures.push_back(wgpu::FeatureName::DawnMultiPlanarFormats);
}
- requiredFeatures.push_back("dawn-internal-usages");
+ requiredFeatures.push_back(wgpu::FeatureName::DawnInternalUsages);
return requiredFeatures;
}
diff --git a/src/tests/end2end/VideoViewsTests.h b/src/tests/end2end/VideoViewsTests.h
index c286d37..c0527b0 100644
--- a/src/tests/end2end/VideoViewsTests.h
+++ b/src/tests/end2end/VideoViewsTests.h
@@ -78,7 +78,7 @@
protected:
void SetUp() override;
void TearDown() override;
- std::vector<const char*> GetRequiredFeatures() override;
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override;
bool IsMultiPlanarFormatsSupported() const;
wgpu::ShaderModule GetTestVertexShaderModule() const;
diff --git a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
index 6303771..7f57c7d 100644
--- a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
+++ b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
@@ -419,8 +419,11 @@
class CopyCommandTest_B2T : public CopyCommandTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
+ wgpu::FeatureName::Depth32FloatStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor);
}
};
@@ -1000,8 +1003,11 @@
class CopyCommandTest_T2B : public CopyCommandTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
+ wgpu::FeatureName::Depth32FloatStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor);
}
};
@@ -1633,8 +1639,11 @@
class CopyCommandTest_T2T : public CopyCommandTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
+ wgpu::FeatureName::Depth32FloatStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor);
}
};
@@ -2076,9 +2085,12 @@
class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
- "texture-compression-astc"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
+ wgpu::FeatureName::TextureCompressionETC2,
+ wgpu::FeatureName::TextureCompressionASTC};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor);
}
diff --git a/src/tests/unittests/validation/InternalUsageValidationTests.cpp b/src/tests/unittests/validation/InternalUsageValidationTests.cpp
index 33f5323..49ebc24 100644
--- a/src/tests/unittests/validation/InternalUsageValidationTests.cpp
+++ b/src/tests/unittests/validation/InternalUsageValidationTests.cpp
@@ -44,9 +44,10 @@
class TextureInternalUsageValidationTest : public ValidationTest {
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures.push_back("dawn-internal-usages");
-
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnInternalUsages};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
diff --git a/src/tests/unittests/validation/QueryValidationTests.cpp b/src/tests/unittests/validation/QueryValidationTests.cpp
index 49d0fb6..51fcdd1 100644
--- a/src/tests/unittests/validation/QueryValidationTests.cpp
+++ b/src/tests/unittests/validation/QueryValidationTests.cpp
@@ -225,9 +225,17 @@
class TimestampQueryValidationTest : public QuerySetValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures.push_back("timestamp-query");
- descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TimestampQuery};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
+
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
+ togglesDesc.forceDisabledToggles = forceDisabledToggles;
+ togglesDesc.forceDisabledTogglesCount = 1;
+
return adapter.CreateDevice(&descriptor);
}
};
@@ -429,11 +437,19 @@
class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures.push_back("pipeline-statistics-query");
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::PipelineStatisticsQuery};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
+
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
// unsafe APIs to test it.
- descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
+ togglesDesc.forceDisabledToggles = forceDisabledToggles;
+ togglesDesc.forceDisabledTogglesCount = 1;
+
return adapter.CreateDevice(&descriptor);
}
};
diff --git a/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp b/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp
index 863e80e..d55be2f 100644
--- a/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp
+++ b/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp
@@ -557,9 +557,12 @@
class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
- "texture-compression-astc"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
+ wgpu::FeatureName::TextureCompressionETC2,
+ wgpu::FeatureName::TextureCompressionASTC};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor);
}
diff --git a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp
index ea403d8..b53378f 100644
--- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp
+++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp
@@ -1172,8 +1172,10 @@
class DepthClampingValidationTest : public RenderPipelineValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth-clamping"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DepthClamping};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
diff --git a/src/tests/unittests/validation/RequestDeviceValidationTests.cpp b/src/tests/unittests/validation/RequestDeviceValidationTests.cpp
index 57ddc76..b8bb1c8 100644
--- a/src/tests/unittests/validation/RequestDeviceValidationTests.cpp
+++ b/src/tests/unittests/validation/RequestDeviceValidationTests.cpp
@@ -58,7 +58,7 @@
// Test that requesting a device without specifying limits is valid.
TEST_F(RequestDeviceValidationTest, NoRequiredLimits) {
- dawn_native::DawnDeviceDescriptor descriptor;
+ wgpu::DeviceDescriptor descriptor;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) {
// Check one of the default limits.
@@ -71,8 +71,8 @@
// Test that requesting a device with the default limits is valid.
TEST_F(RequestDeviceValidationTest, DefaultLimits) {
wgpu::RequiredLimits limits = {};
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
+ wgpu::DeviceDescriptor descriptor;
+ descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) {
// Check one of the default limits.
@@ -85,8 +85,8 @@
// Test that requesting a device where a required limit is above the maximum value.
TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
wgpu::RequiredLimits limits = {};
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
+ wgpu::DeviceDescriptor descriptor;
+ descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@@ -138,8 +138,8 @@
// Test that requesting a device where a required limit is below the minimum value.
TEST_F(RequestDeviceValidationTest, LowerIsBetter) {
wgpu::RequiredLimits limits = {};
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
+ wgpu::DeviceDescriptor descriptor;
+ descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@@ -199,7 +199,7 @@
wgpu::RequiredLimits limits = {};
limits.nextInChain = &depthClamp;
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
+ wgpu::DeviceDescriptor descriptor;
+ descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
}
diff --git a/src/tests/unittests/validation/TextureValidationTests.cpp b/src/tests/unittests/validation/TextureValidationTests.cpp
index 053e9f7..1835cd5 100644
--- a/src/tests/unittests/validation/TextureValidationTests.cpp
+++ b/src/tests/unittests/validation/TextureValidationTests.cpp
@@ -597,8 +597,10 @@
class D24S8TextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth24unorm-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
@@ -617,8 +619,10 @@
class D32S8TextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth32float-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
@@ -639,9 +643,12 @@
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
- "texture-compression-astc"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
+ wgpu::FeatureName::TextureCompressionETC2,
+ wgpu::FeatureName::TextureCompressionASTC};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor);
}
diff --git a/src/tests/unittests/validation/TextureViewValidationTests.cpp b/src/tests/unittests/validation/TextureViewValidationTests.cpp
index 51c531a..2bae28d 100644
--- a/src/tests/unittests/validation/TextureViewValidationTests.cpp
+++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp
@@ -652,8 +652,10 @@
class D24S8TextureViewValidationTests : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth24unorm-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
@@ -696,8 +698,10 @@
class D32S8TextureViewValidationTests : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"depth32float-stencil8"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
diff --git a/src/tests/unittests/validation/ToggleValidationTests.cpp b/src/tests/unittests/validation/ToggleValidationTests.cpp
index de8155c..9a8b22a 100644
--- a/src/tests/unittests/validation/ToggleValidationTests.cpp
+++ b/src/tests/unittests/validation/ToggleValidationTests.cpp
@@ -43,8 +43,11 @@
// Create device with a valid name of a toggle
{
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.forceEnabledToggles.push_back(kValidToggleName);
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ togglesDesc.forceEnabledToggles = &kValidToggleName;
+ togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
@@ -60,8 +63,11 @@
// Create device with an invalid toggle name
{
const char* kInvalidToggleName = "!@#$%^&*";
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.forceEnabledToggles.push_back(kInvalidToggleName);
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ togglesDesc.forceEnabledToggles = &kInvalidToggleName;
+ togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
@@ -77,8 +83,11 @@
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
const char* kValidToggleName = "turn_off_vsync";
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.forceEnabledToggles.push_back(kValidToggleName);
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ togglesDesc.forceEnabledToggles = &kValidToggleName;
+ togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
diff --git a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
index 43cddfa..e1ab1ae 100644
--- a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
+++ b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp
@@ -22,8 +22,12 @@
class UnsafeAPIValidationTest : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ const char* toggle = "disallow_unsafe_apis";
+ togglesDesc.forceEnabledToggles = &toggle;
+ togglesDesc.forceEnabledTogglesCount = 1;
return adapter.CreateDevice(&descriptor);
}
};
@@ -71,10 +75,18 @@
class UnsafeQueryAPIValidationTest : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures.push_back("pipeline-statistics-query");
- descriptor.requiredFeatures.push_back("timestamp-query");
- descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::PipelineStatisticsQuery,
+ wgpu::FeatureName::TimestampQuery};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 2;
+
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ descriptor.nextInChain = &togglesDesc;
+ const char* toggle = "disallow_unsafe_apis";
+ togglesDesc.forceEnabledToggles = &toggle;
+ togglesDesc.forceEnabledTogglesCount = 1;
+
return adapter.CreateDevice(&descriptor);
}
};
diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp
index 669a056..f7bb69b 100644
--- a/src/tests/unittests/validation/ValidationTest.cpp
+++ b/src/tests/unittests/validation/ValidationTest.cpp
@@ -195,17 +195,26 @@
WGPUDevice ValidationTest::CreateTestDevice() {
// Disabled disallowing unsafe APIs so we can test them.
- dawn_native::DawnDeviceDescriptor deviceDescriptor;
- deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
+ std::vector<const char*> forceEnabledToggles;
+ std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) {
- deviceDescriptor.forceEnabledToggles.push_back(toggle.c_str());
+ forceEnabledToggles.push_back(toggle.c_str());
}
for (const std::string& toggle : gToggleParser->GetDisabledToggles()) {
- deviceDescriptor.forceDisabledToggles.push_back(toggle.c_str());
+ forceDisabledToggles.push_back(toggle.c_str());
}
+ wgpu::DeviceDescriptor deviceDescriptor;
+ wgpu::DawnTogglesDeviceDescriptor togglesDesc;
+ deviceDescriptor.nextInChain = &togglesDesc;
+
+ togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
+ togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
+ togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
+ togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
+
return adapter.CreateDevice(&deviceDescriptor);
}
diff --git a/src/tests/unittests/validation/VideoViewsValidationTests.cpp b/src/tests/unittests/validation/VideoViewsValidationTests.cpp
index b5f38bb..8f028e7 100644
--- a/src/tests/unittests/validation/VideoViewsValidationTests.cpp
+++ b/src/tests/unittests/validation/VideoViewsValidationTests.cpp
@@ -21,8 +21,10 @@
class VideoViewsValidation : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
- dawn_native::DawnDeviceDescriptor descriptor;
- descriptor.requiredFeatures = {"multiplanar-formats"};
+ wgpu::DeviceDescriptor descriptor;
+ wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnMultiPlanarFormats};
+ descriptor.requiredFeatures = requiredFeatures;
+ descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor);
}
diff --git a/src/tests/white_box/D3D12ResourceHeapTests.cpp b/src/tests/white_box/D3D12ResourceHeapTests.cpp
index e944ce2..8f1155b 100644
--- a/src/tests/white_box/D3D12ResourceHeapTests.cpp
+++ b/src/tests/white_box/D3D12ResourceHeapTests.cpp
@@ -26,13 +26,13 @@
DAWN_TEST_UNSUPPORTED_IF(UsesWire());
}
- std::vector<const char*> GetRequiredFeatures() override {
- mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"});
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
if (!mIsBCFormatSupported) {
return {};
}
- return {"texture-compression-bc"};
+ return {wgpu::FeatureName::TextureCompressionBC};
}
bool IsBCFormatSupported() const {
diff --git a/src/tests/white_box/EGLImageWrappingTests.cpp b/src/tests/white_box/EGLImageWrappingTests.cpp
index be94756..eb88a7c 100644
--- a/src/tests/white_box/EGLImageWrappingTests.cpp
+++ b/src/tests/white_box/EGLImageWrappingTests.cpp
@@ -115,8 +115,8 @@
class EGLImageTestBase : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- return {"dawn-internal-usages"};
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ return {wgpu::FeatureName::DawnInternalUsages};
}
public:
diff --git a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
index 830d5fd..9786c6a 100644
--- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
+++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
@@ -34,8 +34,8 @@
class VulkanImageWrappingTestBase : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- return {"dawn-internal-usages"};
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ return {wgpu::FeatureName::DawnInternalUsages};
}
public:
diff --git a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
index 74c551a..1bf503e 100644
--- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
+++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
@@ -31,8 +31,8 @@
class VulkanImageWrappingTestBase : public DawnTest {
protected:
- std::vector<const char*> GetRequiredFeatures() override {
- return {"dawn-internal-usages"};
+ std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
+ return {wgpu::FeatureName::DawnInternalUsages};
}
public: