From f056ef7a80ce0453dffb6490eebe7910c8a0c9e8 Mon Sep 17 00:00:00 2001 From: eladash Date: Wed, 26 Sep 2018 12:39:17 +0300 Subject: [PATCH] rsx-capture: Save initial method registers state --- rpcs3/Emu/RSX/Capture/rsx_replay.cpp | 15 ++++++++++----- rpcs3/Emu/RSX/Capture/rsx_replay.h | 7 ++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index c4a5f5be6a..61f1d626ec 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -230,10 +230,15 @@ namespace rsx while (!Emu.IsStopped()) { + // Load registers while the RSX is still idle + method_registers = frame->reg_state; + _mm_mfence(); + // start up fifo buffer by dumping the put ptr to first stop sys_rsx_context_attribute(context_id, 0x001, 0x20000000, fifo_stops[0], 0, 0); - auto renderer = rsx::get_current_renderer(); + auto render = get_current_renderer(); + size_t stopIdx = 0; for (const auto& replay_cmd : frame->replay_commands) { @@ -248,7 +253,7 @@ namespace rsx continue; // wait until rsx idle and at our first 'stop' to apply state - while (!Emu.IsStopped() && (renderer->ctrl->get != renderer->ctrl->put) && (renderer->ctrl->get != fifo_stops[stopIdx])) + while (!Emu.IsStopped() && (render->ctrl->get != render->ctrl->put) && (render->ctrl->get != fifo_stops[stopIdx])) { while (Emu.IsPaused()) std::this_thread::sleep_for(10ms); @@ -263,14 +268,14 @@ namespace rsx if (stopIdx >= fifo_stops.size()) fmt::throw_exception("Capture Replay: StopIdx greater than size of fifo_stops"); - renderer->ctrl->put = fifo_stops[stopIdx]; + render->ctrl->put = fifo_stops[stopIdx]; } // dump put to end of stops, which should have actual end u32 end = fifo_stops.back(); - renderer->ctrl->put = end; + render->ctrl->put = end; - while (renderer->ctrl->get != end && !Emu.IsStopped()) + while (render->ctrl->get != end && !Emu.IsStopped()) { while (Emu.IsPaused()) std::this_thread::sleep_for(10ms); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.h b/rpcs3/Emu/RSX/Capture/rsx_replay.h index f9525fe0ce..c2bfdded30 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.h +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.h @@ -5,6 +5,7 @@ #include "Emu/Cell/PPUModule.h" #include "Emu/Cell/lv2/sys_sync.h" #include "Emu/Cell/lv2/sys_ppu_thread.h" +#include "Emu/RSX/rsx_methods.h" #include "Emu/RSX/gcm_enums.h" #include @@ -16,7 +17,7 @@ namespace rsx { constexpr u32 FRAME_CAPTURE_MAGIC = 0x52524300; // ascii 'RRC/0' - constexpr u32 FRAME_CAPTURE_VERSION = 0x2; + constexpr u32 FRAME_CAPTURE_VERSION = 0x3; struct frame_capture_data { @@ -181,6 +182,8 @@ namespace rsx std::unordered_map display_buffers_map; // actual command queue to hold everything above std::vector replay_commands; + // Initial registers state at the beginning of the capture + rsx::rsx_state reg_state; template void serialize(Archive & ar) @@ -192,6 +195,7 @@ namespace rsx ar(memory_data_map); ar(display_buffers_map); ar(replay_commands); + ar(reg_state); } void reset() @@ -201,6 +205,7 @@ namespace rsx tile_map.clear(); memory_map.clear(); replay_commands.clear(); + reg_state = method_registers; } };