Use sleep micros when waiting for render thread

This commit is contained in:
Dimitris Panokostas 2020-06-29 08:12:07 +02:00
parent 997c377f3c
commit 86bc238c83
3 changed files with 15 additions and 4 deletions

View file

@ -3925,7 +3925,7 @@ void vsync_handle_redraw(int long_field, int lof_changed, uae_u16 bplcon0p, uae_
#ifdef AMIBERRY
if (render_tid) {
while (render_thread_busy)
sleep_millis(1);
sleep_micros(10);
write_comm_pipe_u32(render_pipe, RENDER_SIGNAL_FRAME_DONE, 1);
uae_sem_wait(&render_sem);
}
@ -3938,10 +3938,10 @@ void vsync_handle_redraw(int long_field, int lof_changed, uae_u16 bplcon0p, uae_
#ifdef AMIBERRY
if (render_tid) {
while (render_thread_busy)
sleep_millis(1);
sleep_micros(1);
write_comm_pipe_u32(render_pipe, RENDER_SIGNAL_QUIT, 1);
while (render_tid != 0) {
sleep_millis(10);
sleep_micros(10);
}
destroy_comm_pipe(render_pipe);
xfree(render_pipe);
@ -4163,10 +4163,17 @@ static int render_thread(void *unused)
switch (signal) {
case RENDER_SIGNAL_PARTIAL:
partial_draw_frame();
#ifdef USE_DISPMANX
if(!flip_in_progess)
#endif
partial_draw_frame();
break;
case RENDER_SIGNAL_FRAME_DONE:
#ifdef USE_DISPMANX
while (flip_in_progess)
sleep_micros(1);
#endif
finish_drawing_frame(true);
uae_sem_post(&render_sem);
break;

View file

@ -32,6 +32,7 @@ static bool volatile display_thread_busy = false;
static unsigned int current_vsync_frame = 0;
unsigned long time_per_frame = 20000; // Default for PAL (50 Hz): 20000 microsecs
static int vsync_modulo = 1;
bool volatile flip_in_progess = false;
#endif
/* SDL Surface for output of emulation */
@ -279,6 +280,7 @@ static int display_thread(void *unused)
vc_dispmanx_element_change_source(updateHandle, elementHandle, amigafb_resource_2);
}
vc_dispmanx_update_submit(updateHandle, nullptr, nullptr);
flip_in_progess = false;
break;
case DISPLAY_SIGNAL_QUIT:
@ -988,6 +990,7 @@ void show_screen(int mode)
#ifdef USE_DISPMANX
wait_for_display_thread();
flip_in_progess = true;
write_comm_pipe_u32(display_pipe, DISPLAY_SIGNAL_SHOW, 1);
#else
if (amiberry_options.use_sdl2_render_thread)

View file

@ -41,6 +41,7 @@ extern bool config_loaded;
extern int z3_base_adr;
#ifdef USE_DISPMANX
extern unsigned long time_per_frame;
extern bool volatile flip_in_progess;
#endif
void run_gui(void);
void InGameMessage(const char* msg);