Skip to content

Commit

Permalink
Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some …
Browse files Browse the repository at this point in the history
…Android devices
  • Loading branch information
slouken committed Oct 1, 2018
1 parent 48f7e7f commit 95579f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/video/SDL_egl.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 &&
Expand Down
1 change: 1 addition & 0 deletions src/video/SDL_egl_c.h
Expand Up @@ -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,
Expand Down

0 comments on commit 95579f5

Please sign in to comment.