mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-25 16:03:38 +00:00
Remove GLFW dependency for non-GL tests
As part of enabling WebGPU on Chrome OS, we would like to run the Dawn unit and e2e tests as part of the Chrome OS test suite. This CL removes the GLFW dependency because Chrome OS does not support GLFW. The GLFWwindow is only used to create swap chains for the various backends, but these swap chains are not actually used in the tests (the e2e tests render to textures instead). The swap chains are only referenced as part of an unused debugging function: SwapBuffersForCapture which we can safely remove as per my discussions with kainino@ and enga@. We still need GLFW for OpenGL, so we conditionally include it on platforms that enable the OpenGL backend (which Chrome OS is not). Note: enga@ suggested to create a VulkanWindowlessBinding that has an empty GetSwapChainImplementation, but after exploring the option, it seems like a bit too many ifdefs. In the end, I think it's cleaner to just remove the *Binding classes entirely. BUG=chromium:993457 TEST=tests compile and pass for all values of dawn_enable_opengl Change-Id: I067b12a23f2c236f5506252cd7727b847e79a667 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10080 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Brian Ho <hob@chromium.org>
This commit is contained in:
parent
d4ce736d18
commit
2fb628da46
36
BUILD.gn
36
BUILD.gn
@ -549,8 +549,6 @@ static_library("dawn_utils") {
|
|||||||
configs += [ "${dawn_root}/src/common:dawn_internal" ]
|
configs += [ "${dawn_root}/src/common:dawn_internal" ]
|
||||||
|
|
||||||
sources = [
|
sources = [
|
||||||
"src/utils/BackendBinding.cpp",
|
|
||||||
"src/utils/BackendBinding.h",
|
|
||||||
"src/utils/ComboRenderPipelineDescriptor.cpp",
|
"src/utils/ComboRenderPipelineDescriptor.cpp",
|
||||||
"src/utils/ComboRenderPipelineDescriptor.h",
|
"src/utils/ComboRenderPipelineDescriptor.h",
|
||||||
"src/utils/DawnHelpers.cpp",
|
"src/utils/DawnHelpers.cpp",
|
||||||
@ -570,6 +568,24 @@ static_library("dawn_utils") {
|
|||||||
":libdawn_wire",
|
":libdawn_wire",
|
||||||
"${dawn_root}/src/common",
|
"${dawn_root}/src/common",
|
||||||
"${dawn_shaderc_dir}:libshaderc",
|
"${dawn_shaderc_dir}:libshaderc",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
static_library("dawn_bindings") {
|
||||||
|
configs += [ "${dawn_root}/src/common:dawn_internal" ]
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"src/utils/BackendBinding.cpp",
|
||||||
|
"src/utils/BackendBinding.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
public_deps = [
|
||||||
|
"${dawn_root}/src/dawn:dawn_headers",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":libdawn_native",
|
||||||
|
"${dawn_root}/src/common",
|
||||||
"third_party:glfw",
|
"third_party:glfw",
|
||||||
]
|
]
|
||||||
libs = []
|
libs = []
|
||||||
@ -715,7 +731,6 @@ source_set("dawn_end2end_tests_sources") {
|
|||||||
":libdawn_wire",
|
":libdawn_wire",
|
||||||
"${dawn_root}/src/common",
|
"${dawn_root}/src/common",
|
||||||
"${dawn_root}/src/dawn:libdawn",
|
"${dawn_root}/src/dawn:libdawn",
|
||||||
"third_party:glfw",
|
|
||||||
"third_party:gmock_and_gtest",
|
"third_party:gmock_and_gtest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -767,6 +782,10 @@ source_set("dawn_end2end_tests_sources") {
|
|||||||
|
|
||||||
libs += [ "IOSurface.framework" ]
|
libs += [ "IOSurface.framework" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dawn_enable_opengl) {
|
||||||
|
deps += [ "third_party:glfw" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source_set("dawn_white_box_tests_sources") {
|
source_set("dawn_white_box_tests_sources") {
|
||||||
@ -780,7 +799,6 @@ source_set("dawn_white_box_tests_sources") {
|
|||||||
":libdawn_wire",
|
":libdawn_wire",
|
||||||
"${dawn_root}/src/common",
|
"${dawn_root}/src/common",
|
||||||
"${dawn_root}/src/dawn:libdawn",
|
"${dawn_root}/src/dawn:libdawn",
|
||||||
"third_party:glfw",
|
|
||||||
"third_party:gmock_and_gtest",
|
"third_party:gmock_and_gtest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -796,6 +814,10 @@ source_set("dawn_white_box_tests_sources") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dawn_enable_opengl) {
|
||||||
|
deps += [ "third_party:glfw" ]
|
||||||
|
}
|
||||||
|
|
||||||
libs = []
|
libs = []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +832,6 @@ test("dawn_end2end_tests") {
|
|||||||
":libdawn_wire",
|
":libdawn_wire",
|
||||||
"${dawn_root}/src/common",
|
"${dawn_root}/src/common",
|
||||||
"${dawn_root}/src/dawn:libdawn",
|
"${dawn_root}/src/dawn:libdawn",
|
||||||
"third_party:glfw",
|
|
||||||
"third_party:gmock_and_gtest",
|
"third_party:gmock_and_gtest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -828,6 +849,10 @@ test("dawn_end2end_tests") {
|
|||||||
} else {
|
} else {
|
||||||
sources += [ "src/tests/End2EndTestsMain.cpp" ]
|
sources += [ "src/tests/End2EndTestsMain.cpp" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dawn_enable_opengl) {
|
||||||
|
deps += [ "third_party:glfw" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Temporary groups to make a 5-way patch to fix crbug.com/913171
|
# Temporary groups to make a 5-way patch to fix crbug.com/913171
|
||||||
@ -859,6 +884,7 @@ if (dawn_standalone) {
|
|||||||
|
|
||||||
# Export all of these as public deps so that `gn check` allows includes
|
# Export all of these as public deps so that `gn check` allows includes
|
||||||
public_deps = [
|
public_deps = [
|
||||||
|
":dawn_bindings",
|
||||||
":dawn_utils",
|
":dawn_utils",
|
||||||
":libdawn_native",
|
":libdawn_native",
|
||||||
":libdawn_wire",
|
":libdawn_wire",
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "dawn_native/DawnNative.h"
|
#include "dawn_native/DawnNative.h"
|
||||||
#include "dawn_wire/WireClient.h"
|
#include "dawn_wire/WireClient.h"
|
||||||
#include "dawn_wire/WireServer.h"
|
#include "dawn_wire/WireServer.h"
|
||||||
#include "utils/BackendBinding.h"
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/DawnHelpers.h"
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
#include "utils/TerribleCommandBuffer.h"
|
#include "utils/TerribleCommandBuffer.h"
|
||||||
@ -31,7 +30,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "GLFW/glfw3.h"
|
|
||||||
|
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
||||||
|
# include "GLFW/glfw3.h"
|
||||||
|
# include "dawn_native/OpenGLBackend.h"
|
||||||
|
#endif // DAWN_ENABLE_BACKEND_OPENGL
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -141,27 +144,25 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DawnTestEnvironment::SetUp() {
|
void DawnTestEnvironment::SetUp() {
|
||||||
ASSERT_TRUE(glfwInit());
|
|
||||||
|
|
||||||
mInstance = std::make_unique<dawn_native::Instance>();
|
mInstance = std::make_unique<dawn_native::Instance>();
|
||||||
mInstance->EnableBackendValidation(mEnableBackendValidation);
|
mInstance->EnableBackendValidation(mEnableBackendValidation);
|
||||||
mInstance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup);
|
mInstance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup);
|
||||||
|
|
||||||
static constexpr dawn_native::BackendType kAllBackends[] = {
|
static constexpr dawn_native::BackendType kWindowlessBackends[] = {
|
||||||
dawn_native::BackendType::D3D12,
|
dawn_native::BackendType::D3D12,
|
||||||
dawn_native::BackendType::Metal,
|
dawn_native::BackendType::Metal,
|
||||||
dawn_native::BackendType::OpenGL,
|
|
||||||
dawn_native::BackendType::Vulkan,
|
dawn_native::BackendType::Vulkan,
|
||||||
};
|
};
|
||||||
|
for (dawn_native::BackendType backend : kWindowlessBackends) {
|
||||||
// Create a test window for each backend and discover an adapter using it.
|
|
||||||
for (dawn_native::BackendType backend : kAllBackends) {
|
|
||||||
if (detail::IsBackendAvailable(backend)) {
|
if (detail::IsBackendAvailable(backend)) {
|
||||||
CreateBackendWindow(backend);
|
mInstance.get()->DiscoverDefaultAdapters();
|
||||||
utils::DiscoverAdapter(mInstance.get(), mWindows[backend], backend);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (detail::IsBackendAvailable(dawn_native::BackendType::OpenGL)) {
|
||||||
|
DiscoverOpenGLAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "Testing configuration\n"
|
std::cout << "Testing configuration\n"
|
||||||
"---------------------\n"
|
"---------------------\n"
|
||||||
"UseWire: "
|
"UseWire: "
|
||||||
@ -211,10 +212,6 @@ dawn_native::Instance* DawnTestEnvironment::GetInstance() const {
|
|||||||
return mInstance.get();
|
return mInstance.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWwindow* DawnTestEnvironment::GetWindowForBackend(dawn_native::BackendType type) const {
|
|
||||||
return mWindows.at(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DawnTestEnvironment::HasVendorIdFilter() const {
|
bool DawnTestEnvironment::HasVendorIdFilter() const {
|
||||||
return mHasVendorIdFilter;
|
return mHasVendorIdFilter;
|
||||||
}
|
}
|
||||||
@ -223,14 +220,23 @@ uint32_t DawnTestEnvironment::GetVendorIdFilter() const {
|
|||||||
return mVendorIdFilter;
|
return mVendorIdFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DawnTestEnvironment::CreateBackendWindow(dawn_native::BackendType type) {
|
void DawnTestEnvironment::DiscoverOpenGLAdapter() {
|
||||||
|
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
||||||
|
ASSERT_TRUE(glfwInit());
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
utils::SetupGLFWWindowHintsForBackend(type);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
std::string windowName = "Dawn " + ParamName(type) + " test window";
|
std::string windowName = "Dawn OpenGL test window";
|
||||||
GLFWwindow* window = glfwCreateWindow(400, 400, windowName.c_str(), nullptr, nullptr);
|
GLFWwindow* window = glfwCreateWindow(400, 400, windowName.c_str(), nullptr, nullptr);
|
||||||
|
|
||||||
mWindows[type] = window;
|
glfwMakeContextCurrent(window);
|
||||||
|
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
||||||
|
adapterOptions.getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
||||||
|
mInstance->DiscoverAdapters(&adapterOptions);
|
||||||
|
#endif // DAWN_ENABLE_BACKEND_OPENGL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation of DawnTest
|
// Implementation of DawnTest
|
||||||
@ -241,7 +247,6 @@ DawnTest::~DawnTest() {
|
|||||||
// We need to destroy child objects before the Device
|
// We need to destroy child objects before the Device
|
||||||
mReadbackSlots.clear();
|
mReadbackSlots.clear();
|
||||||
queue = dawn::Queue();
|
queue = dawn::Queue();
|
||||||
swapchain = dawn::SwapChain();
|
|
||||||
device = dawn::Device();
|
device = dawn::Device();
|
||||||
|
|
||||||
mWireClient = nullptr;
|
mWireClient = nullptr;
|
||||||
@ -405,12 +410,6 @@ void DawnTest::SetUp() {
|
|||||||
|
|
||||||
backendProcs = dawn_native::GetProcs();
|
backendProcs = dawn_native::GetProcs();
|
||||||
|
|
||||||
// Get the test window and create the device using it (esp. for OpenGL)
|
|
||||||
GLFWwindow* testWindow = gTestEnv->GetWindowForBackend(backendType);
|
|
||||||
DAWN_ASSERT(testWindow != nullptr);
|
|
||||||
mBinding.reset(utils::CreateBinding(backendType, testWindow, backendDevice));
|
|
||||||
DAWN_ASSERT(mBinding != nullptr);
|
|
||||||
|
|
||||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||||
DawnDevice cDevice = nullptr;
|
DawnDevice cDevice = nullptr;
|
||||||
DawnProcTable procs;
|
DawnProcTable procs;
|
||||||
@ -448,21 +447,10 @@ void DawnTest::SetUp() {
|
|||||||
device = dawn::Device::Acquire(cDevice);
|
device = dawn::Device::Acquire(cDevice);
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
|
|
||||||
// The swapchain isn't used by tests but is useful when debugging with graphics debuggers that
|
|
||||||
// capture at frame boundaries.
|
|
||||||
dawn::SwapChainDescriptor swapChainDesc;
|
|
||||||
swapChainDesc.implementation = mBinding->GetSwapChainImplementation();
|
|
||||||
swapchain = device.CreateSwapChain(&swapChainDesc);
|
|
||||||
FlushWire();
|
|
||||||
swapchain.Configure(
|
|
||||||
static_cast<dawn::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()),
|
|
||||||
dawn::TextureUsageBit::OutputAttachment, 400, 400);
|
|
||||||
|
|
||||||
device.SetErrorCallback(OnDeviceError, this);
|
device.SetErrorCallback(OnDeviceError, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DawnTest::TearDown() {
|
void DawnTest::TearDown() {
|
||||||
swapchain = dawn::SwapChain();
|
|
||||||
FlushWire();
|
FlushWire();
|
||||||
|
|
||||||
MapSlotsSynchronously();
|
MapSlotsSynchronously();
|
||||||
@ -574,12 +562,6 @@ void DawnTest::WaitABit() {
|
|||||||
utils::USleep(100);
|
utils::USleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DawnTest::SwapBuffersForCapture() {
|
|
||||||
// Insert a frame boundary for API capture tools.
|
|
||||||
dawn::Texture backBuffer = swapchain.GetNextTexture();
|
|
||||||
swapchain.Present(backBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DawnTest::FlushWire() {
|
void DawnTest::FlushWire() {
|
||||||
if (gTestEnv->UsesWire()) {
|
if (gTestEnv->UsesWire()) {
|
||||||
bool C2SFlushed = mC2sBuf->Flush();
|
bool C2SFlushed = mC2sBuf->Flush();
|
||||||
|
@ -93,10 +93,7 @@ DawnTestParam ForceWorkarounds(const DawnTestParam& originParam,
|
|||||||
std::initializer_list<const char*> forceEnabledWorkarounds,
|
std::initializer_list<const char*> forceEnabledWorkarounds,
|
||||||
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
||||||
|
|
||||||
struct GLFWwindow;
|
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
class BackendBinding;
|
|
||||||
class TerribleCommandBuffer;
|
class TerribleCommandBuffer;
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
@ -121,12 +118,11 @@ class DawnTestEnvironment : public testing::Environment {
|
|||||||
bool UsesWire() const;
|
bool UsesWire() const;
|
||||||
bool IsBackendValidationEnabled() const;
|
bool IsBackendValidationEnabled() const;
|
||||||
dawn_native::Instance* GetInstance() const;
|
dawn_native::Instance* GetInstance() const;
|
||||||
GLFWwindow* GetWindowForBackend(dawn_native::BackendType type) const;
|
|
||||||
bool HasVendorIdFilter() const;
|
bool HasVendorIdFilter() const;
|
||||||
uint32_t GetVendorIdFilter() const;
|
uint32_t GetVendorIdFilter() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateBackendWindow(dawn_native::BackendType type);
|
void DiscoverOpenGLAdapter();
|
||||||
|
|
||||||
bool mUseWire = false;
|
bool mUseWire = false;
|
||||||
bool mEnableBackendValidation = false;
|
bool mEnableBackendValidation = false;
|
||||||
@ -134,11 +130,6 @@ class DawnTestEnvironment : public testing::Environment {
|
|||||||
bool mHasVendorIdFilter = false;
|
bool mHasVendorIdFilter = false;
|
||||||
uint32_t mVendorIdFilter = 0;
|
uint32_t mVendorIdFilter = 0;
|
||||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||||
|
|
||||||
// Windows don't usually like to be bound to one API than the other, for example switching
|
|
||||||
// from Vulkan to OpenGL causes crashes on some drivers. Because of this, we lazily created
|
|
||||||
// a window for each backing API.
|
|
||||||
std::unordered_map<dawn_native::BackendType, GLFWwindow*> mWindows;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
||||||
@ -177,7 +168,6 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||||||
protected:
|
protected:
|
||||||
dawn::Device device;
|
dawn::Device device;
|
||||||
dawn::Queue queue;
|
dawn::Queue queue;
|
||||||
dawn::SwapChain swapchain;
|
|
||||||
|
|
||||||
DawnProcTable backendProcs = {};
|
DawnProcTable backendProcs = {};
|
||||||
DawnDevice backendDevice = nullptr;
|
DawnDevice backendDevice = nullptr;
|
||||||
@ -204,8 +194,6 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||||||
void WaitABit();
|
void WaitABit();
|
||||||
void FlushWire();
|
void FlushWire();
|
||||||
|
|
||||||
void SwapBuffersForCapture();
|
|
||||||
|
|
||||||
bool SupportsExtensions(const std::vector<const char*>& extensions);
|
bool SupportsExtensions(const std::vector<const char*>& extensions);
|
||||||
|
|
||||||
// Called in SetUp() to get the extensions required to be enabled in the tests. The tests must
|
// Called in SetUp() to get the extensions required to be enabled in the tests. The tests must
|
||||||
@ -268,8 +256,6 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||||||
// Assuming the data is mapped, checks all expectations
|
// Assuming the data is mapped, checks all expectations
|
||||||
void ResolveExpectations();
|
void ResolveExpectations();
|
||||||
|
|
||||||
std::unique_ptr<utils::BackendBinding> mBinding;
|
|
||||||
|
|
||||||
dawn_native::PCIInfo mPCIInfo;
|
dawn_native::PCIInfo mPCIInfo;
|
||||||
|
|
||||||
dawn_native::Adapter mBackendAdapter;
|
dawn_native::Adapter mBackendAdapter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user