From f753efeaa7e35ebbb76674da7ae30a3aef3e4f42 Mon Sep 17 00:00:00 2001 From: valadaa48 Date: Mon, 22 Jun 2020 21:38:11 -0400 Subject: [PATCH] oga_gfx: fix race condition with rgui callback - oga_gfx_frame is sometimes called before set_texture_frame has been called --- gfx/drivers/oga_gfx.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gfx/drivers/oga_gfx.c b/gfx/drivers/oga_gfx.c index 256817d8af..45c89cdad9 100644 --- a/gfx/drivers/oga_gfx.c +++ b/gfx/drivers/oga_gfx.c @@ -41,7 +41,6 @@ #include "../../retroarch.h" #include -#include #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) @@ -133,6 +132,9 @@ static void *oga_gfx_init(const video_info_t *video, vid = (oga_video_t*)calloc(1, sizeof(*vid)); vid->menu_frame = NULL; + vid->menu_width = 0; + vid->menu_height = 0; + vid->menu_pitch = 0; vid->display = go2_display_create(); vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false); vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_XRGB8888); @@ -249,9 +251,20 @@ static bool oga_gfx_frame(void *data, const void *frame, unsigned width, go2_surface_format_get(dst_surface)) / 8; bool menu_is_alive = video_info->menu_is_alive; + if (unlikely(!frame || width == 0 || height == 0)) + return true; + + if (unlikely(video_info->input_driver_nonblock_state) && !vid->threaded) + { + if (frame_count % 4 != 0) + return true; + } + #ifdef HAVE_MENU if (unlikely(menu_is_alive)) { + if (unlikely(vid->menu_width == 0)) + return true; menu_driver_frame(menu_is_alive, video_info); dst_surface = vid->menu_surface; src = (uint8_t*)vid->menu_frame; @@ -262,15 +275,6 @@ static bool oga_gfx_frame(void *data, const void *frame, unsigned width, } #endif - if (unlikely(!frame || width == 0 || height == 0)) - return true; - - if (unlikely(video_info->input_driver_nonblock_state) && !vid->threaded) - { - if (frame_count % 4 != 0) - return true; - } - /* copy buffer to surface */ dst = (uint8_t*)go2_surface_map(dst_surface); yy = height;