mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +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,22 +14,33 @@
|
||||
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "dawn/dawn.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/NullBackend.h"
|
||||
|
||||
namespace dawn_native {
|
||||
namespace null {
|
||||
void Init(dawnProcTable* procs, dawnDevice* device);
|
||||
}
|
||||
}
|
||||
|
||||
ValidationTest::ValidationTest() {
|
||||
dawnProcTable procs = dawn_native::GetProcs();
|
||||
dawnDevice cDevice = dawn_native::null::CreateDevice();
|
||||
mInstance = std::make_unique<dawn_native::Instance>();
|
||||
mInstance->DiscoverDefaultAdapters();
|
||||
|
||||
std::vector<dawn_native::Adapter> adapters = mInstance->GetAdapters();
|
||||
|
||||
// Validation tests run against the null backend, find the corresponding adapter
|
||||
bool foundNullAdapter = false;
|
||||
dawn_native::Adapter nullAdapter;
|
||||
for (auto adapter : adapters) {
|
||||
if (adapter.GetBackendType() == dawn_native::BackendType::Null) {
|
||||
nullAdapter = adapter;
|
||||
foundNullAdapter = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(foundNullAdapter);
|
||||
device = dawn::Device::Acquire(nullAdapter.CreateDevice());
|
||||
|
||||
dawnProcTable procs = dawn_native::GetProcs();
|
||||
dawnSetProcs(&procs);
|
||||
device = dawn::Device::Acquire(cDevice);
|
||||
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user