Merge pull request #3563 from lioncash/opcodedecoder

OpcodeDecoder: Add namespace
This commit is contained in:
Mathew Maidment 2016-01-24 17:17:13 -05:00
commit 44e44f6eb7
6 changed files with 33 additions and 24 deletions

View File

@ -186,7 +186,7 @@ void VideoBackend::Video_Prepare()
Fifo::Init(); Fifo::Init();
IndexGenerator::Init(); IndexGenerator::Init();
VertexLoaderManager::Init(); VertexLoaderManager::Init();
OpcodeDecoder_Init(); OpcodeDecoder::Init();
VertexShaderManager::Init(); VertexShaderManager::Init();
PixelShaderManager::Init(); PixelShaderManager::Init();
GeometryShaderManager::Init(); GeometryShaderManager::Init();
@ -211,7 +211,7 @@ void VideoBackend::Shutdown()
GeometryShaderManager::Shutdown(); GeometryShaderManager::Shutdown();
PixelShaderManager::Shutdown(); PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown(); VertexShaderManager::Shutdown();
OpcodeDecoder_Shutdown(); OpcodeDecoder::Shutdown();
VertexLoaderManager::Shutdown(); VertexLoaderManager::Shutdown();
// internal interfaces // internal interfaces

View File

@ -181,8 +181,8 @@ void VideoBackend::Video_Prepare()
BPInit(); BPInit();
g_vertex_manager = std::make_unique<VertexManager>(); g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = GetPerfQuery(); g_perf_query = GetPerfQuery();
Fifo::Init(); // must be done before OpcodeDecoder_Init() Fifo::Init(); // must be done before OpcodeDecoder::Init()
OpcodeDecoder_Init(); OpcodeDecoder::Init();
IndexGenerator::Init(); IndexGenerator::Init();
VertexShaderManager::Init(); VertexShaderManager::Init();
PixelShaderManager::Init(); PixelShaderManager::Init();
@ -233,7 +233,7 @@ void VideoBackend::Video_Cleanup()
g_perf_query.reset(); g_perf_query.reset();
g_vertex_manager.reset(); g_vertex_manager.reset();
OpcodeDecoder_Shutdown(); OpcodeDecoder::Shutdown();
g_renderer.reset(); g_renderer.reset();
GLInterface->ClearCurrent(); GLInterface->ClearCurrent();
} }

View File

@ -205,7 +205,7 @@ void VideoSoftware::Video_Cleanup()
PixelShaderManager::Shutdown(); PixelShaderManager::Shutdown();
g_perf_query.reset(); g_perf_query.reset();
g_vertex_manager.reset(); g_vertex_manager.reset();
OpcodeDecoder_Shutdown(); OpcodeDecoder::Shutdown();
g_renderer.reset(); g_renderer.reset();
} }
} }
@ -221,8 +221,8 @@ void VideoSoftware::Video_Prepare()
BPInit(); BPInit();
g_vertex_manager = std::make_unique<SWVertexLoader>(); g_vertex_manager = std::make_unique<SWVertexLoader>();
g_perf_query = std::make_unique<PerfQuery>(); g_perf_query = std::make_unique<PerfQuery>();
Fifo::Init(); // must be done before OpcodeDecoder_Init() Fifo::Init(); // must be done before OpcodeDecoder::Init()
OpcodeDecoder_Init(); OpcodeDecoder::Init();
IndexGenerator::Init(); IndexGenerator::Init();
VertexShaderManager::Init(); VertexShaderManager::Init();
PixelShaderManager::Init(); PixelShaderManager::Init();

View File

