savestate vertexmanager (base) since it affects VertexLoader::RunVertices which affects g_pVideoData

This commit is contained in:
nitsuja 2012-01-04 00:42:22 -08:00 committed by skidau
parent ae242e5675
commit 99b202fd2e
5 changed files with 39 additions and 8 deletions

View File

@ -173,6 +173,15 @@ public:
DoVoid((void *)&x, sizeof(x));
}
template<class T>
void DoPointer(T* &x, T*const base) {
// pointers can be more than 2^31 apart, but you're using this function wrong if you need that much range
s32 offset = x - base;
Do(offset);
if (mode == MODE_READ)
x = base + offset;
}
template<class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)>
void DoLinkedList(LinkedListItem<T>*& list_start, LinkedListItem<T>** list_end=0)
{

View File

@ -45,13 +45,8 @@ void Fifo_DoState(PointerWrap &p)
{
p.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size);
int pos = (int)(g_pVideoData - videoBuffer); // get offset
p.Do(pos); // read or write offset (depending on the mode)
if (p.GetMode() == PointerWrap::MODE_READ)
{
g_pVideoData = &videoBuffer[pos];
g_bSkipCurrentFrame = false;
}
p.DoPointer(g_pVideoData, videoBuffer);
p.Do(g_bSkipCurrentFrame);
}
void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)

View File

@ -308,3 +308,20 @@ shader_fail:
ResetBuffer();
}
#endif
void VertexManager::DoState(PointerWrap& p)
{
g_vertex_manager->vDoState(p);
}
void VertexManager::DoStateShared(PointerWrap& p)
{
p.DoPointer(s_pCurBufferPointer, LocalVBuffer);
p.DoArray(LocalVBuffer, MAXVBUFFERSIZE);
p.DoArray(TIBuffer, MAXIBUFFERSIZE);
p.DoArray(LIBuffer, MAXIBUFFERSIZE);
p.DoArray(PIBuffer, MAXIBUFFERSIZE);
if (p.GetMode() == PointerWrap::MODE_READ)
Flushed = false;
}

View File

@ -3,6 +3,7 @@
#define _VERTEXMANAGERBASE_H
class NativeVertexFormat;
class PointerWrap;
class VertexManager
{
@ -44,6 +45,8 @@ public:
static u16* GetPointIndexBuffer() { return PIBuffer; }
static u8* GetVertexBuffer() { return LocalVBuffer; }
static void DoState(PointerWrap& p);
protected:
// TODO: make private after Flush() is merged
static void ResetBuffer();
@ -55,6 +58,9 @@ protected:
static bool Flushed;
virtual void vDoState(PointerWrap& p) { DoStateShared(p); }
void DoStateShared(PointerWrap& p);
private:
static void AddIndices(int primitive, int numVertices);
//virtual void Draw(u32 stride, bool alphapass) = 0;

View File

@ -26,6 +26,7 @@
#include "PixelEngine.h"
#include "PixelShaderManager.h"
#include "VertexShaderManager.h"
#include "VertexManagerBase.h"
static void DoState(PointerWrap &p)
{
@ -68,6 +69,9 @@ static void DoState(PointerWrap &p)
VertexShaderManager::DoState(p);
p.DoMarker("VertexShaderManager");
VertexManager::DoState(p);
p.DoMarker("VertexManager");
// TODO: search for more data that should be saved and add it here
}