Rename DeviceDescriptor -> DawnDeviceDescriptor

This is preventing supporting DeviceDescriptor from upstream
webgpu.h because the name conflicts with the existing struct.

A typedef using the original name DeviceDescriptor is added
until all embedders of Dawn are updated to use the new name.

Bug: dawn:160, dawn:689
Change-Id: Ib9cb7443b7e46e3ffe29d2ec109f2f1a831754e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70581
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2021-11-23 18:03:16 +00:00 committed by Dawn LUCI CQ
parent 7e851c91dd
commit 3482a80bdd
40 changed files with 87 additions and 70 deletions

View File

@ -135,7 +135,7 @@ namespace dawn_native {
return true; return true;
} }
DeviceBase* AdapterBase::CreateDevice(const DeviceDescriptor* descriptor) { DeviceBase* AdapterBase::CreateDevice(const DawnDeviceDescriptor* descriptor) {
DeviceBase* result = nullptr; DeviceBase* result = nullptr;
if (mInstance->ConsumedError(CreateDeviceInternal(&result, descriptor))) { if (mInstance->ConsumedError(CreateDeviceInternal(&result, descriptor))) {
@ -145,7 +145,7 @@ namespace dawn_native {
return result; return result;
} }
void AdapterBase::RequestDevice(const DeviceDescriptor* descriptor, void AdapterBase::RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback, WGPURequestDeviceCallback callback,
void* userdata) { void* userdata) {
DeviceBase* result = nullptr; DeviceBase* result = nullptr;
@ -164,7 +164,7 @@ namespace dawn_native {
} }
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result, MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
const DeviceDescriptor* descriptor) { const DawnDeviceDescriptor* descriptor) {
if (descriptor != nullptr) { if (descriptor != nullptr) {
for (const char* featureStr : descriptor->requiredFeatures) { for (const char* featureStr : descriptor->requiredFeatures) {
Feature featureEnum = mInstance->FeatureNameToEnum(featureStr); Feature featureEnum = mInstance->FeatureNameToEnum(featureStr);

View File

@ -41,9 +41,9 @@ namespace dawn_native {
const PCIInfo& GetPCIInfo() const; const PCIInfo& GetPCIInfo() const;
InstanceBase* GetInstance() const; InstanceBase* GetInstance() const;
DeviceBase* CreateDevice(const DeviceDescriptor* descriptor = nullptr); DeviceBase* CreateDevice(const DawnDeviceDescriptor* descriptor = nullptr);
void RequestDevice(const DeviceDescriptor* descriptor, void RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback, WGPURequestDeviceCallback callback,
void* userdata); void* userdata);
@ -66,7 +66,8 @@ namespace dawn_native {
FeaturesSet mSupportedFeatures; FeaturesSet mSupportedFeatures;
private: private:
virtual ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) = 0; virtual ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) = 0;
virtual MaybeError InitializeImpl() = 0; virtual MaybeError InitializeImpl() = 0;
@ -76,7 +77,8 @@ namespace dawn_native {
// Check base WebGPU limits and populate supported limits. // Check base WebGPU limits and populate supported limits.
virtual MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) = 0; virtual MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) = 0;
MaybeError CreateDeviceInternal(DeviceBase** result, const DeviceDescriptor* descriptor); MaybeError CreateDeviceInternal(DeviceBase** result,
const DawnDeviceDescriptor* descriptor);
virtual MaybeError ResetInternalDeviceForTestingImpl(); virtual MaybeError ResetInternalDeviceForTestingImpl();
InstanceBase* mInstance = nullptr; InstanceBase* mInstance = nullptr;

View File

@ -125,11 +125,11 @@ namespace dawn_native {
return mImpl != nullptr; return mImpl != nullptr;
} }
WGPUDevice Adapter::CreateDevice(const DeviceDescriptor* deviceDescriptor) { WGPUDevice Adapter::CreateDevice(const DawnDeviceDescriptor* deviceDescriptor) {
return reinterpret_cast<WGPUDevice>(mImpl->CreateDevice(deviceDescriptor)); return reinterpret_cast<WGPUDevice>(mImpl->CreateDevice(deviceDescriptor));
} }
void Adapter::RequestDevice(const DeviceDescriptor* descriptor, void Adapter::RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback, WGPURequestDeviceCallback callback,
void* userdata) { void* userdata) {
mImpl->RequestDevice(descriptor, callback, userdata); mImpl->RequestDevice(descriptor, callback, userdata);

View File

@ -172,7 +172,7 @@ namespace dawn_native {
// DeviceBase // DeviceBase
DeviceBase::DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor) DeviceBase::DeviceBase(AdapterBase* adapter, const DawnDeviceDescriptor* descriptor)
: mInstance(adapter->GetInstance()), mAdapter(adapter), mNextPipelineCompatibilityToken(1) { : mInstance(adapter->GetInstance()), mAdapter(adapter), mNextPipelineCompatibilityToken(1) {
if (descriptor != nullptr) { if (descriptor != nullptr) {
ApplyToggleOverrides(descriptor); ApplyToggleOverrides(descriptor);
@ -1111,7 +1111,7 @@ namespace dawn_native {
return result.Detach(); return result.Detach();
} }
void DeviceBase::ApplyFeatures(const DeviceDescriptor* deviceDescriptor) { void DeviceBase::ApplyFeatures(const DawnDeviceDescriptor* deviceDescriptor) {
ASSERT(deviceDescriptor); ASSERT(deviceDescriptor);
ASSERT(GetAdapter()->SupportsAllRequestedFeatures(deviceDescriptor->requiredFeatures)); ASSERT(GetAdapter()->SupportsAllRequestedFeatures(deviceDescriptor->requiredFeatures));
@ -1565,7 +1565,7 @@ namespace dawn_native {
SetToggle(Toggle::DisallowUnsafeAPIs, true); SetToggle(Toggle::DisallowUnsafeAPIs, true);
} }
void DeviceBase::ApplyToggleOverrides(const DeviceDescriptor* deviceDescriptor) { void DeviceBase::ApplyToggleOverrides(const DawnDeviceDescriptor* deviceDescriptor) {
ASSERT(deviceDescriptor); ASSERT(deviceDescriptor);
for (const char* toggleName : deviceDescriptor->forceEnabledToggles) { for (const char* toggleName : deviceDescriptor->forceEnabledToggles) {

View File

@ -56,7 +56,7 @@ namespace dawn_native {
class DeviceBase : public RefCounted { class DeviceBase : public RefCounted {
public: public:
DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor); DeviceBase(AdapterBase* adapter, const DawnDeviceDescriptor* descriptor);
virtual ~DeviceBase(); virtual ~DeviceBase();
void HandleError(InternalErrorType type, const char* message); void HandleError(InternalErrorType type, const char* message);
@ -437,8 +437,8 @@ namespace dawn_native {
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);
void ApplyToggleOverrides(const DeviceDescriptor* deviceDescriptor); void ApplyToggleOverrides(const DawnDeviceDescriptor* deviceDescriptor);
void ApplyFeatures(const DeviceDescriptor* deviceDescriptor); void ApplyFeatures(const DawnDeviceDescriptor* deviceDescriptor);
void SetDefaultToggles(); void SetDefaultToggles();

View File

@ -394,7 +394,7 @@ namespace dawn_native { namespace d3d12 {
infoQueue->PopStorageFilter(); infoQueue->PopStorageFilter();
} }
ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) { ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DawnDeviceDescriptor* descriptor) {
return Device::Create(this, descriptor); return Device::Create(this, descriptor);
} }

View File

@ -40,7 +40,8 @@ namespace dawn_native { namespace d3d12 {
const gpu_info::D3DDriverVersion& GetDriverVersion() const; const gpu_info::D3DDriverVersion& GetDriverVersion() const;
private: private:
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override; ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) override;
MaybeError ResetInternalDeviceForTestingImpl() override; MaybeError ResetInternalDeviceForTestingImpl() override;
bool AreTimestampQueriesSupported() const; bool AreTimestampQueriesSupported() const;

View File

@ -52,7 +52,8 @@ namespace dawn_native { namespace d3d12 {
static constexpr uint64_t kMaxDebugMessagesToPrint = 5; static constexpr uint64_t kMaxDebugMessagesToPrint = 5;
// static // static
ResultOrError<Device*> Device::Create(Adapter* adapter, const DeviceDescriptor* descriptor) { ResultOrError<Device*> Device::Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor));
DAWN_TRY(device->Initialize()); DAWN_TRY(device->Initialize());
return device.Detach(); return device.Detach();

View File

@ -41,7 +41,8 @@ namespace dawn_native { namespace d3d12 {
// Definition of backend types // Definition of backend types
class Device final : public DeviceBase { class Device final : public DeviceBase {
public: public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor); static ResultOrError<Device*> Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor);
~Device() override; ~Device() override;
MaybeError Initialize(); MaybeError Initialize();

View File

@ -277,7 +277,8 @@ namespace dawn_native { namespace metal {
} }
private: private:
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override { ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) override {
return Device::Create(this, mDevice, descriptor); return Device::Create(this, mDevice, descriptor);
} }

View File

@ -40,7 +40,7 @@ namespace dawn_native { namespace metal {
public: public:
static ResultOrError<Device*> Create(AdapterBase* adapter, static ResultOrError<Device*> Create(AdapterBase* adapter,
NSPRef<id<MTLDevice>> mtlDevice, NSPRef<id<MTLDevice>> mtlDevice,
const DeviceDescriptor* descriptor); const DawnDeviceDescriptor* descriptor);
~Device() override; ~Device() override;
MaybeError Initialize(); MaybeError Initialize();
@ -77,7 +77,7 @@ namespace dawn_native { namespace metal {
private: private:
Device(AdapterBase* adapter, Device(AdapterBase* adapter,
NSPRef<id<MTLDevice>> mtlDevice, NSPRef<id<MTLDevice>> mtlDevice,
const DeviceDescriptor* descriptor); const DawnDeviceDescriptor* descriptor);
ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl( ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) override; const BindGroupDescriptor* descriptor) override;

View File

@ -108,7 +108,7 @@ namespace dawn_native { namespace metal {
// static // static
ResultOrError<Device*> Device::Create(AdapterBase* adapter, ResultOrError<Device*> Device::Create(AdapterBase* adapter,
NSPRef<id<MTLDevice>> mtlDevice, NSPRef<id<MTLDevice>> mtlDevice,
const DeviceDescriptor* descriptor) { const DawnDeviceDescriptor* descriptor) {
Ref<Device> device = AcquireRef(new Device(adapter, std::move(mtlDevice), descriptor)); Ref<Device> device = AcquireRef(new Device(adapter, std::move(mtlDevice), descriptor));
DAWN_TRY(device->Initialize()); DAWN_TRY(device->Initialize());
return device.Detach(); return device.Detach();
@ -116,7 +116,7 @@ namespace dawn_native { namespace metal {
Device::Device(AdapterBase* adapter, Device::Device(AdapterBase* adapter,
NSPRef<id<MTLDevice>> mtlDevice, NSPRef<id<MTLDevice>> mtlDevice,
const DeviceDescriptor* descriptor) const DawnDeviceDescriptor* descriptor)
: DeviceBase(adapter, descriptor), mMtlDevice(std::move(mtlDevice)), mCompletedSerial(0) { : DeviceBase(adapter, descriptor), mMtlDevice(std::move(mtlDevice)), mCompletedSerial(0) {
} }

View File

@ -57,7 +57,7 @@ namespace dawn_native { namespace null {
return {}; return {};
} }
ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) { ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DawnDeviceDescriptor* descriptor) {
return Device::Create(this, descriptor); return Device::Create(this, descriptor);
} }
@ -95,7 +95,8 @@ namespace dawn_native { namespace null {
// Device // Device
// static // static
ResultOrError<Device*> Device::Create(Adapter* adapter, const DeviceDescriptor* descriptor) { ResultOrError<Device*> Device::Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor));
DAWN_TRY(device->Initialize()); DAWN_TRY(device->Initialize());
return device.Detach(); return device.Detach();

View File

@ -86,7 +86,8 @@ namespace dawn_native { namespace null {
class Device final : public DeviceBase { class Device final : public DeviceBase {
public: public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor); static ResultOrError<Device*> Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor);
~Device() override; ~Device() override;
MaybeError Initialize(); MaybeError Initialize();
@ -181,7 +182,8 @@ namespace dawn_native { namespace null {
MaybeError InitializeSupportedFeaturesImpl() override; MaybeError InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override; ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) override;
}; };
// Helper class so |BindGroup| can allocate memory for its binding data, // Helper class so |BindGroup| can allocate memory for its binding data,

View File

@ -254,7 +254,8 @@ namespace dawn_native { namespace opengl {
return {}; return {};
} }
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override { ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) override {
// There is no limit on the number of devices created from this adapter because they can // There is no limit on the number of devices created from this adapter because they can
// all share the same backing OpenGL context. // all share the same backing OpenGL context.
return Device::Create(this, descriptor, mFunctions); return Device::Create(this, descriptor, mFunctions);

View File

@ -36,7 +36,7 @@ namespace dawn_native { namespace opengl {
// static // static
ResultOrError<Device*> Device::Create(AdapterBase* adapter, ResultOrError<Device*> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DawnDeviceDescriptor* descriptor,
const OpenGLFunctions& functions) { const OpenGLFunctions& functions) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, functions)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor, functions));
DAWN_TRY(device->Initialize()); DAWN_TRY(device->Initialize());
@ -44,7 +44,7 @@ namespace dawn_native { namespace opengl {
} }
Device::Device(AdapterBase* adapter, Device::Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DawnDeviceDescriptor* descriptor,
const OpenGLFunctions& functions) const OpenGLFunctions& functions)
: DeviceBase(adapter, descriptor), gl(functions) { : DeviceBase(adapter, descriptor), gl(functions) {
} }

View File

@ -38,7 +38,7 @@ namespace dawn_native { namespace opengl {
class Device final : public DeviceBase { class Device final : public DeviceBase {
public: public:
static ResultOrError<Device*> Create(AdapterBase* adapter, static ResultOrError<Device*> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DawnDeviceDescriptor* descriptor,
const OpenGLFunctions& functions); const OpenGLFunctions& functions);
~Device() override; ~Device() override;
@ -81,7 +81,7 @@ namespace dawn_native { namespace opengl {
private: private:
Device(AdapterBase* adapter, Device(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DawnDeviceDescriptor* descriptor,
const OpenGLFunctions& functions); const OpenGLFunctions& functions);
ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl( ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl(

View File

@ -320,7 +320,7 @@ namespace dawn_native { namespace vulkan {
mBackend->GetFunctions()); mBackend->GetFunctions());
} }
ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor) { ResultOrError<DeviceBase*> Adapter::CreateDeviceImpl(const DawnDeviceDescriptor* descriptor) {
return Device::Create(this, descriptor); return Device::Create(this, descriptor);
} }

View File

@ -41,7 +41,8 @@ namespace dawn_native { namespace vulkan {
MaybeError InitializeSupportedFeaturesImpl() override; MaybeError InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override; MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override; ResultOrError<DeviceBase*> CreateDeviceImpl(
const DawnDeviceDescriptor* descriptor) override;
VkPhysicalDevice mPhysicalDevice; VkPhysicalDevice mPhysicalDevice;
Backend* mBackend; Backend* mBackend;

View File

@ -45,13 +45,14 @@
namespace dawn_native { namespace vulkan { namespace dawn_native { namespace vulkan {
// static // static
ResultOrError<Device*> Device::Create(Adapter* adapter, const DeviceDescriptor* descriptor) { ResultOrError<Device*> Device::Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor));
DAWN_TRY(device->Initialize()); DAWN_TRY(device->Initialize());
return device.Detach(); return device.Detach();
} }
Device::Device(Adapter* adapter, const DeviceDescriptor* descriptor) Device::Device(Adapter* adapter, const DawnDeviceDescriptor* descriptor)
: DeviceBase(adapter, descriptor) { : DeviceBase(adapter, descriptor) {
InitTogglesFromDriver(); InitTogglesFromDriver();
} }

View File

@ -42,7 +42,8 @@ namespace dawn_native { namespace vulkan {
class Device final : public DeviceBase { class Device final : public DeviceBase {
public: public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor); static ResultOrError<Device*> Create(Adapter* adapter,
const DawnDeviceDescriptor* descriptor);
~Device() override; ~Device() override;
MaybeError Initialize(); MaybeError Initialize();
@ -104,7 +105,7 @@ namespace dawn_native { namespace vulkan {
float GetTimestampPeriodInNS() const override; float GetTimestampPeriodInNS() const override;
private: private:
Device(Adapter* adapter, const DeviceDescriptor* descriptor); Device(Adapter* adapter, const DawnDeviceDescriptor* descriptor);
ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl( ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl(
const BindGroupDescriptor* descriptor) override; const BindGroupDescriptor* descriptor) override;

View File

@ -168,7 +168,7 @@ 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::DeviceDescriptor desc{}; // TODO(crbug.com/dawn/1133): Fill in. dawn_native::DawnDeviceDescriptor 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);
// See src/dawn_native/Features.cpp for enum <-> string mappings. // See src/dawn_native/Features.cpp for enum <-> string mappings.
@ -194,7 +194,7 @@ namespace wgpu { namespace binding {
} }
// Propogate enabled/disabled dawn features // Propogate enabled/disabled dawn features
// Note: DeviceDescriptor::forceEnabledToggles and forceDisabledToggles are vectors of // Note: DawnDeviceDescriptor::forceEnabledToggles and forceDisabledToggles are vectors of
// 'const char*', so we make sure the parsed strings survive the CreateDevice() call by // 'const char*', so we make sure the parsed strings survive the CreateDevice() call by
// storing them on the stack. // storing them on the stack.
std::vector<std::string> enabledToggles; std::vector<std::string> enabledToggles;

View File

@ -62,7 +62,7 @@ namespace dawn_native {
// An optional parameter of Adapter::CreateDevice() to send additional information when creating // An optional parameter of Adapter::CreateDevice() to send additional information when creating
// a Device. For example, we can use it to enable a workaround, optimization or feature. // a Device. For example, we can use it to enable a workaround, optimization or feature.
struct DAWN_NATIVE_EXPORT DeviceDescriptor { struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
std::vector<const char*> requiredFeatures; std::vector<const char*> requiredFeatures;
std::vector<const char*> forceEnabledToggles; std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles; std::vector<const char*> forceDisabledToggles;
@ -70,6 +70,10 @@ namespace dawn_native {
const WGPURequiredLimits* requiredLimits = nullptr; const WGPURequiredLimits* requiredLimits = nullptr;
}; };
// TODO(crbug.com/dawn/160): Remove when embedders of Dawn are updated to use
// DawnDeviceDescriptor.
using DeviceDescriptor = DawnDeviceDescriptor;
// A struct to record the information of a toggle. A toggle is a code path in Dawn device that // A struct to record the information of a toggle. A toggle is a code path in Dawn device that
// can be manually configured to run or not outside Dawn, including workarounds, special // can be manually configured to run or not outside Dawn, including workarounds, special
// features and optimizations. // features and optimizations.
@ -124,9 +128,9 @@ namespace dawn_native {
// Create a device on this adapter, note that the interface will change to include at least // Create a device on this adapter, note that the interface will change to include at least
// a device descriptor and a pointer to backend specific options. // a device descriptor and a pointer to backend specific options.
// On an error, nullptr is returned. // On an error, nullptr is returned.
WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr); WGPUDevice CreateDevice(const DawnDeviceDescriptor* deviceDescriptor = nullptr);
void RequestDevice(const DeviceDescriptor* descriptor, void RequestDevice(const DawnDeviceDescriptor* descriptor,
WGPURequestDeviceCallback callback, WGPURequestDeviceCallback callback,
void* userdata); void* userdata);

View File

@ -70,7 +70,7 @@ 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::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&deviceDescriptor); return adapter.CreateDevice(&deviceDescriptor);

View File

@ -922,7 +922,7 @@ 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::DeviceDescriptor deviceDescriptor = {}; dawn_native::DawnDeviceDescriptor deviceDescriptor = {};
deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds; deviceDescriptor.forceEnabledToggles = mParam.forceEnabledWorkarounds;
deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds; deviceDescriptor.forceDisabledToggles = mParam.forceDisabledWorkarounds;
deviceDescriptor.requiredFeatures = GetRequiredFeatures(); deviceDescriptor.requiredFeatures = GetRequiredFeatures();

View File

@ -61,7 +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::DeviceDescriptor deviceDescriptor = {}; dawn_native::DawnDeviceDescriptor deviceDescriptor = {};
device = wgpu::Device::Acquire(adapter.CreateDevice(&deviceDescriptor)); device = wgpu::Device::Acquire(adapter.CreateDevice(&deviceDescriptor));
instance.reset(); instance.reset();
break; break;

View File

@ -55,7 +55,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
mAdapterBase.SetSupportedFeatures(featureNamesWithoutOne); mAdapterBase.SetSupportedFeatures(featureNamesWithoutOne);
dawn_native::Adapter adapterWithoutFeature(&mAdapterBase); dawn_native::Adapter adapterWithoutFeature(&mAdapterBase);
dawn_native::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
const char* featureName = FeatureEnumToName(notSupportedFeature); const char* featureName = FeatureEnumToName(notSupportedFeature);
deviceDescriptor.requiredFeatures = std::vector<const char*>(1, featureName); deviceDescriptor.requiredFeatures = std::vector<const char*>(1, featureName);
WGPUDevice deviceWithFeature = adapterWithoutFeature.CreateDevice(&deviceDescriptor); WGPUDevice deviceWithFeature = adapterWithoutFeature.CreateDevice(&deviceDescriptor);
@ -70,7 +70,7 @@ TEST_F(FeatureTests, GetEnabledFeatures) {
dawn_native::Feature feature = static_cast<dawn_native::Feature>(i); dawn_native::Feature feature = static_cast<dawn_native::Feature>(i);
const char* featureName = FeatureEnumToName(feature); const char* featureName = FeatureEnumToName(feature);
dawn_native::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
deviceDescriptor.requiredFeatures = {featureName}; deviceDescriptor.requiredFeatures = {featureName};
dawn_native::DeviceBase* deviceBase = dawn_native::DeviceBase* deviceBase =
reinterpret_cast<dawn_native::DeviceBase*>(adapter.CreateDevice(&deviceDescriptor)); reinterpret_cast<dawn_native::DeviceBase*>(adapter.CreateDevice(&deviceDescriptor));

View File

@ -2046,7 +2046,7 @@ 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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);

View File

@ -44,7 +44,7 @@ TEST_F(TextureInternalUsageValidationDisabledTest, RequiresFeature) {
class TextureInternalUsageValidationTest : public ValidationTest { class TextureInternalUsageValidationTest : public ValidationTest {
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("dawn-internal-usages"); descriptor.requiredFeatures.push_back("dawn-internal-usages");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);

View File

@ -225,7 +225,7 @@ TEST_F(OcclusionQueryValidationTest, InvalidBeginAndEnd) {
class TimestampQueryValidationTest : public QuerySetValidationTest { class TimestampQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("timestamp-query"); descriptor.requiredFeatures.push_back("timestamp-query");
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
@ -429,7 +429,7 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnRenderPassEncoder) {
class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest { class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("pipeline-statistics-query"); descriptor.requiredFeatures.push_back("pipeline-statistics-query");
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing // TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
// unsafe APIs to test it. // unsafe APIs to test it.

View File

@ -557,7 +557,7 @@ namespace {
class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest { class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);

View File

@ -1124,7 +1124,7 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
class DepthClampingValidationTest : public RenderPipelineValidationTest { class DepthClampingValidationTest : public RenderPipelineValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth-clamping"}; descriptor.requiredFeatures = {"depth-clamping"};
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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor 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,7 +71,7 @@ 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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess, adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
CheckDevice([](wgpu::Device device) { CheckDevice([](wgpu::Device device) {
@ -85,7 +85,7 @@ 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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
wgpu::SupportedLimits supportedLimits; wgpu::SupportedLimits supportedLimits;
@ -138,7 +138,7 @@ 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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
wgpu::SupportedLimits supportedLimits; wgpu::SupportedLimits supportedLimits;
@ -199,7 +199,7 @@ TEST_F(RequestDeviceValidationTest, InvalidChainedStruct) {
wgpu::RequiredLimits limits = {}; wgpu::RequiredLimits limits = {};
limits.nextInChain = &depthClamp; limits.nextInChain = &depthClamp;
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits); descriptor.requiredLimits = reinterpret_cast<const WGPURequiredLimits*>(&limits);
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr); adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
} }

View File

@ -586,7 +586,7 @@ namespace {
class CompressedTextureFormatsValidationTests : public TextureValidationTest { class CompressedTextureFormatsValidationTests : public TextureValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2", descriptor.requiredFeatures = {"texture-compression-bc", "texture-compression-etc2",
"texture-compression-astc"}; "texture-compression-astc"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);

View File

@ -43,7 +43,7 @@ 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::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); descriptor.forceEnabledToggles.push_back(kValidToggleName);
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
@ -60,7 +60,7 @@ namespace {
// Create device with an invalid toggle name // Create device with an invalid toggle name
{ {
const char* kInvalidToggleName = "!@#$%^&*"; const char* kInvalidToggleName = "!@#$%^&*";
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kInvalidToggleName); descriptor.forceEnabledToggles.push_back(kInvalidToggleName);
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
@ -77,7 +77,7 @@ namespace {
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) { TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
const char* kValidToggleName = "turn_off_vsync"; const char* kValidToggleName = "turn_off_vsync";
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); descriptor.forceEnabledToggles.push_back(kValidToggleName);
WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);

View File

@ -22,7 +22,7 @@
class UnsafeAPIValidationTest : public ValidationTest { class UnsafeAPIValidationTest : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
@ -109,7 +109,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
class UnsafeQueryAPIValidationTest : public ValidationTest { class UnsafeQueryAPIValidationTest : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures.push_back("pipeline-statistics-query"); descriptor.requiredFeatures.push_back("pipeline-statistics-query");
descriptor.requiredFeatures.push_back("timestamp-query"); descriptor.requiredFeatures.push_back("timestamp-query");
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis"); descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");

View File

@ -195,7 +195,7 @@ 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::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis"); deviceDescriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) { for (const std::string& toggle : gToggleParser->GetEnabledToggles()) {

View File

@ -21,7 +21,7 @@ namespace {
class VideoViewsValidation : public ValidationTest { class VideoViewsValidation : public ValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DawnDeviceDescriptor descriptor;
descriptor.requiredFeatures = {"multiplanar-formats"}; descriptor.requiredFeatures = {"multiplanar-formats"};
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }

View File

@ -318,7 +318,7 @@ namespace dawn_native { namespace vulkan {
protected: protected:
dawn_native::vulkan::Adapter* backendAdapter; dawn_native::vulkan::Adapter* backendAdapter;
dawn_native::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
wgpu::Device secondDevice; wgpu::Device secondDevice;
dawn_native::vulkan::Device* secondDeviceVk; dawn_native::vulkan::Device* secondDeviceVk;

View File

@ -419,7 +419,7 @@ namespace dawn_native { namespace vulkan {
dawn_native::vulkan::Device* secondDeviceVk; dawn_native::vulkan::Device* secondDeviceVk;
dawn_native::vulkan::Adapter* backendAdapter; dawn_native::vulkan::Adapter* backendAdapter;
dawn_native::DeviceDescriptor deviceDescriptor; dawn_native::DawnDeviceDescriptor deviceDescriptor;
wgpu::TextureDescriptor defaultDescriptor; wgpu::TextureDescriptor defaultDescriptor;
VkImage defaultImage; VkImage defaultImage;