Enable SurfactTests on OpenGL.
As well as SurfaceConfigurationValidationTests.
Also does minor fixes to the OpenGL backend:
- Do not use ResultOrError for EGLSurface as it might just be a number
and not an aligned pointer like ResultOrError requires.
- Removes a clearly invalid ASSERT.
Bug: 42241264
Change-Id: Id491412b3398b6466c065ba14ecf0cb938c94164
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/205458
Reviewed-by: Geoff Lang <geofflang@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/opengl/SwapChainEGL.cpp b/src/dawn/native/opengl/SwapChainEGL.cpp
index 050fedd..42d9488 100644
--- a/src/dawn/native/opengl/SwapChainEGL.cpp
+++ b/src/dawn/native/opengl/SwapChainEGL.cpp
@@ -160,8 +160,6 @@
}
void SwapChainEGL::DetachFromSurfaceImpl() {
- DAWN_ASSERT(mTexture == nullptr);
-
if (mEGLSurface != EGL_NO_SURFACE) {
Device* device = ToBackend(GetDevice());
device->GetEGL(false).DestroySurface(device->GetEGLDisplay(), mEGLSurface);
@@ -202,28 +200,34 @@
attribs.push_back(EGL_NONE);
- auto TryCreateSurface = [&]() -> ResultOrError<EGLSurface> {
+ // Note that we cannot use ResultOrError<EGLSurface> as it might not have the required alignment
+ // constraints.
+ auto TryCreateSurface = [&]() -> MaybeError {
switch (surface->GetType()) {
#if DAWN_PLATFORM_IS(ANDROID)
case Surface::Type::AndroidWindow:
- return egl.CreateWindowSurface(
+ mEGLSurface = egl.CreateWindowSurface(
eglDisplay, config,
static_cast<ANativeWindow*>(surface->GetAndroidNativeWindow()), attribs.data());
+ return {};
#endif // DAWN_PLATFORM_IS(ANDROID)
#if defined(DAWN_ENABLE_BACKEND_METAL)
case Surface::Type::MetalLayer:
- return egl.CreateWindowSurface(eglDisplay, config, surface->GetMetalLayer(),
- attribs.data());
+ mEGLSurface = egl.CreateWindowSurface(eglDisplay, config, surface->GetMetalLayer(),
+ attribs.data());
+ return {};
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if DAWN_PLATFORM_IS(WIN32)
case Surface::Type::WindowsHWND:
- return egl.CreateWindowSurface(
+ mEGLSurface = egl.CreateWindowSurface(
eglDisplay, config, static_cast<HWND>(surface->GetHWND()), attribs.data());
+ return {};
#endif // DAWN_PLATFORM_IS(WIN32)
#if defined(DAWN_USE_X11)
case Surface::Type::XlibWindow:
- return egl.CreateWindowSurface(eglDisplay, config, surface->GetXWindow(),
- attribs.data());
+ mEGLSurface = egl.CreateWindowSurface(eglDisplay, config, surface->GetXWindow(),
+ attribs.data());
+ return {};
#endif // defined(DAWN_USE_X11)
// TODO(344814083): Add support for creating surfaces using EGL_KHR_platform_base and
@@ -235,7 +239,7 @@
}
};
- DAWN_TRY_ASSIGN(mEGLSurface, TryCreateSurface());
+ DAWN_TRY(TryCreateSurface());
if (mEGLSurface == EGL_NO_SURFACE) {
return DAWN_FORMAT_INTERNAL_ERROR("Couldn't create an EGLSurface for %s.", surface);
}
diff --git a/src/dawn/tests/end2end/SurfaceConfigurationValidationTests.cpp b/src/dawn/tests/end2end/SurfaceConfigurationValidationTests.cpp
index b283a33..10b4ae7 100644
--- a/src/dawn/tests/end2end/SurfaceConfigurationValidationTests.cpp
+++ b/src/dawn/tests/end2end/SurfaceConfigurationValidationTests.cpp
@@ -344,6 +344,8 @@
D3D12Backend(),
MetalBackend(),
NullBackend(),
+ OpenGLBackend(),
+ OpenGLESBackend(),
VulkanBackend());
} // anonymous namespace
diff --git a/src/dawn/tests/end2end/SurfaceTests.cpp b/src/dawn/tests/end2end/SurfaceTests.cpp
index 9f0a700..d1722be 100644
--- a/src/dawn/tests/end2end/SurfaceTests.cpp
+++ b/src/dawn/tests/end2end/SurfaceTests.cpp
@@ -651,6 +651,8 @@
D3D11Backend(),
D3D12Backend(),
MetalBackend(),
+ OpenGLBackend(),
+ OpenGLESBackend(),
VulkanBackend());
} // anonymous namespace