mirror of
https://github.com/libretro/RetroArch
synced 2025-01-04 02:50:05 +00:00
(EMSCRIPTEN) add shared context support
This commit is contained in:
parent
d16395ffa6
commit
96feb074d0
@ -57,7 +57,8 @@ HAVE_SDL = 0
|
||||
HAVE_ZLIB = 1
|
||||
HAVE_FBO = 1
|
||||
WANT_MINIZ = 1
|
||||
MEMORY = 67108864
|
||||
#MEMORY = 67108864
|
||||
MEMORY = 134217728
|
||||
LTO = 0
|
||||
# XXX: setting this to 1/2 currently crashes Firefox nightly
|
||||
PRECISE_F32 = 0
|
||||
|
@ -32,12 +32,14 @@
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
static EGLContext g_egl_hw_ctx;
|
||||
static EGLContext g_egl_ctx;
|
||||
static EGLSurface g_egl_surf;
|
||||
static EGLDisplay g_egl_dpy;
|
||||
static EGLConfig g_config;
|
||||
|
||||
static bool g_inited;
|
||||
static bool g_use_hw_ctx;
|
||||
|
||||
static unsigned g_fb_width;
|
||||
static unsigned g_fb_height;
|
||||
@ -153,6 +155,16 @@ static bool gfx_ctx_init(void *data)
|
||||
if (!g_egl_ctx)
|
||||
goto error;
|
||||
|
||||
if (g_use_hw_ctx)
|
||||
{
|
||||
g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_config, g_egl_ctx,
|
||||
context_attributes);
|
||||
RARCH_LOG("[VC/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx);
|
||||
|
||||
if (g_egl_hw_ctx == EGL_NO_CONTEXT)
|
||||
goto error;
|
||||
}
|
||||
|
||||
// create an EGL window surface
|
||||
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, 0, NULL);
|
||||
if (!g_egl_surf)
|
||||
@ -271,6 +283,14 @@ static bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned widt
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gfx_ctx_bind_hw_render(void *data, bool enable)
|
||||
{
|
||||
(void)data;
|
||||
g_use_hw_ctx = enable;
|
||||
if (g_egl_dpy && g_egl_surf)
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_emscripten = {
|
||||
gfx_ctx_init,
|
||||
gfx_ctx_destroy,
|
||||
@ -290,4 +310,5 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = {
|
||||
gfx_ctx_write_egl_image,
|
||||
NULL,
|
||||
"emscripten",
|
||||
gfx_ctx_bind_hw_render,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user