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>
This commit is contained in:
Austin Eng 2021-12-22 19:04:33 +00:00 committed by Dawn LUCI CQ
parent 2f218e2b21
commit dc518772c6
35 changed files with 300 additions and 158 deletions

View File

@ -168,6 +168,10 @@ namespace dawn_native {
return ToAPI(mImpl->APICreateDevice(&desc)); 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) { WGPUDevice Adapter::CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor) {
return ToAPI(mImpl->APICreateDevice(FromAPI(deviceDescriptor))); return ToAPI(mImpl->APICreateDevice(FromAPI(deviceDescriptor)));
} }
@ -179,6 +183,20 @@ namespace dawn_native {
mImpl->APIRequestDevice(&desc, callback, userdata); 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() { void Adapter::ResetInternalDeviceForTesting() {
mImpl->ResetInternalDeviceForTesting(); mImpl->ResetInternalDeviceForTesting();
} }

View File

@ -168,23 +168,24 @@ namespace wgpu { namespace binding {
interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevice( interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevice(
Napi::Env env, Napi::Env env,
interop::GPUDeviceDescriptor descriptor) { 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); 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. // 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.requiredFeatures.emplace_back("depth-clamping"); requiredFeatures.emplace_back(wgpu::FeatureName::DepthClamping);
continue; continue;
case interop::GPUFeatureName::kPipelineStatisticsQuery: case interop::GPUFeatureName::kPipelineStatisticsQuery:
desc.requiredFeatures.emplace_back("pipeline-statistics-query"); requiredFeatures.emplace_back(wgpu::FeatureName::PipelineStatisticsQuery);
continue; continue;
case interop::GPUFeatureName::kTextureCompressionBc: case interop::GPUFeatureName::kTextureCompressionBc:
desc.requiredFeatures.emplace_back("texture-compression-bc"); requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionBC);
continue; continue;
case interop::GPUFeatureName::kTimestampQuery: case interop::GPUFeatureName::kTimestampQuery:
desc.requiredFeatures.emplace_back("timestamp-query"); requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery);
continue; continue;
case interop::GPUFeatureName::kDepth24UnormStencil8: case interop::GPUFeatureName::kDepth24UnormStencil8:
case interop::GPUFeatureName::kDepth32FloatStencil8: case interop::GPUFeatureName::kDepth32FloatStencil8:
@ -194,24 +195,36 @@ namespace wgpu { namespace binding {
} }
// Propogate enabled/disabled dawn features // Propogate enabled/disabled dawn features
// Note: DawnDeviceDescriptor::forceEnabledToggles and forceDisabledToggles are vectors of // Note: DawnDeviceTogglesDescriptor::forceEnabledToggles and forceDisabledToggles are
// 'const char*', so we make sure the parsed strings survive the CreateDevice() call by // vectors of 'const char*', so we make sure the parsed strings survive the CreateDevice()
// storing them on the stack. // call by storing them on the stack.
std::vector<std::string> enabledToggles; std::vector<std::string> enabledToggles;
std::vector<std::string> disabledToggles; std::vector<std::string> disabledToggles;
std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles;
if (auto values = flags_.Get("enable-dawn-features")) { if (auto values = flags_.Get("enable-dawn-features")) {
enabledToggles = Split(*values, ','); enabledToggles = Split(*values, ',');
for (auto& t : enabledToggles) { 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")) { if (auto values = flags_.Get("disable-dawn-features")) {
disabledToggles = Split(*values, ','); disabledToggles = Split(*values, ',');
for (auto& t : disabledToggles) { 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); auto wgpu_device = adapter_.CreateDevice(&desc);
if (wgpu_device) { if (wgpu_device) {
promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device)); promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device));

View File

@ -28,6 +28,7 @@ namespace dawn_platform {
namespace wgpu { namespace wgpu {
struct AdapterProperties; struct AdapterProperties;
struct DeviceDescriptor;
} }
namespace dawn_native { namespace dawn_native {
@ -123,11 +124,18 @@ namespace dawn_native {
// Create a device on this adapter. On an error, nullptr is returned. // Create a device on this adapter. On an error, nullptr is returned.
WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor); WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor);
WGPUDevice CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor);
WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr); WGPUDevice CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor = nullptr);
void RequestDevice(const DawnDeviceDescriptor* descriptor, void RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback, WGPURequestDeviceCallback callback,
void* userdata); 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. // Returns the underlying WGPUAdapter object.
WGPUAdapter Get() const; WGPUAdapter Get() const;

View File

@ -70,8 +70,13 @@ void DawnNativeTest::TearDown() {
WGPUDevice DawnNativeTest::CreateTestDevice() { WGPUDevice DawnNativeTest::CreateTestDevice() {
// Disabled disallowing unsafe APIs so we can test them. // Disabled disallowing unsafe APIs so we can test them.
dawn_native::DawnDeviceDescriptor deviceDescriptor; wgpu::DeviceDescriptor deviceDescriptor = {};
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
deviceDescriptor.nextInChain = &togglesDesc;
const char* toggle = "disallow_unsafe_apis";
togglesDesc.forceDisabledToggles = &toggle;
togglesDesc.forceDisabledTogglesCount = 1;
return adapter.CreateDevice(&deviceDescriptor); return adapter.CreateDevice(&deviceDescriptor);
} }

View File

@ -37,6 +37,7 @@
#include <regex> #include <regex>
#include <sstream> #include <sstream>
#include <unordered_map> #include <unordered_map>
#include <unordered_set>
#if defined(DAWN_ENABLE_BACKEND_OPENGL) #if defined(DAWN_ENABLE_BACKEND_OPENGL)
# include "GLFW/glfw3.h" # include "GLFW/glfw3.h"
@ -856,7 +857,7 @@ dawn_native::Adapter DawnTestBase::GetAdapter() const {
return mBackendAdapter; return mBackendAdapter;
} }
std::vector<const char*> DawnTestBase::GetRequiredFeatures() { std::vector<wgpu::FeatureName> DawnTestBase::GetRequiredFeatures() {
return {}; return {};
} }
@ -875,19 +876,25 @@ wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() {
return *reinterpret_cast<wgpu::SupportedLimits*>(&supportedLimits); 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); ASSERT(mBackendAdapter);
std::set<std::string> supportedFeaturesSet; std::vector<wgpu::FeatureName> supportedFeatures;
for (const char* supportedFeatureName : mBackendAdapter.GetSupportedFeatures()) { uint32_t count =
supportedFeaturesSet.insert(supportedFeatureName); 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) { for (wgpu::FeatureName f : features) {
if (supportedFeaturesSet.find(featureName) == supportedFeaturesSet.end()) { if (supportedSet.count(f) == 0) {
return false; return false;
} }
} }
return true; return true;
} }
@ -922,33 +929,45 @@ void DawnTestBase::SetUp() {
for (const char* forceDisabledWorkaround : mParam.forceDisabledWorkarounds) { for (const char* forceDisabledWorkaround : mParam.forceDisabledWorkarounds) {
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceDisabledWorkaround) != nullptr); ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceDisabledWorkaround) != nullptr);
} }
dawn_native::DawnDeviceDescriptor deviceDescriptor = {};
deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds; std::vector<const char*> forceEnabledToggles = mParam.forceEnabledWorkarounds;
deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds; std::vector<const char*> forceDisabledToggles = mParam.forceDisabledWorkarounds;
deviceDescriptor.requiredFeatures = GetRequiredFeatures();
std::vector<wgpu::FeatureName> requiredFeatures = GetRequiredFeatures();
wgpu::SupportedLimits supportedLimits; wgpu::SupportedLimits supportedLimits;
mBackendAdapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)); mBackendAdapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits));
wgpu::RequiredLimits requiredLimits = GetRequiredLimits(supportedLimits); wgpu::RequiredLimits requiredLimits = GetRequiredLimits(supportedLimits);
deviceDescriptor.requiredLimits = reinterpret_cast<WGPURequiredLimits*>(&requiredLimits);
// 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"); forceDisabledToggles.push_back("disallow_unsafe_apis");
for (const std::string& toggle : gTestEnv->GetEnabledToggles()) { for (const std::string& toggle : gTestEnv->GetEnabledToggles()) {
const dawn_native::ToggleInfo* info = const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str()); gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr); ASSERT(info != nullptr);
deviceDescriptor.forceEnabledToggles.push_back(info->name); forceEnabledToggles.push_back(info->name);
} }
for (const std::string& toggle : gTestEnv->GetDisabledToggles()) { for (const std::string& toggle : gTestEnv->GetDisabledToggles()) {
const dawn_native::ToggleInfo* info = const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str()); gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr); 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) = std::tie(device, backendDevice) =
mWireHelper->RegisterDevice(mBackendAdapter.CreateDevice(&deviceDescriptor)); mWireHelper->RegisterDevice(mBackendAdapter.CreateDevice(&deviceDescriptor));
ASSERT_NE(nullptr, backendDevice); ASSERT_NE(nullptr, backendDevice);

