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

View File

@ -168,23 +168,24 @@ namespace wgpu { namespace binding {
interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevice(
Napi::Env env,
interop::GPUDeviceDescriptor descriptor) {
dawn_native::DawnDeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in.
wgpu::DeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in.
interop::Promise<interop::Interface<interop::GPUDevice>> promise(env, PROMISE_INFO);
std::vector<wgpu::FeatureName> requiredFeatures;
// See src/dawn_native/Features.cpp for enum <-> string mappings.
for (auto required : descriptor.requiredFeatures) {
switch (required) {
case interop::GPUFeatureName::kDepthClamping:
desc.requiredFeatures.emplace_back("depth-clamping");
requiredFeatures.emplace_back(wgpu::FeatureName::DepthClamping);
continue;
case interop::GPUFeatureName::kPipelineStatisticsQuery:
desc.requiredFeatures.emplace_back("pipeline-statistics-query");
requiredFeatures.emplace_back(wgpu::FeatureName::PipelineStatisticsQuery);
continue;
case interop::GPUFeatureName::kTextureCompressionBc:
desc.requiredFeatures.emplace_back("texture-compression-bc");
requiredFeatures.emplace_back(wgpu::FeatureName::TextureCompressionBC);
continue;
case interop::GPUFeatureName::kTimestampQuery:
desc.requiredFeatures.emplace_back("timestamp-query");
requiredFeatures.emplace_back(wgpu::FeatureName::TimestampQuery);
continue;
case interop::GPUFeatureName::kDepth24UnormStencil8:
case interop::GPUFeatureName::kDepth32FloatStencil8:
@ -194,24 +195,36 @@ 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<std::string> enabledToggles;
std::vector<std::string> disabledToggles;
std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles;
if (auto values = flags_.Get("enable-dawn-features")) {
enabledToggles = Split(*values, ',');
for (auto& t : enabledToggles) {
desc.forceEnabledToggles.emplace_back(t.c_str());
forceEnabledToggles.emplace_back(t.c_str());
}
}
if (auto values = flags_.Get("disable-dawn-features")) {
disabledToggles = Split(*values, ',');
for (auto& t : disabledToggles) {
desc.forceDisabledToggles.emplace_back(t.c_str());
forceDisabledToggles.emplace_back(t.c_str());
}
}
desc.requiredFeaturesCount = requiredFeatures.size();
desc.requiredFeatures = requiredFeatures.data();
wgpu::DawnDeviceTogglesDescriptor togglesDesc = {};
desc.nextInChain = &togglesDesc;
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
auto wgpu_device = adapter_.CreateDevice(&desc);
if (wgpu_device) {
promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device));

View File

@ -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;

View File

@ -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);
}

View File

@ -37,6 +37,7 @@
#include <regex>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
# include "GLFW/glfw3.h"
@ -856,7 +857,7 @@ dawn_native::Adapter DawnTestBase::GetAdapter() const {
return mBackendAdapter;
}
std::vector<const char*> DawnTestBase::GetRequiredFeatures() {
std::vector<wgpu::FeatureName> DawnTestBase::GetRequiredFeatures() {
return {};
}
@ -875,19 +876,25 @@ wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() {
return *reinterpret_cast<wgpu::SupportedLimits*>(&supportedLimits);
}
bool DawnTestBase::SupportsFeatures(const std::vector<const char*>& features) {
bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& features) {
ASSERT(mBackendAdapter);
std::set<std::string> supportedFeaturesSet;
for (const char* supportedFeatureName : mBackendAdapter.GetSupportedFeatures()) {
supportedFeaturesSet.insert(supportedFeatureName);
std::vector<wgpu::FeatureName> supportedFeatures;
uint32_t count =
dawn_native::GetProcs().adapterEnumerateFeatures(mBackendAdapter.Get(), nullptr);
supportedFeatures.resize(count);
dawn_native::GetProcs().adapterEnumerateFeatures(
mBackendAdapter.Get(), reinterpret_cast<WGPUFeatureName*>(&supportedFeatures[0]));
std::unordered_set<wgpu::FeatureName> supportedSet;
for (wgpu::FeatureName f : supportedFeatures) {
supportedSet.insert(f);
}
for (const char* featureName : features) {
if (supportedFeaturesSet.find(featureName) == supportedFeaturesSet.end()) {
for (wgpu::FeatureName f : features) {
if (supportedSet.count(f) == 0) {
return false;
}
}
return true;
}
@ -922,33 +929,45 @@ 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<const char*> forceEnabledToggles = mParam.forceEnabledWorkarounds;
std::vector<const char*> forceDisabledToggles = mParam.forceDisabledWorkarounds;
std::vector<wgpu::FeatureName> requiredFeatures = GetRequiredFeatures();
wgpu::SupportedLimits supportedLimits;
mBackendAdapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits));
wgpu::RequiredLimits requiredLimits = GetRequiredLimits(supportedLimits);
deviceDescriptor.requiredLimits = reinterpret_cast<WGPURequiredLimits*>(&requiredLimits);
// Disabled disallowing unsafe APIs so we can test them.
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
forceDisabledToggles.push_back("disallow_unsafe_apis");
for (const std::string& toggle : gTestEnv->GetEnabledToggles()) {
const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr);
deviceDescriptor.forceEnabledToggles.push_back(info->name);
forceEnabledToggles.push_back(info->name);
}
for (const std::string& toggle : gTestEnv->GetDisabledToggles()) {
const dawn_native::ToggleInfo* info =
gTestEnv->GetInstance()->GetToggleInfo(toggle.c_str());
ASSERT(info != nullptr);
deviceDescriptor.forceDisabledToggles.push_back(info->name);
forceDisabledToggles.push_back(info->name);
}
wgpu::DeviceDescriptor deviceDescriptor = {};
deviceDescriptor.requiredLimits = &requiredLimits;
deviceDescriptor.requiredFeatures = requiredFeatures.data();
deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();
wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
deviceDescriptor.nextInChain = &togglesDesc;
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
std::tie(device, backendDevice) =
mWireHelper->RegisterDevice(mBackendAdapter.CreateDevice(&deviceDescriptor));
ASSERT_NE(nullptr, backendDevice);

View File

@ -509,13 +509,13 @@ class DawnTestBase {
void FlushWire();
void WaitForAllOperations();
bool SupportsFeatures(const std::vector<const char*>& features);
bool SupportsFeatures(const std::vector<wgpu::FeatureName>& features);
// Called in SetUp() to get the features required to be enabled in the tests. The tests must
// check if the required features are supported by the adapter in this function and guarantee
// the returned features are all supported by the adapter. The tests may provide different
// code path to handle the situation when not all features are supported.
virtual std::vector<const char*> GetRequiredFeatures();
virtual std::vector<wgpu::FeatureName> GetRequiredFeatures();
virtual wgpu::RequiredLimits GetRequiredLimits(const wgpu::SupportedLimits&);

View File

@ -46,10 +46,10 @@ namespace {
class BufferZeroInitTest : public DawnTest {
protected:
std::vector<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {};
if (SupportsFeatures({"timestamp-query"})) {
requiredFeatures.push_back("timestamp-query");
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
}
return requiredFeatures;
}
@ -1316,7 +1316,7 @@ 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));

View File

@ -40,19 +40,22 @@ namespace {
class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> {
protected:
std::vector<const char*> GetRequiredFeatures() override {
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
const wgpu::TextureFormat format = GetParam().mTextureFormat;
if (utils::IsBCTextureFormat(format) && SupportsFeatures({"texture-compression-bc"})) {
if (utils::IsBCTextureFormat(format) &&
SupportsFeatures({wgpu::FeatureName::TextureCompressionBC})) {
mIsFormatSupported = true;
return {"texture-compression-bc"};
return {wgpu::FeatureName::TextureCompressionBC};
}
if (utils::IsETC2TextureFormat(format) && SupportsFeatures({"texture-compression-etc2"})) {
if (utils::IsETC2TextureFormat(format) &&
SupportsFeatures({wgpu::FeatureName::TextureCompressionETC2})) {
mIsFormatSupported = true;
return {"texture-compression-etc2"};
return {wgpu::FeatureName::TextureCompressionETC2};
}
if (utils::IsASTCTextureFormat(format) && SupportsFeatures({"texture-compression-astc"})) {
if (utils::IsASTCTextureFormat(format) &&
SupportsFeatures({wgpu::FeatureName::TextureCompressionASTC})) {
mIsFormatSupported = true;
return {"texture-compression-astc"};
return {wgpu::FeatureName::TextureCompressionASTC};
}
return {};
}
@ -1149,12 +1152,12 @@ DAWN_INSTANTIATE_TEST_P(CompressedTextureFormatTest,
// Suite of regression tests that target specific compression types.
class CompressedTextureFormatSpecificTest : public DawnTest {
protected:
std::vector<const char*> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsFeatures({"texture-compression-bc"});
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
mIsBCFormatSupported = SupportsFeatures({wgpu::FeatureName::TextureCompressionBC});
std::vector<const char*> features;
std::vector<wgpu::FeatureName> features;
if (mIsBCFormatSupported) {
features.emplace_back("texture-compression-bc");
features.emplace_back(wgpu::FeatureName::TextureCompressionBC);
}
return features;
}

View File

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

View File

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

View File

@ -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;
}

View File

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

View File

@ -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<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {};
if (SupportsFeatures({"depth-clamping"})) {
requiredFeatures.push_back("depth-clamping");
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({wgpu::FeatureName::DepthClamping})) {
requiredFeatures.push_back(wgpu::FeatureName::DepthClamping);
}
return requiredFeatures;
}

View File

@ -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<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {};
if (SupportsFeatures({"pipeline-statistics-query"})) {
requiredFeatures.push_back("pipeline-statistics-query");
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({wgpu::FeatureName::PipelineStatisticsQuery})) {
requiredFeatures.push_back(wgpu::FeatureName::PipelineStatisticsQuery);
}
return requiredFeatures;
@ -523,13 +523,13 @@ 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<const char*> GetRequiredFeatures() override {
std::vector<const char*> requiredFeatures = {};
if (SupportsFeatures({"timestamp-query"})) {
requiredFeatures.push_back("timestamp-query");
std::vector<wgpu::FeatureName> GetRequiredFeatures() override {
std::vector<wgpu::FeatureName> requiredFeatures = {};
if (SupportsFeatures({wgpu::FeatureName::TimestampQuery})) {
requiredFeatures.push_back(wgpu::FeatureName::TimestampQuery);
}
return requiredFeatures;
}

View File

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

View File

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

View File

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

View File

@ -45,13 +45,13 @@ void VideoViewsTests::TearDown() {
DawnTest::TearDown();
}
std::vector<const char*> VideoViewsTests::GetRequiredFeatures() {
std::vector<const char*> requiredFeatures = {};
mIsMultiPlanarFormatsSupported = SupportsFeatures({"multiplanar-formats"});
std::vector<wgpu::FeatureName> VideoViewsTests::GetRequiredFeatures() {
std::vector<wgpu::FeatureName> requiredFeatures = {};
mIsMultiPlanarFormatsSupported = SupportsFeatures({wgpu::FeatureName::DawnMultiPlanarFormats});
if (mIsMultiPlanarFormatsSupported) {
requiredFeatures.push_back("multiplanar-formats");
requiredFeatures.push_back(wgpu::FeatureName::DawnMultiPlanarFormats);
}
requiredFeatures.push_back("dawn-internal-usages");
requiredFeatures.push_back(wgpu::FeatureName::DawnInternalUsages);
return requiredFeatures;
}

View File

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

View File

@ -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);
}

View File

@ -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);
}
};

View File

@ -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);
}
};

View File

@ -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);
}

