diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 78abc030e..dfaf28eb9 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -449,6 +449,12 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa return 0; } +void +SDL_EGL_SetRequiredVisualId(_THIS, int visual_id) +{ + _this->egl_data->egl_required_visual_id=visual_id; +} + #ifdef DUMP_EGL_CONFIG #define ATTRIBUTE(_attr) { _attr, #_attr } @@ -513,14 +519,8 @@ SDL_EGL_ChooseConfig(_THIS) /* 64 seems nice. */ EGLint attribs[64]; EGLint found_configs = 0, value; -#ifdef SDL_VIDEO_DRIVER_KMSDRM - /* Intel EGL on KMS/DRM (al least) returns invalid configs that confuse the bitdiff search used */ - /* later in this function, so we simply use the first one when using the KMSDRM driver for now. */ - EGLConfig configs[1]; -#else /* 128 seems even nicer here */ EGLConfig configs[128]; -#endif int i, j, best_bitdiff = -1, bitdiff; if (!_this->egl_data) { @@ -603,6 +603,16 @@ SDL_EGL_ChooseConfig(_THIS) /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */ for (i = 0; i < found_configs; i++ ) { + if (_this->egl_data->egl_required_visual_id) + { + EGLint format; + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + configs[i], + EGL_NATIVE_VISUAL_ID, &format); + if (_this->egl_data->egl_required_visual_id != format) + continue; + } + bitdiff = 0; for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) { if (attribs[j] == EGL_NONE) { diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index d1c41297c..9f7371f49 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -37,6 +37,7 @@ typedef struct SDL_EGL_VideoData int egl_swapinterval; int egl_surfacetype; int egl_version_major, egl_version_minor; + EGLint egl_required_visual_id; EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display); EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform, @@ -102,6 +103,7 @@ extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display, EGLenum platform); extern void *SDL_EGL_GetProcAddress(_THIS, const char *proc); extern void SDL_EGL_UnloadLibrary(_THIS); +extern void SDL_EGL_SetRequiredVisualId(_THIS, int visual_id); extern int SDL_EGL_ChooseConfig(_THIS); extern int SDL_EGL_SetSwapInterval(_THIS, int interval); extern int SDL_EGL_GetSwapInterval(_THIS); diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index bacbe0c1e..1d53ee94a 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -587,6 +587,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) goto error; } } + SDL_EGL_SetRequiredVisualId(_this, surface_fmt); wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wdata->gs); if (wdata->egl_surface == EGL_NO_SURFACE) {