(Android) Start using egl_create_context

This commit is contained in:
twinaphex 2015-11-19 18:25:19 +01:00
parent 033e0ac3ad
commit f84c58e777
4 changed files with 10 additions and 20 deletions

View File

@ -205,10 +205,10 @@ bool egl_init_context(NativeDisplayType display,
return true; return true;
} }
bool egl_create_context(EGLint *attr, EGLint *egl_attribs) bool egl_create_context(EGLint *egl_attribs)
{ {
g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT,
(attr != egl_attribs) ? egl_attribs : NULL); egl_attribs);
if (g_egl_ctx == EGL_NO_CONTEXT) if (g_egl_ctx == EGL_NO_CONTEXT)
return false; return false;
@ -216,7 +216,7 @@ bool egl_create_context(EGLint *attr, EGLint *egl_attribs)
if (g_use_hw_ctx) if (g_use_hw_ctx)
{ {
g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx, g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx,
(attr != egl_attribs) ? egl_attribs : NULL); egl_attribs);
RARCH_LOG("[EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx); RARCH_LOG("[EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx);
if (g_egl_hw_ctx == EGL_NO_CONTEXT) if (g_egl_hw_ctx == EGL_NO_CONTEXT)

View File

@ -55,6 +55,6 @@ bool egl_init_context(NativeDisplayType display,
EGLint *major, EGLint *minor, EGLint *major, EGLint *minor,
EGLint *n, const EGLint *attrib_ptr); EGLint *n, const EGLint *attrib_ptr);
bool egl_create_context(EGLint *attr, EGLint *egl_attribs); bool egl_create_context(EGLint *egl_attribs);
#endif #endif

View File

@ -76,22 +76,10 @@ static bool android_gfx_ctx_init(void *data)
ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format); ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format);
g_egl_ctx = eglCreateContext(g_egl_dpy, if (!egl_create_context(context_attributes))
g_egl_config, EGL_NO_CONTEXT, context_attributes);
if (g_egl_ctx == EGL_NO_CONTEXT)
goto error;
if (g_use_hw_ctx)
{ {
g_egl_hw_ctx = eglCreateContext(g_egl_dpy, egl_report_error();
g_egl_config, g_egl_ctx, goto error;
context_attributes);
RARCH_LOG("[Android/EGL]: Created shared context: %p.\n",
(void*)g_egl_hw_ctx);
if (g_egl_hw_ctx == EGL_NO_CONTEXT)
goto error;
} }
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_surf = eglCreateWindowSurface(g_egl_dpy,

View File

@ -722,6 +722,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
goto error; goto error;
} }
if (!egl_init_context((EGLNativeDisplayType)drm->g_gbm_dev, &major, if (!egl_init_context((EGLNativeDisplayType)drm->g_gbm_dev, &major,
&minor, &n, attrib_ptr)) &minor, &n, attrib_ptr))
{ {
@ -730,8 +731,9 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
} }
attr = egl_fill_attribs(egl_attribs); attr = egl_fill_attribs(egl_attribs);
EGLint *egl_attribs_ptr = &egl_attribs[0];
if (!egl_create_context(attr, &egl_attribs[0])) if (!egl_create_context((attr != egl_attribs_ptr) ? egl_attribs_ptr : NULL))
{ {
egl_report_error(); egl_report_error();
goto error; goto error;