add invalid flag for BPStructs (fix issue 5790)

this flag will be set on loading a state and checked before every rendering.
This commit is contained in:
degasus 2012-12-21 21:04:53 +01:00
parent 2db4549174
commit 2df0c31d13
4 changed files with 51 additions and 31 deletions

View File

@ -34,9 +34,10 @@
using namespace BPFunctions; using namespace BPFunctions;
u32 mapTexAddress; static u32 mapTexAddress;
bool mapTexFound; static bool mapTexFound;
int numWrites; static int numWrites;
static bool s_invalid;
extern volatile bool g_bSkipCurrentFrame; extern volatile bool g_bSkipCurrentFrame;
@ -56,6 +57,7 @@ void BPInit()
mapTexAddress = 0; mapTexAddress = 0;
numWrites = 0; numWrites = 0;
mapTexFound = false; mapTexFound = false;
s_invalid = false;
} }
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight, float gamma) void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight, float gamma)
@ -81,6 +83,9 @@ void BPWritten(const BPCmd& bp)
just stuff geometry in them and don't put state changes there just stuff geometry in them and don't put state changes there
---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------
*/ */
// check for invalid state, else unneeded configuration are built
BPReload();
// Debugging only, this lets you skip a bp update // Debugging only, this lets you skip a bp update
//static int times = 0; //static int times = 0;
@ -680,32 +685,42 @@ void BPWritten(const BPCmd& bp)
// Called when loading a saved state. // Called when loading a saved state.
void BPReload() void BPReload()
{ {
// restore anything that goes straight to the renderer. if(s_invalid) {
// let's not risk actually replaying any writes. s_invalid = false;
// note that PixelShaderManager is already covered since it has its own DoState.
SetGenerationMode(); // restore anything that goes straight to the renderer.
SetScissor(); // let's not risk actually replaying any writes.
SetLineWidth(); // note that PixelShaderManager is already covered since it has its own DoState.
SetDepthMode(); SetGenerationMode();
SetLogicOpMode(); SetScissor();
SetDitherMode(); SetLineWidth();
SetBlendMode(); SetDepthMode();
SetColorMask(); SetLogicOpMode();
OnPixelFormatChange(); SetDitherMode();
{ SetBlendMode();
BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; SetColorMask();
SetTextureMode(bp); OnPixelFormatChange();
} {
{ BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0])};
BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; SetTextureMode(bp);
SetTextureMode(bp); }
} {
{ BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])};
BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMASK])}; SetTextureMode(bp);
SetInterlacingMode(bp); }
} {
{ BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMASK])};
BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMODE])}; SetInterlacingMode(bp);
SetInterlacingMode(bp); }
{
BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMODE])};
SetInterlacingMode(bp);
}
} }
} }
void BPInvalidate()
{
s_invalid = true;
}

View File

@ -23,5 +23,6 @@
void BPInit(); void BPInit();
void LoadBPReg(u32 value0); void LoadBPReg(u32 value0);
void BPReload(); void BPReload();
void BPInvalidate();
#endif // _BPSTRUCTS_H_ #endif // _BPSTRUCTS_H_

View File

@ -198,7 +198,7 @@ void VideoBackendHardware::DoState(PointerWrap& p)
// Refresh state. // Refresh state.
if (p.GetMode() == PointerWrap::MODE_READ) if (p.GetMode() == PointerWrap::MODE_READ)
{ {
BPReload(); BPInvalidate();
RecomputeCachedArraybases(); RecomputeCachedArraybases();
// Clear all caches that touch RAM // Clear all caches that touch RAM

View File

@ -9,6 +9,7 @@
#include "NativeVertexFormat.h" #include "NativeVertexFormat.h"
#include "TextureCacheBase.h" #include "TextureCacheBase.h"
#include "RenderBase.h" #include "RenderBase.h"
#include "BPStructs.h"
#include "VertexManagerBase.h" #include "VertexManagerBase.h"
#include "VideoConfig.h" #include "VideoConfig.h"
@ -159,6 +160,9 @@ void VertexManager::AddVertices(int primitive, int numVertices)
void VertexManager::Flush() void VertexManager::Flush()
{ {
// loading a state will invalidate BP, so check for it
BPReload();
g_vertex_manager->vFlush(); g_vertex_manager->vFlush();
} }