Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
RenderStateSynchronization.cs
1namespace Gondwana.Rendering;
2
9internal static class RenderStateSynchronization
10{
11 private static readonly ManualResetEventSlim NoPendingGpuRenderers = new(initialState: true);
12 private static int _pendingGpuRenderers;
13
14 internal static object SyncRoot { get; } = new();
15
16 internal static bool HasPendingGpuRenderers =>
17 Volatile.Read(ref _pendingGpuRenderers) > 0;
18
24 internal static void WaitForPendingGpuRenderers()
25 {
26 while (Volatile.Read(ref _pendingGpuRenderers) > 0)
27 NoPendingGpuRenderers.Wait();
28 }
29
33 internal static void EnterGpuRender()
34 {
35 if (Interlocked.Increment(ref _pendingGpuRenderers) == 1)
36 NoPendingGpuRenderers.Reset();
37
38 Monitor.Enter(SyncRoot);
39
40 if (Interlocked.Decrement(ref _pendingGpuRenderers) == 0)
41 NoPendingGpuRenderers.Set();
42 }
43
47 internal static void ExitGpuRender() => Monitor.Exit(SyncRoot);
48}