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";
|
return "Null";
|
||||||
case wgpu::BackendType::OpenGL:
|
case wgpu::BackendType::OpenGL:
|
||||||
return "OpenGL";
|
return "OpenGL";
|
||||||
|
case wgpu::BackendType::OpenGLES:
|
||||||
|
return "OpenGLES";
|
||||||
case wgpu::BackendType::Vulkan:
|
case wgpu::BackendType::Vulkan:
|
||||||
return "Vulkan";
|
return "Vulkan";
|
||||||
default:
|
default:
|
||||||
|
@ -125,6 +127,12 @@ BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledW
|
||||||
forceDisabledWorkarounds);
|
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,
|
BackendTestConfig VulkanBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
||||||
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
||||||
return BackendTestConfig(wgpu::BackendType::Vulkan, forceEnabledWorkarounds,
|
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()
|
std::unique_ptr<dawn_native::Instance> DawnTestEnvironment::CreateInstanceAndDiscoverAdapters() {
|
||||||
const {
|
|
||||||
auto instance = std::make_unique<dawn_native::Instance>();
|
auto instance = std::make_unique<dawn_native::Instance>();
|
||||||
instance->EnableBackendValidation(mEnableBackendValidation);
|
instance->EnableBackendValidation(mEnableBackendValidation);
|
||||||
instance->EnableGPUBasedBackendValidation(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_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
std::string windowName = "Dawn OpenGL test window";
|
mOpenGLWindow = glfwCreateWindow(400, 400, "Dawn OpenGL test window", nullptr, nullptr);
|
||||||
GLFWwindow* window = glfwCreateWindow(400, 400, windowName.c_str(), nullptr, nullptr);
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(mOpenGLWindow);
|
||||||
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
||||||
adapterOptions.getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
adapterOptions.getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
||||||
instance->DiscoverAdapters(&adapterOptions);
|
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
|
#endif // DAWN_ENABLE_BACKEND_OPENGL
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWwindow* DawnTestEnvironment::GetOpenGLWindow() const {
|
||||||
|
return mOpenGLWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWwindow* DawnTestEnvironment::GetOpenGLESWindow() const {
|
||||||
|
return mOpenGLESWindow;
|
||||||
|
}
|
||||||
|
|
||||||
void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::Instance* instance) {
|
void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::Instance* instance) {
|
||||||
// Get the first available preferred device type.
|
// Get the first available preferred device type.
|
||||||
dawn_native::DeviceType preferredDeviceType = static_cast<dawn_native::DeviceType>(-1);
|
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;
|
return mParam.adapterProperties.backendType == wgpu::BackendType::OpenGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DawnTestBase::IsOpenGLES() const {
|
||||||
|
return mParam.adapterProperties.backendType == wgpu::BackendType::OpenGLES;
|
||||||
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsVulkan() const {
|
bool DawnTestBase::IsVulkan() const {
|
||||||
return mParam.adapterProperties.backendType == wgpu::BackendType::Vulkan;
|
return mParam.adapterProperties.backendType == wgpu::BackendType::Vulkan;
|
||||||
}
|
}
|
||||||
|
@ -830,6 +861,13 @@ void DawnTestBase::SetUp() {
|
||||||
|
|
||||||
device.SetUncapturedErrorCallback(OnDeviceError, this);
|
device.SetUncapturedErrorCallback(OnDeviceError, this);
|
||||||
device.SetDeviceLostCallback(OnDeviceLost, 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() {
|
void DawnTestBase::TearDown() {
|
||||||
|
|
|
@ -152,9 +152,14 @@ BackendTestConfig NullBackend(std::initializer_list<const char*> forceEnabledWor
|
||||||
BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledWorkarounds = {},
|
BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledWorkarounds = {},
|
||||||
std::initializer_list<const char*> forceDisabledWorkarounds = {});
|
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 = {},
|
BackendTestConfig VulkanBackend(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 PlatformDebugLogger;
|
class PlatformDebugLogger;
|
||||||
class TerribleCommandBuffer;
|
class TerribleCommandBuffer;
|
||||||
|
@ -195,6 +200,8 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
bool HasVendorIdFilter() const;
|
bool HasVendorIdFilter() const;
|
||||||
uint32_t GetVendorIdFilter() const;
|
uint32_t GetVendorIdFilter() const;
|
||||||
const char* GetWireTraceDir() const;
|
const char* GetWireTraceDir() const;
|
||||||
|
GLFWwindow* GetOpenGLWindow() const;
|
||||||
|
GLFWwindow* GetOpenGLESWindow() const;
|
||||||
|
|
||||||
const std::vector<std::string>& GetEnabledToggles() const;
|
const std::vector<std::string>& GetEnabledToggles() const;
|
||||||
const std::vector<std::string>& GetDisabledToggles() const;
|
const std::vector<std::string>& GetDisabledToggles() const;
|
||||||
|
@ -204,7 +211,7 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseArgs(int argc, char** argv);
|
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 SelectPreferredAdapterProperties(const dawn_native::Instance* instance);
|
||||||
void PrintTestConfigurationAndAdapterInfo(dawn_native::Instance* instance) const;
|
void PrintTestConfigurationAndAdapterInfo(dawn_native::Instance* instance) const;
|
||||||
|
|
||||||
|
@ -221,6 +228,8 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
std::vector<TestAdapterProperties> mAdapterProperties;
|
std::vector<TestAdapterProperties> mAdapterProperties;
|
||||||
|
|
||||||
std::unique_ptr<utils::PlatformDebugLogger> mPlatformDebugLogger;
|
std::unique_ptr<utils::PlatformDebugLogger> mPlatformDebugLogger;
|
||||||
|
GLFWwindow* mOpenGLWindow;
|
||||||
|
GLFWwindow* mOpenGLESWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DawnTestBase {
|
class DawnTestBase {
|
||||||
|
@ -237,6 +246,7 @@ class DawnTestBase {
|
||||||
bool IsMetal() const;
|
bool IsMetal() const;
|
||||||
bool IsNull() const;
|
bool IsNull() const;
|
||||||
bool IsOpenGL() const;
|
bool IsOpenGL() const;
|
||||||
|
bool IsOpenGLES() const;
|
||||||
bool IsVulkan() const;
|
bool IsVulkan() const;
|
||||||
|
|
||||||
bool IsAMD() const;
|
bool IsAMD() const;
|
||||||
|
|
|
@ -51,4 +51,9 @@ TEST_P(BasicTests, QueueWriteBufferError) {
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buffer, 1000, &value, sizeof(value)));
|
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