mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Create egl_destroy
This commit is contained in:
parent
36579ae58d
commit
9705dc8d04
@ -17,6 +17,9 @@
|
|||||||
#include <retro_log.h>
|
#include <retro_log.h>
|
||||||
|
|
||||||
#include "egl_common.h"
|
#include "egl_common.h"
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
#include "gl_common.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
EGLContext g_egl_ctx;
|
EGLContext g_egl_ctx;
|
||||||
EGLContext g_egl_hw_ctx;
|
EGLContext g_egl_hw_ctx;
|
||||||
@ -66,3 +69,39 @@ gfx_ctx_proc_t egl_get_proc_address(const char *symbol)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void egl_destroy(void)
|
||||||
|
{
|
||||||
|
if (g_egl_dpy)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
if (g_egl_ctx != EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
glFlush();
|
||||||
|
glFinish();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
eglMakeCurrent(g_egl_dpy,
|
||||||
|
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
if (g_egl_ctx != EGL_NO_CONTEXT)
|
||||||
|
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
||||||
|
|
||||||
|
if (g_egl_hw_ctx != EGL_NO_CONTEXT)
|
||||||
|
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
||||||
|
|
||||||
|
if (g_egl_surf != EGL_NO_SURFACE)
|
||||||
|
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
||||||
|
eglTerminate(g_egl_dpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Be as careful as possible in deinit.
|
||||||
|
* If we screw up, any TTY will not restore.
|
||||||
|
*/
|
||||||
|
|
||||||
|
g_egl_ctx = EGL_NO_CONTEXT;
|
||||||
|
g_egl_hw_ctx = EGL_NO_CONTEXT;
|
||||||
|
g_egl_surf = EGL_NO_SURFACE;
|
||||||
|
g_egl_dpy = EGL_NO_DISPLAY;
|
||||||
|
g_egl_config = 0;
|
||||||
|
}
|
||||||
|
@ -29,6 +29,8 @@ extern EGLConfig g_egl_config;
|
|||||||
|
|
||||||
void egl_report_error(void);
|
void egl_report_error(void);
|
||||||
|
|
||||||
|
void egl_destroy(void);
|
||||||
|
|
||||||
gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
|
gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,11 +23,6 @@
|
|||||||
#include "../../config.h"
|
#include "../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <EGL/eglext.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <glsym/glsym.h>
|
#include <glsym/glsym.h>
|
||||||
|
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
@ -52,49 +52,11 @@ static void android_gfx_ctx_set_swap_interval(void *data, unsigned interval)
|
|||||||
eglSwapInterval(g_egl_dpy, interval);
|
eglSwapInterval(g_egl_dpy, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_gfx_ctx_destroy_resources(gfx_ctx_android_data_t *android)
|
|
||||||
{
|
|
||||||
if (!android)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_egl_dpy)
|
|
||||||
{
|
|
||||||
if (g_egl_ctx)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_egl_hw_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Be as careful as possible in deinit. */
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_hw_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void android_gfx_ctx_destroy(void *data)
|
static void android_gfx_ctx_destroy(void *data)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
gfx_ctx_android_data_t *android = NULL;
|
|
||||||
|
|
||||||
android = (gfx_ctx_android_data_t*)driver->video_context_data;
|
egl_destroy();
|
||||||
(void)data;
|
|
||||||
|
|
||||||
if (!android)
|
|
||||||
return;
|
|
||||||
|
|
||||||
android_gfx_ctx_destroy_resources(android);
|
|
||||||
|
|
||||||
if (driver->video_context_data)
|
if (driver->video_context_data)
|
||||||
free(driver->video_context_data);
|
free(driver->video_context_data);
|
||||||
@ -222,7 +184,7 @@ static bool android_gfx_ctx_init(void *data)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
android_gfx_ctx_destroy_resources(android);
|
egl_destroy();
|
||||||
|
|
||||||
if (android)
|
if (android)
|
||||||
free(android);
|
free(android);
|
||||||
|
@ -52,31 +52,8 @@ static void gfx_ctx_qnx_set_swap_interval(void *data, unsigned interval)
|
|||||||
|
|
||||||
static void gfx_ctx_qnx_destroy(void *data)
|
static void gfx_ctx_qnx_destroy(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
egl_destroy();
|
||||||
|
|
||||||
if (g_egl_dpy)
|
|
||||||
{
|
|
||||||
if (g_egl_ctx)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_egl_hw_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Be as careful as possible in deinit. */
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_hw_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
g_resize = false;
|
g_resize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,32 +371,7 @@ static void gfx_ctx_drm_egl_destroy_resources(gfx_ctx_drm_egl_data_t *drm)
|
|||||||
if (waiting_for_flip)
|
if (waiting_for_flip)
|
||||||
wait_flip(true);
|
wait_flip(true);
|
||||||
|
|
||||||
if (g_egl_dpy)
|
egl_destroy();
|
||||||
{
|
|
||||||
if (g_egl_ctx)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_egl_hw_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Be as careful as possible in deinit.
|
|
||||||
* If we screw up, the KMS tty will not restore.
|
|
||||||
*/
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_hw_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
|
|
||||||
/* Restore original CRTC. */
|
/* Restore original CRTC. */
|
||||||
if (drm->g_orig_crtc)
|
if (drm->g_orig_crtc)
|
||||||
|
@ -203,26 +203,8 @@ static bool gfx_ctx_emscripten_bind_api(void *data,
|
|||||||
|
|
||||||
static void gfx_ctx_emscripten_destroy(void *data)
|
static void gfx_ctx_emscripten_destroy(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
egl_destroy();
|
||||||
|
|
||||||
if (g_egl_dpy)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
|
|
||||||
if (g_egl_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
g_inited = false;
|
g_inited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,26 +58,8 @@ static void gfx_ctx_mali_fbdev_destroy(void *data)
|
|||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
if (g_egl_dpy != EGL_NO_DISPLAY)
|
egl_destroy();
|
||||||
{
|
|
||||||
if (g_egl_ctx != EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
glFlush();
|
|
||||||
glFinish();
|
|
||||||
}
|
|
||||||
|
|
||||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
if (g_egl_ctx != EGL_NO_CONTEXT)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
if (g_egl_surf != EGL_NO_SURFACE)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_egl_dpy = EGL_NO_DISPLAY;
|
|
||||||
g_egl_surf = EGL_NO_SURFACE;
|
|
||||||
g_egl_ctx = EGL_NO_CONTEXT;
|
|
||||||
g_egl_config = 0;
|
|
||||||
g_quit = 0;
|
g_quit = 0;
|
||||||
g_resize = false;
|
g_resize = false;
|
||||||
|
|
||||||
|
@ -44,26 +44,8 @@ static void gfx_ctx_vivante_destroy(void *data)
|
|||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
if (g_egl_dpy != EGL_NO_DISPLAY)
|
egl_destroy();
|
||||||
{
|
|
||||||
if (g_egl_ctx != EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
glFlush();
|
|
||||||
glFinish();
|
|
||||||
}
|
|
||||||
|
|
||||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
if (g_egl_ctx != EGL_NO_CONTEXT)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
if (g_egl_surf != EGL_NO_SURFACE)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_egl_dpy = EGL_NO_DISPLAY;
|
|
||||||
g_egl_surf = EGL_NO_SURFACE;
|
|
||||||
g_egl_ctx = EGL_NO_CONTEXT;
|
|
||||||
g_egl_config = 0;
|
|
||||||
g_quit = 0;
|
g_quit = 0;
|
||||||
g_resize = false;
|
g_resize = false;
|
||||||
}
|
}
|
||||||
|
@ -145,28 +145,7 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
|
|||||||
if (!wl)
|
if (!wl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_egl_dpy)
|
egl_destroy();
|
||||||
{
|
|
||||||
if (g_egl_ctx)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_egl_hw_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_hw_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
|
|
||||||
if (wl->g_win)
|
if (wl->g_win)
|
||||||
wl_egl_window_destroy(wl->g_win);
|
wl_egl_window_destroy(wl->g_win);
|
||||||
|
@ -444,28 +444,7 @@ static void gfx_ctx_xegl_destroy(void *data)
|
|||||||
|
|
||||||
x11_input_ctx_destroy();
|
x11_input_ctx_destroy();
|
||||||
|
|
||||||
if (g_egl_dpy)
|
egl_destroy();
|
||||||
{
|
|
||||||
if (g_egl_ctx)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_egl_hw_ctx)
|
|
||||||
eglDestroyContext(g_egl_dpy, g_egl_hw_ctx);
|
|
||||||
|
|
||||||
if (g_egl_surf)
|
|
||||||
eglDestroySurface(g_egl_dpy, g_egl_surf);
|
|
||||||
eglTerminate(g_egl_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_egl_ctx = NULL;
|
|
||||||
g_egl_hw_ctx = NULL;
|
|
||||||
g_egl_surf = NULL;
|
|
||||||
g_egl_dpy = NULL;
|
|
||||||
g_egl_config = 0;
|
|
||||||
|
|
||||||
if (g_x11_win)
|
if (g_x11_win)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user