@@ -405,7 +405,7 @@ int gpu_async_try_dma(struct psx_gpu *gpu, const uint32_t *data, int words)
405405 return 0 ;
406406 // avoid double copying
407407 used = agpu -> pos_added - RDPOS (agpu -> pos_used );
408- if (agpu -> idle && used == 0 )
408+ if (RDPOS ( agpu -> idle ) && used == 0 )
409409 return 0 ;
410410 // only proceed if there is space to avoid messy sync
411411 if (AGPU_BUF_LEN - used < sizeof (cmd ) / 4 + ((w + 1 ) / 2 ) * (h + 1 )) {
@@ -528,10 +528,15 @@ static STRHEAD_RET_TYPE gpu_async_thread(void *unused)
528528
529529void gpu_async_notify_screen_change (struct psx_gpu * gpu )
530530{
531+ struct psx_gpu_async * agpu = gpu -> async ;
531532 union cmd_screen_change cmd ;
532533
533- if (!gpu -> async )
534+ if (!agpu )
535+ return ;
536+ if (RDPOS (agpu -> idle ) && agpu -> pos_added == RDPOS (agpu -> pos_used )) {
537+ renderer_notify_screen_change (& gpu -> screen );
534538 return ;
539+ }
535540 cmd .cmd = HTOLE32 (FAKECMD_SCREEN_CHANGE << 24 );
536541 cmd .x = gpu -> screen .x ;
537542 cmd .y = gpu -> screen .y ;
@@ -558,10 +563,16 @@ static int noinline do_notify_screen_change(struct psx_gpu *gpu,
558563
559564void gpu_async_set_interlace (struct psx_gpu * gpu , int enable , int is_odd )
560565{
566+ struct psx_gpu_async * agpu = gpu -> async ;
561567 union cmd_set_interlace cmd ;
562568
563- if (!gpu -> async )
569+ if (!agpu )
564570 return ;
571+ if (RDPOS (agpu -> idle ) && agpu -> pos_added == RDPOS (agpu -> pos_used )) {
572+ renderer_flush_queues ();
573+ renderer_set_interlace (enable , is_odd );
574+ return ;
575+ }
565576 cmd .cmd = HTOLE32 (FAKECMD_SET_INTERLACE << 24 );
566577 cmd .enable = enable ;
567578 cmd .is_odd = is_odd ;
@@ -608,7 +619,7 @@ void gpu_async_sync(struct psx_gpu *gpu)
608619{
609620 struct psx_gpu_async * agpu = gpu -> async ;
610621
611- if (!agpu || (agpu -> idle && agpu -> pos_added == RDPOS (agpu -> pos_used )))
622+ if (!agpu || (RDPOS ( agpu -> idle ) && agpu -> pos_added == RDPOS (agpu -> pos_used )))
612623 return ;
613624 agpu_log (gpu , "agpu: sync %d\n" , agpu -> pos_added - agpu -> pos_used );
614625 slock_lock (agpu -> lock );
@@ -637,7 +648,7 @@ void gpu_async_sync_scanout(struct psx_gpu *gpu)
637648 if (!agpu )
638649 return ;
639650 pos = RDPOS (agpu -> pos_used );
640- if (agpu -> idle && agpu -> pos_added == pos )
651+ if (RDPOS ( agpu -> idle ) && agpu -> pos_added == pos )
641652 return ;
642653 i = agpu -> pos_area ;
643654 if (agpu -> idle )
@@ -691,7 +702,11 @@ void gpu_async_sync_scanout(struct psx_gpu *gpu)
691702void gpu_async_sync_ecmds (struct psx_gpu * gpu )
692703{
693704 struct psx_gpu_async * agpu = gpu -> async ;
694- if (agpu )
705+ if (!agpu )
706+ return ;
707+ if (RDPOS (agpu -> idle ) && agpu -> pos_added == RDPOS (agpu -> pos_used ))
708+ memcpy (agpu -> ex_regs + 1 , gpu -> ex_regs + 1 , 6 * 4 );
709+ else
695710 do_add_with_wait (agpu , gpu -> ex_regs + 1 , 6 );
696711}
697712
0 commit comments