VideoCommon: rewrite frame skipping code
This commit is contained in:
parent
e1248599eb
commit
8b84ddce9a
|
@ -19,7 +19,7 @@
|
||||||
#include "VideoCommon/PixelEngine.h"
|
#include "VideoCommon/PixelEngine.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
volatile bool g_bSkipCurrentFrame = false;
|
bool g_bSkipCurrentFrame = false;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ void RunGpuLoop()
|
||||||
|
|
||||||
ReadDataFromFifo(uData, 32);
|
ReadDataFromFifo(uData, 32);
|
||||||
|
|
||||||
cyclesExecuted = OpcodeDecoder_Run(g_bSkipCurrentFrame, GetVideoBufferEndPtr());
|
cyclesExecuted = OpcodeDecoder_Run(GetVideoBufferEndPtr());
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bSyncGPU && Common::AtomicLoad(CommandProcessor::VITicks) > cyclesExecuted)
|
if (Core::g_CoreStartupParameter.bSyncGPU && Common::AtomicLoad(CommandProcessor::VITicks) > cyclesExecuted)
|
||||||
Common::AtomicAdd(CommandProcessor::VITicks, -(s32)cyclesExecuted);
|
Common::AtomicAdd(CommandProcessor::VITicks, -(s32)cyclesExecuted);
|
||||||
|
@ -235,7 +235,7 @@ void RunGpu()
|
||||||
FPURoundMode::SaveSIMDState();
|
FPURoundMode::SaveSIMDState();
|
||||||
FPURoundMode::LoadDefaultSIMDState();
|
FPURoundMode::LoadDefaultSIMDState();
|
||||||
ReadDataFromFifo(uData, 32);
|
ReadDataFromFifo(uData, 32);
|
||||||
OpcodeDecoder_Run(g_bSkipCurrentFrame, GetVideoBufferEndPtr());
|
OpcodeDecoder_Run(GetVideoBufferEndPtr());
|
||||||
FPURoundMode::LoadSIMDState();
|
FPURoundMode::LoadSIMDState();
|
||||||
|
|
||||||
//DEBUG_LOG(COMMANDPROCESSOR, "Fifo wraps to base");
|
//DEBUG_LOG(COMMANDPROCESSOR, "Fifo wraps to base");
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PointerWrap;
|
||||||
|
|
||||||
#define FIFO_SIZE (2*1024*1024)
|
#define FIFO_SIZE (2*1024*1024)
|
||||||
|
|
||||||
extern volatile bool g_bSkipCurrentFrame;
|
extern bool g_bSkipCurrentFrame;
|
||||||
|
|
||||||
|
|
||||||
void Fifo_Init();
|
void Fifo_Init();
|
||||||
|
|
|
@ -91,7 +91,7 @@ static u32 InterpretDisplayList(u32 address, u32 size)
|
||||||
Statistics::SwapDL();
|
Statistics::SwapDL();
|
||||||
|
|
||||||
u8 *end = g_pVideoData + size;
|
u8 *end = g_pVideoData + size;
|
||||||
cycles = OpcodeDecoder_Run(false, end);
|
cycles = OpcodeDecoder_Run(end);
|
||||||
INCSTAT(stats.thisFrame.numDListsCalled);
|
INCSTAT(stats.thisFrame.numDListsCalled);
|
||||||
|
|
||||||
// un-swap
|
// un-swap
|
||||||
|
@ -146,7 +146,7 @@ static void UnknownOpcode(u8 cmd_byte, void *buffer, bool preprocess)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 Decode(u8* end, bool skipped_frame)
|
static u32 Decode(u8* end)
|
||||||
{
|
{
|
||||||
u8 *opcodeStart = g_pVideoData;
|
u8 *opcodeStart = g_pVideoData;
|
||||||
if (g_pVideoData == end)
|
if (g_pVideoData == end)
|
||||||
|
@ -221,10 +221,7 @@ static u32 Decode(u8* end, bool skipped_frame)
|
||||||
return 0;
|
return 0;
|
||||||
u32 address = DataReadU32();
|
u32 address = DataReadU32();
|
||||||
u32 count = DataReadU32();
|
u32 count = DataReadU32();
|
||||||
if (skipped_frame)
|
cycles = 6 + InterpretDisplayList(address, count);
|
||||||
cycles = 45; // xxx
|
|
||||||
else
|
|
||||||
cycles = 6 + InterpretDisplayList(address, count);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -261,21 +258,14 @@ static u32 Decode(u8* end, bool skipped_frame)
|
||||||
return 0;
|
return 0;
|
||||||
u16 numVertices = DataReadU16();
|
u16 numVertices = DataReadU16();
|
||||||
|
|
||||||
if (skipped_frame)
|
if (!VertexLoaderManager::RunVertices(
|
||||||
|
cmd_byte & GX_VAT_MASK, // Vertex loader index (0 - 7)
|
||||||
|
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT,
|
||||||
|
numVertices,
|
||||||
|
end - g_pVideoData,
|
||||||
|
g_bSkipCurrentFrame))
|
||||||
{
|
{
|
||||||
size_t size = numVertices * VertexLoaderManager::GetVertexSize(cmd_byte & GX_VAT_MASK);
|
return 0;
|
||||||
if ((size_t) (end - g_pVideoData) < size)
|
|
||||||
return 0;
|
|
||||||
DataSkip((u32)size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!VertexLoaderManager::RunVertices(
|
|
||||||
cmd_byte & GX_VAT_MASK, // Vertex loader index (0 - 7)
|
|
||||||
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT,
|
|
||||||
numVertices,
|
|
||||||
end - g_pVideoData))
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -311,13 +301,13 @@ void OpcodeDecoder_Shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 OpcodeDecoder_Run(bool skipped_frame, u8* end)
|
u32 OpcodeDecoder_Run(u8* end)
|
||||||
{
|
{
|
||||||
u32 totalCycles = 0;
|
u32 totalCycles = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
u8* old = g_pVideoData;
|
u8* old = g_pVideoData;
|
||||||
u32 cycles = Decode(end, skipped_frame);
|
u32 cycles = Decode(end);
|
||||||
if (cycles == 0)
|
if (cycles == 0)
|
||||||
{
|
{
|
||||||
g_pVideoData = old;
|
g_pVideoData = old;
|
||||||
|
|
|
@ -38,4 +38,4 @@ extern bool g_bRecordFifoData;
|
||||||
|
|
||||||
void OpcodeDecoder_Init();
|
void OpcodeDecoder_Init();
|
||||||
void OpcodeDecoder_Shutdown();
|
void OpcodeDecoder_Shutdown();
|
||||||
u32 OpcodeDecoder_Run(bool skipped_frame, u8* end);
|
u32 OpcodeDecoder_Run(u8* end);
|
||||||
|
|
|
@ -65,7 +65,6 @@ TargetRectangle Renderer::target_rc;
|
||||||
|
|
||||||
int Renderer::s_LastEFBScale;
|
int Renderer::s_LastEFBScale;
|
||||||
|
|
||||||
bool Renderer::s_skipSwap;
|
|
||||||
bool Renderer::XFBWrited;
|
bool Renderer::XFBWrited;
|
||||||
|
|
||||||
PEControl::PixelFormat Renderer::prev_efb_format = PEControl::INVALID_FMT;
|
PEControl::PixelFormat Renderer::prev_efb_format = PEControl::INVALID_FMT;
|
||||||
|
@ -113,8 +112,6 @@ void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbWidt
|
||||||
if (!fbWidth || !fbHeight)
|
if (!fbWidth || !fbHeight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_skipSwap = g_bSkipCurrentFrame;
|
|
||||||
|
|
||||||
VideoFifo_CheckEFBAccess();
|
VideoFifo_CheckEFBAccess();
|
||||||
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
|
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
|
||||||
XFBWrited = true;
|
XFBWrited = true;
|
||||||
|
|
|
@ -152,7 +152,6 @@ protected:
|
||||||
// can probably eliminate this static var
|
// can probably eliminate this static var
|
||||||
static int s_LastEFBScale;
|
static int s_LastEFBScale;
|
||||||
|
|
||||||
static bool s_skipSwap;
|
|
||||||
static bool XFBWrited;
|
static bool XFBWrited;
|
||||||
|
|
||||||
FPSCounter m_fps_counter;
|
FPSCounter m_fps_counter;
|
||||||
|
|
|
@ -151,7 +151,7 @@ static VertexLoaderCacheItem RefreshLoader(int vtx_attr_group)
|
||||||
return s_VertexLoaders[vtx_attr_group];
|
return s_VertexLoaders[vtx_attr_group];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size)
|
bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size, bool skip_drawing)
|
||||||
{
|
{
|
||||||
if (!count)
|
if (!count)
|
||||||
return true;
|
return true;
|
||||||
|
@ -161,7 +161,7 @@ bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size)
|
||||||
if (buf_size < size)
|
if (buf_size < size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5)
|
if (skip_drawing || (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5))
|
||||||
{
|
{
|
||||||
// if cull mode is CULL_ALL, ignore triangles and quads
|
// if cull mode is CULL_ALL, ignore triangles and quads
|
||||||
DataSkip((u32)size);
|
DataSkip((u32)size);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace VertexLoaderManager
|
||||||
|
|
||||||
int GetVertexSize(int vtx_attr_group);
|
int GetVertexSize(int vtx_attr_group);
|
||||||
// Returns false if buf_size is insufficient.
|
// Returns false if buf_size is insufficient.
|
||||||
bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size);
|
bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size, bool skip_drawing = false);
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
void AppendListToString(std::string *dest);
|
void AppendListToString(std::string *dest);
|
||||||
|
|
Loading…
Reference in New Issue