Skip to content

Commit

Permalink
Optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerfulBacon committed Sep 16, 2023
1 parent 3c287ec commit 20586d0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions CorgEng.Core/CorgEngMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static class CorgEngMain
/// <summary>
/// Render planes that are staged to start rendering
/// </summary>
private static SortedList<int, IRenderer> stagedRenderPlanes = new SortedList<int, IRenderer>();
private static volatile SortedList<int, IRenderer> stagedRenderPlanes = new SortedList<int, IRenderer>();

/// <summary>
/// A sorted list containing the planes that are currently drawing directly to the screen.
Expand Down Expand Up @@ -197,18 +197,21 @@ public static void TransferToRenderingThread()
{
lastFrameTime = Glfw.Time;
// Move the staged rendering planes into the active queue
lock (stagedRenderPlanes)
if (stagedRenderPlanes.Count > 0)
{
foreach (var stagedPlane in stagedRenderPlanes)
lock (stagedRenderPlanes)
{
renderingPlanes.TryAdd(stagedPlane.Key, stagedPlane.Value);
if (!stagedPlane.Value.Initialized)
foreach (var stagedPlane in stagedRenderPlanes)
{
stagedPlane.Value.Initialize();
}
}
stagedRenderPlanes.Clear();
}
renderingPlanes.TryAdd(stagedPlane.Key, stagedPlane.Value);
if (!stagedPlane.Value.Initialized)
{
stagedPlane.Value.Initialize();
}
}
stagedRenderPlanes.Clear();
}
}
//Trigger any render thread code
if (!queuedActions.IsEmpty)
{
Expand Down

0 comments on commit 20586d0

Please sign in to comment.