Play it safe for non-GBM targets

This commit is contained in:
twinaphex 2018-12-07 21:15:38 +01:00
parent 96840572ef
commit bfd9141577

View File

@ -336,14 +336,16 @@ 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);
#ifdef HAVE_GBM
if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1)
{ {
RARCH_ERR("[EGL]: No cofigs 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) return false; if (!configs)
return false;
if (!eglChooseConfig(egl->dpy, attrib_ptr, if (!eglChooseConfig(egl->dpy, attrib_ptr,
configs, count, &matched) || !matched) configs, count, &matched) || !matched)
@ -358,25 +360,25 @@ bool egl_init_context(egl_ctx_data_t *egl,
configs[i], EGL_NATIVE_VISUAL_ID, &id)) configs[i], EGL_NATIVE_VISUAL_ID, &id))
continue; continue;
#ifdef HAVE_GBM
if (id == GBM_FORMAT_XRGB8888) if (id == GBM_FORMAT_XRGB8888)
break; break;
#endif
} }
#ifdef HAVE_GBM
if (id != GBM_FORMAT_XRGB8888) if (id != GBM_FORMAT_XRGB8888)
{ {
RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n"); RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n");
return false; return false;
} }
#endif
config_index = i; config_index = i;
if (config_index != -1) if (config_index != -1)
egl->config = configs[config_index]; egl->config = configs[config_index];
free(configs); free(configs);
#else
if (!eglChooseConfig(egl->dpy, attrib_ptr, &egl->config, 1, n) || *n != 1)
return false;
#endif
egl->major = g_egl_major; egl->major = g_egl_major;
egl->minor = g_egl_minor; egl->minor = g_egl_minor;