Improve VideoSoftware save states. They are fairly stable, but not perfect. OpcodeDecoder::DoState() needs to be fixed.

This commit is contained in:
Rachel Bryk 2013-02-25 23:49:24 -05:00
parent 415a2f17c9
commit db838e759b
14 changed files with 138 additions and 14 deletions

View File

@ -65,6 +65,13 @@ namespace Clipper
OutputVertexData ClippedVertices[NUM_CLIPPED_VERTICES];
OutputVertexData *Vertices[NUM_INDICES];
void DoState(PointerWrap &p)
{
p.DoArray(m_ViewOffset,2);
for (int i = 0; i< NUM_CLIPPED_VERTICES; ++i)
ClippedVertices[i].DoState(p);
}
void Init()
{
for (int i = 0; i < NUM_CLIPPED_VERTICES; ++i)

View File

@ -21,6 +21,7 @@
#include "Common.h"
#include "NativeVertexFormat.h"
#include "ChunkFile.h"
namespace Clipper
@ -36,6 +37,8 @@ namespace Clipper
bool CullTest(OutputVertexData *v0, OutputVertexData *v1, OutputVertexData *v2, bool &backface);
void PerspectiveDivide(OutputVertexData *vertex);
void DoState(PointerWrap &p);
}

View File

@ -19,6 +19,7 @@
#define _NATIVEVERTEXFORMAT_H
#include "Vec3.h"
#include "ChunkFile.h"
#ifdef WIN32
#define LOADERDECL __cdecl
@ -92,6 +93,18 @@ struct OutputVertexData
#undef LINTERP
#undef LINTERP_INT
}
void DoState(PointerWrap &p)
{
mvPosition.DoState(p);
p.Do(projectedPosition);
screenPosition.DoState(p);
for (int i = 0; i < 3;++i)
normal[i].DoState(p);
p.DoArray(color, sizeof color);
for (int i = 0; i < 8;++i)
texCoords[i].DoState(p);
}
};
#endif

View File

@ -35,7 +35,6 @@ typedef void (*DecodingFunction)(u32);
namespace OpcodeDecoder
{
static DecodingFunction currentFunction = NULL;
static u32 minCommandSize;
static u16 streamSize;
@ -49,12 +48,15 @@ static u8 lastPrimCmd;
void DoState(PointerWrap &p)
{
p.Do(minCommandSize);
vertexLoader.DoState(p);
p.Do(streamSize);
p.Do(streamAddress);
// Not sure what is wrong with this. Something(s) in here is causing dolphin to crash/hang when loading states saved from another run of dolphin. Doesn't seem too important anyway...
//vertexLoader.DoState(p);
p.Do(readOpcode);
p.Do(inObjectStream);
p.Do(lastPrimCmd);
p.Do(streamSize);
p.Do(streamAddress);
// not sure how to save this... It seems to be the only thing left that is really important.
// uncommenting this will prevent all error messages, and any crashes/hangs on load, but then obviously it'll segfault once you restart dolphin.
//p.Do(currentFunction);
}

View File

@ -62,6 +62,28 @@ s32 scissorBottom = 0;
Tev tev;
RasterBlock rasterBlock;
void DoState(PointerWrap &p)
{
ZSlope.DoState(p);
WSlope.DoState(p);
for (int i=0;i<2;++i)
for (int n=0; n<4; ++n)
ColorSlopes[i][n].DoState(p);
for (int i=0;i<8;++i)
for (int n=0; n<3; ++n)
TexSlopes[i][n].DoState(p);
p.Do(vertex0X);
p.Do(vertex0Y);
p.Do(vertexOffsetX);
p.Do(vertexOffsetY);
p.Do(scissorLeft);
p.Do(scissorTop);
p.Do(scissorRight);
p.Do(scissorBottom);
tev.DoState(p);
p.Do(rasterBlock);
}
void Init()
{
tev.Init();

View File

@ -19,6 +19,7 @@
#define _RASTERIZER_H_
#include "NativeVertexFormat.h"
#include "ChunkFile.h"
namespace Rasterizer
{
@ -37,6 +38,12 @@ namespace Rasterizer
float f0;
float GetValue(float dx, float dy) { return f0 + (dfdx * dx) + (dfdy * dy); }
void DoState(PointerWrap &p)
{
p.Do(dfdx);
p.Do(dfdy);
p.Do(f0);
}
};
struct RasterBlockPixel
@ -53,6 +60,8 @@ namespace Rasterizer
s32 TextureLod[16];
bool TextureLinear[16];
};
void DoState(PointerWrap &p);
}

View File

@ -57,11 +57,15 @@ CPReg cpreg; // shared between gfx and emulator thread
void DoState(PointerWrap &p)
{
p.Do(cpreg);
p.DoArray(commandBuffer, commandBufferSize);
p.Do(readPos);
p.Do(writePos);
p.Do(et_UpdateInterrupts);
p.Do(interruptSet);
p.Do(interruptWaiting);
// Is this right?
p.DoArray(g_pVideoData,writePos);
}
// does it matter that there is no synchronization between threads during writes?

