From 5470fd6de9c244320bce8da4b69574a55148399d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 14 Dec 2021 18:35:30 +0100 Subject: [PATCH] EGL: Use EGL_EXT_present_opaque when available This extensions allows GLFW to instruct the driver to ignore the alpha bits, even in formats which contain them. This makes it possible to use the alpha bits as extra storage, without it affecting the end result getting displayed to the user. Fixes #1434 Fixes #1803 (cherry picked from commit 6281f498c875f49d8ac5c5a02d968fb1792fd9f5) --- src/egl_context.c | 5 +++++ src/egl_context.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/egl_context.c b/src/egl_context.c index 6b34f724..aa824051 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -426,6 +426,8 @@ GLFWbool _glfwInitEGL(void) extensionSupportedEGL("EGL_KHR_get_all_proc_addresses"); _glfw.egl.KHR_context_flush_control = extensionSupportedEGL("EGL_KHR_context_flush_control"); + _glfw.egl.EXT_present_opaque = + extensionSupportedEGL("EGL_EXT_present_opaque"); return GLFW_TRUE; } @@ -599,6 +601,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (!fbconfig->doublebuffer) setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); + if (_glfw.egl.EXT_present_opaque) + setAttrib(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); + setAttrib(EGL_NONE, EGL_NONE); window->context.egl.surface = diff --git a/src/egl_context.h b/src/egl_context.h index c8446dad..47493a6f 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -108,6 +108,7 @@ typedef struct wl_egl_window* EGLNativeWindowType; #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 +#define EGL_PRESENT_OPAQUE_EXT 0x31df typedef int EGLint; typedef unsigned int EGLBoolean; @@ -179,6 +180,7 @@ typedef struct _GLFWlibraryEGL GLFWbool KHR_gl_colorspace; GLFWbool KHR_get_all_proc_addresses; GLFWbool KHR_context_flush_control; + GLFWbool EXT_present_opaque; void* handle;