Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices
authorSam Lantinga <slouken@libsdl.org>
Mon, 01 Oct 2018 09:40:58 -0700
changeset 12269754cd2042e21
parent 12268 818dc37cace8
child 12270 52dddda6fba7
Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices
src/video/SDL_egl.c
src/video/SDL_egl_c.h
     1.1 --- a/src/video/SDL_egl.c	Sun Sep 30 22:43:12 2018 -0700
     1.2 +++ b/src/video/SDL_egl.c	Mon Oct 01 09:40:58 2018 -0700
     1.3 @@ -406,6 +406,9 @@
     1.4          }
     1.5      }
     1.6  
     1.7 +    _this->egl_data->egl_version_major = egl_version_major;
     1.8 +    _this->egl_data->egl_version_minor = egl_version_minor;
     1.9 +
    1.10      if (egl_version_major == 1 && egl_version_minor == 5) {
    1.11          LOAD_FUNC(eglGetPlatformDisplay);
    1.12      }
    1.13 @@ -658,6 +661,24 @@
    1.14          share_context = (EGLContext)SDL_GL_GetCurrentContext();
    1.15      }
    1.16  
    1.17 +#if SDL_VIDEO_DRIVER_ANDROID
    1.18 +    if ((_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) != 0) {
    1.19 +        /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
    1.20 +         * This is required because some Android devices like to complain about it
    1.21 +         * by "silently" failing, logging a hint which could be easily overlooked:
    1.22 +         * E/libEGL  (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
    1.23 +         * The following explicitly checks for EGL_KHR_debug before EGL 1.5
    1.24 +         */
    1.25 +        int egl_version_major = _this->egl_data->egl_version_major;
    1.26 +        int egl_version_minor = _this->egl_data->egl_version_minor;
    1.27 +        if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) &&
    1.28 +            !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) {
    1.29 +            /* SDL profile bits match EGL profile bits. */
    1.30 +            _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG;
    1.31 +        }
    1.32 +    }
    1.33 +#endif
    1.34 +
    1.35      /* Set the context version and other attributes. */
    1.36      if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
    1.37          _this->gl_config.flags == 0 &&
     2.1 --- a/src/video/SDL_egl_c.h	Sun Sep 30 22:43:12 2018 -0700
     2.2 +++ b/src/video/SDL_egl_c.h	Mon Oct 01 09:40:58 2018 -0700
     2.3 @@ -36,6 +36,7 @@
     2.4      EGLConfig egl_config;
     2.5      int egl_swapinterval;
     2.6      int egl_surfacetype;
     2.7 +    int egl_version_major, egl_version_minor;
     2.8      
     2.9      EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display);
    2.10      EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform,