aboutsummaryrefslogtreecommitdiff
path: root/src/GPU3D.h
diff options
context:
space:
mode:
authorJesse Talavera <jesse@jesse.tg>2024-01-07 17:39:43 -0500
committerGitHub <noreply@github.com>2024-01-07 23:39:43 +0100
commit8143f549566029f366b774d0722c5f16011b9b56 (patch)
treee097c2bdd11f852a0886c1861c9c70c896a0d371 /src/GPU3D.h
parentf68f55d002c412ead4e0ce88dd48b11d6f7900e3 (diff)
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 commit 2f49a551c13934b9dc815bbda67a45098f0482a7. * 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 commit 1977566a6d8671d72bd94ba4ebf832c3bf08933a. * 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
Diffstat (limited to 'src/GPU3D.h')
-rw-r--r--src/GPU3D.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/GPU3D.h b/src/GPU3D.h
index 7c42eeb..4a5fe6e 100644
--- a/src/GPU3D.h
+++ b/src/GPU3D.h
@@ -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