@ -261,7 +261,7 @@ static void ReadDataFromFifoOnCPU(u32 readPtr)
} }
} }
Memory::CopyFromEmu(s_video_buffer_write_ptr, readPtr, len); Memory::CopyFromEmu(s_video_buffer_write_ptr, readPtr, len);
s_video_buffer_pp_read_ptr = OpcodeDecoder_Run<true>(DataReader(s_video_buffer_pp_read_ptr, write_ptr + len), nullptr, false); s_video_buffer_pp_read_ptr = OpcodeDecoder::Run<true>(DataReader(s_video_buffer_pp_read_ptr, write_ptr + len), nullptr, false);
// This would have to be locked if the GPU thread didn't spin. // This would have to be locked if the GPU thread didn't spin.
s_video_buffer_write_ptr = write_ptr + len; s_video_buffer_write_ptr = write_ptr + len;
} }
@ -305,7 +305,7 @@ void RunGpuLoop()
// See comment in SyncGPU // See comment in SyncGPU
if (write_ptr > seen_ptr) if (write_ptr > seen_ptr)
{ {
s_video_buffer_read_ptr = OpcodeDecoder_Run(DataReader(s_video_buffer_read_ptr, write_ptr), nullptr, false); s_video_buffer_read_ptr = OpcodeDecoder::Run(DataReader(s_video_buffer_read_ptr, write_ptr), nullptr, false);
s_video_buffer_seen_ptr = write_ptr; s_video_buffer_seen_ptr = write_ptr;
} }
} }
@ -336,7 +336,7 @@ void RunGpuLoop()
"Negative fifo.CPReadWriteDistance = %i in FIFO Loop !\nThat can produce instability in the game. Please report it.", fifo.CPReadWriteDistance - 32); "Negative fifo.CPReadWriteDistance = %i in FIFO Loop !\nThat can produce instability in the game. Please report it.", fifo.CPReadWriteDistance - 32);
u8* write_ptr = s_video_buffer_write_ptr; u8* write_ptr = s_video_buffer_write_ptr;
s_video_buffer_read_ptr = OpcodeDecoder_Run(DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false); s_video_buffer_read_ptr = OpcodeDecoder::Run(DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false);
Common::AtomicStore(fifo.CPReadPointer, readPtr); Common::AtomicStore(fifo.CPReadPointer, readPtr);
Common::AtomicAdd(fifo.CPReadWriteDistance, -32); Common::AtomicAdd(fifo.CPReadWriteDistance, -32);
@ -423,7 +423,7 @@ void RunGpu()
reset_simd_state = true; reset_simd_state = true;
} }
ReadDataFromFifo(fifo.CPReadPointer); ReadDataFromFifo(fifo.CPReadPointer);
s_video_buffer_read_ptr = OpcodeDecoder_Run(DataReader(s_video_buffer_read_ptr, s_video_buffer_write_ptr), nullptr, false); s_video_buffer_read_ptr = OpcodeDecoder::Run(DataReader(s_video_buffer_read_ptr, s_video_buffer_write_ptr), nullptr, false);
} }
//DEBUG_LOG(COMMANDPROCESSOR, "Fifo wraps to base"); //DEBUG_LOG(COMMANDPROCESSOR, "Fifo wraps to base");

View File

@ -28,8 +28,11 @@
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/XFMemory.h" #include "VideoCommon/XFMemory.h"
bool g_bRecordFifoData = false; bool g_bRecordFifoData = false;
namespace OpcodeDecoder
{
static bool s_bFifoErrorSeen = false; static bool s_bFifoErrorSeen = false;
static u32 InterpretDisplayList(u32 address, u32 size) static u32 InterpretDisplayList(u32 address, u32 size)
@ -49,7 +52,7 @@ static u32 InterpretDisplayList(u32 address, u32 size)
// temporarily swap dl and non-dl (small "hack" for the stats) // temporarily swap dl and non-dl (small "hack" for the stats)
Statistics::SwapDL(); Statistics::SwapDL();
OpcodeDecoder_Run(DataReader(startAddress, startAddress + size), &cycles, true); Run(DataReader(startAddress, startAddress + size), &cycles, true);
INCSTAT(stats.thisFrame.numDListsCalled); INCSTAT(stats.thisFrame.numDListsCalled);
// un-swap // un-swap
@ -67,7 +70,7 @@ static void InterpretDisplayListPreprocess(u32 address, u32 size)
if (startAddress != nullptr) if (startAddress != nullptr)
{ {
OpcodeDecoder_Run<true>(DataReader(startAddress, startAddress + size), nullptr, true); Run<true>(DataReader(startAddress, startAddress + size), nullptr, true);
} }
} }
@ -120,18 +123,17 @@ static void UnknownOpcode(u8 cmd_byte, void *buffer, bool preprocess)
} }
} }
void OpcodeDecoder_Init() void Init()
{ {
s_bFifoErrorSeen = false; s_bFifoErrorSeen = false;
} }
void Shutdown()
void OpcodeDecoder_Shutdown()
{ {
} }
template <bool is_preprocess> template <bool is_preprocess>
u8* OpcodeDecoder_Run(DataReader src, u32* cycles, bool in_display_list) u8* Run(DataReader src, u32* cycles, bool in_display_list)
{ {
u32 totalCycles = 0; u32 totalCycles = 0;
u8* opcodeStart; u8* opcodeStart;
@ -314,5 +316,7 @@ end:
return opcodeStart; return opcodeStart;
} }
template u8* OpcodeDecoder_Run<true>(DataReader src, u32* cycles, bool in_display_list); template u8* Run<true>(DataReader src, u32* cycles, bool in_display_list);
template u8* OpcodeDecoder_Run<false>(DataReader src, u32* cycles, bool in_display_list); template u8* Run<false>(DataReader src, u32* cycles, bool in_display_list);
} // namespace OpcodeDecoder

View File

@ -38,8 +38,13 @@
#define GX_DRAW_LINE_STRIP 0x6 // 0xB0 #define GX_DRAW_LINE_STRIP 0x6 // 0xB0
#define GX_DRAW_POINTS 0x7 // 0xB8 #define GX_DRAW_POINTS 0x7 // 0xB8
void OpcodeDecoder_Init(); namespace OpcodeDecoder
void OpcodeDecoder_Shutdown(); {
void Init();
void Shutdown();
template <bool is_preprocess = false> template <bool is_preprocess = false>
u8* OpcodeDecoder_Run(DataReader src, u32* cycles, bool in_display_list); u8* Run(DataReader src, u32* cycles, bool in_display_list);
} // namespace OpcodeDecoder