View File

@ -509,13 +509,13 @@ class DawnTestBase {
void FlushWire(); void FlushWire();
void WaitForAllOperations(); 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 // 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 // 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 // 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. // 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&); virtual wgpu::RequiredLimits GetRequiredLimits(const wgpu::SupportedLimits&);

View File

@ -46,10 +46,10 @@ namespace {
class BufferZeroInitTest : public DawnTest { class BufferZeroInitTest : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {}; std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({"timestamp-query"})) { if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
requiredFeatures.push_back("timestamp-query"); requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
} }
return requiredFeatures; return requiredFeatures;
} }
@ -1316,7 +1316,7 @@ TEST_P(BufferZeroInitTest, ResolveQuerySet) {
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsAMD()); DAWN_SUPPRESS_TEST_IF(IsMetal() && IsAMD());
// Skip if timestamp feature is not supported on device // 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. // 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,22 @@ namespace {
class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> { class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> {
protected: protected:
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
const wgpu::TextureFormat format = GetParam().mTextureFormat; const wgpu::TextureFormat format = GetParam().mTextureFormat;
if (utils::IsBCTextureFormat(format) && SupportsFeatures({"texture-compression-bc"})) { if (utils::IsBCTextureFormat(format) &&
SupportsFeatures({wgpu::FeatureName::TextureCompressionBC})) {
mIsFormatSupported = true; 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; 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; mIsFormatSupported = true;
return {"texture-compression-astc"}; return {wgpu::FeatureName::TextureCompressionASTC};
} }
return {}; return {};
} }
@ -1149,12 +1152,12 @@ 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*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
std::vector<const char*> features; std::vector<wgpu::FeatureName> features;
if (mIsBCFormatSupported) { if (mIsBCFormatSupported) {
features.emplace_back("texture-compression-bc"); features.emplace_back(wgpu::FeatureName::TextureCompressionBC);
} }
return features; return features;
} }

