Enable testing on GLES backend.
Add support for the OpenGL ES backend to DawnTest. Enable its use in BasicTests. BUG=dawn:580 Change-Id: I920f3a8107928d3ecd5b1506fde5242bec4eef31 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33861 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
a66263753a
commit
d45ab07775
|
@ -54,6 +54,8 @@ namespace {
|
|||
return "Null";
|
||||
case wgpu::BackendType::OpenGL:
|
||||
return "OpenGL";
|
||||
case wgpu::BackendType::OpenGLES:
|
||||
return "OpenGLES";
|
||||
case wgpu::BackendType::Vulkan:
|
||||
return "Vulkan";
|
||||
default:
|
||||
|
@ -125,6 +127,12 @@ BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledW
|
|||
forceDisabledWorkarounds);
|
||||
}
|
||||
|
||||
BackendTestConfig OpenGLESBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
||||
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
||||
return BackendTestConfig(wgpu::BackendType::OpenGLES, forceEnabledWorkarounds,
|
||||
forceDisabledWorkarounds);
|
||||
}
|
||||
|
||||
BackendTestConfig VulkanBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
||||
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
||||
return BackendTestConfig(wgpu::BackendType::Vulkan, forceEnabledWorkarounds,
|
||||
|
@ -322,8 +330,7 @@ void DawnTestEnvironment::ParseArgs(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<dawn_native::Instance> DawnTestEnvironment::CreateInstanceAndDiscoverAdapters()
|
||||
const {
|
||||
std::unique_ptr<dawn_native::Instance> DawnTestEnvironment::CreateInstanceAndDiscoverAdapters() {
|
||||
auto instance = std::make_unique<dawn_native::Instance>();
|
||||
instance->EnableBackendValidation(mEnableBackendValidation);
|
||||
instance->EnableGPUBasedBackendValidation(mEnableBackendValidation);
|
||||
|
@ -341,18 +348,38 @@ std::unique_ptr<dawn_native::Instance> DawnTestEnvironment::CreateInstanceAndDis
|
|||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
std::string windowName = "Dawn OpenGL test window";
|
||||
GLFWwindow* window = glfwCreateWindow(400, 400, windowName.c_str(), nullptr, nullptr);
|
||||
mOpenGLWindow = glfwCreateWindow(400, 400, "Dawn OpenGL test window", nullptr, nullptr);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwMakeContextCurrent(mOpenGLWindow);
|
||||
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
||||
adapterOptions.getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
||||
instance->DiscoverAdapters(&adapterOptions);
|
||||
|
||||
glfwDefaultWindowHints();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||
|
||||
mOpenGLESWindow = glfwCreateWindow(400, 400, "Dawn OpenGLES test window", nullptr, nullptr);
|
||||
|
||||
glfwMakeContextCurrent(mOpenGLESWindow);
|
||||
dawn_native::opengl::AdapterDiscoveryOptionsES adapterOptionsES;
|
||||
adapterOptionsES.getProc = adapterOptions.getProc;
|
||||
instance->DiscoverAdapters(&adapterOptionsES);
|
||||
#endif // DAWN_ENABLE_BACKEND_OPENGL
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
GLFWwindow* DawnTestEnvironment::GetOpenGLWindow() const {
|
||||
return mOpenGLWindow;
|
||||
}
|
||||
|
||||
GLFWwindow* DawnTestEnvironment::GetOpenGLESWindow() const {
|
||||
return mOpenGLESWindow;
|
||||
}
|
||||
|
||||
void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::Instance* instance) {
|
||||
// Get the first available preferred device type.
|
||||
dawn_native::DeviceType preferredDeviceType = static_cast<dawn_native::DeviceType>(-1);
|
||||
|
@ -592,6 +619,10 @@ bool DawnTestBase::IsOpenGL() const {
|
|||
return mParam.adapterProperties.backendType == wgpu::BackendType::OpenGL;
|
||||
}
|
||||
|
||||
bool DawnTestBase::IsOpenGLES() const {
|
||||
return mParam.adapterProperties.backendType == wgpu::BackendType::OpenGLES;
|
||||
}
|
||||
|
||||
bool DawnTestBase::IsVulkan() const {
|
||||
return mParam.adapterProperties.backendType == wgpu::BackendType::Vulkan;
|
||||
}
|
||||
|
@ -830,6 +861,13 @@ void DawnTestBase::SetUp() {
|
|||
|
||||
device.SetUncapturedErrorCallback(OnDeviceError, this);
|
||||
device.SetDeviceLostCallback(OnDeviceLost, this);
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
if (IsOpenGL()) {
|
||||
glfwMakeContextCurrent(gTestEnv->GetOpenGLWindow());
|
||||
} else if (IsOpenGLES()) {
|
||||
glfwMakeContextCurrent(gTestEnv->GetOpenGLESWindow());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DawnTestBase::TearDown() {
|
||||
|
|
|
@ -152,9 +152,14 @@ BackendTestConfig NullBackend(std::initializer_list<const char*> forceEnabledWor
|
|||
BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledWorkarounds = {},
|
||||
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
||||
|
||||
BackendTestConfig OpenGLESBackend(std::initializer_list<const char*> forceEnabledWorkarounds = {},
|
||||
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
||||
|
||||
BackendTestConfig VulkanBackend(std::initializer_list<const char*> forceEnabledWorkarounds = {},
|
||||
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace utils {
|
||||
class PlatformDebugLogger;
|
||||
class TerribleCommandBuffer;
|
||||
|
@ -195,6 +200,8 @@ class DawnTestEnvironment : public testing::Environment {
|
|||
bool HasVendorIdFilter() const;
|
||||
uint32_t GetVendorIdFilter() const;
|
||||
const char* GetWireTraceDir() const;
|
||||
GLFWwindow* GetOpenGLWindow() const;
|
||||
GLFWwindow* GetOpenGLESWindow() const;
|
||||
|
||||
const std::vector<std::string>& GetEnabledToggles() const;
|
||||
const std::vector<std::string>& GetDisabledToggles() const;
|
||||
|
@ -204,7 +211,7 @@ class DawnTestEnvironment : public testing::Environment {
|
|||
|
||||
private:
|
||||
void ParseArgs(int argc, char** argv);
|
||||
std::unique_ptr<dawn_native::Instance> CreateInstanceAndDiscoverAdapters() const;
|
||||
std::unique_ptr<dawn_native::Instance> CreateInstanceAndDiscoverAdapters();
|
||||
void SelectPreferredAdapterProperties(const dawn_native::Instance* instance);
|
||||
void PrintTestConfigurationAndAdapterInfo(dawn_native::Instance* instance) const;
|
||||
|
||||
|
@ -221,6 +228,8 @@ class DawnTestEnvironment : public testing::Environment {
|
|||
std::vector<TestAdapterProperties> mAdapterProperties;
|
||||
|
||||
std::unique_ptr<utils::PlatformDebugLogger> mPlatformDebugLogger;
|
||||
GLFWwindow* mOpenGLWindow;
|
||||
GLFWwindow* mOpenGLESWindow;
|
||||
};
|
||||
|
||||
class DawnTestBase {
|
||||
|
@ -237,6 +246,7 @@ class DawnTestBase {
|
|||
bool IsMetal() const;
|
||||
bool IsNull() const;
|
||||
bool IsOpenGL() const;
|
||||
bool IsOpenGLES() const;
|
||||
bool IsVulkan() const;
|
||||
|
||||
bool IsAMD() const;
|
||||
|
|
|
@ -51,4 +51,9 @@ TEST_P(BasicTests, QueueWriteBufferError) {
|
|||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buffer, 1000, &value, sizeof(value)));
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(BasicTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
||||
DAWN_INSTANTIATE_TEST(BasicTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
OpenGLBackend(),
|
||||
OpenGLESBackend(),
|
||||
VulkanBackend());
|
||||
|
|
Loading…
Reference in New Issue