Merge commit '7b284dbb34a8c34f5d6f79c58c860c9f7894fd56' into main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 011d3d8..8fecaff 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -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];
@@ -706,11 +706,6 @@ SDL_EGL_ChooseConfig(_THIS)
SDL_bool has_matching_format = SDL_FALSE;
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;
@@ -720,12 +715,17 @@ SDL_EGL_ChooseConfig(_THIS)
attribs[i++] = _this->gl_config.green_size;
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;
}
-
+
if (_this->gl_config.buffer_size) {
attribs[i++] = EGL_BUFFER_SIZE;
attribs[i++] = _this->gl_config.buffer_size;
@@ -740,12 +740,12 @@ SDL_EGL_ChooseConfig(_THIS)
attribs[i++] = EGL_STENCIL_SIZE;
attribs[i++] = _this->gl_config.stencil_size;
}
-
+
if (_this->gl_config.multisamplebuffers) {
attribs[i++] = EGL_SAMPLE_BUFFERS;
attribs[i++] = _this->gl_config.multisamplebuffers;
}
-
+
if (_this->gl_config.multisamplesamples) {
attribs[i++] = EGL_SAMPLES;
attribs[i++] = _this->gl_config.multisamplesamples;
@@ -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. */
@@ -817,7 +817,7 @@ SDL_EGL_ChooseConfig(_THIS)
if (has_matching_format && _this->egl_data->egl_required_visual_id) {
EGLint format;
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
- configs[i],
+ configs[i],
EGL_NATIVE_VISUAL_ID, &format);
if (_this->egl_data->egl_required_visual_id != format) {
continue;
@@ -839,7 +839,7 @@ SDL_EGL_ChooseConfig(_THIS)
if (attribs[j] == EGL_NONE) {
break;
}
-
+
if ( attribs[j+1] != EGL_DONT_CARE && (
attribs[j] == EGL_RED_SIZE ||
attribs[j] == EGL_GREEN_SIZE ||
@@ -887,10 +887,36 @@ SDL_EGL_ChooseConfig(_THIS)
#ifdef DUMP_EGL_CONFIG
dumpconfig(_this, _this->egl_data->egl_config);
#endif
-
+
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)
{