From a2ba481c7110ba6b402dfd0f2d92ab84548eaa1d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 10 Jul 2024 21:59:13 +0200 Subject: [PATCH] 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 --- intern/ghost/intern/GHOST_ContextEGL.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_ContextEGL.cc b/intern/ghost/intern/GHOST_ContextEGL.cc index be4a6016495..c406c284ba7 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cc +++ b/intern/ghost/intern/GHOST_ContextEGL.cc @@ -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 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 {