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 { namespace dawn::native::d3d11 {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public d3d::AdapterDiscoveryOptions { struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
AdapterDiscoveryOptions(); : public d3d::PhysicalDeviceDiscoveryOptions {
explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter); 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); DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device);
} // namespace dawn::native::d3d11 } // namespace dawn::native::d3d11

View File

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

View File

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

View File

@ -118,15 +118,19 @@ class DAWN_NATIVE_EXPORT Adapter {
AdapterBase* mImpl = nullptr; AdapterBase* mImpl = nullptr;
}; };
// Base class for options passed to Instance::DiscoverAdapters. // Base class for options passed to Instance::DiscoverPhysicalDevices.
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase { struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptionsBase {
public: public:
const WGPUBackendType backendType; const WGPUBackendType backendType;
protected: 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 }; enum BackendValidationLevel { Full, Partial, Disabled };
// Can be chained in InstanceDescriptor // Can be chained in InstanceDescriptor
@ -156,15 +160,20 @@ class DAWN_NATIVE_EXPORT Instance {
Instance(const Instance& other) = delete; Instance(const Instance& other) = delete;
Instance& operator=(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 // Gather all physical devices in the system that can be accessed with no special options.
// adapters will later be returned by GetAdapters. void DiscoverDefaultPhysicalDevices();
void DiscoverDefaultAdapters();
// Adds adapters that can be discovered with the options provided (like a getProcAddress). // Adds physical devices that can be discovered with the options provided (like a
// The backend is chosen based on the type of the options used. Returns true on success. // 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); 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; std::vector<Adapter> GetAdapters() const;
const ToggleInfo* GetToggleInfo(const char* toggleName); const ToggleInfo* GetToggleInfo(const char* toggleName);

View File

@ -35,10 +35,14 @@ typedef __IOSurface* IOSurfaceRef;
namespace dawn::native::metal { namespace dawn::native::metal {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase { struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
AdapterDiscoveryOptions(); : public PhysicalDeviceDiscoveryOptionsBase {
PhysicalDeviceDiscoveryOptions();
}; };
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
struct DAWN_NATIVE_EXPORT ExternalImageMTLSharedEventDescriptor { struct DAWN_NATIVE_EXPORT ExternalImageMTLSharedEventDescriptor {
// Shared event handle `id<MTLSharedEvent>`. // Shared event handle `id<MTLSharedEvent>`.
// This never passes ownership to the callee (when used as an input // 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 { namespace dawn::native::opengl {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase { struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
explicit AdapterDiscoveryOptions(WGPUBackendType type); : public PhysicalDeviceDiscoveryOptionsBase {
explicit PhysicalDeviceDiscoveryOptions(WGPUBackendType type);
void* (*getProc)(const char*); 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. // 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(); 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); DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, const char* pName);
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase { struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
AdapterDiscoveryOptions(); : public PhysicalDeviceDiscoveryOptionsBase {
PhysicalDeviceDiscoveryOptions();
bool forceSwiftShader = false; bool forceSwiftShader = false;
}; };
// TODO(dawn:1774): Deprecated.
using AdapterDiscoveryOptions = PhysicalDeviceDiscoveryOptions;
enum class NeedsDedicatedAllocation { enum class NeedsDedicatedAllocation {
Yes, Yes,
No, No,

View File

@ -70,7 +70,7 @@ int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) {
sVulkanLoader.Open(dawn::GetExecutableDirectory().value_or("") + "vulkan-1.dll"); sVulkanLoader.Open(dawn::GetExecutableDirectory().value_or("") + "vulkan-1.dll");
#endif #endif
sInstance->DiscoverDefaultAdapters(); sInstance->DiscoverDefaultPhysicalDevices();
return 0; return 0;
} }

View File

@ -28,9 +28,9 @@ InstanceBase* BackendConnection::GetInstance() const {
return mInstance; return mInstance;
} }
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> BackendConnection::DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> BackendConnection::DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* options) { const PhysicalDeviceDiscoveryOptionsBase* options) {
return DAWN_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend."); return DAWN_VALIDATION_ERROR("DiscoverPhysicalDevices not implemented for this backend.");
} }
} // namespace dawn::native } // namespace dawn::native

View File

@ -34,13 +34,13 @@ class BackendConnection {
wgpu::BackendType GetType() const; wgpu::BackendType GetType() const;
InstanceBase* GetInstance() const; InstanceBase* GetInstance() const;
// Returns all the adapters for the system that can be created by the backend, without extra // Returns all the physical devices for the system that can be created by the backend, without
// options (such as debug adapters, custom driver libraries, etc.) // extra options (such as debug adapters, custom driver libraries, etc.)
virtual std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() = 0; virtual std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() = 0;
// Returns new adapters created with the backend-specific options. // Returns new physical devices created with the backend-specific options.
virtual ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters( virtual ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* options); const PhysicalDeviceDiscoveryOptionsBase* options);
private: private:
InstanceBase* mInstance = nullptr; InstanceBase* mInstance = nullptr;

View File

@ -132,7 +132,7 @@ void Adapter::ResetInternalDeviceForTesting() {
// AdapterDiscoverOptionsBase // AdapterDiscoverOptionsBase
AdapterDiscoveryOptionsBase::AdapterDiscoveryOptionsBase(WGPUBackendType type) PhysicalDeviceDiscoveryOptionsBase::PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType type)
: backendType(type) {} : backendType(type) {}
// DawnInstanceDescriptor // DawnInstanceDescriptor
@ -162,12 +162,22 @@ Instance::~Instance() {
} }
} }
void Instance::DiscoverDefaultAdapters() { void Instance::DiscoverDefaultPhysicalDevices() {
mImpl->DiscoverDefaultAdapters(); mImpl->DiscoverDefaultPhysicalDevices();
} }
bool Instance::DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options) {
return mImpl->DiscoverPhysicalDevices(options);
}
// Deprecated.
void Instance::DiscoverDefaultAdapters() {
mImpl->DiscoverDefaultPhysicalDevices();
}
// Deprecated.
bool Instance::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) { bool Instance::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) {
return mImpl->DiscoverAdapters(options); return mImpl->DiscoverPhysicalDevices(options);
} }
std::vector<Adapter> Instance::GetAdapters() const { std::vector<Adapter> Instance::GetAdapters() const {

View File

@ -217,10 +217,10 @@ ResultOrError<Ref<AdapterBase>> InstanceBase::RequestAdapterInternal(
if (options->forceFallbackAdapter) { if (options->forceFallbackAdapter) {
#if defined(DAWN_ENABLE_BACKEND_VULKAN) #if defined(DAWN_ENABLE_BACKEND_VULKAN)
if (GetEnabledBackends()[wgpu::BackendType::Vulkan]) { if (GetEnabledBackends()[wgpu::BackendType::Vulkan]) {
dawn_native::vulkan::AdapterDiscoveryOptions vulkanOptions; dawn_native::vulkan::PhysicalDeviceDiscoveryOptions vulkanOptions;
vulkanOptions.forceSwiftShader = true; vulkanOptions.forceSwiftShader = true;
MaybeError result = DiscoverAdaptersInternal(&vulkanOptions); MaybeError result = DiscoverPhysicalDevicesInternal(&vulkanOptions);
if (result.IsError()) { if (result.IsError()) {
dawn::WarningLog() << absl::StrFormat( dawn::WarningLog() << absl::StrFormat(
"Skipping Vulkan Swiftshader adapter because initialization failed: %s", "Skipping Vulkan Swiftshader adapter because initialization failed: %s",
@ -232,7 +232,7 @@ ResultOrError<Ref<AdapterBase>> InstanceBase::RequestAdapterInternal(
return Ref<AdapterBase>(nullptr); return Ref<AdapterBase>(nullptr);
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN) #endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
} else { } else {
DiscoverDefaultAdapters(); DiscoverDefaultPhysicalDevices();
} }
wgpu::AdapterType preferredType; wgpu::AdapterType preferredType;
@ -314,7 +314,7 @@ ResultOrError<Ref<AdapterBase>> InstanceBase::RequestAdapterInternal(
new AdapterBase(std::move(selectedPhysicalDevice), featureLevel, adapterToggles)); new AdapterBase(std::move(selectedPhysicalDevice), featureLevel, adapterToggles));
} }
void InstanceBase::DiscoverDefaultAdapters() { void InstanceBase::DiscoverDefaultPhysicalDevices() {
for (wgpu::BackendType b : IterateBitSet(GetEnabledBackends())) { for (wgpu::BackendType b : IterateBitSet(GetEnabledBackends())) {
EnsureBackendConnection(b); EnsureBackendConnection(b);
} }
@ -325,7 +325,8 @@ void InstanceBase::DiscoverDefaultAdapters() {
// Query and merge all default adapters for all backends // Query and merge all default adapters for all backends
for (std::unique_ptr<BackendConnection>& backend : mBackends) { for (std::unique_ptr<BackendConnection>& backend : mBackends) {
std::vector<Ref<PhysicalDeviceBase>> physicalDevices = backend->DiscoverDefaultAdapters(); std::vector<Ref<PhysicalDeviceBase>> physicalDevices =
backend->DiscoverDefaultPhysicalDevices();
for (Ref<PhysicalDeviceBase>& physicalDevice : physicalDevices) { for (Ref<PhysicalDeviceBase>& physicalDevice : physicalDevices) {
ASSERT(physicalDevice->GetBackendType() == backend->GetType()); ASSERT(physicalDevice->GetBackendType() == backend->GetType());
@ -338,8 +339,8 @@ void InstanceBase::DiscoverDefaultAdapters() {
} }
// This is just a wrapper around the real logic that uses Error.h error handling. // This is just a wrapper around the real logic that uses Error.h error handling.
bool InstanceBase::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) { bool InstanceBase::DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options) {
MaybeError result = DiscoverAdaptersInternal(options); MaybeError result = DiscoverPhysicalDevicesInternal(options);
if (result.IsError()) { if (result.IsError()) {
dawn::WarningLog() << absl::StrFormat( dawn::WarningLog() << absl::StrFormat(
@ -450,7 +451,8 @@ void InstanceBase::EnsureBackendConnection(wgpu::BackendType backendType) {
mBackendsConnected.set(backendType); mBackendsConnected.set(backendType);
} }
MaybeError InstanceBase::DiscoverAdaptersInternal(const AdapterDiscoveryOptionsBase* options) { MaybeError InstanceBase::DiscoverPhysicalDevicesInternal(
const PhysicalDeviceDiscoveryOptionsBase* options) {
wgpu::BackendType backendType = static_cast<wgpu::BackendType>(options->backendType); wgpu::BackendType backendType = static_cast<wgpu::BackendType>(options->backendType);
DAWN_TRY(ValidateBackendType(backendType)); DAWN_TRY(ValidateBackendType(backendType));
@ -468,7 +470,7 @@ MaybeError InstanceBase::DiscoverAdaptersInternal(const AdapterDiscoveryOptionsB
foundBackend = true; foundBackend = true;
std::vector<Ref<PhysicalDeviceBase>> newPhysicalDevices; std::vector<Ref<PhysicalDeviceBase>> newPhysicalDevices;
DAWN_TRY_ASSIGN(newPhysicalDevices, backend->DiscoverAdapters(options)); DAWN_TRY_ASSIGN(newPhysicalDevices, backend->DiscoverPhysicalDevices(options));
for (Ref<PhysicalDeviceBase>& physicalDevice : newPhysicalDevices) { for (Ref<PhysicalDeviceBase>& physicalDevice : newPhysicalDevices) {
ASSERT(physicalDevice->GetBackendType() == backend->GetType()); ASSERT(physicalDevice->GetBackendType() == backend->GetType());

View File

@ -58,9 +58,10 @@ class InstanceBase final : public RefCountedWithExternalCount {
WGPURequestAdapterCallback callback, WGPURequestAdapterCallback callback,
void* userdata); void* userdata);
void DiscoverDefaultAdapters(); void DiscoverDefaultPhysicalDevices();
bool DiscoverAdapters(const AdapterDiscoveryOptionsBase* options); bool DiscoverPhysicalDevices(const PhysicalDeviceDiscoveryOptionsBase* options);
// Return adapters created on every known physical device.
std::vector<Ref<AdapterBase>> GetAdapters() const; std::vector<Ref<AdapterBase>> GetAdapters() const;
// Used to handle error that happen up to device creation. // Used to handle error that happen up to device creation.
@ -134,7 +135,7 @@ class InstanceBase final : public RefCountedWithExternalCount {
// Lazily creates connections to all backends that have been compiled. // Lazily creates connections to all backends that have been compiled.
void EnsureBackendConnection(wgpu::BackendType backendType); void EnsureBackendConnection(wgpu::BackendType backendType);
MaybeError DiscoverAdaptersInternal(const AdapterDiscoveryOptionsBase* options); MaybeError DiscoverPhysicalDevicesInternal(const PhysicalDeviceDiscoveryOptionsBase* options);
ResultOrError<Ref<AdapterBase>> RequestAdapterInternal(const RequestAdapterOptions* options); ResultOrError<Ref<AdapterBase>> RequestAdapterInternal(const RequestAdapterOptions* options);

View File

@ -238,35 +238,35 @@ const PlatformFunctions* Backend::GetFunctions() const {
return mFunctions.get(); return mFunctions.get();
} }
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() { std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultPhysicalDevices() {
AdapterDiscoveryOptions options(ToAPI(GetType()), nullptr); PhysicalDeviceDiscoveryOptions options(ToAPI(GetType()), nullptr);
std::vector<Ref<PhysicalDeviceBase>> adapters; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;
if (GetInstance()->ConsumedError(DiscoverAdapters(&options), &adapters)) { if (GetInstance()->ConsumedError(DiscoverPhysicalDevices(&options), &physicalDevices)) {
return {}; return {};
} }
return adapters; return physicalDevices;
} }
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) { const PhysicalDeviceDiscoveryOptionsBase* optionsBase) {
ASSERT(optionsBase->backendType == ToAPI(GetType())); ASSERT(optionsBase->backendType == ToAPI(GetType()));
const AdapterDiscoveryOptions* options = const PhysicalDeviceDiscoveryOptions* options =
static_cast<const AdapterDiscoveryOptions*>(optionsBase); static_cast<const PhysicalDeviceDiscoveryOptions*>(optionsBase);
std::vector<Ref<PhysicalDeviceBase>> adapters; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;
if (options->dxgiAdapter != nullptr) { if (options->dxgiAdapter != nullptr) {
// |dxgiAdapter| was provided. Discover just that adapter. // |dxgiAdapter| was provided. Discover just that adapter.
Ref<PhysicalDeviceBase> adapter; Ref<PhysicalDeviceBase> adapter;
DAWN_TRY_ASSIGN(adapter, CreatePhysicalDeviceFromIDXGIAdapter(options->dxgiAdapter)); DAWN_TRY_ASSIGN(adapter, CreatePhysicalDeviceFromIDXGIAdapter(options->dxgiAdapter));
adapters.push_back(std::move(adapter)); physicalDevices.push_back(std::move(adapter));
return std::move(adapters); return std::move(physicalDevices);
} }
// Enumerate and discover all available adapters. // Enumerate and discover all available physicalDevices.
for (uint32_t adapterIndex = 0;; ++adapterIndex) { for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr; ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (GetFactory()->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) { if (GetFactory()->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate. break; // No more physicalDevices to enumerate.
} }
ASSERT(dxgiAdapter != nullptr); ASSERT(dxgiAdapter != nullptr);
@ -276,10 +276,10 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
continue; continue;
} }
adapters.push_back(std::move(adapter)); physicalDevices.push_back(std::move(adapter));
} }
return adapters; return physicalDevices;
} }
} // namespace dawn::native::d3d } // namespace dawn::native::d3d

View File

@ -75,9 +75,9 @@ class Backend : public BackendConnection {
const PlatformFunctions* GetFunctions() const; const PlatformFunctions* GetFunctions() const;
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() override; std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() override;
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) override; const PhysicalDeviceDiscoveryOptionsBase* optionsBase) override;
protected: protected:
virtual ResultOrError<Ref<PhysicalDeviceBase>> CreatePhysicalDeviceFromIDXGIAdapter( virtual ResultOrError<Ref<PhysicalDeviceBase>> CreatePhysicalDeviceFromIDXGIAdapter(

View File

@ -33,9 +33,10 @@ Microsoft::WRL::ComPtr<IDXGIAdapter> GetDXGIAdapter(WGPUAdapter adapter) {
return ToBackend(FromAPI(adapter)->GetPhysicalDevice())->GetHardwareAdapter(); return ToBackend(FromAPI(adapter)->GetPhysicalDevice())->GetHardwareAdapter();
} }
AdapterDiscoveryOptions::AdapterDiscoveryOptions(WGPUBackendType type, PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions(
WGPUBackendType type,
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter) Microsoft::WRL::ComPtr<IDXGIAdapter> adapter)
: AdapterDiscoveryOptionsBase(type), dxgiAdapter(std::move(adapter)) {} : PhysicalDeviceDiscoveryOptionsBase(type), dxgiAdapter(std::move(adapter)) {}
ExternalImageDescriptorDXGISharedHandle::ExternalImageDescriptorDXGISharedHandle() ExternalImageDescriptorDXGISharedHandle::ExternalImageDescriptorDXGISharedHandle()
: ExternalImageDescriptor(ExternalImageType::DXGISharedHandle) {} : ExternalImageDescriptor(ExternalImageType::DXGISharedHandle) {}

View File

@ -25,10 +25,11 @@
namespace dawn::native::d3d11 { namespace dawn::native::d3d11 {
AdapterDiscoveryOptions::AdapterDiscoveryOptions() : AdapterDiscoveryOptions(nullptr) {} PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions()
: PhysicalDeviceDiscoveryOptions(nullptr) {}
AdapterDiscoveryOptions::AdapterDiscoveryOptions(ComPtr<IDXGIAdapter> adapter) PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions(ComPtr<IDXGIAdapter> adapter)
: d3d::AdapterDiscoveryOptions(WGPUBackendType_D3D11, std::move(adapter)) {} : d3d::PhysicalDeviceDiscoveryOptions(WGPUBackendType_D3D11, std::move(adapter)) {}
Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device) { Microsoft::WRL::ComPtr<ID3D11Device> GetD3D11Device(WGPUDevice device) {
return ToBackend(FromAPI(device))->GetD3D11Device(); return ToBackend(FromAPI(device))->GetD3D11Device();

View File

@ -39,9 +39,10 @@ uint64_t SetExternalMemoryReservation(WGPUDevice device,
memorySegment, requestedReservationSize); memorySegment, requestedReservationSize);
} }
AdapterDiscoveryOptions::AdapterDiscoveryOptions() : AdapterDiscoveryOptions(nullptr) {} PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions()
: PhysicalDeviceDiscoveryOptions(nullptr) {}
AdapterDiscoveryOptions::AdapterDiscoveryOptions(ComPtr<IDXGIAdapter> adapter) PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions(ComPtr<IDXGIAdapter> adapter)
: d3d::AdapterDiscoveryOptions(WGPUBackendType_D3D12, std::move(adapter)) {} : d3d::PhysicalDeviceDiscoveryOptions(WGPUBackendType_D3D12, std::move(adapter)) {}
} // namespace dawn::native::d3d12 } // namespace dawn::native::d3d12

View File

@ -26,9 +26,9 @@ class Backend : public BackendConnection {
explicit Backend(InstanceBase* instance); explicit Backend(InstanceBase* instance);
~Backend() override; ~Backend() override;
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() override; std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() override;
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) override; const PhysicalDeviceDiscoveryOptionsBase* optionsBase) override;
}; };
} // namespace dawn::native::metal } // namespace dawn::native::metal

View File

@ -819,9 +819,9 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac
Backend::~Backend() = default; Backend::~Backend() = default;
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() { std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultPhysicalDevices() {
AdapterDiscoveryOptions options; PhysicalDeviceDiscoveryOptions options;
auto result = DiscoverAdapters(&options); auto result = DiscoverPhysicalDevices(&options);
if (result.IsError()) { if (result.IsError()) {
GetInstance()->ConsumedError(result.AcquireError()); GetInstance()->ConsumedError(result.AcquireError());
return {}; return {};
@ -829,8 +829,8 @@ std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() {
return result.AcquireSuccess(); return result.AcquireSuccess();
} }
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) { const PhysicalDeviceDiscoveryOptionsBase* optionsBase) {
ASSERT(optionsBase->backendType == WGPUBackendType_Metal); ASSERT(optionsBase->backendType == WGPUBackendType_Metal);
std::vector<Ref<PhysicalDeviceBase>> physicalDevices; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;

View File

@ -23,8 +23,8 @@
namespace dawn::native::metal { namespace dawn::native::metal {
AdapterDiscoveryOptions::AdapterDiscoveryOptions() PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions()
: AdapterDiscoveryOptionsBase(WGPUBackendType_Metal) {} : PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType_Metal) {}
ExternalImageDescriptorIOSurface::ExternalImageDescriptorIOSurface() ExternalImageDescriptorIOSurface::ExternalImageDescriptorIOSurface()
: ExternalImageDescriptor(ExternalImageType::IOSurface) {} : ExternalImageDescriptor(ExternalImageType::IOSurface) {}

View File

@ -86,7 +86,7 @@ class Backend : public BackendConnection {
explicit Backend(InstanceBase* instance) explicit Backend(InstanceBase* instance)
: BackendConnection(instance, wgpu::BackendType::Null) {} : BackendConnection(instance, wgpu::BackendType::Null) {}
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() override { std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() 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>> physicalDevices; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;

View File

@ -33,8 +33,8 @@ namespace dawn::native::opengl {
Backend::Backend(InstanceBase* instance, wgpu::BackendType backendType) Backend::Backend(InstanceBase* instance, wgpu::BackendType backendType)
: BackendConnection(instance, backendType) {} : BackendConnection(instance, backendType) {}
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() { std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultPhysicalDevices() {
std::vector<Ref<PhysicalDeviceBase>> adapters; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;
#if DAWN_PLATFORM_IS(WINDOWS) #if DAWN_PLATFORM_IS(WINDOWS)
const char* eglLib = "libEGL.dll"; const char* eglLib = "libEGL.dll";
#elif DAWN_PLATFORM_IS(MACOS) #elif DAWN_PLATFORM_IS(MACOS)
@ -46,7 +46,7 @@ std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() {
return {}; return {};
} }
AdapterDiscoveryOptions options(ToAPI(GetType())); PhysicalDeviceDiscoveryOptions options(ToAPI(GetType()));
options.getProc = options.getProc =
reinterpret_cast<void* (*)(const char*)>(mLibEGL.GetProc("eglGetProcAddress")); reinterpret_cast<void* (*)(const char*)>(mLibEGL.GetProc("eglGetProcAddress"));
if (!options.getProc) { if (!options.getProc) {
@ -69,39 +69,41 @@ std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() {
context->MakeCurrent(); context->MakeCurrent();
auto result = DiscoverAdapters(&options); auto result = DiscoverPhysicalDevices(&options);
if (result.IsError()) { if (result.IsError()) {
GetInstance()->ConsumedError(result.AcquireError()); GetInstance()->ConsumedError(result.AcquireError());
} else { } else {
auto value = result.AcquireSuccess(); auto value = result.AcquireSuccess();
adapters.insert(adapters.end(), value.begin(), value.end()); physicalDevices.insert(physicalDevices.end(), value.begin(), value.end());
} }
egl.MakeCurrent(prevDisplay, prevDrawSurface, prevReadSurface, prevContext); egl.MakeCurrent(prevDisplay, prevDrawSurface, prevReadSurface, prevContext);
return adapters; return physicalDevices;
} }
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) { const PhysicalDeviceDiscoveryOptionsBase* optionsBase) {
// TODO(cwallez@chromium.org): For now only create a single OpenGL adapter because don't // TODO(cwallez@chromium.org): For now only create a single OpenGL physicalDevice because don't
// know how to handle MakeCurrent. // know how to handle MakeCurrent.
DAWN_INVALID_IF(mCreatedAdapter, "The OpenGL backend can only create a single adapter."); DAWN_INVALID_IF(mCreatedPhysicalDevice,
"The OpenGL backend can only create a single physicalDevice.");
ASSERT(static_cast<wgpu::BackendType>(optionsBase->backendType) == GetType()); ASSERT(static_cast<wgpu::BackendType>(optionsBase->backendType) == GetType());
const AdapterDiscoveryOptions* options = const PhysicalDeviceDiscoveryOptions* options =
static_cast<const AdapterDiscoveryOptions*>(optionsBase); static_cast<const PhysicalDeviceDiscoveryOptions*>(optionsBase);
DAWN_INVALID_IF(options->getProc == nullptr, "AdapterDiscoveryOptions::getProc must be set"); DAWN_INVALID_IF(options->getProc == nullptr,
"PhysicalDeviceDiscoveryOptions::getProc must be set");
Ref<PhysicalDevice> adapter = AcquireRef(new PhysicalDevice( Ref<PhysicalDevice> physicalDevice = AcquireRef(new PhysicalDevice(
GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType))); GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType)));
DAWN_TRY(adapter->InitializeGLFunctions(options->getProc)); DAWN_TRY(physicalDevice->InitializeGLFunctions(options->getProc));
DAWN_TRY(adapter->Initialize()); DAWN_TRY(physicalDevice->Initialize());
mCreatedAdapter = true; mCreatedPhysicalDevice = true;
std::vector<Ref<PhysicalDeviceBase>> adapters{std::move(adapter)}; std::vector<Ref<PhysicalDeviceBase>> adapters{std::move(physicalDevice)};
return std::move(adapters); return std::move(adapters);
} }

View File

@ -26,12 +26,12 @@ class Backend : public BackendConnection {
public: public:
Backend(InstanceBase* instance, wgpu::BackendType backendType); Backend(InstanceBase* instance, wgpu::BackendType backendType);
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() override; std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() override;
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* option) override; const PhysicalDeviceDiscoveryOptionsBase* option) override;
private: private:
bool mCreatedAdapter = false; bool mCreatedPhysicalDevice = false;
DynamicLib mLibEGL; DynamicLib mLibEGL;
}; };

View File

@ -21,11 +21,11 @@
namespace dawn::native::opengl { namespace dawn::native::opengl {
AdapterDiscoveryOptions::AdapterDiscoveryOptions(WGPUBackendType type) PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions(WGPUBackendType type)
: AdapterDiscoveryOptionsBase(type) {} : PhysicalDeviceDiscoveryOptionsBase(type) {}
AdapterDiscoveryOptionsES::AdapterDiscoveryOptionsES() AdapterDiscoveryOptionsES::AdapterDiscoveryOptionsES()
: AdapterDiscoveryOptions(WGPUBackendType_OpenGLES) {} : PhysicalDeviceDiscoveryOptions(WGPUBackendType_OpenGLES) {}
ExternalImageDescriptorEGLImage::ExternalImageDescriptorEGLImage() ExternalImageDescriptorEGLImage::ExternalImageDescriptorEGLImage()
: ExternalImageDescriptor(ExternalImageType::EGLImage) {} : ExternalImageDescriptor(ExternalImageType::EGLImage) {}

View File

@ -457,9 +457,9 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac
Backend::~Backend() = default; Backend::~Backend() = default;
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() { std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultPhysicalDevices() {
AdapterDiscoveryOptions options; PhysicalDeviceDiscoveryOptions options;
auto result = DiscoverAdapters(&options); auto result = DiscoverPhysicalDevices(&options);
if (result.IsError()) { if (result.IsError()) {
GetInstance()->ConsumedError(result.AcquireError()); GetInstance()->ConsumedError(result.AcquireError());
return {}; return {};
@ -467,12 +467,12 @@ std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters() {
return result.AcquireSuccess(); return result.AcquireSuccess();
} }
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) { const PhysicalDeviceDiscoveryOptionsBase* optionsBase) {
ASSERT(optionsBase->backendType == WGPUBackendType_Vulkan); ASSERT(optionsBase->backendType == WGPUBackendType_Vulkan);
const AdapterDiscoveryOptions* options = const PhysicalDeviceDiscoveryOptions* options =
static_cast<const AdapterDiscoveryOptions*>(optionsBase); static_cast<const PhysicalDeviceDiscoveryOptions*>(optionsBase);
std::vector<Ref<PhysicalDeviceBase>> physicalDevices; std::vector<Ref<PhysicalDeviceBase>> physicalDevices;

View File

@ -91,9 +91,9 @@ class Backend : public BackendConnection {
MaybeError Initialize(); MaybeError Initialize();
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters() override; std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultPhysicalDevices() override;
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverPhysicalDevices(
const AdapterDiscoveryOptionsBase* optionsBase) override; const PhysicalDeviceDiscoveryOptionsBase* optionsBase) override;
private: private:
ityp::array<ICD, Ref<VulkanInstance>, 2> mVulkanInstances = {}; ityp::array<ICD, Ref<VulkanInstance>, 2> mVulkanInstances = {};

View File

@ -36,8 +36,8 @@ DAWN_NATIVE_EXPORT PFN_vkVoidFunction GetInstanceProcAddr(WGPUDevice device, con
return (*backendDevice->fn.GetInstanceProcAddr)(backendDevice->GetVkInstance(), pName); return (*backendDevice->fn.GetInstanceProcAddr)(backendDevice->GetVkInstance(), pName);
} }
AdapterDiscoveryOptions::AdapterDiscoveryOptions() PhysicalDeviceDiscoveryOptions::PhysicalDeviceDiscoveryOptions()
: AdapterDiscoveryOptionsBase(WGPUBackendType_Vulkan) {} : PhysicalDeviceDiscoveryOptionsBase(WGPUBackendType_Vulkan) {}
#if DAWN_PLATFORM_IS(LINUX) #if DAWN_PLATFORM_IS(LINUX)
ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD() ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()

View File

@ -272,7 +272,7 @@ int main(int argc, const char* argv[]) {
dawnProcSetProcs(&procs); dawnProcSetProcs(&procs);
instance = std::make_unique<dawn::native::Instance>(); instance = std::make_unique<dawn::native::Instance>();
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters(); std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
dawn::native::Adapter chosenAdapter; dawn::native::Adapter chosenAdapter;

View File

@ -128,7 +128,7 @@ wgpu::Device CreateCppDawnDevice() {
} }
instance = std::make_unique<dawn::native::Instance>(); instance = std::make_unique<dawn::native::Instance>();
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
// Get an adapter for the backend to use, and create the device. // Get an adapter for the backend to use, and create the device.
dawn::native::Adapter backendAdapter; dawn::native::Adapter backendAdapter;

View File

@ -485,7 +485,7 @@ source_set("end2end_tests_sources") {
] ]
sources = [ sources = [
"end2end/AdapterDiscoveryTests.cpp", "end2end/AdapterCreationTests.cpp",
"end2end/BasicTests.cpp", "end2end/BasicTests.cpp",
"end2end/BindGroupTests.cpp", "end2end/BindGroupTests.cpp",
"end2end/BufferTests.cpp", "end2end/BufferTests.cpp",
@ -536,6 +536,7 @@ source_set("end2end_tests_sources") {
"end2end/NonzeroTextureCreationTests.cpp", "end2end/NonzeroTextureCreationTests.cpp",
"end2end/ObjectCachingTests.cpp", "end2end/ObjectCachingTests.cpp",
"end2end/OpArrayLengthTests.cpp", "end2end/OpArrayLengthTests.cpp",
"end2end/PhysicalDeviceDiscoveryTests.cpp",
"end2end/PipelineCachingTests.cpp", "end2end/PipelineCachingTests.cpp",
"end2end/PipelineLayoutTests.cpp", "end2end/PipelineLayoutTests.cpp",
"end2end/PrimitiveStateTests.cpp", "end2end/PrimitiveStateTests.cpp",

View File

@ -64,7 +64,7 @@ void DawnNativeTest::SetUp() {
instance = std::make_unique<dawn::native::Instance>( instance = std::make_unique<dawn::native::Instance>(
reinterpret_cast<const WGPUInstanceDescriptor*>(&instanceDesc)); reinterpret_cast<const WGPUInstanceDescriptor*>(&instanceDesc));
instance->EnableAdapterBlocklist(false); instance->EnableAdapterBlocklist(false);
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters(); std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();

View File

@ -416,7 +416,7 @@ std::unique_ptr<dawn::native::Instance> DawnTestEnvironment::CreateInstanceAndDi
} }
#endif // DAWN_ENABLE_BACKEND_OPENGLES #endif // DAWN_ENABLE_BACKEND_OPENGLES
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
return instance; return instance;
} }

View File

@ -33,7 +33,7 @@ void SetupNullBackend(const benchmark::State& state) {
if (!nativeInstance) { if (!nativeInstance) {
nativeInstance = std::make_unique<dawn::native::Instance>(); nativeInstance = std::make_unique<dawn::native::Instance>();
nativeInstance->DiscoverDefaultAdapters(); nativeInstance->DiscoverDefaultPhysicalDevices();
} }
if (!nullBackendAdapter) { if (!nullBackendAdapter) {

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Dawn Authors // Copyright 2023 The Dawn Authors
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -16,36 +16,11 @@
#include <utility> #include <utility>
#include "dawn/common/GPUInfo.h" #include "dawn/common/GPUInfo.h"
#include "dawn/common/Log.h"
#include "dawn/common/Platform.h"
#include "dawn/common/SystemUtils.h"
#include "dawn/dawn_proc.h" #include "dawn/dawn_proc.h"
#include "dawn/native/DawnNative.h" #include "dawn/native/DawnNative.h"
#include "dawn/tests/MockCallback.h" #include "dawn/tests/MockCallback.h"
#include "dawn/webgpu_cpp.h" #include "dawn/webgpu_cpp.h"
#include "gtest/gtest.h"
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
#include "dawn/native/VulkanBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
#include "dawn/native/D3D11Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
#include "dawn/native/D3D12Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
#if defined(DAWN_ENABLE_BACKEND_METAL)
#include "dawn/native/MetalBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_ENABLE_BACKEND_DESKTOP_GL) || defined(DAWN_ENABLE_BACKEND_OPENGLES)
#include "GLFW/glfw3.h"
#include "dawn/native/OpenGLBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_DESKTOP_GL) || defined(DAWN_ENABLE_BACKEND_OPENGLES)
#include <gtest/gtest.h>
namespace dawn { namespace dawn {
namespace { namespace {
@ -54,209 +29,15 @@ using testing::_;
using testing::MockCallback; using testing::MockCallback;
using testing::SaveArg; using testing::SaveArg;
class AdapterDiscoveryTests : public ::testing::Test {};
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
// Test only discovering the SwiftShader adapter
TEST(AdapterDiscoveryTests, OnlySwiftShader) {
native::Instance instance;
native::vulkan::AdapterDiscoveryOptions options;
options.forceSwiftShader = true;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
EXPECT_LE(adapters.size(), 2u); // 0 or 2 SwiftShader adapters.
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan);
EXPECT_EQ(properties.adapterType, wgpu::AdapterType::CPU);
EXPECT_TRUE(gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID));
}
}
// Test discovering only Vulkan adapters
TEST(AdapterDiscoveryTests, OnlyVulkan) {
native::Instance instance;
native::vulkan::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
// Test discovering only D3D11 adapters
TEST(AdapterDiscoveryTests, OnlyD3D11) {
native::Instance instance;
native::d3d11::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
// Test discovering a D3D11 adapter from a prexisting DXGI adapter
TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D11) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;
HRESULT hr = ::CreateDXGIFactory2(0, IID_PPV_ARGS(&dxgiFactory));
ASSERT_EQ(hr, S_OK);
for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate.
}
native::Instance instance;
native::d3d11::AdapterDiscoveryOptions options;
options.dxgiAdapter = std::move(dxgiAdapter);
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
}
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
// Test discovering only D3D12 adapters
TEST(AdapterDiscoveryTests, OnlyD3D12) {
native::Instance instance;
native::d3d12::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12);
}
}
// Test discovering a D3D12 adapter from a prexisting DXGI adapter
TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D12) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;
HRESULT hr = ::CreateDXGIFactory2(0, IID_PPV_ARGS(&dxgiFactory));
ASSERT_EQ(hr, S_OK);
for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate.
}
native::Instance instance;
native::d3d12::AdapterDiscoveryOptions options;
options.dxgiAdapter = std::move(dxgiAdapter);
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12);
}
}
}
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
#if defined(DAWN_ENABLE_BACKEND_METAL)
// Test discovering only Metal adapters
TEST(AdapterDiscoveryTests, OnlyMetal) {
native::Instance instance;
native::metal::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Metal);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(DAWN_ENABLE_BACKEND_VULKAN)
// Test discovering the Metal backend, then the Vulkan backend
// does not duplicate adapters.
TEST(AdapterDiscoveryTests, OneBackendThenTheOther) {
native::Instance instance;
uint32_t metalAdapterCount = 0;
{
native::metal::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
metalAdapterCount = adapters.size();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
ASSERT_EQ(properties.backendType, wgpu::BackendType::Metal);
}
}
{
native::vulkan::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
uint32_t metalAdapterCount2 = 0;
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_TRUE(properties.backendType == wgpu::BackendType::Metal ||
properties.backendType == wgpu::BackendType::Vulkan);
if (properties.backendType == wgpu::BackendType::Metal) {
metalAdapterCount2++;
}
}
EXPECT_EQ(metalAdapterCount, metalAdapterCount2);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN) && defined(DAWN_ENABLE_BACKEND_METAL)
class AdapterCreationTest : public ::testing::Test { class AdapterCreationTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
dawnProcSetProcs(&dawn_native::GetProcs()); dawnProcSetProcs(&native::GetProcs());
{ {
auto nativeInstance = std::make_unique<dawn_native::Instance>(); auto nativeInstance = std::make_unique<native::Instance>();
nativeInstance->DiscoverDefaultAdapters(); nativeInstance->DiscoverDefaultPhysicalDevices();
for (dawn_native::Adapter& nativeAdapter : nativeInstance->GetAdapters()) { for (native::Adapter& nativeAdapter : nativeInstance->GetAdapters()) {
anyAdapterAvailable = true; anyAdapterAvailable = true;
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;

View File

@ -78,7 +78,7 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) {
{ {
auto instance = std::make_unique<native::Instance>(); auto instance = std::make_unique<native::Instance>();
instance->EnableAdapterBlocklist(false); instance->EnableAdapterBlocklist(false);
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
for (const native::Adapter& adapter : instance->GetAdapters()) { for (const native::Adapter& adapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
adapter.GetProperties(&properties); adapter.GetProperties(&properties);
@ -96,7 +96,7 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) {
auto instance = std::make_unique<native::Instance>(); auto instance = std::make_unique<native::Instance>();
instance->EnableAdapterBlocklist(false); instance->EnableAdapterBlocklist(false);
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
for (native::Adapter& adapter : instance->GetAdapters()) { for (native::Adapter& adapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
adapter.GetProperties(&properties); adapter.GetProperties(&properties);
@ -127,7 +127,7 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) {
{ {
auto instance = std::make_unique<native::Instance>(); auto instance = std::make_unique<native::Instance>();
instance->EnableAdapterBlocklist(false); instance->EnableAdapterBlocklist(false);
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
for (const native::Adapter& adapter : instance->GetAdapters()) { for (const native::Adapter& adapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
adapter.GetProperties(&properties); adapter.GetProperties(&properties);
@ -152,7 +152,7 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) {
// It will only be valid as long as the instance is alive. // It will only be valid as long as the instance is alive.
WGPUInstance unsafeInstancePtr = instance->Get(); WGPUInstance unsafeInstancePtr = instance->Get();
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
for (native::Adapter& nativeAdapter : instance->GetAdapters()) { for (native::Adapter& nativeAdapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
nativeAdapter.GetProperties(&properties); nativeAdapter.GetProperties(&properties);

View File

@ -0,0 +1,243 @@
// Copyright 2021 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <memory>
#include <utility>
#include "dawn/common/GPUInfo.h"
#include "dawn/native/DawnNative.h"
#include "dawn/webgpu_cpp.h"
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
#include "dawn/native/VulkanBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
#include "dawn/native/D3D11Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
#include "dawn/native/D3D12Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
#if defined(DAWN_ENABLE_BACKEND_METAL)
#include "dawn/native/MetalBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_ENABLE_BACKEND_DESKTOP_GL) || defined(DAWN_ENABLE_BACKEND_OPENGLES)
#include "GLFW/glfw3.h"
#include "dawn/native/OpenGLBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_DESKTOP_GL) || defined(DAWN_ENABLE_BACKEND_OPENGLES)
#include <gtest/gtest.h>
namespace dawn {
namespace {
class PhysicalDeviceDiscoveryTests : public ::testing::Test {};
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
// Test only discovering the SwiftShader physical devices
TEST(PhysicalDeviceDiscoveryTests, OnlySwiftShader) {
native::Instance instance;
native::vulkan::PhysicalDeviceDiscoveryOptions options;
options.forceSwiftShader = true;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
EXPECT_LE(adapters.size(), 2u); // 0 or 2 SwiftShader adapters.
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan);
EXPECT_EQ(properties.adapterType, wgpu::AdapterType::CPU);
EXPECT_TRUE(gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID));
}
}
// Test discovering only Vulkan physical devices
TEST(PhysicalDeviceDiscoveryTests, OnlyVulkan) {
native::Instance instance;
native::vulkan::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Vulkan);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
// Test discovering only D3D11 physical devices
TEST(PhysicalDeviceDiscoveryTests, OnlyD3D11) {
native::Instance instance;
native::d3d11::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
// Test discovering a D3D11 physical device from a prexisting DXGI adapter
TEST(PhysicalDeviceDiscoveryTests, MatchingDXGIAdapterD3D11) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;
HRESULT hr = ::CreateDXGIFactory2(0, IID_PPV_ARGS(&dxgiFactory));
ASSERT_EQ(hr, S_OK);
for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate.
}
native::Instance instance;
native::d3d11::PhysicalDeviceDiscoveryOptions options;
options.dxgiAdapter = std::move(dxgiAdapter);
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
}
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
// Test discovering only D3D12 physical devices
TEST(PhysicalDeviceDiscoveryTests, OnlyD3D12) {
native::Instance instance;
native::d3d12::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12);
}
}
// Test discovering a D3D12 physical device from a prexisting DXGI adapter
TEST(PhysicalDeviceDiscoveryTests, MatchingDXGIAdapterD3D12) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;
HRESULT hr = ::CreateDXGIFactory2(0, IID_PPV_ARGS(&dxgiFactory));
ASSERT_EQ(hr, S_OK);
for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate.
}
native::Instance instance;
native::d3d12::PhysicalDeviceDiscoveryOptions options;
options.dxgiAdapter = std::move(dxgiAdapter);
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D12);
}
}
}
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
#if defined(DAWN_ENABLE_BACKEND_METAL)
// Test discovering only Metal physical devices
TEST(PhysicalDeviceDiscoveryTests, OnlyMetal) {
native::Instance instance;
native::metal::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::Metal);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(DAWN_ENABLE_BACKEND_VULKAN)
// Test discovering the Metal backend, then the Vulkan backend
// does not duplicate physical devices.
TEST(PhysicalDeviceDiscoveryTests, OneBackendThenTheOther) {
native::Instance instance;
uint32_t metalAdapterCount = 0;
{
native::metal::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
const auto& adapters = instance.GetAdapters();
metalAdapterCount = adapters.size();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
ASSERT_EQ(properties.backendType, wgpu::BackendType::Metal);
}
}
{
native::vulkan::PhysicalDeviceDiscoveryOptions options;
instance.DiscoverPhysicalDevices(&options);
uint32_t metalAdapterCount2 = 0;
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_TRUE(properties.backendType == wgpu::BackendType::Metal ||
properties.backendType == wgpu::BackendType::Vulkan);
if (properties.backendType == wgpu::BackendType::Metal) {
metalAdapterCount2++;
}
}
EXPECT_EQ(metalAdapterCount, metalAdapterCount2);
}
}
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN) && defined(DAWN_ENABLE_BACKEND_METAL)
} // anonymous namespace
} // namespace dawn

View File

@ -170,10 +170,10 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) {
native::InstanceBase* instance = native::FromAPI(nativeInstance->Get()); native::InstanceBase* instance = native::FromAPI(nativeInstance->Get());
const native::TogglesState& instanceTogglesState = instance->GetTogglesState(); const native::TogglesState& instanceTogglesState = instance->GetTogglesState();
// Discover adapters with default toggles. // Discover physical devices.
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
// Get the adapter created by instance with default toggles. // Get the adapters created by instance with default toggles.
Ref<native::AdapterBase> nullAdapter; Ref<native::AdapterBase> nullAdapter;
for (auto& adapter : instance->GetAdapters()) { for (auto& adapter : instance->GetAdapters()) {
if (adapter->GetPhysicalDevice()->GetBackendType() == wgpu::BackendType::Null) { if (adapter->GetPhysicalDevice()->GetBackendType() == wgpu::BackendType::Null) {

View File

@ -43,7 +43,7 @@ class DeviceCreationTest : public testing::Test {
// Create an instance with default toggles and create an adapter from it. // Create an instance with default toggles and create an adapter from it.
WGPUInstanceDescriptor safeInstanceDesc = {}; WGPUInstanceDescriptor safeInstanceDesc = {};
instance = std::make_unique<dawn::native::Instance>(&safeInstanceDesc); instance = std::make_unique<dawn::native::Instance>(&safeInstanceDesc);
instance->DiscoverDefaultAdapters(); instance->DiscoverDefaultPhysicalDevices();
for (dawn::native::Adapter& nativeAdapter : instance->GetAdapters()) { for (dawn::native::Adapter& nativeAdapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
nativeAdapter.GetProperties(&properties); nativeAdapter.GetProperties(&properties);
@ -67,7 +67,7 @@ class DeviceCreationTest : public testing::Test {
unsafeInstanceDesc.nextInChain = &unsafeInstanceTogglesDesc.chain; unsafeInstanceDesc.nextInChain = &unsafeInstanceTogglesDesc.chain;
unsafeInstanceDisallow = std::make_unique<dawn::native::Instance>(&unsafeInstanceDesc); unsafeInstanceDisallow = std::make_unique<dawn::native::Instance>(&unsafeInstanceDesc);
unsafeInstanceDisallow->DiscoverDefaultAdapters(); unsafeInstanceDisallow->DiscoverDefaultPhysicalDevices();
for (dawn::native::Adapter& nativeAdapter : unsafeInstanceDisallow->GetAdapters()) { for (dawn::native::Adapter& nativeAdapter : unsafeInstanceDisallow->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
nativeAdapter.GetProperties(&properties); nativeAdapter.GetProperties(&properties);
@ -90,7 +90,7 @@ class DeviceCreationTest : public testing::Test {
unsafeInstanceDesc.nextInChain = &unsafeInstanceTogglesDesc.chain; unsafeInstanceDesc.nextInChain = &unsafeInstanceTogglesDesc.chain;
unsafeInstance = std::make_unique<dawn::native::Instance>(&unsafeInstanceDesc); unsafeInstance = std::make_unique<dawn::native::Instance>(&unsafeInstanceDesc);
unsafeInstance->DiscoverDefaultAdapters(); unsafeInstance->DiscoverDefaultPhysicalDevices();
for (dawn::native::Adapter& nativeAdapter : unsafeInstance->GetAdapters()) { for (dawn::native::Adapter& nativeAdapter : unsafeInstance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
nativeAdapter.GetProperties(&properties); nativeAdapter.GetProperties(&properties);

View File

@ -145,7 +145,7 @@ void ValidationTest::SetUp() {
mDawnInstance = std::make_unique<dawn::native::Instance>(&instanceDesc); mDawnInstance = std::make_unique<dawn::native::Instance>(&instanceDesc);
mDawnInstance->DiscoverDefaultAdapters(); mDawnInstance->DiscoverDefaultPhysicalDevices();
mInstance = mWireHelper->RegisterInstance(mDawnInstance->Get()); mInstance = mWireHelper->RegisterInstance(mDawnInstance->Get());
std::string traceName = std::string traceName =