Run graphics rendering on a dedicated thread.

The main game thread can offload some of the CPU cost to the rendering thread, freeing up its time to run more logic and render ticks.
This commit is contained in:
RoosterDragon
2018-05-26 18:18:13 +01:00
committed by Paul Chote
parent 8ec90525e3
commit b96e062a0d
14 changed files with 875 additions and 48 deletions

View File

@@ -51,7 +51,7 @@ namespace OpenRA
{
var resolution = GetResolution(graphicSettings);
Device = platform.CreateGraphics(new Size(resolution.Width, resolution.Height), graphicSettings.Mode);
Device = platform.CreateGraphics(new Size(resolution.Width, resolution.Height), graphicSettings.Mode, graphicSettings.BatchSize);
TempBufferSize = graphicSettings.BatchSize;
SheetSize = graphicSettings.SheetSize;
@@ -92,8 +92,11 @@ namespace OpenRA
Device.OnWindowScaleChanged += (before, after) =>
{
foreach (var f in Fonts)
f.Value.SetScale(after);
Game.RunAfterTick(() =>
{
foreach (var f in Fonts)
f.Value.SetScale(after);
});
};
}
@@ -264,7 +267,6 @@ namespace OpenRA
public void Dispose()
{
Device.Dispose();
WorldModelRenderer.Dispose();
tempBuffer.Dispose();
if (fontSheetBuilder != null)
@@ -272,6 +274,7 @@ namespace OpenRA
if (Fonts != null)
foreach (var font in Fonts.Values)
font.Dispose();
Device.Dispose();
}
public string GetClipboardText()