mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Create egl_set_swap_interval
This commit is contained in:
parent
00be95159d
commit
5aedc1c4ca
@ -27,6 +27,7 @@ EGLSurface g_egl_surf;
|
||||
EGLDisplay g_egl_dpy;
|
||||
EGLConfig g_egl_config;
|
||||
bool g_use_hw_ctx;
|
||||
unsigned g_interval;
|
||||
|
||||
void egl_report_error(void)
|
||||
{
|
||||
@ -123,3 +124,24 @@ void egl_swap_buffers(void *data)
|
||||
{
|
||||
eglSwapBuffers(g_egl_dpy, g_egl_surf);
|
||||
}
|
||||
|
||||
void egl_set_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
/* Can be called before initialization.
|
||||
* Some contexts require that swap interval
|
||||
* is known at startup time.
|
||||
*/
|
||||
g_interval = interval;
|
||||
|
||||
if (!g_egl_dpy)
|
||||
return;
|
||||
if (!(eglGetCurrentContext()))
|
||||
return;
|
||||
|
||||
RARCH_LOG("[EGL]: eglSwapInterval(%u)\n", interval);
|
||||
if (!eglSwapInterval(g_egl_dpy, interval))
|
||||
{
|
||||
RARCH_ERR("[EGL]: eglSwapInterval() failed.\n");
|
||||
egl_report_error();
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ extern EGLSurface g_egl_surf;
|
||||
extern EGLDisplay g_egl_dpy;
|
||||
extern EGLConfig g_egl_config;
|
||||
extern bool g_use_hw_ctx;
|
||||
extern unsigned g_interval;
|
||||
|
||||
void egl_report_error(void);
|
||||
|
||||
@ -40,4 +41,6 @@ void egl_bind_hw_render(void *data, bool enable);
|
||||
|
||||
void egl_swap_buffers(void *data);
|
||||
|
||||
void egl_set_swap_interval(void *data, unsigned interval);
|
||||
|
||||
#endif
|
||||
|
@ -33,11 +33,6 @@ int system_property_get(const char *cmd, const char *args, char *value);
|
||||
|
||||
static bool g_es3;
|
||||
|
||||
static void android_gfx_ctx_set_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
|
||||
static void android_gfx_ctx_destroy(void *data)
|
||||
{
|
||||
egl_destroy();
|
||||
@ -296,7 +291,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
|
||||
android_gfx_ctx_init,
|
||||
android_gfx_ctx_destroy,
|
||||
android_gfx_ctx_bind_api,
|
||||
android_gfx_ctx_set_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
android_gfx_ctx_set_video_mode,
|
||||
android_gfx_ctx_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -43,11 +43,6 @@ static screen_display_t screen_disp;
|
||||
|
||||
static enum gfx_ctx_api g_api;
|
||||
|
||||
static void gfx_ctx_qnx_set_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
|
||||
static void gfx_ctx_qnx_destroy(void *data)
|
||||
{
|
||||
egl_destroy();
|
||||
@ -381,7 +376,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
|
||||
gfx_ctx_qnx_init,
|
||||
gfx_ctx_qnx_destroy,
|
||||
gfx_ctx_qnx_bind_api,
|
||||
gfx_ctx_qnx_set_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_qnx_set_video_mode,
|
||||
gfx_ctx_qnx_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -43,14 +43,6 @@ static void gfx_ctx_mali_fbdev_sighandler(int sig)
|
||||
g_quit = 1;
|
||||
}
|
||||
|
||||
static void gfx_ctx_mali_fbdev_set_swap_interval(
|
||||
void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
if (g_egl_dpy)
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
|
||||
static void gfx_ctx_mali_fbdev_destroy(void *data)
|
||||
{
|
||||
int fb;
|
||||
@ -282,7 +274,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
|
||||
gfx_ctx_mali_fbdev_init,
|
||||
gfx_ctx_mali_fbdev_destroy,
|
||||
gfx_ctx_mali_fbdev_bind_api,
|
||||
gfx_ctx_mali_fbdev_set_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_mali_fbdev_set_video_mode,
|
||||
gfx_ctx_mali_fbdev_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
static volatile sig_atomic_t g_quit;
|
||||
static bool g_inited;
|
||||
static unsigned g_interval;
|
||||
static enum gfx_ctx_api g_api;
|
||||
|
||||
static unsigned g_fb_width;
|
||||
@ -72,20 +71,6 @@ static void sighandler(int sig)
|
||||
g_quit = 1;
|
||||
}
|
||||
|
||||
static void gfx_ctx_vc_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
/* Can be called before initialization.
|
||||
* Some contexts require that swap interval
|
||||
* is known at startup time.
|
||||
*/
|
||||
g_interval = interval;
|
||||
|
||||
if (g_egl_dpy)
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
|
||||
static void gfx_ctx_vc_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||
{
|
||||
@ -332,7 +317,7 @@ static bool gfx_ctx_vc_set_video_mode(void *data,
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
|
||||
gfx_ctx_vc_swap_interval(data, g_interval);
|
||||
egl_set_swap_interval(data, g_interval);
|
||||
|
||||
g_inited = true;
|
||||
|
||||
@ -607,7 +592,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
|
||||
gfx_ctx_vc_init,
|
||||
gfx_ctx_vc_destroy,
|
||||
gfx_ctx_vc_bind_api,
|
||||
gfx_ctx_vc_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_vc_set_video_mode,
|
||||
gfx_ctx_vc_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -33,13 +33,6 @@ static void sighandler(int sig)
|
||||
g_quit = 1;
|
||||
}
|
||||
|
||||
static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
if (g_egl_dpy)
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
|
||||
static void gfx_ctx_vivante_destroy(void *data)
|
||||
{
|
||||
(void)data;
|
||||
@ -127,12 +120,6 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gfx_ctx_vivante_swap_buffers(void *data)
|
||||
{
|
||||
(void)data;
|
||||
eglSwapBuffers(g_egl_dpy, g_egl_surf);
|
||||
}
|
||||
|
||||
static void gfx_ctx_vivante_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||
{
|
||||
@ -261,7 +248,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
|
||||
gfx_ctx_vivante_init,
|
||||
gfx_ctx_vivante_destroy,
|
||||
gfx_ctx_vivante_bind_api,
|
||||
gfx_ctx_vivante_set_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_vivante_set_video_mode,
|
||||
gfx_ctx_vivante_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
@ -275,7 +262,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
|
||||
gfx_ctx_vivante_has_focus,
|
||||
gfx_ctx_vivante_suppress_screensaver,
|
||||
gfx_ctx_vivante_has_windowed,
|
||||
gfx_ctx_vivante_swap_buffers,
|
||||
egl_swap_buffers,
|
||||
gfx_ctx_vivante_input_driver,
|
||||
egl_get_proc_address,
|
||||
NULL,
|
||||
|
@ -34,7 +34,6 @@ typedef struct gfx_ctx_wayland_data
|
||||
int g_fd;
|
||||
unsigned g_width;
|
||||
unsigned g_height;
|
||||
unsigned g_interval;
|
||||
struct wl_display *g_dpy;
|
||||
struct wl_registry *g_registry;
|
||||
struct wl_compositor *g_compositor;
|
||||
@ -177,30 +176,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
|
||||
wl->g_height = 0;
|
||||
}
|
||||
|
||||
static void gfx_ctx_wl_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
|
||||
driver->video_context_data;
|
||||
|
||||
(void)data;
|
||||
|
||||
if (!wl)
|
||||
return;
|
||||
|
||||
wl->g_interval = interval;
|
||||
|
||||
if (g_egl_dpy && eglGetCurrentContext())
|
||||
{
|
||||
RARCH_LOG("[Wayland/EGL]: eglSwapInterval(%u)\n", wl->g_interval);
|
||||
if (!eglSwapInterval(g_egl_dpy, wl->g_interval))
|
||||
{
|
||||
RARCH_ERR("[Wayland/EGL]: eglSwapInterval() failed.\n");
|
||||
egl_report_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void flush_wayland_fd(void)
|
||||
{
|
||||
struct pollfd fd = {0};
|
||||
@ -579,7 +554,7 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
|
||||
|
||||
RARCH_LOG("[Wayland/EGL]: Current context: %p.\n", (void*)eglGetCurrentContext());
|
||||
|
||||
gfx_ctx_wl_swap_interval(data, wl->g_interval);
|
||||
egl_set_swap_interval(data, g_interval);
|
||||
|
||||
if (fullscreen)
|
||||
wl_shell_surface_set_fullscreen(wl->g_shell_surf, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);
|
||||
@ -804,7 +779,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
|
||||
gfx_ctx_wl_init,
|
||||
gfx_ctx_wl_destroy,
|
||||
gfx_ctx_wl_bind_api,
|
||||
gfx_ctx_wl_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_wl_set_video_mode,
|
||||
gfx_ctx_wl_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -34,7 +34,6 @@ static XF86VidModeModeInfo g_desktop_mode;
|
||||
static bool g_should_reset_mode;
|
||||
|
||||
static bool g_inited;
|
||||
static unsigned g_interval;
|
||||
static enum gfx_ctx_api g_api;
|
||||
static unsigned g_major;
|
||||
static unsigned g_minor;
|
||||
@ -48,24 +47,6 @@ static int egl_nul_handler(Display *dpy, XErrorEvent *event)
|
||||
|
||||
static void gfx_ctx_xegl_destroy(void *data);
|
||||
|
||||
static void gfx_ctx_xegl_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
g_interval = interval;
|
||||
|
||||
if (!g_egl_dpy)
|
||||
return;
|
||||
if (!(eglGetCurrentContext()))
|
||||
return;
|
||||
|
||||
RARCH_LOG("[X/EGL]: eglSwapInterval(%u)\n", g_interval);
|
||||
if (!eglSwapInterval(g_egl_dpy, g_interval))
|
||||
{
|
||||
RARCH_ERR("[X/EGL]: eglSwapInterval() failed.\n");
|
||||
egl_report_error();
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_xegl_set_resize(void *data,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
@ -396,7 +377,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
|
||||
x11_event_queue_check(&event);
|
||||
x11_install_quit_atom();
|
||||
|
||||
gfx_ctx_xegl_swap_interval(data, g_interval);
|
||||
egl_set_swap_interval(data, g_interval);
|
||||
|
||||
/* This can blow up on some drivers. It's not fatal,
|
||||
* so override errors for this call.
|
||||
@ -550,7 +531,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl =
|
||||
gfx_ctx_xegl_init,
|
||||
gfx_ctx_xegl_destroy,
|
||||
gfx_ctx_xegl_bind_api,
|
||||
gfx_ctx_xegl_swap_interval,
|
||||
egl_set_swap_interval,
|
||||
gfx_ctx_xegl_set_video_mode,
|
||||
x11_get_video_size,
|
||||
NULL, /* get_video_output_size */
|
||||
|
Loading…
x
Reference in New Issue
Block a user