mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 07:39:56 -06:00
Protect savestates while the threaded software renderer is running (#1864)
* First crack at ensuring the render thread doesn't touch GPU state while it's being serialized * Get rid of the semaphore wait * Add some extra fields into GPU3D's serialization * Oops, TempVertexBuffer is already serialized * Move vertex serialization into its own method * Lock the GPU3D state when rendering on the render thread or serializing it * Revert "Lock the GPU3D state when rendering on the render thread or serializing it" This reverts commit2f49a551c1
. * Add comments that describe the synchronization within GPU3D_Soft - I need to understand it before I can solve my actual problem - Now I do * Revert "Revert "Lock the GPU3D state when rendering on the render thread or serializing it"" This reverts commit1977566a6d
. * Let's try locking the GPU3D state throughout NDS::RunFrame - Just to see what happens * Slim down the lock's scope * Narrow the lock's scope some more * Remove the lock entirely * Try protecting the GPU3D state with just a mutex - I'll clean this up once I know it works * Remove a duplicate method definition * Add a missing `noexcept` specifier * Remove an unused function * Cut some non-hardware state from `GPU3D`'s savestate * Assume that the next frame after loading a savestate won't be identical * Actually, it _is_ worth it * Don't serialize the clip matrix - It's recalculated anyway * Serialize `RenderPolygonRAM` as an array of indexes * Clean up some comments - I liked the dialogue style, but oh well * Try restarting the render thread instead of using the lock - Let's see what happens * Put the lock back * Fix some polygon and vertex indexes being saved incorrectly - Taking the difference between two pointers results in the number of elements, not the number of bytes * Remove `SoftRenderer::StateBusy` since it turns out we don't need it - The real synchronization was the friends we made along the way
This commit is contained in:
@ -47,6 +47,7 @@ struct Vertex
|
||||
// TODO maybe: hi-res color? (that survives clipping)
|
||||
s32 HiresPosition[2];
|
||||
|
||||
void DoSavestate(Savestate* file) noexcept;
|
||||
};
|
||||
|
||||
struct Polygon
|
||||
@ -78,6 +79,7 @@ struct Polygon
|
||||
|
||||
u32 SortKey;
|
||||
|
||||
void DoSavestate(Savestate* file) noexcept;
|
||||
};
|
||||
|
||||
class Renderer3D;
|
||||
@ -269,7 +271,7 @@ public:
|
||||
u32 RenderClearAttr1 = 0;
|
||||
u32 RenderClearAttr2 = 0;
|
||||
|
||||
bool RenderFrameIdentical = false;
|
||||
bool RenderFrameIdentical = false; // not part of the hardware state, don't serialize
|
||||
|
||||
bool AbortFrame = false;
|
||||
|
||||
@ -323,7 +325,7 @@ public:
|
||||
|
||||
u32 FlushRequest = 0;
|
||||
u32 FlushAttributes = 0;
|
||||
u32 ScrolledLine[256];
|
||||
u32 ScrolledLine[256]; // not part of the hardware state, don't serialize
|
||||
};
|
||||
|
||||
class Renderer3D
|
||||
|
Reference in New Issue
Block a user