Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'osx-savegame-fix'
  • Loading branch information
degasus committed Dec 24, 2012
2 parents eedca57 + bd0abb3 commit 78ff8a7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Source/Core/Common/Src/VideoBackendBase.h
Expand Up @@ -137,6 +137,8 @@ class VideoBackend

// 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;
Expand Down Expand Up @@ -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
9 changes: 6 additions & 3 deletions Source/Core/VideoCommon/Src/BPStructs.cpp
Expand Up @@ -34,9 +34,9 @@

using namespace BPFunctions;

u32 mapTexAddress;
bool mapTexFound;
int numWrites;
static u32 mapTexAddress;
static bool mapTexFound;
static int numWrites;

extern volatile bool g_bSkipCurrentFrame;

Expand Down Expand Up @@ -81,6 +81,9 @@ void BPWritten(const BPCmd& bp)
just stuff geometry in them and don't put state changes there
----------------------------------------------------------------------------------------------------------------
*/

// check for invalid state, else unneeded configuration are built
g_video_backend->CheckInvalidState();

// Debugging only, this lets you skip a bp update
//static int times = 0;
Expand Down
14 changes: 12 additions & 2 deletions Source/Core/VideoCommon/Src/MainBase.cpp
Expand Up @@ -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
Expand All @@ -198,16 +199,25 @@ void VideoBackendHardware::DoState(PointerWrap& p)
// Refresh state.
if (p.GetMode() == PointerWrap::MODE_READ)
{
BPReload();
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::Invalidate();
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);
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoCommon/Src/VertexManagerBase.cpp
Expand Up @@ -9,6 +9,7 @@
#include "NativeVertexFormat.h"
#include "TextureCacheBase.h"
#include "RenderBase.h"
#include "BPStructs.h"

#include "VertexManagerBase.h"
#include "VideoConfig.h"
Expand Down Expand Up @@ -159,6 +160,9 @@ void VertexManager::AddVertices(int primitive, int numVertices)

void VertexManager::Flush()
{
// loading a state will invalidate BP, so check for it
g_video_backend->CheckInvalidState();

g_vertex_manager->vFlush();
}

Expand Down
5 changes: 5 additions & 0 deletions Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h
Expand Up @@ -50,6 +50,9 @@ class VideoSoftware : public VideoBackend

void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
void DoState(PointerWrap &p);

public:
void CheckInvalidState();
};

}
Expand Down

0 comments on commit 78ff8a7

Please sign in to comment.