From 415a2f17c95db405309d9d259134a40f21a3582d Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Mon, 25 Feb 2013 20:05:02 -0500 Subject: [PATCH 1/4] Begin implementing save states to video software. Kind of works, sometimes. --- .../Plugin_VideoSoftware/Src/EfbInterface.cpp | 7 +++++++ .../Plugins/Plugin_VideoSoftware/Src/EfbInterface.h | 1 + .../Plugin_VideoSoftware/Src/OpcodeDecoder.cpp | 12 ++++++++++++ .../Plugin_VideoSoftware/Src/OpcodeDecoder.h | 3 +++ .../Plugin_VideoSoftware/Src/SWCommandProcessor.cpp | 5 +++++ .../Plugin_VideoSoftware/Src/SWVertexLoader.cpp | 13 ++++++++++++- .../Plugin_VideoSoftware/Src/SWVertexLoader.h | 3 ++- Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp | 10 ++++++++-- .../Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp | 7 +++++++ Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.h | 2 ++ 10 files changed, 59 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.cpp index 6722ec7935..8fdc0425a4 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.cpp @@ -28,6 +28,7 @@ u8 efb[EFB_WIDTH*EFB_HEIGHT*6]; namespace EfbInterface { + u8 efbColorTexture[EFB_WIDTH*EFB_HEIGHT*4]; inline u32 GetColorOffset(u16 x, u16 y) @@ -40,6 +41,12 @@ namespace EfbInterface return (x + y * EFB_WIDTH) * 3 + DEPTH_BUFFER_START; } + void DoState(PointerWrap &p) + { + p.DoArray(efb, EFB_WIDTH*EFB_HEIGHT*6); + p.DoArray(efbColorTexture, EFB_WIDTH*EFB_HEIGHT*4); + } + void SetPixelAlphaOnly(u32 offset, u8 a) { switch (bpmem.zcontrol.pixel_format) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.h b/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.h index 15d19e7783..fdad69567c 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/EfbInterface.h @@ -47,6 +47,7 @@ namespace EfbInterface void UpdateColorTexture(); extern u8 efbColorTexture[EFB_WIDTH*EFB_HEIGHT*4]; // RGBA format + void DoState(PointerWrap &p); } #endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp index 0091e4eaca..396a5a54af 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp @@ -46,6 +46,18 @@ static bool inObjectStream; static u8 lastPrimCmd; +void DoState(PointerWrap &p) +{ + p.Do(minCommandSize); + vertexLoader.DoState(p); + p.Do(streamSize); + p.Do(streamAddress); + p.Do(readOpcode); + p.Do(inObjectStream); + p.Do(lastPrimCmd); + //p.Do(currentFunction); +} + void DecodePrimitiveStream(u32 iBufferSize) { u32 vertexSize = vertexLoader.GetVertexSize(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h index 635fcc24ee..53715b2832 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h @@ -20,6 +20,7 @@ #define _OPCODEDECODER_H_ #include "CommonTypes.h" +#include "ChunkFile.h" namespace OpcodeDecoder { @@ -57,6 +58,8 @@ namespace OpcodeDecoder bool CommandRunnable(u32 iBufferSize); void Run(u32 iBufferSize); + + void DoState(PointerWrap &p); } #endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp index b9afc1abb5..97a99ff710 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp @@ -57,6 +57,11 @@ CPReg cpreg; // shared between gfx and emulator thread void DoState(PointerWrap &p) { p.Do(cpreg); + p.Do(readPos); + p.Do(writePos); + p.Do(et_UpdateInterrupts); + p.Do(interruptSet); + p.Do(interruptWaiting); } // does it matter that there is no synchronization between threads during writes? diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp index cc5ee66772..3142fc4262 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp @@ -328,4 +328,15 @@ void SWVertexLoader::LoadTexCoord(SWVertexLoader *vertexLoader, InputVertexData vertexLoader->m_texCoordLoader[index](); } - +void SWVertexLoader::DoState(PointerWrap &p) +{ + p.DoArray(m_AttributeLoaders, sizeof m_AttributeLoaders); + p.Do(m_VertexSize); + p.Do(m_CurrentVat); + p.Do(m_positionLoader); + p.Do(m_normalLoader); + p.DoArray(m_colorLoader, sizeof m_colorLoader); + p.Do(m_NumAttributeLoaders); + m_SetupUnit->DoState(p); + p.Do(m_TexGenSpecialCase); +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.h b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.h index 91a0d8e911..e05346a7a5 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.h @@ -22,6 +22,7 @@ #include "NativeVertexFormat.h" #include "CPMemLoader.h" +#include "ChunkFile.h" class SetupUnit; @@ -69,7 +70,7 @@ public: u32 GetVertexSize() { return m_VertexSize; } void LoadVertex(); - + void DoState(PointerWrap &p); }; #endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index 332e83d0e8..096315af4e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -39,6 +39,8 @@ #include "FileUtil.h" #include "VideoBackend.h" #include "Core.h" +#include "OpcodeDecoder.h" +#include "SWVertexLoader.h" #define VSYNC_ENABLED 0 @@ -93,9 +95,13 @@ bool VideoSoftware::Initialize(void *&window_handle) return true; } -void VideoSoftware::DoState(PointerWrap&) +void VideoSoftware::DoState(PointerWrap& p) { - // NYI + // TODO: incomplete + SWCommandProcessor::DoState(p); + SWPixelEngine::DoState(p); + EfbInterface::DoState(p); + OpcodeDecoder::DoState(p); } void VideoSoftware::CheckInvalidState() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp index 6e0fab57d8..57d69af7bd 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp @@ -169,3 +169,10 @@ void SetupUnit::SetupLineStrip() void SetupUnit::SetupPoint() {} + +void SetupUnit::DoState(PointerWrap &p) +{ + p.Do(m_PrimType); + p.Do(m_VertexCounter); + p.DoArray(m_Vertices, sizeof m_Vertices); +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.h b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.h index 45a575afcb..f337de21a2 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.h @@ -21,6 +21,7 @@ #include "Common.h" #include "NativeVertexFormat.h" +#include "ChunkFile.h" class SetupUnit { @@ -45,6 +46,7 @@ public: OutputVertexData* GetVertex() { return m_VertWritePointer; } void SetupVertex(); + void DoState(PointerWrap &p); }; #endif From db838e759b8935e213fa225be88ac0bfc78c27f7 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Mon, 25 Feb 2013 23:49:24 -0500 Subject: [PATCH 2/4] Improve VideoSoftware save states. They are fairly stable, but not perfect. OpcodeDecoder::DoState() needs to be fixed. --- .../Plugin_VideoSoftware/Src/Clipper.cpp | 7 +++++ .../Plugin_VideoSoftware/Src/Clipper.h | 3 ++ .../Src/NativeVertexFormat.h | 13 +++++++++ .../Src/OpcodeDecoder.cpp | 10 ++++--- .../Plugin_VideoSoftware/Src/Rasterizer.cpp | 22 ++++++++++++++ .../Plugin_VideoSoftware/Src/Rasterizer.h | 9 ++++++ .../Src/SWCommandProcessor.cpp | 4 +++ .../Src/SWPixelEngine.cpp | 2 ++ .../Src/SWVertexLoader.cpp | 2 +- .../Plugin_VideoSoftware/Src/SWmain.cpp | 13 +++++++++ .../Plugin_VideoSoftware/Src/SetupUnit.cpp | 29 +++++++++++++------ .../Plugins/Plugin_VideoSoftware/Src/Tev.cpp | 28 ++++++++++++++++++ Source/Plugins/Plugin_VideoSoftware/Src/Tev.h | 3 ++ .../Plugins/Plugin_VideoSoftware/Src/Vec3.h | 7 +++++ 14 files changed, 138 insertions(+), 14 deletions(-) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp index e9a3525d84..c4755b50bf 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp @@ -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) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.h b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.h index 5e5dd4d02c..babc8b4e88 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.h @@ -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); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexFormat.h b/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexFormat.h index d19844105f..e2d87e207e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexFormat.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexFormat.h @@ -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 diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp index 396a5a54af..4401916e1f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp @@ -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); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp index 225400e08b..5eed912dcb 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp @@ -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(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.h b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.h index f8850571a9..784c4a8d62 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.h @@ -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); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp index 97a99ff710..c15a02f93e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp @@ -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? diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp index 33a6164b01..e9d2c1fe96 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp @@ -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(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp index 3142fc4262..1c1eeb2005 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp @@ -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); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index 096315af4e..d78b8ba13b 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -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() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp index 57d69af7bd..d2185e31d5 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SetupUnit.cpp @@ -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); -} \ No newline at end of file + 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]; + }*/ +} diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp index 927f8931e9..0f4b4fce20 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp @@ -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); +} diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h index bdd265170c..1d1bc8d2ba 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h @@ -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 diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Vec3.h b/Source/Plugins/Plugin_VideoSoftware/Src/Vec3.h index 3a36a13307..80460edd60 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Vec3.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Vec3.h @@ -20,6 +20,7 @@ #include #include +#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 From 08fe3c213ad71e903fed83edfada5a79c75f11f9 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Tue, 26 Feb 2013 18:28:56 -0500 Subject: [PATCH 3/4] Abort loading states from incompatible graphics backends. --- Source/Core/Core/Src/State.cpp | 2 +- Source/Core/VideoCommon/Src/MainBase.cpp | 5 +++++ Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 0facf2f387..773d757337 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent; static std::thread g_save_thread; // Don't forget to increase this after doing changes on the savestate system -static const u32 STATE_VERSION = 14; +static const u32 STATE_VERSION = 15; struct StateHeader { diff --git a/Source/Core/VideoCommon/Src/MainBase.cpp b/Source/Core/VideoCommon/Src/MainBase.cpp index 726ef71b38..a881bebfb2 100644 --- a/Source/Core/VideoCommon/Src/MainBase.cpp +++ b/Source/Core/VideoCommon/Src/MainBase.cpp @@ -186,6 +186,11 @@ void VideoBackendHardware::InitializeShared() // Run from the CPU thread void VideoBackendHardware::DoState(PointerWrap& p) { + bool software = false; + p.Do(software); + if (p.GetMode() == PointerWrap::MODE_READ && software == true) + // change mode to abort load of incompatible save state. + p.SetMode(PointerWrap::MODE_VERIFY); VideoCommon_DoState(p); p.DoMarker("VideoCommon"); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index d78b8ba13b..6976b18690 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -41,6 +41,7 @@ #include "Core.h" #include "OpcodeDecoder.h" #include "SWVertexLoader.h" +#include "SWStatistics.h" #define VSYNC_ENABLED 0 @@ -97,6 +98,11 @@ bool VideoSoftware::Initialize(void *&window_handle) void VideoSoftware::DoState(PointerWrap& p) { + bool software = true; + p.Do(software); + if (p.GetMode() == PointerWrap::MODE_READ && software == false) + // change mode to abort load of incompatible save state. + p.SetMode(PointerWrap::MODE_VERIFY); // TODO: incomplete SWCommandProcessor::DoState(p); SWPixelEngine::DoState(p); @@ -105,6 +111,7 @@ void VideoSoftware::DoState(PointerWrap& p) Clipper::DoState(p); p.Do(swxfregs); p.Do(bpmem); + p.Do(swstats); // CP Memory p.DoArray(arraybases, 16); From 46f5c19c6d2fbd3318e9a6de3c3c2e313c669cf0 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Tue, 26 Feb 2013 18:43:37 -0500 Subject: [PATCH 4/4] Not sure if this is the right way to handle this, but it makes the save states perfectly stable. That's all that really matters, right? --- Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp | 5 ++--- Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp index 4401916e1f..8e3f0c2925 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp @@ -55,9 +55,8 @@ void DoState(PointerWrap &p) 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); + if (p.GetMode() == PointerWrap::MODE_READ) + ResetDecoding(); } void DecodePrimitiveStream(u32 iBufferSize) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index 6976b18690..0e2d6afa72 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -103,7 +103,8 @@ void VideoSoftware::DoState(PointerWrap& p) if (p.GetMode() == PointerWrap::MODE_READ && software == false) // change mode to abort load of incompatible save state. p.SetMode(PointerWrap::MODE_VERIFY); - // TODO: incomplete + + // TODO: incomplete? SWCommandProcessor::DoState(p); SWPixelEngine::DoState(p); EfbInterface::DoState(p);