Merge pull request #7984 from myfreeweb/egl-fix

Fix EGL initialization not setting 'n'
This commit is contained in:
Twinaphex 2019-01-12 05:10:46 +01:00 committed by GitHub
commit ff8e10f014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 30 deletions

View File

@ -330,12 +330,11 @@ bool egl_init_context(egl_ctx_data_t *egl,
EGLenum platform, EGLenum platform,
void *display_data, void *display_data,
EGLint *major, EGLint *minor, EGLint *major, EGLint *minor,
EGLint *n, const EGLint *attrib_ptr, EGLint *count, const EGLint *attrib_ptr,
egl_accept_config_cb_t cb) egl_accept_config_cb_t cb)
{ {
EGLint i; EGLint i;
EGLConfig *configs = NULL; EGLConfig *configs = NULL;
EGLint count = 0;
EGLint matched = 0; EGLint matched = 0;
int config_index = -1; int config_index = -1;
EGLDisplay dpy = get_egl_display(platform, display_data); EGLDisplay dpy = get_egl_display(platform, display_data);
@ -353,24 +352,24 @@ bool egl_init_context(egl_ctx_data_t *egl,
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor); RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
{ {
RARCH_ERR("[EGL]: No configs to choose from.\n"); RARCH_ERR("[EGL]: No configs to choose from.\n");
return false; return false;
} }
configs = malloc(count * sizeof(*configs)); configs = malloc(*count * sizeof(*configs));
if (!configs) if (!configs)
return false; return false;
if (!eglChooseConfig(egl->dpy, attrib_ptr, if (!eglChooseConfig(egl->dpy, attrib_ptr,
configs, count, &matched) || !matched) configs, *count, &matched) || !matched)
{ {
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n"); RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
return false; return false;
} }
for (i = 0; i < count; i++) for (i = 0; i < *count; i++)
{ {
if (!cb || cb(display_data, egl->dpy, configs[i])) if (!cb || cb(display_data, egl->dpy, configs[i]))
{ {
@ -381,7 +380,7 @@ bool egl_init_context(egl_ctx_data_t *egl,
free(configs); free(configs);
if (i == count) if (i == *count)
{ {
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n"); RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
return false; return false;