mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
dawn_native: Add Instance and Adapters
New objects are introduced to control what happens before device creation in dawn_native: - Instance: a connection from the application to dawn_native that is used for dependency injection and to discover adapters. - Adapters: represents the possibility of device creation for a specific (GPU, backend) pair. - BackendConnection: an internal object that standardizes the interface between the frontend and backends. The BackendConnection interface is implemented for the Null backend and stubbed out in other backends. This allows this change to port the ValidationTests to use the new Instance and Adapters concept and deal with other backends later. BUG=dawn:29 Change-Id: I19719a9342b4af091accc0c02fb6b9697eadde7b Reviewed-on: https://dawn-review.googlesource.com/c/3500 Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
e9212dfe30
commit
ac67fec1c9
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/Device.h"
|
||||
#include "dawn_native/Instance.h"
|
||||
|
||||
// Contains the entry-points into dawn_native
|
||||
|
||||
@@ -30,4 +31,50 @@ namespace dawn_native {
|
||||
return deviceBase->GetPCIInfo();
|
||||
}
|
||||
|
||||
// Adapter
|
||||
|
||||
Adapter::Adapter() = default;
|
||||
|
||||
Adapter::Adapter(AdapterBase* impl) : mImpl(impl) {
|
||||
}
|
||||
|
||||
Adapter::~Adapter() {
|
||||
mImpl = nullptr;
|
||||
}
|
||||
|
||||
BackendType Adapter::GetBackendType() const {
|
||||
return mImpl->GetBackendType();
|
||||
}
|
||||
|
||||
const PCIInfo& Adapter::GetPCIInfo() const {
|
||||
return mImpl->GetPCIInfo();
|
||||
}
|
||||
|
||||
dawnDevice Adapter::CreateDevice() {
|
||||
return reinterpret_cast<dawnDevice>(mImpl->CreateDevice());
|
||||
}
|
||||
|
||||
// Instance
|
||||
|
||||
Instance::Instance() : mImpl(new InstanceBase()) {
|
||||
}
|
||||
|
||||
Instance::~Instance() {
|
||||
delete mImpl;
|
||||
mImpl = nullptr;
|
||||
}
|
||||
|
||||
void Instance::DiscoverDefaultAdapters() {
|
||||
mImpl->DiscoverDefaultAdapters();
|
||||
}
|
||||
|
||||
std::vector<Adapter> Instance::GetAdapters() const {
|
||||
// Adapters are owned by mImpl so it is safe to return non RAII pointers to them
|
||||
std::vector<Adapter> adapters;
|
||||
for (const std::unique_ptr<AdapterBase>& adapter : mImpl->GetAdapters()) {
|
||||
adapters.push_back({adapter.get()});
|
||||
}
|
||||
return adapters;
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
Reference in New Issue
Block a user