mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(VC EGL) Cleanups
This commit is contained in:
parent
fb257eb21e
commit
f97d6ec909
@ -56,26 +56,23 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
bool smooth;
|
||||||
|
bool vsync_callback_set;
|
||||||
|
bool resize;
|
||||||
|
unsigned res;
|
||||||
|
unsigned fb_width, fb_height;
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
egl_ctx_data_t egl;
|
egl_ctx_data_t egl;
|
||||||
#endif
|
#endif
|
||||||
EGL_DISPMANX_WINDOW_T native_window;
|
EGL_DISPMANX_WINDOW_T native_window;
|
||||||
DISPMANX_DISPLAY_HANDLE_T dispman_display;
|
DISPMANX_DISPLAY_HANDLE_T dispman_display;
|
||||||
|
|
||||||
/* For vsync wait after eglSwapBuffers when max_swapchain < 3 */
|
/* For vsync wait after eglSwapBuffers when max_swapchain < 3 */
|
||||||
scond_t *vsync_condition;
|
scond_t *vsync_condition;
|
||||||
slock_t *vsync_condition_mutex;
|
slock_t *vsync_condition_mutex;
|
||||||
bool vsync_callback_set;
|
|
||||||
|
|
||||||
bool resize;
|
|
||||||
unsigned fb_width, fb_height;
|
|
||||||
|
|
||||||
EGLImageKHR eglBuffer[MAX_EGLIMAGE_TEXTURES];
|
EGLImageKHR eglBuffer[MAX_EGLIMAGE_TEXTURES];
|
||||||
EGLContext eglimage_ctx;
|
EGLContext eglimage_ctx;
|
||||||
EGLSurface pbuff_surf;
|
EGLSurface pbuff_surf;
|
||||||
VGImage vgimage[MAX_EGLIMAGE_TEXTURES];
|
VGImage vgimage[MAX_EGLIMAGE_TEXTURES];
|
||||||
bool smooth;
|
|
||||||
unsigned res;
|
|
||||||
} vc_ctx_data_t;
|
} vc_ctx_data_t;
|
||||||
|
|
||||||
static enum gfx_ctx_api vc_api;
|
static enum gfx_ctx_api vc_api;
|
||||||
@ -145,6 +142,9 @@ static void dispmanx_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data)
|
|||||||
{
|
{
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
|
|
||||||
|
if (!vc)
|
||||||
|
return;
|
||||||
|
|
||||||
slock_lock(vc->vsync_condition_mutex);
|
slock_lock(vc->vsync_condition_mutex);
|
||||||
scond_signal(vc->vsync_condition);
|
scond_signal(vc->vsync_condition);
|
||||||
slock_unlock(vc->vsync_condition_mutex);
|
slock_unlock(vc->vsync_condition_mutex);
|
||||||
@ -238,8 +238,8 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
|
|||||||
|
|
||||||
/* Use dispmanx upscaling if fullscreen_x
|
/* Use dispmanx upscaling if fullscreen_x
|
||||||
* and fullscreen_y are set. */
|
* and fullscreen_y are set. */
|
||||||
if (settings->uints.video_fullscreen_x != 0 &&
|
if ((settings->uints.video_fullscreen_x != 0) &&
|
||||||
settings->uints.video_fullscreen_y != 0)
|
(settings->uints.video_fullscreen_y != 0))
|
||||||
{
|
{
|
||||||
/* Keep input and output aspect ratio equal.
|
/* Keep input and output aspect ratio equal.
|
||||||
* There are other aspect ratio settings which can be used to stretch video output. */
|
* There are other aspect ratio settings which can be used to stretch video output. */
|
||||||
@ -262,7 +262,9 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
|
|||||||
|
|
||||||
dispman_display = vc_dispmanx_display_open(0 /* LCD */);
|
dispman_display = vc_dispmanx_display_open(0 /* LCD */);
|
||||||
vc->dispman_display = dispman_display;
|
vc->dispman_display = dispman_display;
|
||||||
|
|
||||||
vc_dispmanx_display_get_info(dispman_display, &dispman_modeinfo);
|
vc_dispmanx_display_get_info(dispman_display, &dispman_modeinfo);
|
||||||
|
|
||||||
dispman_update = vc_dispmanx_update_start(0);
|
dispman_update = vc_dispmanx_update_start(0);
|
||||||
|
|
||||||
alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
|
alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
|
||||||
@ -312,9 +314,12 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
|
|||||||
vc->vsync_condition = scond_new();
|
vc->vsync_condition = scond_new();
|
||||||
vc->vsync_condition_mutex = slock_new();
|
vc->vsync_condition_mutex = slock_new();
|
||||||
vc->vsync_callback_set = false;
|
vc->vsync_callback_set = false;
|
||||||
if (video_info->max_swapchain_images <= 2) {
|
|
||||||
|
if (video_info->max_swapchain_images <= 2)
|
||||||
|
{
|
||||||
/* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */
|
/* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */
|
||||||
vc_dispmanx_vsync_callback(vc->dispman_display, dispmanx_vsync_callback, (void*)vc);
|
vc_dispmanx_vsync_callback(vc->dispman_display,
|
||||||
|
dispmanx_vsync_callback, (void*)vc);
|
||||||
vc->vsync_callback_set = true;
|
vc->vsync_callback_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,8 +332,9 @@ error:
|
|||||||
|
|
||||||
static void gfx_ctx_vc_set_swap_interval(void *data, unsigned swap_interval)
|
static void gfx_ctx_vc_set_swap_interval(void *data, unsigned swap_interval)
|
||||||
{
|
{
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
|
if (vc)
|
||||||
egl_set_swap_interval(&vc->egl, swap_interval);
|
egl_set_swap_interval(&vc->egl, swap_interval);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -338,11 +344,9 @@ static bool gfx_ctx_vc_set_video_mode(void *data,
|
|||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
bool fullscreen)
|
bool fullscreen)
|
||||||
{
|
{
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
if (g_egl_inited)
|
if (!vc || g_egl_inited)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
frontend_driver_install_signal_handler();
|
frontend_driver_install_signal_handler();
|
||||||
@ -466,10 +470,11 @@ static void gfx_ctx_vc_destroy(void *data)
|
|||||||
vc->vgimage[i] = 0;
|
vc->vgimage[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop generating vsync callbacks if we are doing so. Don't destroy the context while cbs are being generated! */
|
/* Stop generating vsync callbacks if we are doing so.
|
||||||
if (vc->vsync_callback_set) {
|
* Don't destroy the context while cbs are being generated! */
|
||||||
|
if (vc->vsync_callback_set)
|
||||||
vc_dispmanx_vsync_callback(vc->dispman_display, NULL, NULL);
|
vc_dispmanx_vsync_callback(vc->dispman_display, NULL, NULL);
|
||||||
}
|
|
||||||
/* Destroy mutexes and conditions. */
|
/* Destroy mutexes and conditions. */
|
||||||
slock_free(vc->vsync_condition_mutex);
|
slock_free(vc->vsync_condition_mutex);
|
||||||
scond_free(vc->vsync_condition);
|
scond_free(vc->vsync_condition);
|
||||||
@ -509,8 +514,8 @@ static float gfx_ctx_vc_translate_aspect(void *data,
|
|||||||
static bool gfx_ctx_vc_image_buffer_init(void *data,
|
static bool gfx_ctx_vc_image_buffer_init(void *data,
|
||||||
const video_info_t *video)
|
const video_info_t *video)
|
||||||
{
|
{
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
|
||||||
EGLBoolean result;
|
EGLBoolean result;
|
||||||
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
EGLint pbufsurface_list[] =
|
EGLint pbufsurface_list[] =
|
||||||
{
|
{
|
||||||
EGL_WIDTH, vc->res,
|
EGL_WIDTH, vc->res,
|
||||||
@ -525,8 +530,10 @@ static bool gfx_ctx_vc_image_buffer_init(void *data,
|
|||||||
peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)egl_get_proc_address("eglCreateImageKHR");
|
peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)egl_get_proc_address("eglCreateImageKHR");
|
||||||
peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)egl_get_proc_address("eglDestroyImageKHR");
|
peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)egl_get_proc_address("eglDestroyImageKHR");
|
||||||
|
|
||||||
if (!peglCreateImageKHR || !peglDestroyImageKHR
|
if ( !peglCreateImageKHR ||
|
||||||
|| !gfx_ctx_vc_egl_query_extension(vc, "KHR_image"))
|
!peglDestroyImageKHR ||
|
||||||
|
!gfx_ctx_vc_egl_query_extension(vc, "KHR_image")
|
||||||
|
)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vc->res = video->input_scale * RARCH_SCALE_BASE;
|
vc->res = video->input_scale * RARCH_SCALE_BASE;
|
||||||
@ -585,7 +592,7 @@ static bool gfx_ctx_vc_image_buffer_write(void *data, const void *frame, unsigne
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
|
|
||||||
if (index >= MAX_EGLIMAGE_TEXTURES)
|
if (!vc || index >= MAX_EGLIMAGE_TEXTURES)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENVG_API);
|
eglBindAPI(EGL_OPENVG_API);
|
||||||
@ -629,27 +636,32 @@ error:
|
|||||||
|
|
||||||
static void gfx_ctx_vc_swap_buffers(void *data, void *data2)
|
static void gfx_ctx_vc_swap_buffers(void *data, void *data2)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_EGL
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
video_frame_info_t *video_info = (video_frame_info_t*)data2;
|
video_frame_info_t *video_info = (video_frame_info_t*)data2;
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
if (!vc)
|
||||||
|
return;
|
||||||
|
|
||||||
egl_swap_buffers(&vc->egl);
|
egl_swap_buffers(&vc->egl);
|
||||||
|
|
||||||
/* Wait for vsync immediately if we don't want egl_swap_buffers to triple-buffer */
|
/* Wait for vsync immediately if we don't want egl_swap_buffers to triple-buffer */
|
||||||
if (video_info->max_swapchain_images <= 2) {
|
if (video_info->max_swapchain_images <= 2)
|
||||||
|
{
|
||||||
/* We DON'T wait to wait without callback function ready! */
|
/* We DON'T wait to wait without callback function ready! */
|
||||||
if(!vc->vsync_callback_set) {
|
if (!vc->vsync_callback_set)
|
||||||
vc_dispmanx_vsync_callback(vc->dispman_display, dispmanx_vsync_callback, (void*)vc);
|
{
|
||||||
|
vc_dispmanx_vsync_callback(vc->dispman_display,
|
||||||
|
dispmanx_vsync_callback, (void*)vc);
|
||||||
vc->vsync_callback_set = true;
|
vc->vsync_callback_set = true;
|
||||||
}
|
}
|
||||||
slock_lock(vc->vsync_condition_mutex);
|
slock_lock(vc->vsync_condition_mutex);
|
||||||
scond_wait(vc->vsync_condition, vc->vsync_condition_mutex);
|
scond_wait(vc->vsync_condition, vc->vsync_condition_mutex);
|
||||||
slock_unlock(vc->vsync_condition_mutex);
|
slock_unlock(vc->vsync_condition_mutex);
|
||||||
}
|
}
|
||||||
else if (vc->vsync_callback_set) {
|
|
||||||
/* Stop generating vsync callbacks from now on */
|
/* Stop generating vsync callbacks from now on */
|
||||||
|
else if (vc->vsync_callback_set)
|
||||||
vc_dispmanx_vsync_callback(vc->dispman_display, NULL, NULL);
|
vc_dispmanx_vsync_callback(vc->dispman_display, NULL, NULL);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,6 +669,9 @@ static void gfx_ctx_vc_bind_hw_render(void *data, bool enable)
|
|||||||
{
|
{
|
||||||
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
|
||||||
|
|
||||||
|
if (!vc)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
egl_bind_hw_render(&vc->egl, enable);
|
egl_bind_hw_render(&vc->egl, enable);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user