Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index c3b4376..78abc03 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -406,6 +406,9 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
}
+ _this->egl_data->egl_version_major = egl_version_major;
+ _this->egl_data->egl_version_minor = egl_version_minor;
+
if (egl_version_major == 1 && egl_version_minor == 5) {
LOAD_FUNC(eglGetPlatformDisplay);
}
@@ -658,6 +661,24 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
share_context = (EGLContext)SDL_GL_GetCurrentContext();
}
+#if SDL_VIDEO_DRIVER_ANDROID
+ if ((_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) != 0) {
+ /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
+ * This is required because some Android devices like to complain about it
+ * by "silently" failing, logging a hint which could be easily overlooked:
+ * E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
+ * The following explicitly checks for EGL_KHR_debug before EGL 1.5
+ */
+ int egl_version_major = _this->egl_data->egl_version_major;
+ int egl_version_minor = _this->egl_data->egl_version_minor;
+ if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) &&
+ !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) {
+ /* SDL profile bits match EGL profile bits. */
+ _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG;
+ }
+ }
+#endif
+
/* Set the context version and other attributes. */
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
_this->gl_config.flags == 0 &&
diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h
index 80b1319..d1c4129 100644
--- a/src/video/SDL_egl_c.h
+++ b/src/video/SDL_egl_c.h
@@ -36,6 +36,7 @@ typedef struct SDL_EGL_VideoData
EGLConfig egl_config;
int egl_swapinterval;
int egl_surfacetype;
+ int egl_version_major, egl_version_minor;
EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform,