Turn AdapterBase into a wrapper class.

Change AdapterBase from an alias to PhysicalDeviceBase to a thin
wrapper class holding a ref to a PhysicalDeviceBase. This way,
mutiple AdapterBases can point at the same PhysicalDeviceBase.

For now, InstanceBase wraps all PhysicalDeviceBases discovered by a
backend in a single AdapterBase. In the future, this relationship will
become many-to-one.

Since Devices now maintain a ref on the AdapterBase wrapper (in order to
query toggles, etc), PhysicalDeviceBase::CreateDeviceImpl() now takes
the AdapterBase as an argument, so that the PhysicalDeviceBase knows
which AdapterBase to vend a Device for.

Note that the Toggles also still remain on the PhysicalDeviceBase, to
be moved up to the AdapterBase in a future change.

Bug: dawn:1774
Change-Id: Idef5d24fbd66d8552959230e246e453abddcc736
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131001
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White
2023-05-03 01:29:44 +00:00
committed by Dawn LUCI CQ
parent 5eb3619d3e
commit fed6b6b35b
39 changed files with 225 additions and 102 deletions

View File

@@ -34,7 +34,8 @@ struct DeviceDescriptor;
namespace dawn::native {
class InstanceBase;
class PhysicalDeviceBase;
class AdapterBase;
// 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.
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
@@ -84,10 +85,8 @@ struct FeatureInfo {
class DAWN_NATIVE_EXPORT Adapter {
public:
Adapter();
// TODO(dawn:1774): all references to PhysicalDeviceBase in this class will go back to
// using AdapterBase once the latter becomes a real class again.
// NOLINTNEXTLINE(runtime/explicit)
Adapter(PhysicalDeviceBase* impl);
Adapter(AdapterBase* impl);
~Adapter();
Adapter(const Adapter& other);
@@ -132,7 +131,7 @@ class DAWN_NATIVE_EXPORT Adapter {
void ResetInternalDeviceForTesting();
private:
PhysicalDeviceBase* mImpl = nullptr;
AdapterBase* mImpl = nullptr;
};
// Base class for options passed to Instance::DiscoverAdapters.