From b2a9c365011a501ead2b5505d219f9c817b6b7e9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Dec 2019 08:11:52 -0500 Subject: [PATCH] VideoCommon/OpcodeDecoding: Move g_bRecordFifoData into namespace Keeps the global localized with the code that it's primarily related to. Now it's obvious from a glance what the global variable is affecting. --- Source/Core/VideoCommon/BPStructs.cpp | 5 +++-- Source/Core/VideoCommon/OpcodeDecoding.cpp | 6 +++--- Source/Core/VideoCommon/OpcodeDecoding.h | 3 +++ Source/Core/VideoCommon/RenderBase.cpp | 20 ++++++++++---------- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 +++++-- Source/Core/VideoCommon/VideoCommon.h | 3 --- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index f9be647114..4a45ba7c52 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -25,6 +25,7 @@ #include "VideoCommon/Fifo.h" #include "VideoCommon/FramebufferManager.h" #include "VideoCommon/GeometryShaderManager.h" +#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/PerfQueryBase.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelShaderManager.h" @@ -343,7 +344,7 @@ static void BPWritten(const BPCmd& bp) Memory::CopyFromEmu(texMem + tlutTMemAddr, addr, tlutXferCount); - if (g_bRecordFifoData) + if (OpcodeDecoder::g_record_fifo_data) FifoRecorder::GetInstance().UseMemory(addr, tlutXferCount, MemoryUpdate::TMEM); TextureCacheBase::InvalidateAllBindPoints(); @@ -566,7 +567,7 @@ static void BPWritten(const BPCmd& bp) } } - if (g_bRecordFifoData) + if (OpcodeDecoder::g_record_fifo_data) FifoRecorder::GetInstance().UseMemory(src_addr, bytes_read, MemoryUpdate::TMEM); TextureCacheBase::InvalidateAllBindPoints(); diff --git a/Source/Core/VideoCommon/OpcodeDecoding.cpp b/Source/Core/VideoCommon/OpcodeDecoding.cpp index 39bb0a5765..e52bfe0137 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/OpcodeDecoding.cpp @@ -30,8 +30,6 @@ #include "VideoCommon/VideoCommon.h" #include "VideoCommon/XFMemory.h" -bool g_bRecordFifoData = false; - namespace OpcodeDecoder { static bool s_is_fifo_error_seen = false; @@ -75,6 +73,8 @@ static void InterpretDisplayListPreprocess(u32 address, u32 size) Run(DataReader(start_address, start_address + size), nullptr, true); } +bool g_record_fifo_data = false; + void Init() { s_is_fifo_error_seen = false; @@ -255,7 +255,7 @@ u8* Run(DataReader src, u32* cycles, bool in_display_list) } // Display lists get added directly into the FIFO stream - if (!is_preprocess && g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL) + if (!is_preprocess && g_record_fifo_data && cmd_byte != GX_CMD_CALL_DL) { const u8* const opcode_end = src.GetPointer(); FifoRecorder::GetInstance().WriteGPCommand(opcode_start, u32(opcode_end - opcode_start)); diff --git a/Source/Core/VideoCommon/OpcodeDecoding.h b/Source/Core/VideoCommon/OpcodeDecoding.h index 3d2e5c8361..f3533c3735 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.h +++ b/Source/Core/VideoCommon/OpcodeDecoding.h @@ -10,6 +10,9 @@ class DataReader; namespace OpcodeDecoder { +// Global flag to signal if FifoRecorder is active. +extern bool g_record_fifo_data; + enum { GX_NOP = 0x00, diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 1c193f9fdc..d94eac2c0d 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -65,6 +65,7 @@ #include "VideoCommon/NetPlayChatUI.h" #include "VideoCommon/NetPlayGolfUI.h" #include "VideoCommon/OnScreenDisplay.h" +#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/PostProcessing.h" @@ -880,19 +881,18 @@ std::tuple Renderer::CalculateOutputDimensions(int width, int height) void Renderer::CheckFifoRecording() { - bool wasRecording = g_bRecordFifoData; - g_bRecordFifoData = FifoRecorder::GetInstance().IsRecording(); + const bool was_recording = OpcodeDecoder::g_record_fifo_data; + OpcodeDecoder::g_record_fifo_data = FifoRecorder::GetInstance().IsRecording(); - if (g_bRecordFifoData) + if (!OpcodeDecoder::g_record_fifo_data) + return; + + if (!was_recording) { - if (!wasRecording) - { - RecordVideoMemory(); - } - - FifoRecorder::GetInstance().EndFrame(CommandProcessor::fifo.CPBase, - CommandProcessor::fifo.CPEnd); + RecordVideoMemory(); } + + FifoRecorder::GetInstance().EndFrame(CommandProcessor::fifo.CPBase, CommandProcessor::fifo.CPEnd); } void Renderer::RecordVideoMemory() diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index f38745a318..c68ed147c2 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -38,6 +38,7 @@ #include "VideoCommon/BPMemory.h" #include "VideoCommon/FramebufferManager.h" #include "VideoCommon/HiresTextures.h" +#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/SamplerCommon.h" @@ -1260,9 +1261,11 @@ TextureCacheBase::GetTexture(u32 address, u32 width, u32 height, const TextureFo // If we are recording a FifoLog, keep track of what memory we read. FifoRecorder does // its own memory modification tracking independent of the texture hashing below. - if (g_bRecordFifoData && !from_tmem) + if (OpcodeDecoder::g_record_fifo_data && !from_tmem) + { FifoRecorder::GetInstance().UseMemory(address, texture_size + additional_mips_size, MemoryUpdate::TEXTURE_MAP); + } // TODO: This doesn't hash GB tiles for preloaded RGBA8 textures (instead, it's hashing more data // from the low tmem bank than it should) @@ -2294,7 +2297,7 @@ void TextureCacheBase::CopyRenderTargetToTexture( ++iter.first; } - if (g_bRecordFifoData) + if (OpcodeDecoder::g_record_fifo_data) { // Mark the memory behind this efb copy as dynamicly generated for the Fifo log u32 address = dstAddr; diff --git a/Source/Core/VideoCommon/VideoCommon.h b/Source/Core/VideoCommon/VideoCommon.h index 5c4b1b3615..f3d4251690 100644 --- a/Source/Core/VideoCommon/VideoCommon.h +++ b/Source/Core/VideoCommon/VideoCommon.h @@ -6,9 +6,6 @@ #include "Common/CommonTypes.h" -// Global flag to signal if FifoRecorder is active. -extern bool g_bRecordFifoData; - // These are accurate (disregarding AA modes). constexpr u32 EFB_WIDTH = 640; constexpr u32 EFB_HEIGHT = 528;