From 61e4f2d931449e60d8d720862997ac565fce6634 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Wed, 7 Dec 2022 00:45:06 -0500 Subject: dma_pusher: Rework command_headers usage Uses ScratchBuffer and avoids overwriting the command_headers buffer with the prefetch_command_list --- src/video_core/dma_pusher.cpp | 17 ++++++++++------- src/video_core/dma_pusher.h | 8 ++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index 9835e3ac1..d1f541bf5 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp @@ -56,7 +56,7 @@ bool DmaPusher::Step() { if (command_list.prefetch_command_list.size()) { // Prefetched command list from nvdrv, used for things like synchronization - command_headers = std::move(command_list.prefetch_command_list); + ProcessCommands(command_list.prefetch_command_list); dma_pushbuffer.pop(); } else { const CommandListHeader command_list_header{ @@ -82,16 +82,21 @@ bool DmaPusher::Step() { memory_manager.ReadBlockUnsafe(dma_get, command_headers.data(), command_list_header.size * sizeof(u32)); } + ProcessCommands(command_headers); } - for (std::size_t index = 0; index < command_headers.size();) { - const CommandHeader& command_header = command_headers[index]; + + return true; +} + +void DmaPusher::ProcessCommands(std::span commands) { + for (std::size_t index = 0; index < commands.size();) { + const CommandHeader& command_header = commands[index]; if (dma_state.method_count) { // Data word of methods command if (dma_state.non_incrementing) { const u32 max_write = static_cast( - std::min(index + dma_state.method_count, command_headers.size()) - - index); + std::min(index + dma_state.method_count, commands.size()) - index); CallMultiMethod(&command_header.argument, max_write); dma_state.method_count -= max_write; dma_state.is_last_call = true; @@ -142,8 +147,6 @@ bool DmaPusher::Step() { } index++; } - - return true; } void DmaPusher::SetState(const CommandHeader& command_header) { diff --git a/src/video_core/dma_pusher.h b/src/video_core/dma_pusher.h index 938f0f11c..6f00de937 100644 --- a/src/video_core/dma_pusher.h +++ b/src/video_core/dma_pusher.h @@ -4,11 +4,13 @@ #pragma once #include +#include #include #include #include "common/bit_field.h" #include "common/common_types.h" +#include "common/scratch_buffer.h" #include "video_core/engines/engine_interface.h" #include "video_core/engines/puller.h" @@ -136,13 +138,15 @@ private: static constexpr u32 non_puller_methods = 0x40; static constexpr u32 max_subchannels = 8; bool Step(); + void ProcessCommands(std::span commands); void SetState(const CommandHeader& command_header); void CallMethod(u32 argument) const; void CallMultiMethod(const u32* base_start, u32 num_methods) const; - std::vector command_headers; ///< Buffer for list of commands fetched at once + Common::ScratchBuffer + command_headers; ///< Buffer for list of commands fetched at once std::queue dma_pushbuffer; ///< Queue of command lists to be processed std::size_t dma_pushbuffer_subindex{}; ///< Index within a command list within the pushbuffer @@ -159,7 +163,7 @@ private: DmaState dma_state{}; bool dma_increment_once{}; - bool ib_enable{true}; ///< IB mode enabled + const bool ib_enable{true}; ///< IB mode enabled std::array subchannels{}; -- cgit v1.2.3