src/video/SDL_egl.c
changeset 12376 cfc65d4d49ae
parent 12269 754cd2042e21
child 12493 82f9397db3e7
     1.1 --- a/src/video/SDL_egl.c	Wed Oct 31 15:01:20 2018 -0700
     1.2 +++ b/src/video/SDL_egl.c	Wed Oct 31 15:16:51 2018 -0700
     1.3 @@ -449,6 +449,12 @@
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +void
     1.8 +SDL_EGL_SetRequiredVisualId(_THIS, int visual_id) 
     1.9 +{
    1.10 +    _this->egl_data->egl_required_visual_id=visual_id;
    1.11 +}
    1.12 +
    1.13  #ifdef DUMP_EGL_CONFIG
    1.14  
    1.15  #define ATTRIBUTE(_attr) { _attr, #_attr }
    1.16 @@ -513,14 +519,8 @@
    1.17  /* 64 seems nice. */
    1.18      EGLint attribs[64];
    1.19      EGLint found_configs = 0, value;
    1.20 -#ifdef SDL_VIDEO_DRIVER_KMSDRM
    1.21 -    /* Intel EGL on KMS/DRM (al least) returns invalid configs that confuse the bitdiff search used */
    1.22 -    /* later in this function, so we simply use the first one when using the KMSDRM driver for now. */
    1.23 -    EGLConfig configs[1];
    1.24 -#else
    1.25      /* 128 seems even nicer here */
    1.26      EGLConfig configs[128];
    1.27 -#endif
    1.28      int i, j, best_bitdiff = -1, bitdiff;
    1.29     
    1.30      if (!_this->egl_data) {
    1.31 @@ -603,6 +603,16 @@
    1.32      /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
    1.33  
    1.34      for (i = 0; i < found_configs; i++ ) {
    1.35 +        if (_this->egl_data->egl_required_visual_id)
    1.36 +        {
    1.37 +            EGLint format;
    1.38 +            _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
    1.39 +                                            configs[i], 
    1.40 +                                            EGL_NATIVE_VISUAL_ID, &format);
    1.41 +            if (_this->egl_data->egl_required_visual_id != format)
    1.42 +                continue;
    1.43 +        }
    1.44 +
    1.45          bitdiff = 0;
    1.46          for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
    1.47              if (attribs[j] == EGL_NONE) {