View File

@ -331,8 +331,8 @@ namespace {
class CopyTests_T2T : public CopyTests, public DawnTestWithParams<CopyTestsParams> { class CopyTests_T2T : public CopyTests, public DawnTestWithParams<CopyTestsParams> {
protected: protected:
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
return {"dawn-internal-usages"}; return {wgpu::FeatureName::DawnInternalUsages};
} }
void DoTest(const TextureSpec& srcSpec, void DoTest(const TextureSpec& srcSpec,

View File

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

View File

@ -61,8 +61,7 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) {
properties.adapterType == desiredProperties.adapterType && properties.adapterType == desiredProperties.adapterType &&
properties.backendType == desiredProperties.backendType) { properties.backendType == desiredProperties.backendType) {
// Create the device, destroy the instance, and break out of the loop. // Create the device, destroy the instance, and break out of the loop.
dawn_native::DawnDeviceDescriptor deviceDescriptor = {}; device = wgpu::Device::Acquire(adapter.CreateDevice());
device = wgpu::Device::Acquire(adapter.CreateDevice(&deviceDescriptor));
instance.reset(); instance.reset();
break; break;
} }

View File

@ -75,17 +75,17 @@ namespace {
protected: protected:
constexpr static uint32_t kSize = 128; constexpr static uint32_t kSize = 128;
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
if (GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && if (GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm &&
SupportsFeatures({"texture-compression-bc"})) { SupportsFeatures({wgpu::FeatureName::TextureCompressionBC})) {
return {"texture-compression-bc"}; return {wgpu::FeatureName::TextureCompressionBC};
} }
return {}; return {};
} }
void Run() { void Run() {
DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && 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 // TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support
// reading from Snorm textures. // reading from Snorm textures.

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(!SupportsFeatures({"depth-clamping"})); DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::DepthClamping}));
wgpu::TextureDescriptor renderTargetDescriptor; wgpu::TextureDescriptor renderTargetDescriptor;
renderTargetDescriptor.size = {kRTSize, kRTSize}; renderTargetDescriptor.size = {kRTSize, kRTSize};
@ -67,10 +67,10 @@ class DepthClampingTest : public DawnTest {
})"); })");
} }
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {}; std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({"depth-clamping"})) { if (SupportsFeatures({wgpu::FeatureName::DepthClamping})) {
requiredFeatures.push_back("depth-clamping"); requiredFeatures.push_back(wgpu::FeatureName::DepthClamping);
} }
return requiredFeatures; return requiredFeatures;
} }

