diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index 86a6bb4653..03afef264a 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -168,6 +168,10 @@ namespace dawn_native { return ToAPI(mImpl->APICreateDevice(&desc)); } + WGPUDevice Adapter::CreateDevice(const wgpu::DeviceDescriptor* deviceDescriptor) { + return CreateDevice(reinterpret_cast(deviceDescriptor)); + } + WGPUDevice Adapter::CreateDevice(const WGPUDeviceDescriptor* deviceDescriptor) { return ToAPI(mImpl->APICreateDevice(FromAPI(deviceDescriptor))); } @@ -179,6 +183,20 @@ namespace dawn_native { mImpl->APIRequestDevice(&desc, callback, userdata); } + void Adapter::RequestDevice(const wgpu::DeviceDescriptor* descriptor, + WGPURequestDeviceCallback callback, + void* userdata) { + mImpl->APIRequestDevice(reinterpret_cast(descriptor), callback, + userdata); + } + + void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor, + WGPURequestDeviceCallback callback, + void* userdata) { + mImpl->APIRequestDevice(reinterpret_cast(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 c9a6edb42e..4b4def5232 100644 --- a/src/dawn_node/binding/GPUAdapter.cpp +++ b/src/dawn_node/binding/GPUAdapter.cpp @@ -168,23 +168,24 @@ namespace wgpu { namespace binding { interop::Promise> 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> promise(env, PROMISE_INFO); + std::vector 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 @@ namespace wgpu { namespace binding { } // 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 enabledToggles; std::vector disabledToggles; + std::vector forceEnabledToggles; + std::vector 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(env, env, wgpu_device)); diff --git a/src/include/dawn_native/DawnNative.h b/src/include/dawn_native/DawnNative.h index fb2bd7861c..79f6fa7afe 100644 --- a/src/include/dawn_native/DawnNative.h +++ b/src/include/dawn_native/DawnNative.h @@ -28,6 +28,7 @@ namespace dawn_platform { namespace wgpu { struct AdapterProperties; + struct DeviceDescriptor; } namespace dawn_native { @@ -123,11 +124,18 @@ namespace dawn_native { // 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 0e4705348d..20d7146ea7 100644 --- a/src/tests/DawnNativeTest.cpp +++ b/src/tests/DawnNativeTest.cpp @@ -70,8 +70,13 @@ void DawnNativeTest::TearDown() { 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 490b2cad23..2955e30f16 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #if defined(DAWN_ENABLE_BACKEND_OPENGL) # include "GLFW/glfw3.h" @@ -856,7 +857,7 @@ dawn_native::Adapter DawnTestBase::GetAdapter() const { return mBackendAdapter; } -std::vector DawnTestBase::GetRequiredFeatures() { +std::vector DawnTestBase::GetRequiredFeatures() { return {}; } @@ -875,19 +876,25 @@ wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() { return *reinterpret_cast(&supportedLimits); } -bool DawnTestBase::SupportsFeatures(const std::vector& features) { +bool DawnTestBase::SupportsFeatures(const std::vector& features) { ASSERT(mBackendAdapter); - std::set supportedFeaturesSet; - for (const char* supportedFeatureName : mBackendAdapter.GetSupportedFeatures()) { - supportedFeaturesSet.insert(supportedFeatureName); + std::vector supportedFeatures; + uint32_t count = + dawn_native::GetProcs().adapterEnumerateFeatures(mBackendAdapter.Get(), nullptr); + supportedFeatures.resize(count); + dawn_native::GetProcs().adapterEnumerateFeatures( + mBackendAdapter.Get(), reinterpret_cast(&supportedFeatures[0])); + + std::unordered_set 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 @@ void DawnTestBase::SetUp() { 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 forceEnabledToggles = mParam.forceEnabledWorkarounds; + std::vector forceDisabledToggles = mParam.forceDisabledWorkarounds; + + std::vector requiredFeatures = GetRequiredFeatures(); wgpu::SupportedLimits supportedLimits; mBackendAdapter.GetLimits(reinterpret_cast(&supportedLimits)); wgpu::RequiredLimits requiredLimits = GetRequiredLimits(supportedLimits); - deviceDescriptor.requiredLimits = reinterpret_cast(&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 c38d6ee620..8f96aff99c 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -509,13 +509,13 @@ class DawnTestBase { void FlushWire(); void WaitForAllOperations(); - bool SupportsFeatures(const std::vector& features); + bool SupportsFeatures(const std::vector& 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 GetRequiredFeatures(); + virtual std::vector GetRequiredFeatures(); virtual wgpu::RequiredLimits GetRequiredLimits(const wgpu::SupportedLimits&); diff --git a/src/tests/end2end/BufferZeroInitTests.cpp b/src/tests/end2end/BufferZeroInitTests.cpp index 63df6b8c52..76f51fecae 100644 --- a/src/tests/end2end/BufferZeroInitTests.cpp +++ b/src/tests/end2end/BufferZeroInitTests.cpp @@ -46,10 +46,10 @@ namespace { class BufferZeroInitTest : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - std::vector requiredFeatures = {}; - if (SupportsFeatures({"timestamp-query"})) { - requiredFeatures.push_back("timestamp-query"); + std::vector GetRequiredFeatures() override { + std::vector requiredFeatures = {}; + if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) { + requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery); } return requiredFeatures; } @@ -1316,7 +1316,7 @@ TEST_P(BufferZeroInitTest, ResolveQuerySet) { 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 70b90a24ed..69f5a7afc9 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -40,19 +40,22 @@ namespace { class CompressedTextureFormatTest : public DawnTestWithParams { protected: - std::vector GetRequiredFeatures() override { + std::vector 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 @@ DAWN_INSTANTIATE_TEST_P(CompressedTextureFormatTest, // Suite of regression tests that target specific compression types. class CompressedTextureFormatSpecificTest : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); + std::vector GetRequiredFeatures() override { + mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC}); - std::vector features; + std::vector 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 9e7aae1854..1907ffd301 100644 --- a/src/tests/end2end/CopyTests.cpp +++ b/src/tests/end2end/CopyTests.cpp @@ -331,8 +331,8 @@ namespace { class CopyTests_T2T : public CopyTests, public DawnTestWithParams { protected: - std::vector GetRequiredFeatures() override { - return {"dawn-internal-usages"}; + std::vector 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 3c1ffd0ed8..34f7a58941 100644 --- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp +++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp @@ -29,8 +29,8 @@ namespace { class D3D12ResourceTestBase : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - return {"dawn-internal-usages"}; + std::vector GetRequiredFeatures() override { + return {wgpu::FeatureName::DawnInternalUsages}; } public: diff --git a/src/tests/end2end/DeviceInitializationTests.cpp b/src/tests/end2end/DeviceInitializationTests.cpp index e379300bfa..0eb1795473 100644 --- a/src/tests/end2end/DeviceInitializationTests.cpp +++ b/src/tests/end2end/DeviceInitializationTests.cpp @@ -61,8 +61,7 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) { 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 63c1a39052..957fe02adc 100644 --- a/src/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp @@ -75,17 +75,17 @@ namespace { protected: constexpr static uint32_t kSize = 128; - std::vector GetRequiredFeatures() override { + std::vector 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 5bf00b740c..4741b91ad5 100644 --- a/src/tests/end2end/PrimitiveStateTests.cpp +++ b/src/tests/end2end/PrimitiveStateTests.cpp @@ -24,7 +24,7 @@ class DepthClampingTest : public DawnTest { 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 @@ class DepthClampingTest : public DawnTest { })"); } - std::vector GetRequiredFeatures() override { - std::vector requiredFeatures = {}; - if (SupportsFeatures({"depth-clamping"})) { - requiredFeatures.push_back("depth-clamping"); + std::vector GetRequiredFeatures() override { + std::vector 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 6a6708d881..57e6624eb9 100644 --- a/src/tests/end2end/QueryTests.cpp +++ b/src/tests/end2end/QueryTests.cpp @@ -454,13 +454,13 @@ class PipelineStatisticsQueryTests : public QueryTests { 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 GetRequiredFeatures() override { - std::vector requiredFeatures = {}; - if (SupportsFeatures({"pipeline-statistics-query"})) { - requiredFeatures.push_back("pipeline-statistics-query"); + std::vector GetRequiredFeatures() override { + std::vector requiredFeatures = {}; + if (SupportsFeatures({wgpu::FeatureName::PipelineStatisticsQuery})) { + requiredFeatures.push_back(wgpu::FeatureName::PipelineStatisticsQuery); } return requiredFeatures; @@ -523,13 +523,13 @@ class TimestampQueryTests : public QueryTests { 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 GetRequiredFeatures() override { - std::vector requiredFeatures = {}; - if (SupportsFeatures({"timestamp-query"})) { - requiredFeatures.push_back("timestamp-query"); + std::vector GetRequiredFeatures() override { + std::vector 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 ccc07cef5a..c31a322fe4 100644 --- a/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp +++ b/src/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp @@ -34,19 +34,19 @@ class ReadOnlyDepthStencilAttachmentTests uint32_t stencilRefValue; }; - std::vector GetRequiredFeatures() override { + std::vector 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 f284070e46..e059c9fd3c 100644 --- a/src/tests/end2end/ShaderFloat16Tests.cpp +++ b/src/tests/end2end/ShaderFloat16Tests.cpp @@ -19,13 +19,13 @@ class ShaderFloat16Tests : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - mIsShaderFloat16Supported = SupportsFeatures({"shader-float16"}); + std::vector 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 55f7b53fd4..98c69c5e71 100644 --- a/src/tests/end2end/TextureZeroInitTests.cpp +++ b/src/tests/end2end/TextureZeroInitTests.cpp @@ -1719,13 +1719,13 @@ class CompressedTextureZeroInitTest : public TextureZeroInitTest { DAWN_TEST_UNSUPPORTED_IF(!IsBCFormatSupported()); } - std::vector GetRequiredFeatures() override { - mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); + std::vector 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 b640ea07d4..2b07ba0674 100644 --- a/src/tests/end2end/VideoViewsTests.cpp +++ b/src/tests/end2end/VideoViewsTests.cpp @@ -45,13 +45,13 @@ void VideoViewsTests::TearDown() { DawnTest::TearDown(); } -std::vector VideoViewsTests::GetRequiredFeatures() { - std::vector requiredFeatures = {}; - mIsMultiPlanarFormatsSupported = SupportsFeatures({"multiplanar-formats"}); +std::vector VideoViewsTests::GetRequiredFeatures() { + std::vector 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 c286d37810..c0527b0983 100644 --- a/src/tests/end2end/VideoViewsTests.h +++ b/src/tests/end2end/VideoViewsTests.h @@ -78,7 +78,7 @@ class VideoViewsTests : public DawnTest { protected: void SetUp() override; void TearDown() override; - std::vector GetRequiredFeatures() override; + std::vector 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 63037714da..7f57c7dc1a 100644 --- a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp +++ b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp @@ -419,8 +419,11 @@ TEST_F(CopyCommandTest_B2B, CopyWithinSameBuffer) { 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 @@ TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) { 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 @@ TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) { 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 @@ TEST_F(CopyCommandTest_T2T, CopyWithinSameTexture) { 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 33f5323c2b..49ebc24fc8 100644 --- a/src/tests/unittests/validation/InternalUsageValidationTests.cpp +++ b/src/tests/unittests/validation/InternalUsageValidationTests.cpp @@ -44,9 +44,10 @@ TEST_F(TextureInternalUsageValidationDisabledTest, RequiresFeature) { 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 49d0fb6dff..51fcdd16aa 100644 --- a/src/tests/unittests/validation/QueryValidationTests.cpp +++ b/src/tests/unittests/validation/QueryValidationTests.cpp @@ -225,9 +225,17 @@ TEST_F(OcclusionQueryValidationTest, InvalidBeginAndEnd) { 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 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnRenderPassEncoder) { 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 863e80ec40..d55be2f1c9 100644 --- a/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp +++ b/src/tests/unittests/validation/QueueWriteTextureValidationTests.cpp @@ -557,9 +557,12 @@ namespace { 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 ea403d83ee..b53378fd92 100644 --- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -1172,8 +1172,10 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) { 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 57ddc76e48..b8bb1c8313 100644 --- a/src/tests/unittests/validation/RequestDeviceValidationTests.cpp +++ b/src/tests/unittests/validation/RequestDeviceValidationTests.cpp @@ -58,7 +58,7 @@ class RequestDeviceValidationTest : public ValidationTest { // 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_F(RequestDeviceValidationTest, NoRequiredLimits) { // 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(&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_F(RequestDeviceValidationTest, DefaultLimits) { // 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(&limits); + wgpu::DeviceDescriptor descriptor; + descriptor.requiredLimits = &limits; wgpu::SupportedLimits supportedLimits; EXPECT_TRUE(adapter.GetLimits(reinterpret_cast(&supportedLimits))); @@ -138,8 +138,8 @@ TEST_F(RequestDeviceValidationTest, HigherIsBetter) { // 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(&limits); + wgpu::DeviceDescriptor descriptor; + descriptor.requiredLimits = &limits; wgpu::SupportedLimits supportedLimits; EXPECT_TRUE(adapter.GetLimits(reinterpret_cast(&supportedLimits))); @@ -199,7 +199,7 @@ TEST_F(RequestDeviceValidationTest, InvalidChainedStruct) { wgpu::RequiredLimits limits = {}; limits.nextInChain = &depthClamp; - dawn_native::DawnDeviceDescriptor descriptor; - descriptor.requiredLimits = reinterpret_cast(&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 053e9f71f6..1835cd5206 100644 --- a/src/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/tests/unittests/validation/TextureValidationTests.cpp @@ -597,8 +597,10 @@ namespace { 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 @@ namespace { 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 @@ namespace { 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 51c531aec8..2bae28d1c2 100644 --- a/src/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp @@ -652,8 +652,10 @@ namespace { 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 @@ namespace { 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 de8155ca69..9a8b22ae1e 100644 --- a/src/tests/unittests/validation/ToggleValidationTests.cpp +++ b/src/tests/unittests/validation/ToggleValidationTests.cpp @@ -43,8 +43,11 @@ namespace { // 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 toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); @@ -60,8 +63,11 @@ namespace { // 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 toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); @@ -77,8 +83,11 @@ namespace { 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 toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); diff --git a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp index 43cddfab02..e1ab1ae1d6 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 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) { 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 669a056fb6..f7bb69b1e6 100644 --- a/src/tests/unittests/validation/ValidationTest.cpp +++ b/src/tests/unittests/validation/ValidationTest.cpp @@ -195,17 +195,26 @@ wgpu::SupportedLimits ValidationTest::GetSupportedLimits() { 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 forceEnabledToggles; + std::vector 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 b5f38bb77a..8f028e7dac 100644 --- a/src/tests/unittests/validation/VideoViewsValidationTests.cpp +++ b/src/tests/unittests/validation/VideoViewsValidationTests.cpp @@ -21,8 +21,10 @@ namespace { 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 e944ce2f35..8f1155bf5e 100644 --- a/src/tests/white_box/D3D12ResourceHeapTests.cpp +++ b/src/tests/white_box/D3D12ResourceHeapTests.cpp @@ -26,13 +26,13 @@ class D3D12ResourceHeapTests : public DawnTest { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); } - std::vector GetRequiredFeatures() override { - mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"}); + std::vector 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 be94756b98..eb88a7c359 100644 --- a/src/tests/white_box/EGLImageWrappingTests.cpp +++ b/src/tests/white_box/EGLImageWrappingTests.cpp @@ -115,8 +115,8 @@ namespace { class EGLImageTestBase : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - return {"dawn-internal-usages"}; + std::vector GetRequiredFeatures() override { + return {wgpu::FeatureName::DawnInternalUsages}; } public: diff --git a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp index 830d5fde3f..9786c6ab0f 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp @@ -34,8 +34,8 @@ namespace dawn_native { namespace vulkan { class VulkanImageWrappingTestBase : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - return {"dawn-internal-usages"}; + std::vector GetRequiredFeatures() override { + return {wgpu::FeatureName::DawnInternalUsages}; } public: diff --git a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp index 74c551a9b6..1bf503e382 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp @@ -31,8 +31,8 @@ namespace dawn_native { namespace vulkan { class VulkanImageWrappingTestBase : public DawnTest { protected: - std::vector GetRequiredFeatures() override { - return {"dawn-internal-usages"}; + std::vector GetRequiredFeatures() override { + return {wgpu::FeatureName::DawnInternalUsages}; } public: