mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
mali_fbdev: fix assertion failed on video threaded switch (#14316)
* mali_fbdev: fix assertion failed on video thread switch * mali_fbdev: added fallback to get refresh rate currently set
This commit is contained in:
parent
b32ec36130
commit
093432d6c4
@ -38,6 +38,8 @@
|
||||
#include "../../verbosity.h"
|
||||
#include "../../configuration.h"
|
||||
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
@ -93,7 +95,25 @@ static int gfx_ctx_mali_fbdev_get_vinfo(void *data)
|
||||
(vinfo.yres + vinfo.upper_margin + vinfo.lower_margin + vinfo.vsync_len) /
|
||||
(vinfo.xres + vinfo.left_margin + vinfo.right_margin + vinfo.hsync_len);
|
||||
}else{
|
||||
mali->refresh_rate = 60;
|
||||
/* Workaround to retrieve current refresh rate if no info is available from IOCTL.
|
||||
If this fails as well, 60Hz is assumed... */
|
||||
int j=0;
|
||||
float k=60.0;
|
||||
char temp[32];
|
||||
RFILE *fr = filestream_open("/sys/class/display/mode", RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||
if (fr){
|
||||
if (filestream_gets(fr, temp, sizeof(temp))){
|
||||
for (int i=0;i<sizeof(temp);i++){
|
||||
if (*(temp+i)=='p' || *(temp+i)=='i')
|
||||
j=i;
|
||||
else if (*(temp+i)=='h')
|
||||
*(temp+i)='\0';
|
||||
}
|
||||
k = j ? atof(temp+j+1) : k;
|
||||
}
|
||||
filestream_close(fr);
|
||||
}
|
||||
mali->refresh_rate = k;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -127,6 +147,27 @@ static void gfx_ctx_mali_fbdev_clear_screen(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_mali_fbdev_destroy_really(void)
|
||||
{
|
||||
if (gfx_ctx_mali_fbdev_global)
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
egl_destroy(&gfx_ctx_mali_fbdev_global->egl);
|
||||
#endif
|
||||
gfx_ctx_mali_fbdev_global->resize=false;
|
||||
free(gfx_ctx_mali_fbdev_global);
|
||||
gfx_ctx_mali_fbdev_global=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_mali_fbdev_maybe_restart(void)
|
||||
{
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
|
||||
if (!runloop_st->shutdown_initiated)
|
||||
frontend_driver_set_fork(FRONTEND_FORK_RESTART);
|
||||
}
|
||||
|
||||
/*TODO FIXME
|
||||
As egl_destroy does not work properly with libmali (big fps drop after destroy and initialization/creation of new context/surface), it is not used.
|
||||
A global pointers is initialized at startup in gfx_ctx_mali_fbdev_init, and returned each time gfx_ctx_mali_fbdev_init is called.
|
||||
@ -137,31 +178,25 @@ All these workarounds should be reverted when and if egl_destroy issues in libma
|
||||
*/
|
||||
static void gfx_ctx_mali_fbdev_destroy(void *data)
|
||||
{
|
||||
/* mali_ctx_data_t *mali = (mali_ctx_data_t*)data;
|
||||
|
||||
if (mali)
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
egl_destroy(&mali->egl);
|
||||
#endif
|
||||
|
||||
mali->resize = false;
|
||||
free(mali);
|
||||
}
|
||||
*/
|
||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||
|
||||
if (runloop_st->shutdown_initiated && gfx_ctx_mali_fbdev_was_threaded==*video_driver_get_threaded() && !gfx_ctx_mali_fbdev_hw_ctx_trigger)
|
||||
if (runloop_st->shutdown_initiated)
|
||||
{
|
||||
gfx_ctx_mali_fbdev_clear_screen();
|
||||
}else if (gfx_ctx_mali_fbdev_hw_ctx_trigger)
|
||||
if (!gfx_ctx_mali_fbdev_restart_pending)
|
||||
{
|
||||
gfx_ctx_mali_fbdev_destroy_really();
|
||||
gfx_ctx_mali_fbdev_clear_screen();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
video_context_driver_reset();
|
||||
gfx_ctx_mali_fbdev_global=NULL;
|
||||
gfx_ctx_mali_fbdev_restart_pending=true;
|
||||
}else if (gfx_ctx_mali_fbdev_was_threaded!=*video_driver_get_threaded()){
|
||||
gfx_ctx_mali_fbdev_global=NULL;
|
||||
command_event(CMD_EVENT_RESTART_RETROARCH,NULL);
|
||||
if (gfx_ctx_mali_fbdev_hw_ctx_trigger || gfx_ctx_mali_fbdev_was_threaded!=*video_driver_get_threaded())
|
||||
{
|
||||
gfx_ctx_mali_fbdev_destroy_really();
|
||||
gfx_ctx_mali_fbdev_restart_pending=true;
|
||||
if (!gfx_ctx_mali_fbdev_hw_ctx_trigger)
|
||||
gfx_ctx_mali_fbdev_maybe_restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +279,7 @@ static void gfx_ctx_mali_fbdev_check_window(void *data, bool *quit,
|
||||
*quit = (bool)frontend_driver_get_signal_handler_state();
|
||||
|
||||
if (gfx_ctx_mali_fbdev_restart_pending)
|
||||
command_event(CMD_EVENT_RESTART_RETROARCH,NULL);
|
||||
gfx_ctx_mali_fbdev_maybe_restart();
|
||||
}
|
||||
|
||||
static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user