From 556147c3333f8a8f2a457a082598ae7595c49883 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Mon, 1 May 2023 21:37:44 +0000 Subject: [PATCH] Rename null::Adapter -> null::PhysicalDevice. Bug: dawn:1774 Change-Id: I05f4578e08175c4ce5703c5555689ba517b4590d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130780 Reviewed-by: Austin Eng Kokoro: Kokoro Commit-Queue: Stephen White --- src/dawn/native/null/DeviceNull.cpp | 43 ++++++++++--------- src/dawn/native/null/DeviceNull.h | 14 +++--- src/dawn/tests/unittests/FeatureTests.cpp | 4 +- .../tests/unittests/GetProcAddressTests.cpp | 2 +- .../tests/unittests/PerThreadProcTests.cpp | 2 +- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index 26632fdb0b..9e2e4b425f 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp @@ -28,13 +28,14 @@ namespace dawn::native::null { -// Implementation of pre-Device objects: the null adapter, null backend connection and Connect() +// Implementation of pre-Device objects: the null physical device, null backend connection and +// Connect() -Adapter::Adapter(InstanceBase* instance) - : Adapter(instance, - TogglesState(ToggleStage::Adapter).InheritFrom(instance->GetTogglesState())) {} +PhysicalDevice::PhysicalDevice(InstanceBase* instance) + : PhysicalDevice(instance, + TogglesState(ToggleStage::Adapter).InheritFrom(instance->GetTogglesState())) {} -Adapter::Adapter(InstanceBase* instance, const TogglesState& adapterToggles) +PhysicalDevice::PhysicalDevice(InstanceBase* instance, const TogglesState& adapterToggles) : PhysicalDeviceBase(instance, wgpu::BackendType::Null, adapterToggles) { mVendorId = 0; mDeviceId = 0; @@ -44,37 +45,38 @@ Adapter::Adapter(InstanceBase* instance, const TogglesState& adapterToggles) ASSERT(err.IsSuccess()); } -Adapter::~Adapter() = default; +PhysicalDevice::~PhysicalDevice() = default; -bool Adapter::SupportsExternalImages() const { +bool PhysicalDevice::SupportsExternalImages() const { return false; } -MaybeError Adapter::InitializeImpl() { +MaybeError PhysicalDevice::InitializeImpl() { return {}; } -void Adapter::InitializeSupportedFeaturesImpl() { +void PhysicalDevice::InitializeSupportedFeaturesImpl() { // Enable all features by default for the convenience of tests. for (uint32_t i = 0; i < static_cast(Feature::EnumCount); i++) { EnableFeature(static_cast(i)); } } -MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { +MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) { GetDefaultLimits(&limits->v1); return {}; } -void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {} +void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {} -ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, - const TogglesState& deviceToggles) { +ResultOrError> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor, + const TogglesState& deviceToggles) { return Device::Create(this, descriptor, deviceToggles); } -MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, - const TogglesState& toggles) const { +MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl( + wgpu::FeatureName feature, + const TogglesState& toggles) const { return {}; } @@ -87,10 +89,11 @@ class Backend : public BackendConnection { const TogglesState& adapterToggles) override { // There is always a single Null adapter because it is purely CPU based and doesn't // depend on the system. - std::vector> adapters; - Ref adapter = AcquireRef(new Adapter(GetInstance(), adapterToggles)); - adapters.push_back(std::move(adapter)); - return adapters; + std::vector> physicalDevices; + Ref physicalDevice = + AcquireRef(new PhysicalDevice(GetInstance(), adapterToggles)); + physicalDevices.push_back(std::move(physicalDevice)); + return physicalDevices; } }; @@ -113,7 +116,7 @@ struct CopyFromStagingToBufferOperation : PendingOperation { // Device // static -ResultOrError> Device::Create(Adapter* adapter, +ResultOrError> Device::Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles) { Ref device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); diff --git a/src/dawn/native/null/DeviceNull.h b/src/dawn/native/null/DeviceNull.h index 641ca3284e..263f82e9e8 100644 --- a/src/dawn/native/null/DeviceNull.h +++ b/src/dawn/native/null/DeviceNull.h @@ -40,13 +40,13 @@ namespace dawn::native::null { -class Adapter; class BindGroup; class BindGroupLayout; class Buffer; class CommandBuffer; class ComputePipeline; class Device; +class PhysicalDevice; using PipelineLayout = PipelineLayoutBase; class QuerySet; class Queue; @@ -58,13 +58,13 @@ class Texture; using TextureView = TextureViewBase; struct NullBackendTraits { - using AdapterType = Adapter; using BindGroupType = BindGroup; using BindGroupLayoutType = BindGroupLayout; using BufferType = Buffer; using CommandBufferType = CommandBuffer; using ComputePipelineType = ComputePipeline; using DeviceType = Device; + using PhysicalDeviceType = PhysicalDevice; using PipelineLayoutType = PipelineLayout; using QuerySetType = QuerySet; using QueueType = Queue; @@ -88,7 +88,7 @@ struct PendingOperation { class Device final : public DeviceBase { public: - static ResultOrError> Create(Adapter* adapter, + static ResultOrError> Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles); ~Device() override; @@ -170,13 +170,13 @@ class Device final : public DeviceBase { size_t mMemoryUsage = 0; }; -class Adapter : public PhysicalDeviceBase { +class PhysicalDevice : public PhysicalDeviceBase { public: // Create null adapter without providing toggles state for testing, only inherit instance's // toggles state - explicit Adapter(InstanceBase* instance); - Adapter(InstanceBase* instance, const TogglesState& adapterToggles); - ~Adapter() override; + explicit PhysicalDevice(InstanceBase* instance); + PhysicalDevice(InstanceBase* instance, const TogglesState& adapterToggles); + ~PhysicalDevice() override; // PhysicalDeviceBase Implementation bool SupportsExternalImages() const override; diff --git a/src/dawn/tests/unittests/FeatureTests.cpp b/src/dawn/tests/unittests/FeatureTests.cpp index 8153c20777..477119692f 100644 --- a/src/dawn/tests/unittests/FeatureTests.cpp +++ b/src/dawn/tests/unittests/FeatureTests.cpp @@ -47,9 +47,9 @@ class FeatureTests : public testing::Test { Ref mInstanceBase; // The adapter that inherit toggles states from the instance, also have DisallowUnsafeAPIs // enabled. - dawn::native::null::Adapter mAdapterBase; + dawn::native::null::PhysicalDevice mAdapterBase; // The adapter that override DisallowUnsafeAPIs to disabled in toggles state. - dawn::native::null::Adapter mUnsafeAdapterBase; + dawn::native::null::PhysicalDevice mUnsafeAdapterBase; }; // Test the creation of a device will fail if the requested feature is not supported on the diff --git a/src/dawn/tests/unittests/GetProcAddressTests.cpp b/src/dawn/tests/unittests/GetProcAddressTests.cpp index a49c042f17..b04cf777c4 100644 --- a/src/dawn/tests/unittests/GetProcAddressTests.cpp +++ b/src/dawn/tests/unittests/GetProcAddressTests.cpp @@ -94,7 +94,7 @@ class GetProcAddressTests : public testing::TestWithParam { protected: Ref mNativeInstance; - dawn::native::null::Adapter mNativeAdapter; + dawn::native::null::PhysicalDevice mNativeAdapter; std::unique_ptr mC2sBuf; std::unique_ptr mWireClient; diff --git a/src/dawn/tests/unittests/PerThreadProcTests.cpp b/src/dawn/tests/unittests/PerThreadProcTests.cpp index 65d64d6a9f..690fa4d545 100644 --- a/src/dawn/tests/unittests/PerThreadProcTests.cpp +++ b/src/dawn/tests/unittests/PerThreadProcTests.cpp @@ -32,7 +32,7 @@ class PerThreadProcTests : public testing::Test { protected: Ref mNativeInstance; - dawn::native::null::Adapter mNativeAdapter; + dawn::native::null::PhysicalDevice mNativeAdapter; }; // Test that procs can be set per thread. This test overrides deviceCreateBuffer with a placeholder