Browse Source

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 <xbzk@eden-emu.dev>
xbzk-dma-pusher-step-redesign
xbzk 2 weeks ago
committed by crueter
parent
commit
991512af4c
  1. 16
      src/video_core/dma_pusher.cpp

16
src/video_core/dma_pusher.cpp

@ -78,17 +78,19 @@ bool DmaPusher::Step() {
synced = false; synced = false;
} }
if (header.size > 0 && dma_state.method >= MacroRegistersStart && subchannels[dma_state.subchannel]) {
if (header.size > 0) {
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)); 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::GpuGuestMemory<Tegra::CommandHeader, Tegra::Memory::GuestMemoryFlags::SafeRead>headers(memory_manager, dma_state.dma_get, header.size, &command_headers);
auto run = [&]<Tegra::Memory::GuestMemoryFlags Flags>() {
Tegra::Memory::GpuGuestMemory<Tegra::CommandHeader, Flags>
headers(memory_manager, dma_state.dma_get, header.size, &command_headers);
ProcessCommands(headers); ProcessCommands(headers);
};
if (Settings::IsDMALevelSafe() || (Settings::IsDMALevelDefault() && !Settings::IsGPULevelLow())) {
run.template operator()<Tegra::Memory::GuestMemoryFlags::SafeRead>();
} else { } else {
Tegra::Memory::GpuGuestMemory<Tegra::CommandHeader, Tegra::Memory::GuestMemoryFlags::UnsafeRead>headers(memory_manager, dma_state.dma_get, header.size, &command_headers);
ProcessCommands(headers);
run.template operator()<Tegra::Memory::GuestMemoryFlags::UnsafeRead>();
} }
} }

Loading…
Cancel
Save