View File

@ -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);
}
};

View File

@ -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<const WGPURequiredLimits*>(&limits);
wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) {
// Check one of the default limits.
@ -85,8 +85,8 @@ TEST_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<const WGPURequiredLimits*>(&limits);
wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@ -138,8 +138,8 @@ TEST_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<const WGPURequiredLimits*>(&limits);
wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = &limits;
wgpu::SupportedLimits supportedLimits;
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
@ -199,7 +199,7 @@ TEST_F(RequestDeviceValidationTest, InvalidChainedStruct) {
wgpu::RequiredLimits limits = {};
limits.nextInChain = &depthClamp;
dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
wgpu::DeviceDescriptor descriptor;
descriptor.requiredLimits = &limits;
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
}

View File

@ -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);
}

View File

@ -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);
}
};

View File

@ -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<const char*> 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<const char*> 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<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);

View File

@ -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);
}
};

View File

@ -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<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) {
deviceDescriptor.forceEnabledToggles.push_back(toggle.c_str());
forceEnabledToggles.push_back(toggle.c_str());
}
for (const std::string& toggle : gToggleParser->GetDisabledToggles()) {
deviceDescriptor.forceDisabledToggles.push_back(toggle.c_str());
forceDisabledToggles.push_back(toggle.c_str());
}
wgpu::DeviceDescriptor deviceDescriptor;
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
deviceDescriptor.nextInChain = &togglesDesc;
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
return adapter.CreateDevice(&deviceDescriptor);
}

View File

@ -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);
}

View File

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

View File

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

View File

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

View File

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