mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Simplify BackendBinding following adapters.
It doesn't need to care about device creation anymore, except for the GLFW window hints and creating a GL context to discover the adapter. Also remove the non-adapter GetPCIInfo. BUG=dawn:29 Change-Id: I9bc8232536a55d2f973463ae0f2e0548dfc35456 Reviewed-on: https://dawn-review.googlesource.com/c/4381 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
5987c4e839
commit
bb5696bcd3
@@ -26,6 +26,7 @@
|
||||
#include "utils/SystemUtils.h"
|
||||
#include "utils/TerribleCommandBuffer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include "GLFW/glfw3.h"
|
||||
@@ -55,7 +56,7 @@ namespace {
|
||||
std::unordered_map<dawn_native::BackendType, GLFWwindow*> windows;
|
||||
|
||||
// Creates a GLFW window set up for use with a given backend.
|
||||
GLFWwindow* GetWindowForBackend(utils::BackendBinding* binding, dawn_native::BackendType type) {
|
||||
GLFWwindow* GetWindowForBackend(dawn_native::BackendType type) {
|
||||
GLFWwindow** window = &windows[type];
|
||||
|
||||
if (*window != nullptr) {
|
||||
@@ -67,7 +68,7 @@ namespace {
|
||||
}
|
||||
|
||||
glfwDefaultWindowHints();
|
||||
binding->SetupGLFWWindowHints();
|
||||
utils::SetupGLFWWindowHintsForBackend(type);
|
||||
|
||||
std::string windowName = "Dawn " + ParamName(type) + " test window";
|
||||
*window = glfwCreateWindow(400, 400, windowName.c_str(), nullptr, nullptr);
|
||||
@@ -174,17 +175,35 @@ bool DawnTest::IsMacOS() const {
|
||||
bool gTestUsesWire = false;
|
||||
|
||||
void DawnTest::SetUp() {
|
||||
mBinding.reset(utils::CreateBinding(GetParam()));
|
||||
DAWN_ASSERT(mBinding != nullptr);
|
||||
|
||||
GLFWwindow* testWindow = GetWindowForBackend(mBinding.get(), GetParam());
|
||||
// Create the test window and discover adapters using it (esp. for OpenGL)
|
||||
GLFWwindow* testWindow = GetWindowForBackend(GetParam());
|
||||
DAWN_ASSERT(testWindow != nullptr);
|
||||
|
||||
mBinding->SetWindow(testWindow);
|
||||
mInstance = std::make_unique<dawn_native::Instance>();
|
||||
utils::DiscoverAdapter(mInstance.get(), testWindow, GetParam());
|
||||
|
||||
dawnDevice backendDevice = mBinding->CreateDevice();
|
||||
// Get an adapter for the backend to use, and create the device.
|
||||
dawn_native::Adapter backendAdapter;
|
||||
{
|
||||
std::vector<dawn_native::Adapter> adapters = mInstance->GetAdapters();
|
||||
auto adapterIt = std::find_if(adapters.begin(), adapters.end(),
|
||||
[this](const dawn_native::Adapter adapter) -> bool {
|
||||
// Chromium's GTest harness has GetParam() as a regular
|
||||
// function and not a member function of this.
|
||||
DAWN_UNUSED(this);
|
||||
return adapter.GetBackendType() == GetParam();
|
||||
});
|
||||
ASSERT(adapterIt != adapters.end());
|
||||
backendAdapter = *adapterIt;
|
||||
}
|
||||
|
||||
mPCIInfo = backendAdapter.GetPCIInfo();
|
||||
dawnDevice backendDevice = backendAdapter.CreateDevice();
|
||||
dawnProcTable backendProcs = dawn_native::GetProcs();
|
||||
|
||||
mBinding.reset(utils::CreateBinding(GetParam(), testWindow, backendDevice));
|
||||
DAWN_ASSERT(mBinding != nullptr);
|
||||
|
||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||
dawnDevice cDevice = nullptr;
|
||||
dawnProcTable procs;
|
||||
@@ -225,8 +244,6 @@ void DawnTest::SetUp() {
|
||||
|
||||
// The end2end tests should never cause validation errors. These should be tested in unittests.
|
||||
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
|
||||
|
||||
mPCIInfo = dawn_native::GetPCIInfo(backendDevice);
|
||||
}
|
||||
|
||||
void DawnTest::TearDown() {
|
||||
|
||||
@@ -177,6 +177,7 @@ class DawnTest : public ::testing::TestWithParam<dawn_native::BackendType> {
|
||||
// Assuming the data is mapped, checks all expectations
|
||||
void ResolveExpectations();
|
||||
|
||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||
std::unique_ptr<utils::BackendBinding> mBinding;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
|
||||
Reference in New Issue
Block a user