mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Add RETRO_ENVIRONMENT_MAKE_CURRENT_CONTEXT
This commit is contained in:
parent
598aa98202
commit
90e5cffab8
@ -324,6 +324,12 @@ CFStringRef)BOXSTRING(symbol_name)
|
||||
);
|
||||
}
|
||||
|
||||
static void apple_gfx_ctx_make_current_context(void *data)
|
||||
{
|
||||
(void)data;
|
||||
[g_hw_ctx makeCurrentContext];
|
||||
}
|
||||
|
||||
static void apple_gfx_ctx_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||
{
|
||||
@ -384,6 +390,7 @@ const gfx_ctx_driver_t gfx_ctx_apple = {
|
||||
apple_gfx_ctx_swap_buffers,
|
||||
apple_gfx_ctx_input_driver,
|
||||
apple_gfx_ctx_get_proc_address,
|
||||
apple_gfx_ctx_make_current_context,
|
||||
NULL,
|
||||
"apple",
|
||||
apple_gfx_ctx_bind_hw_render,
|
||||
|
12
dynamic.c
12
dynamic.c
@ -1237,6 +1237,18 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
|
||||
break;
|
||||
|
||||
case RETRO_ENVIRONMENT_MAKE_CURRENT_CONTEXT:
|
||||
case RETRO_ENVIRONMENT_MAKE_CURRENT_CONTEXT | RETRO_ENVIRONMENT_EXPERIMENTAL:
|
||||
{
|
||||
struct retro_hw_make_current_context_callback *cb =
|
||||
(struct retro_hw_make_current_context_callback*)data;
|
||||
|
||||
RARCH_LOG("Environ MAKE_CURRENT_CONTEXT.\n");
|
||||
|
||||
cb->make_current_context = video_driver_make_current_context;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);
|
||||
return false;
|
||||
|
@ -1607,8 +1607,9 @@ static const video_poke_interface_t exynos_poke_interface = {
|
||||
NULL, /* set_filtering */
|
||||
#ifdef HAVE_FBO
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL, /* get_proc_address */
|
||||
#endif
|
||||
NULL, /* get_proc_address */
|
||||
NULL, /* make_current_context */
|
||||
exynos_set_aspect_ratio,
|
||||
exynos_apply_state_changes,
|
||||
#ifdef HAVE_MENU
|
||||
|
@ -3100,13 +3100,21 @@ static struct video_shader *gl_get_current_shader(void *data)
|
||||
return (gl && gl->shader) ? gl->shader->get_current_shader() : NULL;
|
||||
}
|
||||
|
||||
static void gl_make_current_context(void *data)
|
||||
{
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
if (gl && gl->ctx_driver->make_current_context)
|
||||
gl->ctx_driver->make_current_context(gl);
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gl_poke_interface = {
|
||||
NULL,
|
||||
#ifdef HAVE_FBO
|
||||
gl_get_current_framebuffer,
|
||||
gl_get_proc_address,
|
||||
#endif
|
||||
gl_get_proc_address,
|
||||
gl_make_current_context,
|
||||
gl_set_aspect_ratio,
|
||||
gl_apply_state_changes,
|
||||
#if defined(HAVE_MENU)
|
||||
|
@ -1139,6 +1139,8 @@ static bool gx_read_viewport(void *data, uint8_t *buffer)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gx_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gx_set_aspect_ratio,
|
||||
gx_apply_state_changes,
|
||||
|
@ -838,6 +838,8 @@ static void psp_viewport_info(void *data, struct rarch_viewport *vp)
|
||||
|
||||
static const video_poke_interface_t psp_poke_interface = {
|
||||
psp_set_filtering,
|
||||
NULL,
|
||||
NULL,
|
||||
psp_set_aspect_ratio,
|
||||
psp_apply_state_changes,
|
||||
#ifdef HAVE_MENU
|
||||
|
@ -717,8 +717,9 @@ static video_poke_interface_t sdl2_video_poke_interface = {
|
||||
sdl2_poke_set_filtering,
|
||||
#ifdef HAVE_FBO
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
sdl2_poke_set_aspect_ratio,
|
||||
sdl2_poke_apply_state_changes,
|
||||
#ifdef HAVE_MENU
|
||||
|
@ -316,6 +316,16 @@ static gfx_ctx_proc_t android_gfx_ctx_get_proc_address(
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void android_gfx_ctx_make_current_context(void *data)
|
||||
{
|
||||
gfx_ctx_android_data_t *android = (gfx_ctx_android_data_t*)
|
||||
driver.video_context_data;
|
||||
|
||||
if (android)
|
||||
eglMakeCurrent(android->g_egl_dpy, android->g_egl_surf,
|
||||
android->g_egl_surf, android->g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static bool android_gfx_ctx_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -390,6 +400,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
|
||||
android_gfx_ctx_swap_buffers,
|
||||
android_gfx_ctx_input_driver,
|
||||
android_gfx_ctx_get_proc_address,
|
||||
android_gfx_ctx_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -398,6 +398,14 @@ static gfx_ctx_proc_t gfx_ctx_qnx_get_proc_address(const char *symbol)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gfx_ctx_qnx_make_current_context(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf,
|
||||
g_egl_surf, g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_qnx_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -461,6 +469,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
|
||||
gfx_ctx_qnx_swap_buffers,
|
||||
gfx_ctx_qnx_input_driver,
|
||||
gfx_ctx_qnx_get_proc_address,
|
||||
gfx_ctx_qnx_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -509,6 +509,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = {
|
||||
gfx_ctx_d3d_swap_buffers,
|
||||
gfx_ctx_d3d_input_driver,
|
||||
NULL,
|
||||
NULL,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -898,6 +898,15 @@ static gfx_ctx_proc_t gfx_ctx_drm_egl_get_proc_address(const char *symbol)
|
||||
return eglGetProcAddress(symbol);
|
||||
}
|
||||
|
||||
static void gfx_ctx_drm_egl_make_current_context(void *data)
|
||||
{
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)data;
|
||||
|
||||
if (drm)
|
||||
eglMakeCurrent(drm->g_egl_dpy, drm->g_egl_surf,
|
||||
drm->g_egl_surf, drm->g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_drm_egl_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -967,6 +976,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
|
||||
gfx_ctx_drm_egl_swap_buffers,
|
||||
gfx_ctx_drm_egl_input_driver,
|
||||
gfx_ctx_drm_egl_get_proc_address,
|
||||
gfx_ctx_drm_egl_make_current_context,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -150,6 +150,7 @@ const gfx_ctx_driver_t gfx_ctx_null = {
|
||||
gfx_ctx_null_swap_buffers,
|
||||
gfx_ctx_null_input_driver,
|
||||
NULL,
|
||||
NULL,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -686,6 +686,15 @@ static gfx_ctx_proc_t gfx_ctx_glx_get_proc_address(const char *symbol)
|
||||
return glXGetProcAddress((const GLubyte*)symbol);
|
||||
}
|
||||
|
||||
static void gfx_ctx_glx_make_current_context(void *data)
|
||||
{
|
||||
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)data;
|
||||
|
||||
if (glx)
|
||||
glXMakeContextCurrent(glx->g_dpy, glx->g_glx_win,
|
||||
glx->g_glx_win, glx->g_hw_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_glx_bind_api(void *data, enum gfx_ctx_api api,
|
||||
unsigned major, unsigned minor)
|
||||
{
|
||||
@ -743,6 +752,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = {
|
||||
gfx_ctx_glx_swap_buffers,
|
||||
gfx_ctx_glx_input_driver,
|
||||
gfx_ctx_glx_get_proc_address,
|
||||
gfx_ctx_glx_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -285,6 +285,12 @@ static gfx_ctx_proc_t gfx_ctx_mali_fbdev_get_proc_address(const char *symbol)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gfx_ctx_mali_fbdev_make_current_context(void *data)
|
||||
{
|
||||
/* FIXME : Hookup bind_hw_render */
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_mali_fbdev_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -328,6 +334,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
|
||||
gfx_ctx_mali_fbdev_swap_buffers,
|
||||
gfx_ctx_mali_fbdev_input_driver,
|
||||
gfx_ctx_mali_fbdev_get_proc_address,
|
||||
gfx_ctx_mali_fbdev_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -390,6 +390,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
|
||||
gfx_ctx_ps3_input_driver,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"ps3",
|
||||
};
|
||||
|
||||
|
@ -407,6 +407,12 @@ static gfx_ctx_proc_t sdl_ctx_get_proc_address(const char *name)
|
||||
return (gfx_ctx_proc_t)SDL_GL_GetProcAddress(name);
|
||||
}
|
||||
|
||||
static void sdl_ctx_make_current_context(void *data)
|
||||
{
|
||||
/* TODO/FIXME: implement */
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void sdl_ctx_show_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
@ -431,6 +437,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl =
|
||||
sdl_ctx_swap_buffers,
|
||||
sdl_ctx_input_driver,
|
||||
sdl_ctx_get_proc_address,
|
||||
sdl_ctx_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -442,6 +442,13 @@ static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol)
|
||||
return eglGetProcAddress(symbol);
|
||||
}
|
||||
|
||||
static gfx_ctx_proc_t gfx_ctx_vc_make_current_context(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static float gfx_ctx_vc_translate_aspect(void *data,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
@ -606,6 +613,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
|
||||
gfx_ctx_vc_swap_buffers,
|
||||
gfx_ctx_vc_input_driver,
|
||||
gfx_ctx_vc_get_proc_address,
|
||||
gfx_ctx_vc_make_current_context,
|
||||
gfx_ctx_vc_init_egl_image_buffer,
|
||||
gfx_ctx_vc_write_egl_image,
|
||||
NULL,
|
||||
|
@ -270,6 +270,13 @@ static gfx_ctx_proc_t gfx_ctx_vivante_get_proc_address(const char *symbol)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gfx_ctx_vivante_make_current_context(void *data)
|
||||
{
|
||||
/* TODO/FIXME: Implement bind_hw_render */
|
||||
(void)data;
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_vivante_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -313,6 +320,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
|
||||
gfx_ctx_vivante_swap_buffers,
|
||||
gfx_ctx_vivante_input_driver,
|
||||
gfx_ctx_vivante_get_proc_address,
|
||||
gfx_ctx_vivante_make_current_context,
|
||||
#ifdef HAVE_EGL
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -682,6 +682,15 @@ static gfx_ctx_proc_t gfx_ctx_wl_get_proc_address(const char *symbol)
|
||||
return eglGetProcAddress(symbol);
|
||||
}
|
||||
|
||||
static void gfx_ctx_wl_make_current_context(void *data)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
|
||||
if (wl)
|
||||
eglMakeCurrent(wl->g_egl_dpy, wl->g_egl_surf, wl->g_egl_surf,
|
||||
wl->g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wl_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -890,6 +899,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
|
||||
gfx_ctx_wl_swap_buffers,
|
||||
gfx_ctx_wl_input_driver,
|
||||
gfx_ctx_wl_get_proc_address,
|
||||
gfx_ctx_wl_make_current_context,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -652,6 +652,12 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
return (gfx_ctx_proc_t)GetProcAddress(dll_handle, symbol);
|
||||
}
|
||||
|
||||
static void gfx_ctx_wgl_make_current_context(void *data)
|
||||
{
|
||||
(void)data;
|
||||
wglMakeCurrent(g_hdc, g_hw_hrc);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wgl_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -694,6 +700,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
|
||||
gfx_ctx_wgl_swap_buffers,
|
||||
gfx_ctx_wgl_input_driver,
|
||||
gfx_ctx_wgl_get_proc_address,
|
||||
gfx_ctx_wgl_make_current_context,
|
||||
gfx_ctx_wgl_show_mouse,
|
||||
"wgl",
|
||||
gfx_ctx_wgl_bind_hw_render,
|
||||
|
@ -742,6 +742,12 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol)
|
||||
return eglGetProcAddress(symbol);
|
||||
}
|
||||
|
||||
static void gfx_ctx_xegl_make_current_context(void *data)
|
||||
{
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf,
|
||||
g_egl_surf, g_egl_hw_ctx);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_xegl_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -809,6 +815,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = {
|
||||
gfx_ctx_xegl_swap_buffers,
|
||||
gfx_ctx_xegl_input_driver,
|
||||
gfx_ctx_xegl_get_proc_address,
|
||||
gfx_ctx_xegl_make_current_context,
|
||||
NULL,
|
||||
NULL,
|
||||
gfx_ctx_xegl_show_mouse,
|
||||
|
@ -110,6 +110,8 @@ typedef struct gfx_ctx_driver
|
||||
* Does not take opaque, to avoid lots of ugly wrapper code. */
|
||||
gfx_ctx_proc_t (*get_proc_address)(const char*);
|
||||
|
||||
void (*make_current_context)(void *data);
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
/* Returns true if this context supports EGLImage buffers for
|
||||
* screen drawing and was initalized correctly. */
|
||||
|
@ -222,13 +222,17 @@ uintptr_t video_driver_get_current_framebuffer(void)
|
||||
|
||||
retro_proc_address_t video_driver_get_proc_address(const char *sym)
|
||||
{
|
||||
#ifdef HAVE_FBO
|
||||
if (driver.video_poke && driver.video_poke->get_proc_address)
|
||||
return driver.video_poke->get_proc_address(driver.video_data, sym);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void video_driver_make_current_context(void)
|
||||
{
|
||||
if (driver.video_poke && driver.video_poke->make_current_context)
|
||||
driver.video_poke->make_current_context(driver.video_data);
|
||||
}
|
||||
|
||||
static void deinit_video_filter(void)
|
||||
{
|
||||
rarch_softfilter_free(g_extern.filter.filter);
|
||||
|
@ -89,8 +89,9 @@ typedef struct video_poke_interface
|
||||
void (*set_filtering)(void *data, unsigned index, bool smooth);
|
||||
#ifdef HAVE_FBO
|
||||
uintptr_t (*get_current_framebuffer)(void *data);
|
||||
retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
|
||||
#endif
|
||||
retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
|
||||
void (*make_current_context)(void *data);
|
||||
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
|
||||
void (*apply_state_changes)(void *data);
|
||||
|
||||
@ -241,6 +242,8 @@ uintptr_t video_driver_get_current_framebuffer(void);
|
||||
|
||||
retro_proc_address_t video_driver_get_proc_address(const char *sym);
|
||||
|
||||
void video_driver_make_current_context(void);
|
||||
|
||||
void uninit_video_input(void);
|
||||
|
||||
void init_video(void);
|
||||
|
@ -853,8 +853,9 @@ static const video_poke_interface_t thread_poke = {
|
||||
thread_set_filtering,
|
||||
#ifdef HAVE_FBO
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
thread_set_aspect_ratio,
|
||||
thread_apply_state_changes,
|
||||
#if defined(HAVE_MENU)
|
||||
|
13
libretro.h
13
libretro.h
@ -852,6 +852,10 @@ enum retro_mod
|
||||
* It can be used by the core for localization purposes.
|
||||
*/
|
||||
|
||||
#define RETRO_ENVIRONMENT_MAKE_CURRENT_CONTEXT 40
|
||||
/* struct retro_hw_make_current_context_callback *
|
||||
*/
|
||||
|
||||
#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
|
||||
#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
|
||||
#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */
|
||||
@ -1467,6 +1471,15 @@ enum retro_hw_context_type
|
||||
RETRO_HW_CONTEXT_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
/* Call video context driver's 'make current context' function */
|
||||
typedef void (*retro_hw_make_current_context)(void);
|
||||
|
||||
struct retro_hw_make_current_context_callback
|
||||
{
|
||||
/* Set by frontend. */
|
||||
retro_hw_make_current_context make_current_context;
|
||||
};
|
||||
|
||||
struct retro_hw_render_callback
|
||||
{
|
||||
/* Which API to use. Set by libretro core. */
|
||||
|
Loading…
Reference in New Issue
Block a user