View File

@ -454,13 +454,13 @@ class PipelineStatisticsQueryTests : public QueryTests {
DawnTest::SetUp(); DawnTest::SetUp();
// Skip all tests if pipeline statistics feature is not supported // 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<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {}; std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({"pipeline-statistics-query"})) { if (SupportsFeatures({wgpu::FeatureName::PipelineStatisticsQuery})) {
requiredFeatures.push_back("pipeline-statistics-query"); requiredFeatures.push_back(wgpu::FeatureName::PipelineStatisticsQuery);
} }
return requiredFeatures; return requiredFeatures;
@ -523,13 +523,13 @@ class TimestampQueryTests : public QueryTests {
DawnTest::SetUp(); DawnTest::SetUp();
// Skip all tests if timestamp feature is not supported // 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<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {}; std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({"timestamp-query"})) { if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
requiredFeatures.push_back("timestamp-query"); requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
} }
return requiredFeatures; return requiredFeatures;
} }

View File

@ -34,19 +34,19 @@ class ReadOnlyDepthStencilAttachmentTests
uint32_t stencilRefValue; uint32_t stencilRefValue;
}; };
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
switch (GetParam().mTextureFormat) { switch (GetParam().mTextureFormat) {
case wgpu::TextureFormat::Depth24UnormStencil8: case wgpu::TextureFormat::Depth24UnormStencil8:
if (SupportsFeatures({"depth24unorm-stencil8"})) { if (SupportsFeatures({wgpu::FeatureName::Depth24UnormStencil8})) {
mIsFormatSupported = true; mIsFormatSupported = true;
return {"depth24unorm-stencil8"}; return {wgpu::FeatureName::Depth24UnormStencil8};
} }
return {}; return {};
case wgpu::TextureFormat::Depth32FloatStencil8: case wgpu::TextureFormat::Depth32FloatStencil8:
if (SupportsFeatures({"depth32float-stencil8"})) { if (SupportsFeatures({wgpu::FeatureName::Depth32FloatStencil8})) {
mIsFormatSupported = true; mIsFormatSupported = true;
return {"depth32float-stencil8"}; return {wgpu::FeatureName::Depth32FloatStencil8};
} }
return {}; return {};

View File

@ -19,13 +19,13 @@
class ShaderFloat16Tests : public DawnTest { class ShaderFloat16Tests : public DawnTest {
protected: protected:
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
mIsShaderFloat16Supported = SupportsFeatures({"shader-float16"}); mIsShaderFloat16Supported = SupportsFeatures({wgpu::FeatureName::DawnShaderFloat16});
if (!mIsShaderFloat16Supported) { if (!mIsShaderFloat16Supported) {
return {}; return {};
} }
return {"shader-float16"}; return {wgpu::FeatureName::DawnShaderFloat16};
} }
bool IsShaderFloat16Supported() const { bool IsShaderFloat16Supported() const {

View File

@ -1719,13 +1719,13 @@ class CompressedTextureZeroInitTest : public TextureZeroInitTest {
DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported()); DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported());
} }
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
if (!mIsBCFormatSupported) { if (!mIsBCFormatSupported) {
return {}; return {};
} }
return {"texture-compression-bc"}; return {wgpu::FeatureName::TextureCompressionBC};
} }
bool IsBCFormatSupported() const { bool IsBCFormatSupported() const {

View File

@ -45,13 +45,13 @@ void VideoViewsTests::TearDown() {
DawnTest::TearDown(); DawnTest::TearDown();
} }
std::vector<const char*> VideoViewsTests::GetRequiredFeatures() { std::vector<wgpu::FeatureName> VideoViewsTests::GetRequiredFeatures() {
std::vector<const char*> requiredFeatures = {}; std::vector<wgpu::FeatureName> requiredFeatures = {};
mIsMultiPlanarFormatsSupported = SupportsFeatures({"multiplanar-formats"}); mIsMultiPlanarFormatsSupported = SupportsFeatures({wgpu::FeatureName::DawnMultiPlanarFormats});
if (mIsMultiPlanarFormatsSupported) { 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; return requiredFeatures;
} }

View File

@ -78,7 +78,7 @@ class VideoViewsTests : public DawnTest {
protected: protected:
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
std::vector<const char*> GetRequiredFeatures() override; std::vector<wgpu::FeatureName> GetRequiredFeatures() override;
bool IsMultiPlanarFormatsSupported() const; bool IsMultiPlanarFormatsSupported() const;
wgpu::ShaderModule GetTestVertexShaderModule() const; wgpu::ShaderModule GetTestVertexShaderModule() const;

View File

@ -419,8 +419,11 @@ TEST_F(CopyCommandTest_B2B, CopyWithinSameBuffer) {
class CopyCommandTest_B2T : public CopyCommandTest { class CopyCommandTest_B2T : public CopyCommandTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"}; wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
wgpu::FeatureName::Depth32FloatStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -1000,8 +1003,11 @@ TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) {
class CopyCommandTest_T2B : public CopyCommandTest { class CopyCommandTest_T2B : public CopyCommandTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"}; wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
wgpu::FeatureName::Depth32FloatStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -1633,8 +1639,11 @@ TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) {
class CopyCommandTest_T2T : public CopyCommandTest { class CopyCommandTest_T2T : public CopyCommandTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8", "depth32float-stencil8"}; wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
wgpu::FeatureName::Depth32FloatStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 2;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -2076,9 +2085,12 @@ TEST_F(CopyCommandTest_T2T, CopyWithinSameTexture) {
class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest { class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
"texture-compression-astc"}; wgpu::FeatureName::TextureCompressionETC2,
wgpu::FeatureName::TextureCompressionASTC};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -44,9 +44,10 @@ TEST_F(TextureInternalUsageValidationDisabledTest, RequiresFeature) {
class TextureInternalUsageValidationTest : public ValidationTest { class TextureInternalUsageValidationTest : public ValidationTest {
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("dawn-internal-usages"); wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnInternalUsages};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -225,9 +225,17 @@ TEST_F(OcclusionQueryValidationTest, InvalidBeginAndEnd) {
class TimestampQueryValidationTest : public QuerySetValidationTest { class TimestampQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("timestamp-query"); wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TimestampQuery};
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); 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); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -429,11 +437,19 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnRenderPassEncoder) {
class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest { class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("pipeline-statistics-query"); 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 // 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"); wgpu::DawnTogglesDeviceDescriptor togglesDesc;
descriptor.nextInChain = &togglesDesc;
const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
togglesDesc.forceDisabledToggles = forceDisabledToggles;
togglesDesc.forceDisabledTogglesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -557,9 +557,12 @@ namespace {
class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest { class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
"texture-compression-astc"}; wgpu::FeatureName::TextureCompressionETC2,
wgpu::FeatureName::TextureCompressionASTC};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -1172,8 +1172,10 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
class DepthClampingValidationTest : public RenderPipelineValidationTest { class DepthClampingValidationTest : public RenderPipelineValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth-clamping"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DepthClamping};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -58,7 +58,7 @@ class RequestDeviceValidationTest : public ValidationTest {
// Test that requesting a device without specifying limits is valid. // Test that requesting a device without specifying limits is valid.
TEST_F(RequestDeviceValidationTest, NoRequiredLimits) { TEST_F(RequestDeviceValidationTest, NoRequiredLimits) {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess, adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) { CheckDevice([](wgpu::Device device) {
// Check one of the default limits. // Check one of the default limits.
@ -71,8 +71,8 @@ TEST_F(RequestDeviceValidationTest, NoRequiredLimits) {
// Test that requesting a device with the default limits is valid. // Test that requesting a device with the default limits is valid.
TEST_F(RequestDeviceValidationTest, DefaultLimits) { TEST_F(RequestDeviceValidationTest, DefaultLimits) {
wgpu::RequiredLimits limits = {}; wgpu::RequiredLimits limits = {};
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess, adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) { CheckDevice([](wgpu::Device device) {
// Check one of the default limits. // Check one of the default limits.
@ -85,8 +85,8 @@ TEST_F(RequestDeviceValidationTest, DefaultLimits) {
// Test that requesting a device where a required limit is above the maximum value. // Test that requesting a device where a required limit is above the maximum value.
TEST_F(RequestDeviceValidationTest, HigherIsBetter) { TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
wgpu::RequiredLimits limits = {}; wgpu::RequiredLimits limits = {};
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits; wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits))); EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@ -138,8 +138,8 @@ TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
// Test that requesting a device where a required limit is below the minimum value. // Test that requesting a device where a required limit is below the minimum value.
TEST_F(RequestDeviceValidationTest, LowerIsBetter) { TEST_F(RequestDeviceValidationTest, LowerIsBetter) {
wgpu::RequiredLimits limits = {}; wgpu::RequiredLimits limits = {};
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits; wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits))); EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@ -199,7 +199,7 @@ TEST_F(RequestDeviceValidationTest, InvalidChainedStruct) {
wgpu::RequiredLimits limits = {}; wgpu::RequiredLimits limits = {};
limits.nextInChain = &depthClamp; limits.nextInChain = &depthClamp;
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr); adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
} }

View File

@ -597,8 +597,10 @@ namespace {
class D24S8TextureFormatsValidationTests : public TextureValidationTest { class D24S8TextureFormatsValidationTests : public TextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -617,8 +619,10 @@ namespace {
class D32S8TextureFormatsValidationTests : public TextureValidationTest { class D32S8TextureFormatsValidationTests : public TextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth32float-stencil8"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -639,9 +643,12 @@ namespace {
class CompressedTextureFormatsValidationTests : public TextureValidationTest { class CompressedTextureFormatsValidationTests : public TextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
"texture-compression-astc"}; wgpu::FeatureName::TextureCompressionETC2,
wgpu::FeatureName::TextureCompressionASTC};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 3;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -652,8 +652,10 @@ namespace {
class D24S8TextureViewValidationTests : public ValidationTest { class D24S8TextureViewValidationTests : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -696,8 +698,10 @@ namespace {
class D32S8TextureViewValidationTests : public ValidationTest { class D32S8TextureViewValidationTests : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth32float-stencil8"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -43,8 +43,11 @@ namespace {
// Create device with a valid name of a toggle // Create device with a valid name of a toggle
{ {
const char* kValidToggleName = "emulate_store_and_msaa_resolve"; const char* kValidToggleName = "emulate_store_and_msaa_resolve";
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); wgpu::DawnTogglesDeviceDescriptor togglesDesc;
descriptor.nextInChain = &togglesDesc;
togglesDesc.forceEnabledToggles = &kValidToggleName;
togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
@ -60,8 +63,11 @@ namespace {
// Create device with an invalid toggle name // Create device with an invalid toggle name
{ {
const char* kInvalidToggleName = "!@#$%^&*"; const char* kInvalidToggleName = "!@#$%^&*";
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kInvalidToggleName); wgpu::DawnTogglesDeviceDescriptor togglesDesc;
descriptor.nextInChain = &togglesDesc;
togglesDesc.forceEnabledToggles = &kInvalidToggleName;
togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
@ -77,8 +83,11 @@ namespace {
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) { TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
const char* kValidToggleName = "turn_off_vsync"; const char* kValidToggleName = "turn_off_vsync";
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); wgpu::DawnTogglesDeviceDescriptor togglesDesc;
descriptor.nextInChain = &togglesDesc;
togglesDesc.forceEnabledToggles = &kValidToggleName;
togglesDesc.forceEnabledTogglesCount = 1;
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);

View File

@ -22,8 +22,12 @@
class UnsafeAPIValidationTest : public ValidationTest { class UnsafeAPIValidationTest : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis"); wgpu::DawnTogglesDeviceDescriptor togglesDesc;
descriptor.nextInChain = &togglesDesc;
const char* toggle = "disallow_unsafe_apis";
togglesDesc.forceEnabledToggles = &toggle;
togglesDesc.forceEnabledTogglesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -71,10 +75,18 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
class UnsafeQueryAPIValidationTest : public ValidationTest { class UnsafeQueryAPIValidationTest : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("pipeline-statistics-query"); wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::PipelineStatisticsQuery,
descriptor.requiredFeatures.push_back("timestamp-query"); wgpu::FeatureName::TimestampQuery};
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis"); 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); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -195,17 +195,26 @@ wgpu::SupportedLimits ValidationTest::GetSupportedLimits() {
WGPUDevice ValidationTest::CreateTestDevice() { WGPUDevice ValidationTest::CreateTestDevice() {
// Disabled disallowing unsafe APIs so we can test them. // Disabled disallowing unsafe APIs so we can test them.
dawn_native::DawnDeviceDescriptor deviceDescriptor; std::vector<const char*> forceEnabledToggles;
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) { 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()) { 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); return adapter.CreateDevice(&deviceDescriptor);
} }

View File

@ -21,8 +21,10 @@ namespace {
class VideoViewsValidation : public ValidationTest { class VideoViewsValidation : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DawnDeviceDescriptor descriptor; wgpu::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"multiplanar-formats"}; wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnMultiPlanarFormats};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -26,13 +26,13 @@ class D3D12ResourceHeapTests : public DawnTest {
DAWN_TEST_UNSUPPORTED_IF(UsesWire()); DAWN_TEST_UNSUPPORTED_IF(UsesWire());
} }
std::vector<const char*> GetRequiredFeatures() override { std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
if (!mIsBCFormatSupported) { if (!mIsBCFormatSupported) {
return {}; return {};
} }
return {"texture-compression-bc"}; return {wgpu::FeatureName::TextureCompressionBC};
} }
bool IsBCFormatSupported() const { bool IsBCFormatSupported() const {

View File

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

View File

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

View File

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