revert last commit, add CheckInvalidState to VideoBackend

This commit is contained in:
degasus 2012-12-23 13:32:23 +01:00
parent ffddfd8662
commit bd0abb3d2f
9 changed files with 57 additions and 57 deletions

View File

@ -137,6 +137,8 @@ public:
// the implementation needs not do synchronization logic, because calls to it are surrounded by PauseAndLock now
virtual void DoState(PointerWrap &p) = 0;
virtual void CheckInvalidState() = 0;
};
extern std::vector<VideoBackend*> g_available_video_backends;
@ -176,9 +178,15 @@ class VideoBackendHardware : public VideoBackend
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
void DoState(PointerWrap &p);
bool m_invalid;
public:
void CheckInvalidState();
protected:
void InitializeShared();
void InvalidState();
};
#endif

View File

@ -37,7 +37,6 @@ using namespace BPFunctions;
static u32 mapTexAddress;
static bool mapTexFound;
static int numWrites;
static bool s_invalid;
extern volatile bool g_bSkipCurrentFrame;
@ -57,7 +56,6 @@ void BPInit()
mapTexAddress = 0;
numWrites = 0;
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)
@ -85,7 +83,7 @@ void BPWritten(const BPCmd& bp)
*/
// check for invalid state, else unneeded configuration are built
BPReload();
g_video_backend->CheckInvalidState();
// Debugging only, this lets you skip a bp update
//static int times = 0;
@ -685,42 +683,32 @@ void BPWritten(const BPCmd& bp)
// Called when loading a saved state.
void BPReload()
{
if(s_invalid) {
s_invalid = false;
// restore anything that goes straight to the renderer.
// let's not risk actually replaying any writes.
// note that PixelShaderManager is already covered since it has its own DoState.
SetGenerationMode();
SetScissor();
SetLineWidth();
SetDepthMode();
SetLogicOpMode();
SetDitherMode();
SetBlendMode();
SetColorMask();
OnPixelFormatChange();
{
BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMASK])};
SetInterlacingMode(bp);
}
{
BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMODE])};
SetInterlacingMode(bp);
}
// restore anything that goes straight to the renderer.
// let's not risk actually replaying any writes.
// note that PixelShaderManager is already covered since it has its own DoState.
SetGenerationMode();
SetScissor();
SetLineWidth();
SetDepthMode();
SetLogicOpMode();
SetDitherMode();
SetBlendMode();
SetColorMask();
OnPixelFormatChange();
{
BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMASK])};
SetInterlacingMode(bp);
}
{
BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMODE])};
SetInterlacingMode(bp);
}
}
void BPInvalidate()
{
s_invalid = true;
}

View File

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

View File

@ -180,6 +180,7 @@ void VideoBackendHardware::InitializeShared()
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
memset(&s_accessEFBArgs, 0, sizeof(s_accessEFBArgs));
s_AccessEFBResult = 0;
m_invalid = false;
}
// Run from the CPU thread
@ -198,16 +199,25 @@ void VideoBackendHardware::DoState(PointerWrap& p)
// Refresh state.
if (p.GetMode() == PointerWrap::MODE_READ)
{
BPInvalidate();
m_invalid = true;
RecomputeCachedArraybases();
// Clear all caches that touch RAM
// (? these don't appear to touch any emulation state that gets saved. moved to on load only.)
TextureCache::InvalidateHashes();
VertexLoaderManager::MarkAllDirty();
}
}
void VideoBackendHardware::CheckInvalidState() {
if (m_invalid)
{
m_invalid = false;
BPReload();
TextureCache::Invalidate();
}
}
void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
Fifo_PauseAndLock(doLock, unpauseOnUnlock);

View File

@ -72,18 +72,6 @@ void TextureCache::Invalidate()
textures.clear();
}
// this function is dirty hack to work around a OGL bug.
// it is only used on loading states. It will work for normal textures,
// but for efb2ram, it wouldn't be checked. So there may be glitches on loading
void TextureCache::InvalidateHashes()
{
TexCache::iterator
iter = textures.begin(),
tcend = textures.end();
for (; iter != tcend; ++iter)
iter->second->hash = TEXHASH_INVALID;
}
TextureCache::~TextureCache()
{
Invalidate();

View File

@ -106,7 +106,6 @@ public:
static void Cleanup();
static void Invalidate();
static void InvalidateHashes();
static void InvalidateRange(u32 start_address, u32 size);
static void MakeRangeDynamic(u32 start_address, u32 size);
static void ClearRenderTargets(); // currently only used by OGL

View File

@ -161,7 +161,7 @@ void VertexManager::AddVertices(int primitive, int numVertices)
void VertexManager::Flush()
{
// loading a state will invalidate BP, so check for it
BPReload();
g_video_backend->CheckInvalidState();
g_vertex_manager->vFlush();
}

View File

@ -95,6 +95,11 @@ void VideoSoftware::DoState(PointerWrap&)
// NYI
}
void VideoSoftware::CheckInvalidState()
{
// there is no state to invalidate
}
void VideoSoftware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (doLock)

View File

@ -50,6 +50,9 @@ class VideoSoftware : public VideoBackend
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
void DoState(PointerWrap &p);
public:
void CheckInvalidState();
};
}