From eb61ae37ae206cc19d682fb96853fd10ec1c6727 Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 25 Aug 2023 19:39:19 +0300 Subject: [PATCH] rsx: Optimize RET returning to following CALL --- rpcs3/Emu/RSX/RSXFIFO.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rpcs3/Emu/RSX/RSXFIFO.cpp b/rpcs3/Emu/RSX/RSXFIFO.cpp index c4e52c6e6b..637db20913 100644 --- a/rpcs3/Emu/RSX/RSXFIFO.cpp +++ b/rpcs3/Emu/RSX/RSXFIFO.cpp @@ -701,6 +701,24 @@ namespace rsx return; } + // Optimize returning to another CALL + if ((ctrl->put & ~3) != fifo_ret_addr) + { + if (u32 addr = iomap_table.get_addr(fifo_ret_addr); addr != umax) + { + const u32 cmd0 = vm::read32(addr); + + // Check for missing step flags, in case the user is single-stepping in the debugger + if ((cmd0 & RSX_METHOD_CALL_CMD_MASK) == RSX_METHOD_CALL_CMD && cpu_flag::dbg_step - state) + { + fifo_ctrl->set_get(cmd0 & RSX_METHOD_CALL_OFFSET_MASK); + last_known_code_start = ctrl->get; + fifo_ret_addr += 4; + return; + } + } + } + fifo_ctrl->set_get(std::exchange(fifo_ret_addr, RSX_CALL_STACK_EMPTY)); last_known_code_start = ctrl->get; return;