Merge pull request #957 from degasus/frame_skipping

VideoCommon: rewrite frame skipping code
This commit is contained in:
Dolphin Bot 2014-09-04 18:27:19 +02:00
commit 830a03c540
8 changed files with 20 additions and 34 deletions

View File

@ -19,7 +19,7 @@
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/VideoConfig.h"
volatile bool g_bSkipCurrentFrame = false;
bool g_bSkipCurrentFrame = false;
namespace
{
@ -173,7 +173,7 @@ void RunGpuLoop()
ReadDataFromFifo(uData, 32);
cyclesExecuted = OpcodeDecoder_Run(g_bSkipCurrentFrame, GetVideoBufferEndPtr());
cyclesExecuted = OpcodeDecoder_Run(GetVideoBufferEndPtr());
if (Core::g_CoreStartupParameter.bSyncGPU && Common::AtomicLoad(CommandProcessor::VITicks) > cyclesExecuted)
Common::AtomicAdd(CommandProcessor::VITicks, -(s32)cyclesExecuted);
@ -235,7 +235,7 @@ void RunGpu()
FPURoundMode::SaveSIMDState();
FPURoundMode::LoadDefaultSIMDState();
ReadDataFromFifo(uData, 32);
OpcodeDecoder_Run(g_bSkipCurrentFrame, GetVideoBufferEndPtr());
OpcodeDecoder_Run(GetVideoBufferEndPtr());
FPURoundMode::LoadSIMDState();
//DEBUG_LOG(COMMANDPROCESSOR, "Fifo wraps to base");

View File

@ -11,7 +11,7 @@ class PointerWrap;
#define FIFO_SIZE (2*1024*1024)
extern volatile bool g_bSkipCurrentFrame;
extern bool g_bSkipCurrentFrame;
void Fifo_Init();

View File

@ -50,7 +50,7 @@ static u32 InterpretDisplayList(u32 address, u32 size)
Statistics::SwapDL();
u8 *end = g_pVideoData + size;
cycles = OpcodeDecoder_Run(false, end);
cycles = OpcodeDecoder_Run(end);
INCSTAT(stats.thisFrame.numDListsCalled);
// un-swap
@ -105,7 +105,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;
if (g_pVideoData == end)
@ -178,10 +178,7 @@ static u32 Decode(u8* end, bool skipped_frame)
return 0;
u32 address = DataReadU32();
u32 count = DataReadU32();
if (skipped_frame)
cycles = 45; // xxx
else
cycles = 6 + InterpretDisplayList(address, count);
cycles = 6 + InterpretDisplayList(address, count);
}
break;
@ -218,21 +215,14 @@ static u32 Decode(u8* end, bool skipped_frame)
return 0;
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);
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;
return 0;
}
}
else
@ -260,13 +250,13 @@ void OpcodeDecoder_Shutdown()
{
}
u32 OpcodeDecoder_Run(bool skipped_frame, u8* end)
u32 OpcodeDecoder_Run(u8* end)
{
u32 totalCycles = 0;
while (true)
{
u8* old = g_pVideoData;
u32 cycles = Decode(end, skipped_frame);
u32 cycles = Decode(end);
if (cycles == 0)
{
g_pVideoData = old;

View File

@ -38,4 +38,4 @@ extern bool g_bRecordFifoData;
void OpcodeDecoder_Init();
void OpcodeDecoder_Shutdown();
u32 OpcodeDecoder_Run(bool skipped_frame, u8* end);
u32 OpcodeDecoder_Run(u8* end);

View File

@ -65,7 +65,6 @@ TargetRectangle Renderer::target_rc;
int Renderer::s_LastEFBScale;
bool Renderer::s_skipSwap;
bool Renderer::XFBWrited;
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)
return;
s_skipSwap = g_bSkipCurrentFrame;
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
XFBWrited = true;

View File

@ -152,7 +152,6 @@ protected:
// can probably eliminate this static var
static int s_LastEFBScale;
static bool s_skipSwap;
static bool XFBWrited;
FPSCounter m_fps_counter;

View File

@ -151,7 +151,7 @@ static VertexLoaderCacheItem RefreshLoader(int 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)
return true;
@ -161,7 +161,7 @@ bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size)
if (buf_size < size)
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
DataSkip((u32)size);

View File

@ -18,7 +18,7 @@ namespace VertexLoaderManager
int GetVertexSize(int vtx_attr_group);
// 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
void AppendListToString(std::string *dest);