refactor(render): compose render frame orchestrator
Move the accepted draw transaction and failure recovery behind typed frame-phase owners so GameWindow only supplies immutable frame input. Preserve retail draw order, make ImGui/bootstrap shutdown ownership explicit, and restore exact text-render GL state on failures.\n\nCo-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
28e1cf8029
commit
9d7df1bfc5
25 changed files with 1675 additions and 279 deletions
|
|
@ -7,32 +7,33 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
[Fact]
|
||||
public void ProductionRender_PreservesPrivatePresentationAndCaptureOrder()
|
||||
{
|
||||
string source = GameWindowSource();
|
||||
string presentation = Source("PrivatePresentationRenderer.cs");
|
||||
string orchestrator = Source("RenderFrameOrchestrator.cs");
|
||||
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"_localPlayerTeleport?.DrawPortalViewport(",
|
||||
"_paperdollFramePresenter?.Render();",
|
||||
"_retailUiRuntime.Tick(deltaSeconds);",
|
||||
"_devToolsFramePresenter?.Render(",
|
||||
"_frameScreenshots?.CapturePending() == true;",
|
||||
"_renderFrameDiagnostics?.Publish(");
|
||||
presentation,
|
||||
"_portal.Draw(",
|
||||
"_paperdoll?.Render();",
|
||||
"_gameplayUi?.Render(",
|
||||
"_devTools?.Render(",
|
||||
"_screenshots?.CapturePending(");
|
||||
AssertAppearsInOrder(
|
||||
orchestrator,
|
||||
"_world.Render(input);",
|
||||
"_presentation.Render(input, world);",
|
||||
"_diagnostics.Publish(input, outcome);");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProductionRender_Prepares_resources_then_devtools_weather_and_world()
|
||||
{
|
||||
string source = GameWindowSource();
|
||||
string source = Source("RenderFramePreparationController.cs");
|
||||
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"_renderFrameResources!.Prepare(frameInput);",
|
||||
"_devToolsFramePresenter?.BeginFrame((float)deltaSeconds);",
|
||||
"_renderWeatherFrame!.Tick(deltaSeconds);",
|
||||
"_worldSceneRenderer!.Render(frameInput);");
|
||||
Assert.DoesNotContain("_wbDrawDispatcher?.BeginFrame(", source);
|
||||
Assert.DoesNotContain("_wbMeshAdapter?.Tick();", source);
|
||||
Assert.DoesNotContain("_particleRenderer?.BeginFrame(", source);
|
||||
"_resources.Prepare(input);",
|
||||
"_devTools?.BeginFrame((float)input.DeltaSeconds);",
|
||||
"_weather.Tick(input.DeltaSeconds);");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -46,7 +47,9 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
"_portalTunnel = null;",
|
||||
"_localPlayerTeleportSink.Bind(_localPlayerTeleport);",
|
||||
"new AcDream.App.Rendering.LocalPlayerTeleportRenderStateSource(",
|
||||
"new AcDream.App.Rendering.RenderFrameResourceController(");
|
||||
"new AcDream.App.Rendering.RenderFrameResourceController(",
|
||||
"new AcDream.App.Rendering.PrivatePresentationRenderer(",
|
||||
"new AcDream.App.Rendering.RenderFrameOrchestrator(");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -78,6 +81,13 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
"ApplyFramePacingPreference",
|
||||
"RefreshActiveMonitorFramePacing",
|
||||
"private void OnFrameRendered(",
|
||||
"private AcDream.App.Rendering.WorldRenderDiagnostics? _worldRenderDiagnostics",
|
||||
"private AcDream.App.Rendering.WorldRenderFrameBuilder?",
|
||||
"private AcDream.App.Rendering.SkyPesFrameController?",
|
||||
"private AcDream.App.Rendering.RetailPViewRenderer?",
|
||||
"private AcDream.App.Rendering.RetailPViewPassExecutor?",
|
||||
"private AcDream.App.Rendering.RetailPViewCellSource?",
|
||||
"private AcDream.App.Rendering.TerrainDrawDiagnosticsController?",
|
||||
];
|
||||
foreach (string identifier in removed)
|
||||
Assert.DoesNotContain(identifier, source, StringComparison.Ordinal);
|
||||
|
|
@ -86,6 +96,8 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
Assert.Contains("new AcDream.App.Rendering.DevToolsFramePresenter(", source);
|
||||
Assert.Contains("new AcDream.App.Rendering.RenderFrameResourceController(", source);
|
||||
Assert.Contains("new AcDream.App.Rendering.RenderWeatherFrameController(", source);
|
||||
Assert.Contains("new AcDream.App.Rendering.PrivatePresentationRenderer(", source);
|
||||
Assert.Contains("new AcDream.App.Rendering.RenderFrameOrchestrator(", source);
|
||||
Assert.Contains("new DisplayFramePacingController(", source);
|
||||
Assert.Contains("_inputCapture.WantCaptureMouse", source);
|
||||
}
|
||||
|
|
@ -99,40 +111,70 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
source,
|
||||
"new ResourceShutdownStage(\"submitted GPU work\"",
|
||||
"new ResourceShutdownStage(\"render frontends\"",
|
||||
"new(\"frame composition\"",
|
||||
"new(\"developer tools\"",
|
||||
"_devToolsBackend?.Dispose()",
|
||||
"new(\"portal tunnel\"",
|
||||
"new(\"paperdoll viewport\"",
|
||||
"new ResourceShutdownStage(\"OpenGL context\"");
|
||||
Assert.Contains("_renderFrameResources = null;", source);
|
||||
Assert.Contains("_renderFrameLivePreparation = null;", source);
|
||||
Assert.Contains("_renderWeatherFrame = null;", source);
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"new ResourceShutdownStage(\"frame borrowers\"",
|
||||
"_retailPViewPassExecutor = null;",
|
||||
"_retailPViewCells = null;",
|
||||
"_terrainDrawDiagnostics = null;",
|
||||
"_retailPViewRenderer = null;",
|
||||
"_renderFrameOrchestrator = null;",
|
||||
"new ResourceShutdownStage(\"session dependents\"");
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"new(\"frame pacing\", _displayFramePacing.Dispose)",
|
||||
"new(\"frame profiler\", _frameProfiler.Dispose)");
|
||||
Assert.DoesNotContain("_devToolsBackend?.Dispose()", source);
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"_renderFrameOrchestrator = null;",
|
||||
"_devToolsBackend?.Dispose()",
|
||||
"new ResourceShutdownStage(\"input\"",
|
||||
"_input?.Dispose();",
|
||||
"new ResourceShutdownStage(\"OpenGL context\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProductionOutcome_UsesObservedWorldAndScreenshotFacts()
|
||||
{
|
||||
string source = GameWindowSource();
|
||||
string presentation = Source("PrivatePresentationRenderer.cs");
|
||||
string orchestrator = Source("RenderFrameOrchestrator.cs");
|
||||
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"_worldSceneRenderer!.Render(frameInput);",
|
||||
"worldOutcome.NormalWorldDrawn;",
|
||||
"bool screenshotCaptured = _frameScreenshots?.CapturePending() == true;",
|
||||
"normalWorldDrawn),",
|
||||
"screenshotCaptured)));");
|
||||
presentation,
|
||||
"_foundation.Foundation.PortalViewportVisible;",
|
||||
"_portal.Draw(",
|
||||
"bool screenshotCaptured = _screenshots?.CapturePending(",
|
||||
"portalViewportVisible,",
|
||||
"screenshotCaptured);");
|
||||
AssertAppearsInOrder(
|
||||
orchestrator,
|
||||
"WorldRenderFrameOutcome world = _world.Render(input);",
|
||||
"_presentation.Render(input, world);",
|
||||
"new RenderFrameOutcome(world, presentation);",
|
||||
"_diagnostics.Publish(input, outcome);");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GameWindow_OnRenderIsOneImmutableOrchestratorHandoff()
|
||||
{
|
||||
string source = GameWindowSource();
|
||||
int start = source.IndexOf(
|
||||
"private void OnRender(double deltaSeconds)",
|
||||
StringComparison.Ordinal);
|
||||
int end = source.IndexOf(
|
||||
"private AcDream.App.Diagnostics.WorldLifecycleResourceSnapshot",
|
||||
start,
|
||||
StringComparison.Ordinal);
|
||||
Assert.True(start >= 0 && end > start);
|
||||
string body = source[start..end];
|
||||
|
||||
Assert.Equal(1, CountOccurrences(body, "_renderFrameOrchestrator!.Render("));
|
||||
Assert.DoesNotContain("_gpuFrameFlights", body);
|
||||
Assert.DoesNotContain("_worldScene", body);
|
||||
Assert.DoesNotContain("_devToolsFramePresenter", body);
|
||||
Assert.DoesNotContain("_retailUiRuntime", body);
|
||||
Assert.DoesNotContain("_frameScreenshots", body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -168,6 +210,25 @@ public sealed class GameWindowRenderLeafCompositionTests
|
|||
"Rendering",
|
||||
"GameWindow.cs"));
|
||||
|
||||
private static string Source(string fileName) => File.ReadAllText(Path.Combine(
|
||||
FindRepoRoot(),
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
fileName));
|
||||
|
||||
private static int CountOccurrences(string source, string value)
|
||||
{
|
||||
int count = 0;
|
||||
int cursor = 0;
|
||||
while ((cursor = source.IndexOf(value, cursor, StringComparison.Ordinal)) >= 0)
|
||||
{
|
||||
count++;
|
||||
cursor += value.Length;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static void AssertAppearsInOrder(string source, params string[] needles)
|
||||
{
|
||||
int cursor = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue