Fix 102994: GHOST: Fix transparent viewports

On specific platforms the viewport could be rendered transparent on
top of the OS desktop. Mesa adviced us to enable a `EGL_PRESENT_OPAQUE`
when its extension exists.

Partially fixes #102994; mesa-zink (https://docs.mesa3d.org/drivers/zink.html)
still shows transparent viewports. As this PR already improves the situation we
it will be merged.

Pull Request: https://projects.blender.org/blender/blender/pulls/124395
This commit is contained in:
Jeroen Bakker
2024-07-10 21:59:13 +02:00
parent 6390f2e4c6
commit a2ba481c71

View File

@@ -472,7 +472,27 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
}
if (m_nativeWindow != 0) {
m_surface = ::eglCreateWindowSurface(m_display, m_config, m_nativeWindow, nullptr);
std::vector<EGLint> surface_attrib_list;
surface_attrib_list.reserve(3);
#if WITH_GHOST_WAYLAND
/* Fix transparency issue on Wayland + Nouveau/Zink+NVK. Due to unsupported texture formats
* drivers can hit transparency code-paths resulting in showing the desktop in viewports.
*
* See #102994. */
/* EGL_EXT_present_opaque isn't added to the latest release of epoxy, but is part of the latest
* EGL https://github.com/KhronosGroup/EGL-Registry/blob/main/api/egl.xml */
if (epoxy_has_egl_extension(m_display, "EGL_EXT_present_opaque")) {
# ifndef EGL_PRESENT_OPAQUE_EXT
# define EGL_PRESENT_OPAQUE_EXT 0x31DF
# endif
surface_attrib_list.push_back(EGL_PRESENT_OPAQUE_EXT);
surface_attrib_list.push_back(EGL_TRUE);
}
#endif
surface_attrib_list.push_back(EGL_NONE);
m_surface = ::eglCreateWindowSurface(
m_display, m_config, m_nativeWindow, surface_attrib_list.data());
m_surface_from_native_window = true;
}
else {