mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 11:21:40 +00:00
Add WGPUAdapterProperties and expose it in DawnNative
The dawn_native::Adapter::GetPCIInfo/GetBackendType/GetDeviceType methods are now deprecated in favor of a method returning a webgpu.h AdapterProperties structure. Deprecated function are still available to avoid breaking Chromium or Skia compilation. This reduces the difference between dawn.json and webgpu.h BUG=dawn:160 Change-Id: Ib68fe1c4d1d87676c01c212c91f80fdd26056c56 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14541 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
5fc2c82c11
commit
f12c9dba6d
32
dawn.json
32
dawn.json
@ -14,6 +14,26 @@
|
|||||||
"See the License for the specific language governing permissions and",
|
"See the License for the specific language governing permissions and",
|
||||||
"limitations under the License."
|
"limitations under the License."
|
||||||
],
|
],
|
||||||
|
"adapter properties": {
|
||||||
|
"category": "structure",
|
||||||
|
"extensible": true,
|
||||||
|
"members": [
|
||||||
|
{"name": "device ID", "type": "uint32_t"},
|
||||||
|
{"name": "vendor ID", "type": "uint32_t"},
|
||||||
|
{"name": "name", "type": "char", "annotation": "const*"},
|
||||||
|
{"name": "adapter type", "type": "adapter type"},
|
||||||
|
{"name": "backend type", "type": "backend type"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"adapter type": {
|
||||||
|
"category": "enum",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "discrete GPU"},
|
||||||
|
{"value": 1, "name": "integrated GPU"},
|
||||||
|
{"value": 2, "name": "CPU"},
|
||||||
|
{"value": 3, "name": "Unknown"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"address mode": {
|
"address mode": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
@ -22,6 +42,18 @@
|
|||||||
{"value": 2, "name": "clamp to edge"}
|
{"value": 2, "name": "clamp to edge"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"backend type": {
|
||||||
|
"category": "enum",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "D3D11"},
|
||||||
|
{"value": 1, "name": "D3D12"},
|
||||||
|
{"value": 2, "name": "metal"},
|
||||||
|
{"value": 3, "name": "vulkan"},
|
||||||
|
{"value": 4, "name": "openGL"},
|
||||||
|
{"value": 5, "name": "openGLES"},
|
||||||
|
{"value": 6, "name": "null"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"bind group": {
|
"bind group": {
|
||||||
"category": "object"
|
"category": "object"
|
||||||
},
|
},
|
||||||
|
@ -65,13 +65,13 @@ enum class CmdBufType {
|
|||||||
// Default to D3D12, Metal, Vulkan, OpenGL in that order as D3D12 and Metal are the preferred on
|
// Default to D3D12, Metal, Vulkan, OpenGL in that order as D3D12 and Metal are the preferred on
|
||||||
// their respective platforms, and Vulkan is preferred to OpenGL
|
// their respective platforms, and Vulkan is preferred to OpenGL
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
static dawn_native::BackendType backendType = dawn_native::BackendType::D3D12;
|
static wgpu::BackendType backendType = wgpu::BackendType::D3D12;
|
||||||
#elif defined(DAWN_ENABLE_BACKEND_METAL)
|
#elif defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
static dawn_native::BackendType backendType = dawn_native::BackendType::Metal;
|
static wgpu::BackendType backendType = wgpu::BackendType::Metal;
|
||||||
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
|
|
||||||
static dawn_native::BackendType backendType = dawn_native::BackendType::OpenGL;
|
|
||||||
#elif defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#elif defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
static dawn_native::BackendType backendType = dawn_native::BackendType::Vulkan;
|
static wgpu::BackendType backendType = wgpu::BackendType::Vulkan;
|
||||||
|
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
|
static wgpu::BackendType backendType = wgpu::BackendType::OpenGL;
|
||||||
#else
|
#else
|
||||||
#error
|
#error
|
||||||
#endif
|
#endif
|
||||||
@ -109,7 +109,9 @@ wgpu::Device CreateCppDawnDevice() {
|
|||||||
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
|
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
|
||||||
auto adapterIt = std::find_if(adapters.begin(), adapters.end(),
|
auto adapterIt = std::find_if(adapters.begin(), adapters.end(),
|
||||||
[](const dawn_native::Adapter adapter) -> bool {
|
[](const dawn_native::Adapter adapter) -> bool {
|
||||||
return adapter.GetBackendType() == backendType;
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
|
return properties.backendType == backendType;
|
||||||
});
|
});
|
||||||
ASSERT(adapterIt != adapters.end());
|
ASSERT(adapterIt != adapters.end());
|
||||||
backendAdapter = *adapterIt;
|
backendAdapter = *adapterIt;
|
||||||
@ -200,23 +202,23 @@ bool InitSample(int argc, const char** argv) {
|
|||||||
if (std::string("-b") == argv[i] || std::string("--backend") == argv[i]) {
|
if (std::string("-b") == argv[i] || std::string("--backend") == argv[i]) {
|
||||||
i++;
|
i++;
|
||||||
if (i < argc && std::string("d3d12") == argv[i]) {
|
if (i < argc && std::string("d3d12") == argv[i]) {
|
||||||
backendType = dawn_native::BackendType::D3D12;
|
backendType = wgpu::BackendType::D3D12;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i < argc && std::string("metal") == argv[i]) {
|
if (i < argc && std::string("metal") == argv[i]) {
|
||||||
backendType = dawn_native::BackendType::Metal;
|
backendType = wgpu::BackendType::Metal;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i < argc && std::string("null") == argv[i]) {
|
if (i < argc && std::string("null") == argv[i]) {
|
||||||
backendType = dawn_native::BackendType::Null;
|
backendType = wgpu::BackendType::Null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i < argc && std::string("opengl") == argv[i]) {
|
if (i < argc && std::string("opengl") == argv[i]) {
|
||||||
backendType = dawn_native::BackendType::OpenGL;
|
backendType = wgpu::BackendType::OpenGL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i < argc && std::string("vulkan") == argv[i]) {
|
if (i < argc && std::string("vulkan") == argv[i]) {
|
||||||
backendType = dawn_native::BackendType::Vulkan;
|
backendType = wgpu::BackendType::Vulkan;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "--backend expects a backend name (opengl, metal, d3d12, null, vulkan)\n");
|
fprintf(stderr, "--backend expects a backend name (opengl, metal, d3d12, null, vulkan)\n");
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
AdapterBase::AdapterBase(InstanceBase* instance, BackendType backend)
|
AdapterBase::AdapterBase(InstanceBase* instance, wgpu::BackendType backend)
|
||||||
: mInstance(instance), mBackend(backend) {
|
: mInstance(instance), mBackend(backend) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendType AdapterBase::GetBackendType() const {
|
wgpu::BackendType AdapterBase::GetBackendType() const {
|
||||||
return mBackend;
|
return mBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceType AdapterBase::GetDeviceType() const {
|
wgpu::AdapterType AdapterBase::GetAdapterType() const {
|
||||||
return mDeviceType;
|
return mAdapterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PCIInfo& AdapterBase::GetPCIInfo() const {
|
const PCIInfo& AdapterBase::GetPCIInfo() const {
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include "dawn_native/Error.h"
|
#include "dawn_native/Error.h"
|
||||||
#include "dawn_native/Extensions.h"
|
#include "dawn_native/Extensions.h"
|
||||||
|
#include "dawn_native/dawn_platform.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
@ -26,11 +29,11 @@ namespace dawn_native {
|
|||||||
|
|
||||||
class AdapterBase {
|
class AdapterBase {
|
||||||
public:
|
public:
|
||||||
AdapterBase(InstanceBase* instance, BackendType backend);
|
AdapterBase(InstanceBase* instance, wgpu::BackendType backend);
|
||||||
virtual ~AdapterBase() = default;
|
virtual ~AdapterBase() = default;
|
||||||
|
|
||||||
BackendType GetBackendType() const;
|
wgpu::BackendType GetBackendType() const;
|
||||||
DeviceType GetDeviceType() const;
|
wgpu::AdapterType GetAdapterType() const;
|
||||||
const PCIInfo& GetPCIInfo() const;
|
const PCIInfo& GetPCIInfo() const;
|
||||||
InstanceBase* GetInstance() const;
|
InstanceBase* GetInstance() const;
|
||||||
|
|
||||||
@ -43,7 +46,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
PCIInfo mPCIInfo = {};
|
PCIInfo mPCIInfo = {};
|
||||||
DeviceType mDeviceType = DeviceType::Unknown;
|
wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown;
|
||||||
ExtensionsSet mSupportedExtensions;
|
ExtensionsSet mSupportedExtensions;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -52,7 +55,7 @@ namespace dawn_native {
|
|||||||
MaybeError CreateDeviceInternal(DeviceBase** result, const DeviceDescriptor* descriptor);
|
MaybeError CreateDeviceInternal(DeviceBase** result, const DeviceDescriptor* descriptor);
|
||||||
|
|
||||||
InstanceBase* mInstance = nullptr;
|
InstanceBase* mInstance = nullptr;
|
||||||
BackendType mBackend;
|
wgpu::BackendType mBackend;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
BackendConnection::BackendConnection(InstanceBase* instance, BackendType type)
|
BackendConnection::BackendConnection(InstanceBase* instance, wgpu::BackendType type)
|
||||||
: mInstance(instance), mType(type) {
|
: mInstance(instance), mType(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendType BackendConnection::GetType() const {
|
wgpu::BackendType BackendConnection::GetType() const {
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ namespace dawn_native {
|
|||||||
// backend.
|
// backend.
|
||||||
class BackendConnection {
|
class BackendConnection {
|
||||||
public:
|
public:
|
||||||
BackendConnection(InstanceBase* instance, BackendType type);
|
BackendConnection(InstanceBase* instance, wgpu::BackendType type);
|
||||||
virtual ~BackendConnection() = default;
|
virtual ~BackendConnection() = default;
|
||||||
|
|
||||||
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 adapters for the system that can be created by the backend, without extra
|
||||||
@ -42,7 +42,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
InstanceBase* mInstance = nullptr;
|
InstanceBase* mInstance = nullptr;
|
||||||
BackendType mType;
|
wgpu::BackendType mType;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -44,12 +44,44 @@ namespace dawn_native {
|
|||||||
mImpl = nullptr;
|
mImpl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adapter::GetProperties(wgpu::AdapterProperties* properties) const {
|
||||||
|
properties->backendType = mImpl->GetBackendType();
|
||||||
|
properties->adapterType = mImpl->GetAdapterType();
|
||||||
|
properties->deviceID = mImpl->GetPCIInfo().deviceId;
|
||||||
|
properties->vendorID = mImpl->GetPCIInfo().vendorId;
|
||||||
|
properties->name = mImpl->GetPCIInfo().name.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
BackendType Adapter::GetBackendType() const {
|
BackendType Adapter::GetBackendType() const {
|
||||||
return mImpl->GetBackendType();
|
switch (mImpl->GetBackendType()) {
|
||||||
|
case wgpu::BackendType::D3D12:
|
||||||
|
return BackendType::D3D12;
|
||||||
|
case wgpu::BackendType::Metal:
|
||||||
|
return BackendType::Metal;
|
||||||
|
case wgpu::BackendType::Null:
|
||||||
|
return BackendType::Null;
|
||||||
|
case wgpu::BackendType::OpenGL:
|
||||||
|
return BackendType::OpenGL;
|
||||||
|
case wgpu::BackendType::Vulkan:
|
||||||
|
return BackendType::Vulkan;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return BackendType::Null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceType Adapter::GetDeviceType() const {
|
DeviceType Adapter::GetDeviceType() const {
|
||||||
return mImpl->GetDeviceType();
|
switch (mImpl->GetAdapterType()) {
|
||||||
|
case wgpu::AdapterType::DiscreteGPU:
|
||||||
|
return DeviceType::DiscreteGPU;
|
||||||
|
case wgpu::AdapterType::IntegratedGPU:
|
||||||
|
return DeviceType::IntegratedGPU;
|
||||||
|
case wgpu::AdapterType::CPU:
|
||||||
|
return DeviceType::CPU;
|
||||||
|
case wgpu::AdapterType::Unknown:
|
||||||
|
return DeviceType::Unknown;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const PCIInfo& Adapter::GetPCIInfo() const {
|
const PCIInfo& Adapter::GetPCIInfo() const {
|
||||||
@ -75,7 +107,8 @@ namespace dawn_native {
|
|||||||
|
|
||||||
// AdapterDiscoverOptionsBase
|
// AdapterDiscoverOptionsBase
|
||||||
|
|
||||||
AdapterDiscoveryOptionsBase::AdapterDiscoveryOptionsBase(BackendType type) : backendType(type) {
|
AdapterDiscoveryOptionsBase::AdapterDiscoveryOptionsBase(WGPUBackendType type)
|
||||||
|
: backendType(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
|
@ -120,7 +120,7 @@ namespace dawn_native {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Register = [this](BackendConnection* connection, BackendType expectedType) {
|
auto Register = [this](BackendConnection* connection, wgpu::BackendType expectedType) {
|
||||||
if (connection != nullptr) {
|
if (connection != nullptr) {
|
||||||
ASSERT(connection->GetType() == expectedType);
|
ASSERT(connection->GetType() == expectedType);
|
||||||
ASSERT(connection->GetInstance() == this);
|
ASSERT(connection->GetInstance() == this);
|
||||||
@ -129,25 +129,25 @@ namespace dawn_native {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
Register(d3d12::Connect(this), BackendType::D3D12);
|
Register(d3d12::Connect(this), wgpu::BackendType::D3D12);
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
|
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
Register(metal::Connect(this), BackendType::Metal);
|
Register(metal::Connect(this), wgpu::BackendType::Metal);
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
Register(vulkan::Connect(this), BackendType::Vulkan);
|
Register(vulkan::Connect(this), wgpu::BackendType::Vulkan);
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
Register(opengl::Connect(this), BackendType::OpenGL);
|
Register(opengl::Connect(this), wgpu::BackendType::OpenGL);
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#endif // defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
||||||
Register(null::Connect(this), BackendType::Null);
|
Register(null::Connect(this), wgpu::BackendType::Null);
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_NULL)
|
#endif // defined(DAWN_ENABLE_BACKEND_NULL)
|
||||||
|
|
||||||
mBackendsConnected = true;
|
mBackendsConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<BackendConnection*> InstanceBase::FindBackend(BackendType type) {
|
ResultOrError<BackendConnection*> InstanceBase::FindBackend(wgpu::BackendType type) {
|
||||||
for (std::unique_ptr<BackendConnection>& backend : mBackends) {
|
for (std::unique_ptr<BackendConnection>& backend : mBackends) {
|
||||||
if (backend->GetType() == type) {
|
if (backend->GetType() == type) {
|
||||||
return backend.get();
|
return backend.get();
|
||||||
@ -161,7 +161,7 @@ namespace dawn_native {
|
|||||||
EnsureBackendConnections();
|
EnsureBackendConnections();
|
||||||
|
|
||||||
BackendConnection* backend;
|
BackendConnection* backend;
|
||||||
DAWN_TRY_ASSIGN(backend, FindBackend(options->backendType));
|
DAWN_TRY_ASSIGN(backend, FindBackend(static_cast<wgpu::BackendType>(options->backendType)));
|
||||||
|
|
||||||
std::vector<std::unique_ptr<AdapterBase>> newAdapters;
|
std::vector<std::unique_ptr<AdapterBase>> newAdapters;
|
||||||
DAWN_TRY_ASSIGN(newAdapters, backend->DiscoverAdapters(options));
|
DAWN_TRY_ASSIGN(newAdapters, backend->DiscoverAdapters(options));
|
||||||
|
@ -77,7 +77,7 @@ namespace dawn_native {
|
|||||||
void EnsureBackendConnections();
|
void EnsureBackendConnections();
|
||||||
|
|
||||||
// Finds the BackendConnection for `type` or returns an error.
|
// Finds the BackendConnection for `type` or returns an error.
|
||||||
ResultOrError<BackendConnection*> FindBackend(BackendType type);
|
ResultOrError<BackendConnection*> FindBackend(wgpu::BackendType type);
|
||||||
|
|
||||||
MaybeError DiscoverAdaptersInternal(const AdapterDiscoveryOptionsBase* options);
|
MaybeError DiscoverAdaptersInternal(const AdapterDiscoveryOptionsBase* options);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Adapter::Adapter(Backend* backend, ComPtr<IDXGIAdapter1> hardwareAdapter)
|
Adapter::Adapter(Backend* backend, ComPtr<IDXGIAdapter1> hardwareAdapter)
|
||||||
: AdapterBase(backend->GetInstance(), BackendType::D3D12),
|
: AdapterBase(backend->GetInstance(), wgpu::BackendType::D3D12),
|
||||||
mHardwareAdapter(hardwareAdapter),
|
mHardwareAdapter(hardwareAdapter),
|
||||||
mBackend(backend) {
|
mBackend(backend) {
|
||||||
}
|
}
|
||||||
@ -75,9 +75,10 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
|
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
|
||||||
|
|
||||||
if (adapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
|
if (adapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
|
||||||
mDeviceType = DeviceType::CPU;
|
mAdapterType = wgpu::AdapterType::CPU;
|
||||||
} else {
|
} else {
|
||||||
mDeviceType = (mDeviceInfo.isUMA) ? DeviceType::IntegratedGPU : DeviceType::DiscreteGPU;
|
mAdapterType = (mDeviceInfo.isUMA) ? wgpu::AdapterType::IntegratedGPU
|
||||||
|
: wgpu::AdapterType::DiscreteGPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring_convert<DeletableFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> converter(
|
std::wstring_convert<DeletableFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> converter(
|
||||||
|
@ -70,7 +70,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
Backend::Backend(InstanceBase* instance) : BackendConnection(instance, BackendType::D3D12) {
|
Backend::Backend(InstanceBase* instance)
|
||||||
|
: BackendConnection(instance, wgpu::BackendType::D3D12) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Backend::Initialize() {
|
MaybeError Backend::Initialize() {
|
||||||
|
@ -154,8 +154,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
std::unique_ptr<DescriptorHeapAllocator> mDescriptorHeapAllocator;
|
std::unique_ptr<DescriptorHeapAllocator> mDescriptorHeapAllocator;
|
||||||
std::unique_ptr<MapRequestTracker> mMapRequestTracker;
|
std::unique_ptr<MapRequestTracker> mMapRequestTracker;
|
||||||
std::unique_ptr<ResourceAllocatorManager> mResourceAllocatorManager;
|
std::unique_ptr<ResourceAllocatorManager> mResourceAllocatorManager;
|
||||||
|
|
||||||
dawn_native::PCIInfo mPCIInfo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::d3d12
|
}} // namespace dawn_native::d3d12
|
||||||
|
@ -176,7 +176,7 @@ namespace dawn_native { namespace metal {
|
|||||||
class Adapter : public AdapterBase {
|
class Adapter : public AdapterBase {
|
||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance, id<MTLDevice> device)
|
Adapter(InstanceBase* instance, id<MTLDevice> device)
|
||||||
: AdapterBase(instance, BackendType::Metal), mDevice([device retain]) {
|
: AdapterBase(instance, wgpu::BackendType::Metal), mDevice([device retain]) {
|
||||||
mPCIInfo.name = std::string([mDevice.name UTF8String]);
|
mPCIInfo.name = std::string([mDevice.name UTF8String]);
|
||||||
|
|
||||||
PCIIDs ids;
|
PCIIDs ids;
|
||||||
@ -186,12 +186,12 @@ namespace dawn_native { namespace metal {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if defined(DAWN_PLATFORM_IOS)
|
||||||
mDeviceType = DeviceType::IntegratedGPU;
|
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||||
#elif defined(DAWN_PLATFORM_MACOS)
|
#elif defined(DAWN_PLATFORM_MACOS)
|
||||||
if ([device isLowPower]) {
|
if ([device isLowPower]) {
|
||||||
mDeviceType = DeviceType::IntegratedGPU;
|
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||||
} else {
|
} else {
|
||||||
mDeviceType = DeviceType::DiscreteGPU;
|
mAdapterType = wgpu::AdapterType::DiscreteGPU;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# error "Unsupported Apple platform."
|
# error "Unsupported Apple platform."
|
||||||
@ -221,7 +221,8 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
// Implementation of the Metal backend's BackendConnection
|
// Implementation of the Metal backend's BackendConnection
|
||||||
|
|
||||||
Backend::Backend(InstanceBase* instance) : BackendConnection(instance, BackendType::Metal) {
|
Backend::Backend(InstanceBase* instance)
|
||||||
|
: BackendConnection(instance, wgpu::BackendType::Metal) {
|
||||||
if (GetInstance()->IsBackendValidationEnabled()) {
|
if (GetInstance()->IsBackendValidationEnabled()) {
|
||||||
setenv("METAL_DEVICE_WRAPPER_TYPE", "1", 1);
|
setenv("METAL_DEVICE_WRAPPER_TYPE", "1", 1);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ namespace dawn_native { namespace null {
|
|||||||
|
|
||||||
// Implementation of pre-Device objects: the null adapter, null backend connection and Connect()
|
// Implementation of pre-Device objects: the null adapter, null backend connection and Connect()
|
||||||
|
|
||||||
Adapter::Adapter(InstanceBase* instance) : AdapterBase(instance, BackendType::Null) {
|
Adapter::Adapter(InstanceBase* instance) : AdapterBase(instance, wgpu::BackendType::Null) {
|
||||||
mPCIInfo.name = "Null backend";
|
mPCIInfo.name = "Null backend";
|
||||||
mDeviceType = DeviceType::CPU;
|
mAdapterType = wgpu::AdapterType::CPU;
|
||||||
|
|
||||||
// Enable all extensions by default for the convenience of tests.
|
// Enable all extensions by default for the convenience of tests.
|
||||||
mSupportedExtensions.extensionsBitSet.flip();
|
mSupportedExtensions.extensionsBitSet.flip();
|
||||||
@ -47,7 +47,7 @@ namespace dawn_native { namespace null {
|
|||||||
|
|
||||||
class Backend : public BackendConnection {
|
class Backend : public BackendConnection {
|
||||||
public:
|
public:
|
||||||
Backend(InstanceBase* instance) : BackendConnection(instance, BackendType::Null) {
|
Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::BackendType::Null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<AdapterBase>> DiscoverDefaultAdapters() override {
|
std::vector<std::unique_ptr<AdapterBase>> DiscoverDefaultAdapters() override {
|
||||||
|
@ -119,7 +119,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public AdapterBase {
|
||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance) : AdapterBase(instance, BackendType::OpenGL) {
|
Adapter(InstanceBase* instance) : AdapterBase(instance, wgpu::BackendType::OpenGL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Initialize(const AdapterDiscoveryOptions* options) {
|
MaybeError Initialize(const AdapterDiscoveryOptions* options) {
|
||||||
@ -225,7 +225,8 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
// Implementation of the OpenGL backend's BackendConnection
|
// Implementation of the OpenGL backend's BackendConnection
|
||||||
|
|
||||||
Backend::Backend(InstanceBase* instance) : BackendConnection(instance, BackendType::OpenGL) {
|
Backend::Backend(InstanceBase* instance)
|
||||||
|
: BackendConnection(instance, wgpu::BackendType::OpenGL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<AdapterBase>> Backend::DiscoverDefaultAdapters() {
|
std::vector<std::unique_ptr<AdapterBase>> Backend::DiscoverDefaultAdapters() {
|
||||||
@ -241,7 +242,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
return DAWN_VALIDATION_ERROR("The OpenGL backend can only create a single adapter");
|
return DAWN_VALIDATION_ERROR("The OpenGL backend can only create a single adapter");
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(optionsBase->backendType == BackendType::OpenGL);
|
ASSERT(optionsBase->backendType == WGPUBackendType_OpenGL);
|
||||||
const AdapterDiscoveryOptions* options =
|
const AdapterDiscoveryOptions* options =
|
||||||
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
namespace dawn_native { namespace opengl {
|
namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
AdapterDiscoveryOptions::AdapterDiscoveryOptions()
|
AdapterDiscoveryOptions::AdapterDiscoveryOptions()
|
||||||
: AdapterDiscoveryOptionsBase(BackendType::OpenGL) {
|
: AdapterDiscoveryOptionsBase(WGPUBackendType_OpenGL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
Adapter::Adapter(Backend* backend, VkPhysicalDevice physicalDevice)
|
Adapter::Adapter(Backend* backend, VkPhysicalDevice physicalDevice)
|
||||||
: AdapterBase(backend->GetInstance(), BackendType::Vulkan),
|
: AdapterBase(backend->GetInstance(), wgpu::BackendType::Vulkan),
|
||||||
mPhysicalDevice(physicalDevice),
|
mPhysicalDevice(physicalDevice),
|
||||||
mBackend(backend) {
|
mBackend(backend) {
|
||||||
}
|
}
|
||||||
@ -54,16 +54,16 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
switch (mDeviceInfo.properties.deviceType) {
|
switch (mDeviceInfo.properties.deviceType) {
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||||
mDeviceType = DeviceType::IntegratedGPU;
|
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||||
break;
|
break;
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||||
mDeviceType = DeviceType::DiscreteGPU;
|
mAdapterType = wgpu::AdapterType::DiscreteGPU;
|
||||||
break;
|
break;
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||||
mDeviceType = DeviceType::CPU;
|
mAdapterType = wgpu::AdapterType::CPU;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mDeviceType = DeviceType::Unknown;
|
mAdapterType = wgpu::AdapterType::Unknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ const char kVulkanLibName[] = "libvulkan.so";
|
|||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
Backend::Backend(InstanceBase* instance) : BackendConnection(instance, BackendType::Vulkan) {
|
Backend::Backend(InstanceBase* instance)
|
||||||
|
: BackendConnection(instance, wgpu::BackendType::Vulkan) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend::~Backend() {
|
Backend::~Backend() {
|
||||||
|
@ -29,7 +29,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
|
|
||||||
wgpu::Device nullDevice;
|
wgpu::Device nullDevice;
|
||||||
for (dawn_native::Adapter adapter : adapters) {
|
for (dawn_native::Adapter adapter : adapters) {
|
||||||
if (adapter.GetBackendType() == dawn_native::BackendType::Null) {
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
|
if (properties.backendType == wgpu::BackendType::Null) {
|
||||||
nullDevice = wgpu::Device::Acquire(adapter.CreateDevice());
|
nullDevice = wgpu::Device::Acquire(adapter.CreateDevice());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
|
|
||||||
wgpu::Device device;
|
wgpu::Device device;
|
||||||
for (dawn_native::Adapter adapter : adapters) {
|
for (dawn_native::Adapter adapter : adapters) {
|
||||||
if (adapter.GetBackendType() == dawn_native::BackendType::Vulkan &&
|
wgpu::AdapterProperties properties;
|
||||||
adapter.GetDeviceType() == dawn_native::DeviceType::CPU) {
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
|
if (properties.backendType == wgpu::BackendType::Vulkan &&
|
||||||
|
properties.adapterType == wgpu::AdapterType::CPU) {
|
||||||
device = wgpu::Device::Acquire(adapter.CreateDevice());
|
device = wgpu::Device::Acquire(adapter.CreateDevice());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,20 @@ namespace dawn_platform {
|
|||||||
class Platform;
|
class Platform;
|
||||||
} // namespace dawn_platform
|
} // namespace dawn_platform
|
||||||
|
|
||||||
|
namespace wgpu {
|
||||||
|
struct AdapterProperties;
|
||||||
|
}
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
|
// DEPRECATED: use WGPUAdapterProperties instead.
|
||||||
struct PCIInfo {
|
struct PCIInfo {
|
||||||
uint32_t deviceId = 0;
|
uint32_t deviceId = 0;
|
||||||
uint32_t vendorId = 0;
|
uint32_t vendorId = 0;
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DEPRECATED: use WGPUBackendType instead.
|
||||||
enum class BackendType {
|
enum class BackendType {
|
||||||
D3D12,
|
D3D12,
|
||||||
Metal,
|
Metal,
|
||||||
@ -42,6 +48,7 @@ namespace dawn_native {
|
|||||||
Vulkan,
|
Vulkan,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DEPRECATED: use WGPUAdapterType instead.
|
||||||
enum class DeviceType {
|
enum class DeviceType {
|
||||||
DiscreteGPU,
|
DiscreteGPU,
|
||||||
IntegratedGPU,
|
IntegratedGPU,
|
||||||
@ -86,9 +93,15 @@ namespace dawn_native {
|
|||||||
Adapter(AdapterBase* impl);
|
Adapter(AdapterBase* impl);
|
||||||
~Adapter();
|
~Adapter();
|
||||||
|
|
||||||
|
// DEPRECATED: use GetProperties instead.
|
||||||
BackendType GetBackendType() const;
|
BackendType GetBackendType() const;
|
||||||
DeviceType GetDeviceType() const;
|
DeviceType GetDeviceType() const;
|
||||||
const PCIInfo& GetPCIInfo() const;
|
const PCIInfo& GetPCIInfo() const;
|
||||||
|
|
||||||
|
// Essentially webgpu.h's wgpuAdapterGetProperties while we don't have WGPUAdapter in
|
||||||
|
// dawn.json
|
||||||
|
void GetProperties(wgpu::AdapterProperties* properties) const;
|
||||||
|
|
||||||
std::vector<const char*> GetSupportedExtensions() const;
|
std::vector<const char*> GetSupportedExtensions() const;
|
||||||
WGPUDeviceProperties GetAdapterProperties() const;
|
WGPUDeviceProperties GetAdapterProperties() const;
|
||||||
|
|
||||||
@ -106,10 +119,10 @@ namespace dawn_native {
|
|||||||
// Base class for options passed to Instance::DiscoverAdapters.
|
// Base class for options passed to Instance::DiscoverAdapters.
|
||||||
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase {
|
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsBase {
|
||||||
public:
|
public:
|
||||||
const BackendType backendType;
|
const WGPUBackendType backendType;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AdapterDiscoveryOptionsBase(BackendType type);
|
AdapterDiscoveryOptionsBase(WGPUBackendType type);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a connection to dawn_native and is used for dependency injection, discovering
|
// Represents a connection to dawn_native and is used for dependency injection, discovering
|
||||||
|
@ -41,32 +41,32 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string ParamName(dawn_native::BackendType type) {
|
std::string ParamName(wgpu::BackendType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn_native::BackendType::D3D12:
|
case wgpu::BackendType::D3D12:
|
||||||
return "D3D12";
|
return "D3D12";
|
||||||
case dawn_native::BackendType::Metal:
|
case wgpu::BackendType::Metal:
|
||||||
return "Metal";
|
return "Metal";
|
||||||
case dawn_native::BackendType::Null:
|
case wgpu::BackendType::Null:
|
||||||
return "Null";
|
return "Null";
|
||||||
case dawn_native::BackendType::OpenGL:
|
case wgpu::BackendType::OpenGL:
|
||||||
return "OpenGL";
|
return "OpenGL";
|
||||||
case dawn_native::BackendType::Vulkan:
|
case wgpu::BackendType::Vulkan:
|
||||||
return "Vulkan";
|
return "Vulkan";
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DeviceTypeName(dawn_native::DeviceType type) {
|
const char* AdapterTypeName(wgpu::AdapterType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn_native::DeviceType::DiscreteGPU:
|
case wgpu::AdapterType::DiscreteGPU:
|
||||||
return "Discrete GPU";
|
return "Discrete GPU";
|
||||||
case dawn_native::DeviceType::IntegratedGPU:
|
case wgpu::AdapterType::IntegratedGPU:
|
||||||
return "Integrated GPU";
|
return "Integrated GPU";
|
||||||
case dawn_native::DeviceType::CPU:
|
case wgpu::AdapterType::CPU:
|
||||||
return "CPU";
|
return "CPU";
|
||||||
case dawn_native::DeviceType::Unknown:
|
case wgpu::AdapterType::Unknown:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@ -90,10 +90,10 @@ const RGBA8 RGBA8::kBlue = RGBA8(0, 0, 255, 255);
|
|||||||
const RGBA8 RGBA8::kYellow = RGBA8(255, 255, 0, 255);
|
const RGBA8 RGBA8::kYellow = RGBA8(255, 255, 0, 255);
|
||||||
const RGBA8 RGBA8::kWhite = RGBA8(255, 255, 255, 255);
|
const RGBA8 RGBA8::kWhite = RGBA8(255, 255, 255, 255);
|
||||||
|
|
||||||
const DawnTestParam D3D12Backend(dawn_native::BackendType::D3D12);
|
const DawnTestParam D3D12Backend(wgpu::BackendType::D3D12);
|
||||||
const DawnTestParam MetalBackend(dawn_native::BackendType::Metal);
|
const DawnTestParam MetalBackend(wgpu::BackendType::Metal);
|
||||||
const DawnTestParam OpenGLBackend(dawn_native::BackendType::OpenGL);
|
const DawnTestParam OpenGLBackend(wgpu::BackendType::OpenGL);
|
||||||
const DawnTestParam VulkanBackend(dawn_native::BackendType::Vulkan);
|
const DawnTestParam VulkanBackend(wgpu::BackendType::Vulkan);
|
||||||
|
|
||||||
DawnTestParam ForceToggles(const DawnTestParam& originParam,
|
DawnTestParam ForceToggles(const DawnTestParam& originParam,
|
||||||
std::initializer_list<const char*> forceEnabledWorkarounds,
|
std::initializer_list<const char*> forceEnabledWorkarounds,
|
||||||
@ -224,23 +224,25 @@ void DawnTestEnvironment::SetUp() {
|
|||||||
"\n"
|
"\n"
|
||||||
<< "System adapters: \n";
|
<< "System adapters: \n";
|
||||||
for (const dawn_native::Adapter& adapter : mInstance->GetAdapters()) {
|
for (const dawn_native::Adapter& adapter : mInstance->GetAdapters()) {
|
||||||
const dawn_native::PCIInfo& pci = adapter.GetPCIInfo();
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
std::ostringstream vendorId;
|
std::ostringstream vendorId;
|
||||||
std::ostringstream deviceId;
|
std::ostringstream deviceId;
|
||||||
vendorId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
vendorId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
||||||
<< pci.vendorId;
|
<< properties.vendorID;
|
||||||
deviceId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
deviceId << std::setfill('0') << std::uppercase << std::internal << std::hex << std::setw(4)
|
||||||
<< pci.deviceId;
|
<< properties.deviceID;
|
||||||
|
|
||||||
// Preparing for outputting hex numbers
|
// Preparing for outputting hex numbers
|
||||||
dawn::InfoLog() << std::showbase << std::hex << std::setfill('0') << std::setw(4)
|
dawn::InfoLog() << std::showbase << std::hex << std::setfill('0') << std::setw(4)
|
||||||
|
|
||||||
<< " - \"" << pci.name << "\"\n"
|
<< " - \"" << properties.name << "\"\n"
|
||||||
<< " type: " << DeviceTypeName(adapter.GetDeviceType())
|
<< " type: " << AdapterTypeName(properties.adapterType)
|
||||||
<< ", backend: " << ParamName(adapter.GetBackendType()) << "\n"
|
<< ", backend: " << ParamName(properties.backendType) << "\n"
|
||||||
<< " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
<< " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
||||||
<< (mHasVendorIdFilter && mVendorIdFilter == pci.vendorId ? " [Selected]"
|
<< (mHasVendorIdFilter && mVendorIdFilter == properties.vendorID
|
||||||
|
? " [Selected]"
|
||||||
: "")
|
: "")
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
@ -346,43 +348,43 @@ DawnTestBase::~DawnTestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsD3D12() const {
|
bool DawnTestBase::IsD3D12() const {
|
||||||
return mParam.backendType == dawn_native::BackendType::D3D12;
|
return mParam.backendType == wgpu::BackendType::D3D12;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsMetal() const {
|
bool DawnTestBase::IsMetal() const {
|
||||||
return mParam.backendType == dawn_native::BackendType::Metal;
|
return mParam.backendType == wgpu::BackendType::Metal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsOpenGL() const {
|
bool DawnTestBase::IsOpenGL() const {
|
||||||
return mParam.backendType == dawn_native::BackendType::OpenGL;
|
return mParam.backendType == wgpu::BackendType::OpenGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsVulkan() const {
|
bool DawnTestBase::IsVulkan() const {
|
||||||
return mParam.backendType == dawn_native::BackendType::Vulkan;
|
return mParam.backendType == wgpu::BackendType::Vulkan;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsAMD() const {
|
bool DawnTestBase::IsAMD() const {
|
||||||
return gpu_info::IsAMD(mPCIInfo.vendorId);
|
return gpu_info::IsAMD(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsARM() const {
|
bool DawnTestBase::IsARM() const {
|
||||||
return gpu_info::IsARM(mPCIInfo.vendorId);
|
return gpu_info::IsARM(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsImgTec() const {
|
bool DawnTestBase::IsImgTec() const {
|
||||||
return gpu_info::IsImgTec(mPCIInfo.vendorId);
|
return gpu_info::IsImgTec(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsIntel() const {
|
bool DawnTestBase::IsIntel() const {
|
||||||
return gpu_info::IsIntel(mPCIInfo.vendorId);
|
return gpu_info::IsIntel(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsNvidia() const {
|
bool DawnTestBase::IsNvidia() const {
|
||||||
return gpu_info::IsNvidia(mPCIInfo.vendorId);
|
return gpu_info::IsNvidia(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsQualcomm() const {
|
bool DawnTestBase::IsQualcomm() const {
|
||||||
return gpu_info::IsQualcomm(mPCIInfo.vendorId);
|
return gpu_info::IsQualcomm(mAdapterProperties.vendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsWindows() const {
|
bool DawnTestBase::IsWindows() const {
|
||||||
@ -437,6 +439,10 @@ std::vector<const char*> DawnTestBase::GetRequiredExtensions() {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wgpu::AdapterProperties& DawnTestBase::GetAdapterProperties() const {
|
||||||
|
return mAdapterProperties;
|
||||||
|
}
|
||||||
|
|
||||||
// This function can only be called after SetUp() because it requires mBackendAdapter to be
|
// This function can only be called after SetUp() because it requires mBackendAdapter to be
|
||||||
// initialized.
|
// initialized.
|
||||||
bool DawnTestBase::SupportsExtensions(const std::vector<const char*>& extensions) {
|
bool DawnTestBase::SupportsExtensions(const std::vector<const char*>& extensions) {
|
||||||
@ -458,20 +464,23 @@ bool DawnTestBase::SupportsExtensions(const std::vector<const char*>& extensions
|
|||||||
|
|
||||||
void DawnTestBase::SetUp() {
|
void DawnTestBase::SetUp() {
|
||||||
// Initialize mBackendAdapter, and create the device.
|
// Initialize mBackendAdapter, and create the device.
|
||||||
const dawn_native::BackendType backendType = mParam.backendType;
|
const wgpu::BackendType backendType = mParam.backendType;
|
||||||
{
|
{
|
||||||
dawn_native::Instance* instance = gTestEnv->GetInstance();
|
dawn_native::Instance* instance = gTestEnv->GetInstance();
|
||||||
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
|
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
|
||||||
|
|
||||||
for (const dawn_native::Adapter& adapter : adapters) {
|
for (const dawn_native::Adapter& adapter : adapters) {
|
||||||
if (adapter.GetBackendType() == backendType) {
|
wgpu::AdapterProperties properties;
|
||||||
if (adapter.GetDeviceType() == dawn_native::DeviceType::CPU) {
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
|
if (properties.backendType == backendType) {
|
||||||
|
if (properties.adapterType == wgpu::AdapterType::CPU) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter adapter by vendor id
|
// Filter adapter by vendor id
|
||||||
if (HasVendorIdFilter()) {
|
if (HasVendorIdFilter()) {
|
||||||
if (adapter.GetPCIInfo().vendorId == GetVendorIdFilter()) {
|
if (properties.vendorID == GetVendorIdFilter()) {
|
||||||
mBackendAdapter = adapter;
|
mBackendAdapter = adapter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -480,7 +489,8 @@ void DawnTestBase::SetUp() {
|
|||||||
|
|
||||||
// Prefer discrete GPU on multi-GPU systems, otherwise get integrated GPU.
|
// Prefer discrete GPU on multi-GPU systems, otherwise get integrated GPU.
|
||||||
mBackendAdapter = adapter;
|
mBackendAdapter = adapter;
|
||||||
if (mBackendAdapter.GetDeviceType() == dawn_native::DeviceType::DiscreteGPU) {
|
mAdapterProperties = properties;
|
||||||
|
if (properties.adapterType == wgpu::AdapterType::DiscreteGPU) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,8 +501,6 @@ void DawnTestBase::SetUp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPCIInfo = mBackendAdapter.GetPCIInfo();
|
|
||||||
|
|
||||||
for (const char* forceEnabledWorkaround : mParam.forceEnabledWorkarounds) {
|
for (const char* forceEnabledWorkaround : mParam.forceEnabledWorkarounds) {
|
||||||
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
||||||
}
|
}
|
||||||
@ -600,10 +608,6 @@ bool DawnTestBase::EndExpectDeviceError() {
|
|||||||
return mError;
|
return mError;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_native::PCIInfo DawnTestBase::GetPCIInfo() const {
|
|
||||||
return mPCIInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void DawnTestBase::OnDeviceError(WGPUErrorType type, const char* message, void* userdata) {
|
void DawnTestBase::OnDeviceError(WGPUErrorType type, const char* message, void* userdata) {
|
||||||
ASSERT(type != WGPUErrorType_NoError);
|
ASSERT(type != WGPUErrorType_NoError);
|
||||||
@ -813,19 +817,19 @@ std::ostream& operator<<(std::ostream& stream, const RGBA8& color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
bool IsBackendAvailable(dawn_native::BackendType type) {
|
bool IsBackendAvailable(wgpu::BackendType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
case dawn_native::BackendType::D3D12:
|
case wgpu::BackendType::D3D12:
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
case dawn_native::BackendType::Metal:
|
case wgpu::BackendType::Metal:
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
case dawn_native::BackendType::OpenGL:
|
case wgpu::BackendType::OpenGL:
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
case dawn_native::BackendType::Vulkan:
|
case wgpu::BackendType::Vulkan:
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ struct RGBA8 {
|
|||||||
std::ostream& operator<<(std::ostream& stream, const RGBA8& color);
|
std::ostream& operator<<(std::ostream& stream, const RGBA8& color);
|
||||||
|
|
||||||
struct DawnTestParam {
|
struct DawnTestParam {
|
||||||
explicit DawnTestParam(dawn_native::BackendType backendType) : backendType(backendType) {
|
explicit DawnTestParam(wgpu::BackendType backendType) : backendType(backendType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_native::BackendType backendType;
|
wgpu::BackendType backendType;
|
||||||
|
|
||||||
std::vector<const char*> forceEnabledWorkarounds;
|
std::vector<const char*> forceEnabledWorkarounds;
|
||||||
std::vector<const char*> forceDisabledWorkarounds;
|
std::vector<const char*> forceDisabledWorkarounds;
|
||||||
@ -196,8 +196,6 @@ class DawnTestBase {
|
|||||||
bool HasVendorIdFilter() const;
|
bool HasVendorIdFilter() const;
|
||||||
uint32_t GetVendorIdFilter() const;
|
uint32_t GetVendorIdFilter() const;
|
||||||
|
|
||||||
dawn_native::PCIInfo GetPCIInfo() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wgpu::Device device;
|
wgpu::Device device;
|
||||||
wgpu::Queue queue;
|
wgpu::Queue queue;
|
||||||
@ -236,6 +234,8 @@ class DawnTestBase {
|
|||||||
// code path to handle the situation when not all extensions are supported.
|
// code path to handle the situation when not all extensions are supported.
|
||||||
virtual std::vector<const char*> GetRequiredExtensions();
|
virtual std::vector<const char*> GetRequiredExtensions();
|
||||||
|
|
||||||
|
const wgpu::AdapterProperties& GetAdapterProperties() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DawnTestParam mParam;
|
DawnTestParam mParam;
|
||||||
|
|
||||||
@ -294,9 +294,8 @@ class DawnTestBase {
|
|||||||
// Assuming the data is mapped, checks all expectations
|
// Assuming the data is mapped, checks all expectations
|
||||||
void ResolveExpectations();
|
void ResolveExpectations();
|
||||||
|
|
||||||
dawn_native::PCIInfo mPCIInfo;
|
|
||||||
|
|
||||||
dawn_native::Adapter mBackendAdapter;
|
dawn_native::Adapter mBackendAdapter;
|
||||||
|
wgpu::AdapterProperties mAdapterProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Skip a test when the given condition is satisfied.
|
// Skip a test when the given condition is satisfied.
|
||||||
@ -350,7 +349,7 @@ using DawnTest = DawnTestWithParams<>;
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
// Helper functions used for DAWN_INSTANTIATE_TEST
|
// Helper functions used for DAWN_INSTANTIATE_TEST
|
||||||
bool IsBackendAvailable(dawn_native::BackendType type);
|
bool IsBackendAvailable(wgpu::BackendType type);
|
||||||
std::vector<DawnTestParam> FilterBackends(const DawnTestParam* params, size_t numParams);
|
std::vector<DawnTestParam> FilterBackends(const DawnTestParam* params, size_t numParams);
|
||||||
|
|
||||||
// All classes used to implement the deferred expectations should inherit from this.
|
// All classes used to implement the deferred expectations should inherit from this.
|
||||||
|
@ -23,7 +23,7 @@ class BasicTests : public DawnTest {
|
|||||||
TEST_P(BasicTests, VendorIdFilter) {
|
TEST_P(BasicTests, VendorIdFilter) {
|
||||||
DAWN_SKIP_TEST_IF(!HasVendorIdFilter());
|
DAWN_SKIP_TEST_IF(!HasVendorIdFilter());
|
||||||
|
|
||||||
ASSERT_EQ(GetPCIInfo().vendorId, GetVendorIdFilter());
|
ASSERT_EQ(GetAdapterProperties().vendorID, GetVendorIdFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test Buffer::SetSubData changes the content of the buffer, but really this is the most
|
// Test Buffer::SetSubData changes the content of the buffer, but really this is the most
|
||||||
|
@ -28,7 +28,10 @@ ValidationTest::ValidationTest() {
|
|||||||
// Validation tests run against the null backend, find the corresponding adapter
|
// Validation tests run against the null backend, find the corresponding adapter
|
||||||
bool foundNullAdapter = false;
|
bool foundNullAdapter = false;
|
||||||
for (auto ¤tAdapter : adapters) {
|
for (auto ¤tAdapter : adapters) {
|
||||||
if (currentAdapter.GetBackendType() == dawn_native::BackendType::Null) {
|
wgpu::AdapterProperties adapterProperties;
|
||||||
|
currentAdapter.GetProperties(&adapterProperties);
|
||||||
|
|
||||||
|
if (adapterProperties.backendType == wgpu::BackendType::Null) {
|
||||||
adapter = currentAdapter;
|
adapter = currentAdapter;
|
||||||
foundNullAdapter = true;
|
foundNullAdapter = true;
|
||||||
break;
|
break;
|
||||||
|
@ -44,8 +44,8 @@ namespace utils {
|
|||||||
: mWindow(window), mDevice(device) {
|
: mWindow(window), mDevice(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type) {
|
void SetupGLFWWindowHintsForBackend(wgpu::BackendType type) {
|
||||||
if (type == dawn_native::BackendType::OpenGL) {
|
if (type == wgpu::BackendType::OpenGL) {
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
@ -57,11 +57,11 @@ namespace utils {
|
|||||||
|
|
||||||
void DiscoverAdapter(dawn_native::Instance* instance,
|
void DiscoverAdapter(dawn_native::Instance* instance,
|
||||||
GLFWwindow* window,
|
GLFWwindow* window,
|
||||||
dawn_native::BackendType type) {
|
wgpu::BackendType type) {
|
||||||
DAWN_UNUSED(type);
|
DAWN_UNUSED(type);
|
||||||
DAWN_UNUSED(window);
|
DAWN_UNUSED(window);
|
||||||
|
|
||||||
if (type == dawn_native::BackendType::OpenGL) {
|
if (type == wgpu::BackendType::OpenGL) {
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
||||||
@ -73,32 +73,30 @@ namespace utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
BackendBinding* CreateBinding(wgpu::BackendType type, GLFWwindow* window, WGPUDevice device) {
|
||||||
GLFWwindow* window,
|
|
||||||
WGPUDevice device) {
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
case dawn_native::BackendType::D3D12:
|
case wgpu::BackendType::D3D12:
|
||||||
return CreateD3D12Binding(window, device);
|
return CreateD3D12Binding(window, device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
case dawn_native::BackendType::Metal:
|
case wgpu::BackendType::Metal:
|
||||||
return CreateMetalBinding(window, device);
|
return CreateMetalBinding(window, device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
||||||
case dawn_native::BackendType::Null:
|
case wgpu::BackendType::Null:
|
||||||
return CreateNullBinding(window, device);
|
return CreateNullBinding(window, device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
case dawn_native::BackendType::OpenGL:
|
case wgpu::BackendType::OpenGL:
|
||||||
return CreateOpenGLBinding(window, device);
|
return CreateOpenGLBinding(window, device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
case dawn_native::BackendType::Vulkan:
|
case wgpu::BackendType::Vulkan:
|
||||||
return CreateVulkanBinding(window, device);
|
return CreateVulkanBinding(window, device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#ifndef UTILS_BACKENDBINDING_H_
|
#ifndef UTILS_BACKENDBINDING_H_
|
||||||
#define UTILS_BACKENDBINDING_H_
|
#define UTILS_BACKENDBINDING_H_
|
||||||
|
|
||||||
#include "dawn/webgpu.h"
|
#include "dawn/webgpu_cpp.h"
|
||||||
#include "dawn_native/DawnNative.h"
|
#include "dawn_native/DawnNative.h"
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
@ -36,13 +36,11 @@ namespace utils {
|
|||||||
WGPUDevice mDevice = nullptr;
|
WGPUDevice mDevice = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type);
|
void SetupGLFWWindowHintsForBackend(wgpu::BackendType type);
|
||||||
void DiscoverAdapter(dawn_native::Instance* instance,
|
void DiscoverAdapter(dawn_native::Instance* instance,
|
||||||
GLFWwindow* window,
|
GLFWwindow* window,
|
||||||
dawn_native::BackendType type);
|
wgpu::BackendType type);
|
||||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
BackendBinding* CreateBinding(wgpu::BackendType type, GLFWwindow* window, WGPUDevice device);
|
||||||
GLFWwindow* window,
|
|
||||||
WGPUDevice device);
|
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user