OpcodeDecoder: Add namespace

This commit is contained in:
Lioncash 2016-01-24 01:29:44 -05:00
parent aa39b0dab1
commit e187c55bdd
6 changed files with 33 additions and 24 deletions

View File

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

View File

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

View File

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

View File

@ -261,7 +261,7 @@ static void ReadDataFromFifoOnCPU(u32 readPtr)
}
}
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.
s_video_buffer_write_ptr = write_ptr + len;
}
@ -305,7 +305,7 @@ void RunGpuLoop()
// See comment in SyncGPU
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;
}
}
@ -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);
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::AtomicAdd(fifo.CPReadWriteDistance, -32);
@ -423,7 +423,7 @@ void RunGpu()
reset_simd_state = true;
}
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");

View File

@ -28,8 +28,11 @@
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/XFMemory.h"
bool g_bRecordFifoData = false;
namespace OpcodeDecoder
{
static bool s_bFifoErrorSeen = false;
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)
Statistics::SwapDL();
OpcodeDecoder_Run(DataReader(startAddress, startAddress + size), &cycles, true);
Run(DataReader(startAddress, startAddress + size), &cycles, true);
INCSTAT(stats.thisFrame.numDListsCalled);
// un-swap
@ -67,7 +70,7 @@ static void InterpretDisplayListPreprocess(u32 address, u32 size)
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;
}
void OpcodeDecoder_Shutdown()
void Shutdown()
{
}
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;
u8* opcodeStart;
@ -314,5 +316,7 @@ end:
return opcodeStart;
}
template u8* OpcodeDecoder_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<true>(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_POINTS 0x7 // 0xB8
void OpcodeDecoder_Init();
void OpcodeDecoder_Shutdown();
namespace OpcodeDecoder
{
void Init();
void Shutdown();
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