From 3be4f1983d89f0d8f1ab4e04ab866ba9df2afb35 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 17 Jan 2025 13:22:40 +1000 Subject: [PATCH] GPU: Fix playback of VRAM updates during draws --- src/core/gpu.cpp | 66 +++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 99a4a40c5..7a61ef828 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -2103,27 +2103,26 @@ void GPU::StopRecordingGPUDump() Host::AddIconOSDMessage( osd_key, ICON_EMOJI_CAMERA_WITH_FLASH, fmt::format(TRANSLATE_FS("GPU", "Compressing GPU trace '{}'..."), Path::GetFileName(source_path)), 60.0f); - System::QueueAsyncTask( - [compress_mode, source_path = std::move(source_path), osd_key = std::move(osd_key)]() mutable { - Error error; - if (GPUDump::Recorder::Compress(source_path, compress_mode, &error)) - { - Host::AddIconOSDMessage( - std::move(osd_key), ICON_EMOJI_CAMERA_WITH_FLASH, - fmt::format(TRANSLATE_FS("GPU", "Saved GPU trace to '{}'."), Path::GetFileName(source_path)), - Host::OSD_QUICK_DURATION); - } - else - { - Host::AddIconOSDWarning( - std::move(osd_key), ICON_EMOJI_CAMERA_WITH_FLASH, - fmt::format("{}\n{}", - SmallString::from_format(TRANSLATE_FS("GPU", "Failed to save GPU trace to '{}':"), - Path::GetFileName(source_path)), - error.GetDescription()), - Host::OSD_ERROR_DURATION); - } - }); + System::QueueAsyncTask([compress_mode, source_path = std::move(source_path), osd_key = std::move(osd_key)]() mutable { + Error error; + if (GPUDump::Recorder::Compress(source_path, compress_mode, &error)) + { + Host::AddIconOSDMessage( + std::move(osd_key), ICON_EMOJI_CAMERA_WITH_FLASH, + fmt::format(TRANSLATE_FS("GPU", "Saved GPU trace to '{}'."), Path::GetFileName(source_path)), + Host::OSD_QUICK_DURATION); + } + else + { + Host::AddIconOSDWarning( + std::move(osd_key), ICON_EMOJI_CAMERA_WITH_FLASH, + fmt::format("{}\n{}", + SmallString::from_format(TRANSLATE_FS("GPU", "Failed to save GPU trace to '{}':"), + Path::GetFileName(source_path)), + error.GetDescription()), + Host::OSD_ERROR_DURATION); + } + }); } void GPU::WriteCurrentVideoModeToDump(GPUDump::Recorder* dump) const @@ -2166,6 +2165,15 @@ void GPU::WriteCurrentVideoModeToDump(GPUDump::Recorder* dump) const void GPU::ProcessGPUDumpPacket(GPUDump::PacketType type, const std::span data) { + const auto execute_all_commands = [this]() { + do + { + m_pending_command_ticks = 0; + s_command_tick_event.Deactivate(); + ExecuteCommands(); + } while (m_pending_command_ticks > 0); + }; + switch (type) { case GPUDump::PacketType::GPUPort0Data: @@ -2176,14 +2184,11 @@ void GPU::ProcessGPUDumpPacket(GPUDump::PacketType type, const std::span(data.size() - current_word)); + // normally this would be constrained to the "real" fifo size, but VRAM updates also go through here + // it's easier to just push everything in and execute + const u32 block_size = std::min(m_fifo.GetSpace(), static_cast(data.size() - current_word)); if (block_size == 0) { ERROR_LOG("FIFO overflow while processing dump packet of {} words", data.size()); @@ -2200,7 +2207,9 @@ void GPU::ProcessGPUDumpPacket(GPUDump::PacketType type, const std::span