From 105f14a0153c90bcd36ce26b1b197dc8b0fa0ac1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 16 Nov 2020 03:04:44 -0500 Subject: [PATCH] cdma_pusher: Remove unnecessary intermediate std::vector in Step() We can use the underlying raw u32 instead of copying all command headers to another vector as u32s before using them. --- src/video_core/cdma_pusher.cpp | 7 +++---- src/video_core/cdma_pusher.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 46667ce693..8c277aab6c 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp @@ -52,10 +52,9 @@ void CDmaPusher::Step() { const auto entries{cdma_queue.front()}; cdma_queue.pop(); - std::vector values(entries.size()); - std::memcpy(values.data(), entries.data(), entries.size() * sizeof(u32)); + for (const auto entry : entries) { + const u32 value = entry.raw; - for (const u32 value : values) { if (mask != 0) { const u32 lbs = Common::CountTrailingZeroes32(mask); mask &= ~(1U << lbs); @@ -72,7 +71,7 @@ void CDmaPusher::Step() { continue; } - const auto mode = static_cast((value >> 28) & 0xf); + const auto mode = entry.submission_mode.Value(); switch (mode) { case ChSubmissionMode::SetClass: { mask = value & 0x3f; diff --git a/src/video_core/cdma_pusher.h b/src/video_core/cdma_pusher.h index 161c05aa2f..0df5bd535a 100644 --- a/src/video_core/cdma_pusher.h +++ b/src/video_core/cdma_pusher.h @@ -67,8 +67,8 @@ struct ChCommand { std::vector arguments; }; -using ChCommandHeaderList = std::vector; -using ChCommandList = std::vector; +using ChCommandHeaderList = std::vector; +using ChCommandList = std::vector; struct ThiRegisters { u32_le increment_syncpt{};