Start using egl_init_context for most GLES context drivers

This commit is contained in:
twinaphex 2015-11-19 18:10:59 +01:00
parent 4c1ac3222c
commit c1e61f7ff0
6 changed files with 35 additions and 110 deletions

View File

@ -52,8 +52,8 @@ static void gfx_ctx_qnx_destroy(void *data)
static bool gfx_ctx_qnx_init(void *data)
{
EGLint num_config;
EGLint egl_version_major, egl_version_minor;
EGLint n;
EGLint major, minor;
EGLint context_attributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
@ -98,30 +98,18 @@ static bool gfx_ctx_qnx_init(void *data)
usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
RARCH_LOG("Initializing context\n");
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
RARCH_ERR("eglGetDisplay failed.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
{
RARCH_ERR("eglInitialize failed.\n");
goto error;
}
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
RARCH_ERR("eglBindAPI failed.\n");
goto error;
}
RARCH_LOG("[BLACKBERRY QNX/EGL]: EGL version: %d.%d\n", egl_version_major, egl_version_minor);
if (!eglChooseConfig(g_egl_dpy, attribs, &g_egl_config, 1, &num_config))
if (!egl_init_context(EGL_DEFAULT_DISPLAY, &major, &minor,
&n, attribs))
{
egl_report_error();
goto error;
}
g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, context_attributes);

View File

@ -106,7 +106,7 @@ static void gfx_ctx_emscripten_destroy(void *data);
static bool gfx_ctx_emscripten_init(void *data)
{
EGLint width, height, num_config;
EGLint width, height, n, major, minor;
static const EGLint attribute_list[] =
{
EGL_RED_SIZE, 8,
@ -124,26 +124,18 @@ static bool gfx_ctx_emscripten_init(void *data)
(void)data;
RARCH_LOG("[EMSCRIPTEN/EGL]: Initializing...\n");
if (g_inited)
{
RARCH_LOG("[EMSCRIPTEN/EGL]: Attempted to re-initialize driver.\n");
return true;
}
/* Get an EGL display connection. */
g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!g_egl_dpy)
goto error;
/* Initialize the EGL display connection. */
if (!eglInitialize(g_egl_dpy, NULL, NULL))
goto error;
/* Get an appropriate EGL frame buffer configuration. */
if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_egl_config, 1, &num_config))
if (!egl_init_context(EGL_DEFAULT_DISPLAY, &major, &minor,
&n, attribute_list))
{
egl_report_error();
goto error;
}
/* Create an EGL rendering context. */
g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, context_attributes);

View File

