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

@ -172,7 +172,16 @@ public:
void Do(T &x) { void Do(T &x) {
DoVoid((void *)&x, sizeof(x)); 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*)> 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) 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.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size); p.Do(size);
int pos = (int)(g_pVideoData - videoBuffer); // get offset p.DoPointer(g_pVideoData, videoBuffer);
p.Do(pos); // read or write offset (depending on the mode) p.Do(g_bSkipCurrentFrame);
if (p.GetMode() == PointerWrap::MODE_READ)
{
g_pVideoData = &videoBuffer[pos];
g_bSkipCurrentFrame = false;
}
} }
void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock) void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)

View File

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

View File

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