Dawn: Deprecate DiscoverAdapters with DiscoverPhysicalDevices

This CL deprecate Discover[Default]Adapters and replace them with
Discover[Default]PhysicalDevices. This help clearify the behavior of
discovering physical devices and requesting / getting adapters, and
prepare for adding adapter toggles in GetAdapters.

Related end-to-end tests AdapterDiscoveryTests are split into
PhysicalDeviceDiscoveryTests and AdapterCreationTests as well.

Bug: dawn:1774, dawn:1495
Change-Id: Iac3d9da3022e5eb3c6dd6b3e3b2224f523792289
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133968
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Zhaoming Jiang
2023-05-25 02:42:27 +00:00
committed by Dawn LUCI CQ
parent dd7b314105
commit 6663a97b74
40 changed files with 445 additions and 368 deletions

View File

@@ -25,11 +25,15 @@
namespace dawn::native::d3d11 {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public d3d::AdapterDiscoveryOptions {
AdapterDiscoveryOptions();
explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public d3d::PhysicalDeviceDiscoveryOptions {
PhysicalDeviceDiscoveryOptions();
explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device);
} // namespace dawn::native::d3d11

View File

@@ -38,11 +38,15 @@ DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
uint64_t requestedReservationSize,
MemorySegment memorySegment);
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public d3d::AdapterDiscoveryOptions {
AdapterDiscoveryOptions();
explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public d3d::PhysicalDeviceDiscoveryOptions {
PhysicalDeviceDiscoveryOptions();
explicit PhysicalDeviceDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
} // namespace dawn::native::d3d12
#endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_

View File

@@ -30,11 +30,16 @@ class ExternalImageDXGIImpl;
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<IDXGIAdapter> GetDXGIAdapter(WGPUAdapter adapter);
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
AdapterDiscoveryOptions(WGPUBackendType type, Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public PhysicalDeviceDiscoveryOptionsBase {
PhysicalDeviceDiscoveryOptions(WGPUBackendType type,
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
Microsoft::WRL::ComPtr<IDXGIAdapter> dxgiAdapter;
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor {
public:
ExternalImageDescriptorDXGISharedHandle();

View File

@@ -118,15 +118,19 @@ class DAWN_NATIVE_EXPORT Adapter {
AdapterBase* mImpl = nullptr;
};
// Base class for options passed to Instance::DiscoverAdapters.
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase {
// Base class for options passed to Instance::DiscoverPhysicalDevices.
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptionsBase {
public:
const WGPUBackendType backendType;
protected:
explicit AdapterDiscoveryOptionsBase(WGPUBackendType type);
explicit PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType type);
};
// Deprecated, use PhysicalDeviceDiscoveryOptionsBase instead.
// TODO(dawn:1774): Remove this.
using AdapterDiscoveryOptionsBase = PhysicalDeviceDiscoveryOptionsBase;
enum BackendValidationLevel { Full, Partial, Disabled };
// Can be chained in InstanceDescriptor
@@ -156,15 +160,20 @@ class DAWN_NATIVE_EXPORT Instance {
Instance(const Instance& other) = delete;
Instance& operator=(const Instance& other) = delete;
// Gather all adapters in the system that can be accessed with no special options. These
// adapters will later be returned by GetAdapters.
void DiscoverDefaultAdapters();
// Gather all physical devices in the system that can be accessed with no special options.
void DiscoverDefaultPhysicalDevices();
// Adds adapters that can be discovered with the options provided (like a getProcAddress).
// The backend is chosen based on the type of the options used. Returns true on success.
// Adds physical devices that can be discovered with the options provided (like a
// getProcAddress). The backend is chosen based on the type of the options used. Returns true on
// success.
bool DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options);
// Deprecated, use DiscoverDefaultPhysicalDevices and DiscoverPhysicalDevices instead.
// TODO(Dawn:1774): Remove these.
void DiscoverDefaultAdapters();
bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options);
// Returns all the adapters that the instance knows about.
// Returns a vector of adapters, one for each physical device the instance knows about.
std::vector<Adapter> GetAdapters() const;
const ToggleInfo* GetToggleInfo(const char* toggleName);

View File

@@ -35,10 +35,14 @@ typedef __IOSurface* IOSurfaceRef;
namespace dawn::native::metal {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
AdapterDiscoveryOptions();
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public PhysicalDeviceDiscoveryOptionsBase {
PhysicalDeviceDiscoveryOptions();
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
struct DAWN_NATIVE_EXPORT ExternalImageMTLSharedEventDescriptor {
// Shared event handle `id<MTLSharedEvent>`.
// This never passes ownership to the callee (when used as an input

View File

@@ -21,14 +21,18 @@ typedef void* EGLImage;
namespace dawn::native::opengl {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
explicit AdapterDiscoveryOptions(WGPUBackendType type);
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public PhysicalDeviceDiscoveryOptionsBase {
explicit PhysicalDeviceDiscoveryOptions(WGPUBackendType type);
void* (*getProc)(const char*);
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
// TODO(crbug.com/dawn/810): This struct can be removed once Chrome is no longer using it.
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public AdapterDiscoveryOptions {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public PhysicalDeviceDiscoveryOptions {
AdapterDiscoveryOptionsES();
};

View File

@@ -28,12 +28,16 @@ DAWN_NATIVE_EXPORT VkInstance GetInstance(WGPUDevice device);
DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
AdapterDiscoveryOptions();
struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
: public PhysicalDeviceDiscoveryOptionsBase {
PhysicalDeviceDiscoveryOptions();
bool forceSwiftShader = false;
};
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
enum class NeedsDedicatedAllocation {
Yes,
No,