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 <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2023-05-01 21:37:44 +00:00 committed by Dawn LUCI CQ
parent be4b208ab6
commit 556147c333
5 changed files with 34 additions and 31 deletions

View File

@ -28,13 +28,14 @@
namespace dawn::native::null { 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) PhysicalDevice::PhysicalDevice(InstanceBase* instance)
: Adapter(instance, : PhysicalDevice(instance,
TogglesState(ToggleStage::Adapter).InheritFrom(instance->GetTogglesState())) {} 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) { : PhysicalDeviceBase(instance, wgpu::BackendType::Null, adapterToggles) {
mVendorId = 0; mVendorId = 0;
mDeviceId = 0; mDeviceId = 0;
@ -44,37 +45,38 @@ Adapter::Adapter(InstanceBase* instance, const TogglesState& adapterToggles)
ASSERT(err.IsSuccess()); ASSERT(err.IsSuccess());
} }
Adapter::~Adapter() = default; PhysicalDevice::~PhysicalDevice() = default;
bool Adapter::SupportsExternalImages() const { bool PhysicalDevice::SupportsExternalImages() const {
return false; return false;
} }
MaybeError Adapter::InitializeImpl() { MaybeError PhysicalDevice::InitializeImpl() {
return {}; return {};
} }
void Adapter::InitializeSupportedFeaturesImpl() { void PhysicalDevice::InitializeSupportedFeaturesImpl() {
// Enable all features by default for the convenience of tests. // Enable all features by default for the convenience of tests.
for (uint32_t i = 0; i < static_cast<uint32_t>(Feature::EnumCount); i++) { for (uint32_t i = 0; i < static_cast<uint32_t>(Feature::EnumCount); i++) {
EnableFeature(static_cast<Feature>(i)); EnableFeature(static_cast<Feature>(i));
} }
} }
MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
GetDefaultLimits(&limits->v1); GetDefaultLimits(&limits->v1);
return {}; return {};
} }
void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {} void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {}
ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
return Device::Create(this, descriptor, deviceToggles); return Device::Create(this, descriptor, deviceToggles);
} }
MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
const TogglesState& toggles) const { wgpu::FeatureName feature,
const TogglesState& toggles) const {
return {}; return {};
} }
@ -87,10 +89,11 @@ class Backend : public BackendConnection {
const TogglesState& adapterToggles) override { const TogglesState& adapterToggles) override {
// There is always a single Null adapter because it is purely CPU based and doesn't // There is always a single Null adapter because it is purely CPU based and doesn't
// depend on the system. // depend on the system.
std::vector<Ref<PhysicalDeviceBase>> adapters; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;
Ref<Adapter> adapter = AcquireRef(new Adapter(GetInstance(), adapterToggles)); Ref<PhysicalDevice> physicalDevice =
adapters.push_back(std::move(adapter)); AcquireRef(new PhysicalDevice(GetInstance(), adapterToggles));
return adapters; physicalDevices.push_back(std::move(physicalDevice));
return physicalDevices;
} }
}; };
@ -113,7 +116,7 @@ struct CopyFromStagingToBufferOperation : PendingOperation {
// Device // Device
// static // static
ResultOrError<Ref<Device>> Device::Create(Adapter* adapter, ResultOrError<Ref<Device>> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles));

View File

@ -40,13 +40,13 @@
namespace dawn::native::null { namespace dawn::native::null {
class Adapter;
class BindGroup; class BindGroup;
class BindGroupLayout; class BindGroupLayout;
class Buffer; class Buffer;
class CommandBuffer; class CommandBuffer;
class ComputePipeline; class ComputePipeline;
class Device; class Device;
class PhysicalDevice;
using PipelineLayout = PipelineLayoutBase; using PipelineLayout = PipelineLayoutBase;
class QuerySet; class QuerySet;
class Queue; class Queue;
@ -58,13 +58,13 @@ class Texture;
using TextureView = TextureViewBase; using TextureView = TextureViewBase;
struct NullBackendTraits { struct NullBackendTraits {
using AdapterType = Adapter;
using BindGroupType = BindGroup; using BindGroupType = BindGroup;
using BindGroupLayoutType = BindGroupLayout; using BindGroupLayoutType = BindGroupLayout;
using BufferType = Buffer; using BufferType = Buffer;
using CommandBufferType = CommandBuffer; using CommandBufferType = CommandBuffer;
using ComputePipelineType = ComputePipeline; using ComputePipelineType = ComputePipeline;
using DeviceType = Device; using DeviceType = Device;
using PhysicalDeviceType = PhysicalDevice;
using PipelineLayoutType = PipelineLayout; using PipelineLayoutType = PipelineLayout;
using QuerySetType = QuerySet; using QuerySetType = QuerySet;
using QueueType = Queue; using QueueType = Queue;
@ -88,7 +88,7 @@ struct PendingOperation {
class Device final : public DeviceBase { class Device final : public DeviceBase {
public: public:
static ResultOrError<Ref<Device>> Create(Adapter* adapter, static ResultOrError<Ref<Device>> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles); const TogglesState& deviceToggles);
~Device() override; ~Device() override;
@ -170,13 +170,13 @@ class Device final : public DeviceBase {
size_t mMemoryUsage = 0; size_t mMemoryUsage = 0;
}; };
class Adapter : public PhysicalDeviceBase { class PhysicalDevice : public PhysicalDeviceBase {
public: public:
// Create null adapter without providing toggles state for testing, only inherit instance's // Create null adapter without providing toggles state for testing, only inherit instance's
// toggles state // toggles state
explicit Adapter(InstanceBase* instance); explicit PhysicalDevice(InstanceBase* instance);
Adapter(InstanceBase* instance, const TogglesState& adapterToggles); PhysicalDevice(InstanceBase* instance, const TogglesState& adapterToggles);
~Adapter() override; ~PhysicalDevice() override;
// PhysicalDeviceBase Implementation // PhysicalDeviceBase Implementation
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;

View File

@ -47,9 +47,9 @@ class FeatureTests : public testing::Test {
Ref<dawn::native::InstanceBase> mInstanceBase; Ref<dawn::native::InstanceBase> mInstanceBase;
// The adapter that inherit toggles states from the instance, also have DisallowUnsafeAPIs // The adapter that inherit toggles states from the instance, also have DisallowUnsafeAPIs
// enabled. // enabled.
dawn::native::null::Adapter mAdapterBase; dawn::native::null::PhysicalDevice mAdapterBase;
// The adapter that override DisallowUnsafeAPIs to disabled in toggles state. // 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 // Test the creation of a device will fail if the requested feature is not supported on the

View File

@ -94,7 +94,7 @@ class GetProcAddressTests : public testing::TestWithParam<DawnFlavor> {
protected: protected:
Ref<dawn::native::InstanceBase> mNativeInstance; Ref<dawn::native::InstanceBase> mNativeInstance;
dawn::native::null::Adapter mNativeAdapter; dawn::native::null::PhysicalDevice mNativeAdapter;
std::unique_ptr<utils::TerribleCommandBuffer> mC2sBuf; std::unique_ptr<utils::TerribleCommandBuffer> mC2sBuf;
std::unique_ptr<dawn::wire::WireClient> mWireClient; std::unique_ptr<dawn::wire::WireClient> mWireClient;

View File

@ -32,7 +32,7 @@ class PerThreadProcTests : public testing::Test {
protected: protected:
Ref<dawn::native::InstanceBase> mNativeInstance; Ref<dawn::native::InstanceBase> 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 // Test that procs can be set per thread. This test overrides deviceCreateBuffer with a placeholder