@ -64,9 +64,8 @@ static void gfx_ctx_mali_fbdev_get_video_size(void *data,
static bool gfx_ctx_mali_fbdev_init(void *data)
{
EGLint num_config;
EGLint egl_version_major, egl_version_minor;
EGLint n;
EGLint major, minor;
EGLint format;
static const EGLint attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
@ -83,26 +82,10 @@ static bool gfx_ctx_mali_fbdev_init(void *data)
/* Disable cursor blinking so it's not visible in RetroArch. */
system("setterm -cursor off");
RARCH_LOG("[Mali fbdev]: Initializing context\n");
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
if (!egl_init_context(EGL_DEFAULT_DISPLAY,
&major, &minor, &n, attribs))
{
RARCH_ERR("[Mali fbdev]: eglGetDisplay failed.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
{
RARCH_ERR("[Mali fbdev]: eglInitialize failed.\n");
goto error;
}
RARCH_LOG("[Mali fbdev]: EGL version: %d.%d\n",
egl_version_major, egl_version_minor);
if (!eglChooseConfig(g_egl_dpy, attribs, &g_egl_config, 1, &num_config))
{
RARCH_ERR("[Mali fbdev]: eglChooseConfig failed.\n");
egl_report_error();
goto error;
}

View File

@ -137,7 +137,7 @@ static void gfx_ctx_vc_destroy(void *data);
static bool gfx_ctx_vc_init(void *data)
{
VC_DISPMANX_ALPHA_T alpha;
EGLint num_config;
EGLint n, major, minor;
static EGL_DISPMANX_WINDOW_T nativewindow;
DISPMANX_ELEMENT_HANDLE_T dispman_element;
@ -164,7 +164,6 @@ static bool gfx_ctx_vc_init(void *data)
};
settings_t *settings = config_get_ptr();
RARCH_LOG("[VC/EGL]: Initializing...\n");
if (g_inited)
{
RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n");
@ -173,18 +172,12 @@ static bool gfx_ctx_vc_init(void *data)
bcm_host_init();
/* Get an EGL display connection. */
g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!g_egl_dpy)
goto error;
/* Initialize the EGL display connection. */
if (!eglInitialize(g_egl_dpy, NULL, NULL))
goto error;
/* Get an appropriate EGL frame buffer configuration. */
if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_egl_config, 1, &num_config))
if (!egl_init_context(EGL_DEFAULT_DISPLAY,
&major, &minor, &n, attribute_list))
{
egl_report_error();
goto error;
}
/* Create an EGL rendering context. */
g_egl_ctx = eglCreateContext(

View File

@ -35,8 +35,8 @@ static void gfx_ctx_vivante_destroy(void *data)
static bool gfx_ctx_vivante_init(void *data)
{
EGLint num_config;
EGLint egl_version_major, egl_version_minor;
EGLint n;
EGLint major, minor;
EGLint format;
static const EGLint attribs[] = {
#if 0
@ -55,26 +55,10 @@ static bool gfx_ctx_vivante_init(void *data)
egl_install_sighandlers();
RARCH_LOG("[Vivante fbdev]: Initializing context\n");
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
if (!egl_init_context(EGL_DEFAULT_DISPLAY, &major, &minor,
&n, attribs))
{
RARCH_ERR("[Vivante fbdev]: eglGetDisplay failed.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
{
RARCH_ERR("[Vivante fbdev]: eglInitialize failed.\n");
goto error;
}
RARCH_LOG("[Vivante fbdev]: EGL version: %d.%d\n",
egl_version_major, egl_version_minor);
if (!eglChooseConfig(g_egl_dpy, attribs, &g_egl_config, 1, &num_config))
{
RARCH_ERR("[Vivante fbdev]: eglChooseConfig failed.\n");
egl_report_error();
goto error;
}

View File

@ -303,8 +303,8 @@ static bool gfx_ctx_wl_init(void *data)
EGL_NONE,
};
EGLint egl_major = 0, egl_minor = 0;
EGLint num_configs;
EGLint major = 0, minor = 0;
EGLint n;
const EGLint *attrib_ptr;
driver_t *driver = driver_get_ptr();
@ -365,29 +365,14 @@ static bool gfx_ctx_wl_init(void *data)
wl->g_fd = wl_display_get_fd(wl->g_dpy);
g_egl_dpy = eglGetDisplay((EGLNativeDisplayType)wl->g_dpy);
if (!g_egl_dpy)
if (!egl_init_context((EGLNativeDisplayType)wl->g_dpy,
&major, &minor, &n, attrib_ptr))
{
RARCH_ERR("Failed to create EGL window.\n");
egl_report_error();
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_major, &egl_minor))
{
RARCH_ERR("Failed to initialize EGL.\n");
goto error;
}
RARCH_LOG("[Wayland/EGL]: EGL version: %d.%d\n", egl_major, egl_minor);
if (!eglChooseConfig(g_egl_dpy, attrib_ptr, &g_egl_config, 1, &num_configs))
{
RARCH_ERR("[Wayland/EGL]: eglChooseConfig failed with 0x%x.\n", eglGetError());
goto error;
}
if (num_configs == 0 || !g_egl_config)
if (n == 0 || !g_egl_config)
{
RARCH_ERR("[Wayland/EGL]: No EGL configurations available.\n");
goto error;