Merge commit '7b284dbb34a8c34f5d6f79c58c860c9f7894fd56' into main

This commit is contained in:
Sam Lantinga 2021-05-07 12:28:42 -07:00
commit 069a68a5c5

View File

@ -695,8 +695,8 @@ static void dumpconfig(_THIS, EGLConfig config)
#endif /* DUMP_EGL_CONFIG */
int
SDL_EGL_ChooseConfig(_THIS)
static int
SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none)
{
/* 64 seems nice. */
EGLint attribs[64];
@ -707,11 +707,6 @@ SDL_EGL_ChooseConfig(_THIS)
int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1;
int truecolor_config_idx = -1;
if (!_this->egl_data) {
/* The EGL library wasn't loaded, SDL_GetError() should have info */
return -1;
}
/* Get a valid EGL configuration */
i = 0;
attribs[i++] = EGL_RED_SIZE;
@ -721,6 +716,11 @@ SDL_EGL_ChooseConfig(_THIS)
attribs[i++] = EGL_BLUE_SIZE;
attribs[i++] = _this->gl_config.blue_size;
if (set_config_caveat_none) {
attribs[i++] = EGL_CONFIG_CAVEAT;
attribs[i++] = EGL_NONE;
}
if (_this->gl_config.alpha_size) {
attribs[i++] = EGL_ALPHA_SIZE;
attribs[i++] = _this->gl_config.alpha_size;
@ -789,7 +789,7 @@ SDL_EGL_ChooseConfig(_THIS)
configs, SDL_arraysize(configs),
&found_configs) == EGL_FALSE ||
found_configs == 0) {
return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
return -1;
}
/* first ensure that a found config has a matching format, or the function will fall through. */
@ -891,6 +891,32 @@ SDL_EGL_ChooseConfig(_THIS)
return 0;
}
int
SDL_EGL_ChooseConfig(_THIS)
{
int ret;
if (!_this->egl_data) {
/* The EGL library wasn't loaded, SDL_GetError() should have info */
return -1;
}
/* Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG */
ret = SDL_EGL_PrivateChooseConfig(_this, SDL_TRUE);
if (ret == 0) {
return 0;
}
/* Fallback with all configs */
ret = SDL_EGL_PrivateChooseConfig(_this, SDL_FALSE);
if (ret == 0) {
SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config");
return 0;
}
return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
}
SDL_GLContext
SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
{