View File

@ -53,6 +53,8 @@ void DoState(PointerWrap &p)
p.Do(pereg);
p.Do(g_bSignalTokenInterrupt);
p.Do(g_bSignalFinishInterrupt);
p.Do(et_SetTokenOnMainThread);
p.Do(et_SetFinishOnMainThread);
}
void UpdateInterrupts();

View File

@ -332,7 +332,7 @@ void SWVertexLoader::DoState(PointerWrap &p)
{
p.DoArray(m_AttributeLoaders, sizeof m_AttributeLoaders);
p.Do(m_VertexSize);
p.Do(m_CurrentVat);
p.Do(*m_CurrentVat);
p.Do(m_positionLoader);
p.Do(m_normalLoader);
p.DoArray(m_colorLoader, sizeof m_colorLoader);

View File

@ -102,6 +102,19 @@ void VideoSoftware::DoState(PointerWrap& p)
SWPixelEngine::DoState(p);
EfbInterface::DoState(p);
OpcodeDecoder::DoState(p);
Clipper::DoState(p);
p.Do(swxfregs);
p.Do(bpmem);
// CP Memory
p.DoArray(arraybases, 16);
p.DoArray(arraystrides, 16);
p.Do(MatrixIndexA);
p.Do(MatrixIndexB);
p.Do(g_VtxDesc.Hex);
p.DoArray(g_VtxAttr, 8);
p.DoMarker("CP Memory");
}
void VideoSoftware::CheckInvalidState()

View File

@ -25,13 +25,13 @@
void SetupUnit::Init(u8 primitiveType)
{
m_PrimType = primitiveType;
m_PrimType = primitiveType;
m_VertexCounter = 0;
m_VertPointer[0] = &m_Vertices[0];
m_VertPointer[1] = &m_Vertices[1];
m_VertPointer[2] = &m_Vertices[2];
m_VertWritePointer = m_VertPointer[0];
m_VertexCounter = 0;
m_VertPointer[0] = &m_Vertices[0];
m_VertPointer[1] = &m_Vertices[1];
m_VertPointer[2] = &m_Vertices[2];
m_VertWritePointer = m_VertPointer[0];
}
void SetupUnit::SetupVertex()
@ -172,7 +172,18 @@ void SetupUnit::SetupPoint()
void SetupUnit::DoState(PointerWrap &p)
{
p.Do(m_PrimType);
// TODO: some or all of this is making the save states stop working once dolphin is closed...sometimes (usually)
// I have no idea what specifically is wrong, or if this is even important. Disabling it doesn't seem to make any noticible difference...
/* p.Do(m_PrimType);
p.Do(m_VertexCounter);
p.DoArray(m_Vertices, sizeof m_Vertices);
}
for (int i = 0; i < 3; ++i)
m_Vertices[i].DoState(p);
if (p.GetMode() == PointerWrap::MODE_READ)
{
m_VertPointer[0] = &m_Vertices[0];
m_VertPointer[1] = &m_Vertices[1];
m_VertPointer[2] = &m_Vertices[2];
m_VertWritePointer = m_VertPointer[0];
}*/
}

View File

@ -827,3 +827,31 @@ void Tev::SetRegColor(int reg, int comp, bool konst, s16 color)
Reg[reg][comp] = color;
}
}
void Tev::DoState(PointerWrap &p)
{
p.DoArray(Reg, sizeof(Reg));
p.DoArray(KonstantColors, sizeof(KonstantColors));
p.DoArray(TexColor,4);
p.DoArray(RasColor,4);
p.DoArray(StageKonst,4);
p.DoArray(Zero16,4);
p.DoArray(FixedConstants,9);
p.Do(AlphaBump);
p.DoArray(IndirectTex, sizeof(IndirectTex));
p.Do(TexCoord);
p.DoArray(m_BiasLUT,4);
p.DoArray(m_ScaleLShiftLUT,4);
p.DoArray(m_ScaleRShiftLUT,4);
p.DoArray(Position,3);
p.DoArray(Color, sizeof(Color));
p.DoArray(Uv, 8);
p.DoArray(IndirectLod,4);
p.DoArray(IndirectLinear,4);
p.DoArray(TextureLod,16);
p.DoArray(TextureLinear,16);
}

View File

@ -19,6 +19,7 @@
#define _TEV_H_
#include "BPMemLoader.h"
#include "ChunkFile.h"
class Tev
{
@ -96,6 +97,8 @@ public:
void SetRegColor(int reg, int comp, bool konst, s16 color);
enum { ALP_C, BLU_C, GRN_C, RED_C };
void DoState(PointerWrap &p);
};
#endif

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <math.h>
#include "ChunkFile.h"
class Vec3
{
@ -111,6 +112,12 @@ public:
{
memset((void *)this,0,sizeof(float)*3);
}
void DoState(PointerWrap &p)
{
p.Do(x);
p.Do(y);
p.Do(z);
}
};
#endif