From 991512af4ca7bfee728464bcbc60a07d644e5949 Mon Sep 17 00:00:00 2001 From: xbzk Date: Mon, 23 Feb 2026 03:33:22 +0100 Subject: [PATCH] Update src/video_core/dma_pusher.cpp Upon investigating ender magnolia crashes i need to add lots of instrumentation in the "if (header.size > 0) {...}" block (between headers(...) and ProcessCommands(...)) for both safe and unsafe paths. The old way i need to add same instrumentation twice, always ending up maintaining only one path, and when i realize i need to test the other, i have to update/copy/move instrumentation between methods. This new writing preserves exactly the same logic, but gathers both paths into a single one, and by no means should have performance impact. And it's more elegant too. You're welcome ^^. We must let the compiler do the hard work for us, right? Feel free to blame! Signed-off-by: xbzk --- src/video_core/dma_pusher.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index 3844a8e2f9..bd0eef6347 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp @@ -78,17 +78,19 @@ bool DmaPusher::Step() { synced = false; } - if (header.size > 0 && dma_state.method >= MacroRegistersStart && subchannels[dma_state.subchannel]) { - subchannels[dma_state.subchannel]->current_dirty = memory_manager.IsMemoryDirty(dma_state.dma_get, header.size * sizeof(u32)); - } - if (header.size > 0) { - if (Settings::IsDMALevelDefault() ? (Settings::IsGPULevelMedium() || Settings::IsGPULevelHigh()) : Settings::IsDMALevelSafe()) { - Tegra::Memory::GpuGuestMemoryheaders(memory_manager, dma_state.dma_get, header.size, &command_headers); + if (dma_state.method >= MacroRegistersStart && subchannels[dma_state.subchannel]) { + subchannels[dma_state.subchannel]->current_dirty = memory_manager.IsMemoryDirty(dma_state.dma_get, header.size * sizeof(u32)); + } + auto run = [&]() { + Tegra::Memory::GpuGuestMemory + headers(memory_manager, dma_state.dma_get, header.size, &command_headers); ProcessCommands(headers); + }; + if (Settings::IsDMALevelSafe() || (Settings::IsDMALevelDefault() && !Settings::IsGPULevelLow())) { + run.template operator()(); } else { - Tegra::Memory::GpuGuestMemoryheaders(memory_manager, dma_state.dma_get, header.size, &command_headers); - ProcessCommands(headers); + run.template operator()(); } }