Vulkan is the sole, user-signed-off backend (V10 landed) and step 1 already removed ImGui/Studio/DevTools. This step deletes the GL rendering backend itself: every Gpu/Gl/** implementation, the Wb ManagedGL*/GLHelpers/GLSLShader/GLStateScope/RenderStateCache/ BindlessSupport family, Shader/ShaderProgramConstruction/SamplerCache, RenderBootstrap, and RenderFrameGlStateController. GameWindow.cs's Run()/CreateGraphics()/CreateBackbufferReader()/ OnLoad() collapse to their Vulkan-only arm; GameWindowGraphics loses its OpenGlGameWindowGraphics subclass. RuntimeOptions.RenderBackend and RenderBackendKind (incl. the Gl member of GpuBackendKind) are gone — there is nothing left to select between. The five world-draw dual-arm renderers (WbDrawDispatcher, EnvCellRenderer, TerrainModernRenderer, ParticleRenderer, SkyRenderer) and the composition roots (WorldRenderComposition, HostInputCameraComposition, LivePresentationComposition, FrameRootComposition) collapse to their RHI-only arm. GL-only diagnostic properties with a live external reader (DynamicBufferCount and friends) simplify to a documented `=> 0`/no-op rather than disappearing, since the reader is out of this commit's scope. A few GL-flavored mechanisms turned out to be backend-neutral once isolated: GlConstructionCleanupLedger is renamed ResourceConstructionCleanupLedger (exception-chain walking has nothing to do with GL), and GlfwNativePlatformProbe moved out of the otherwise GL-only GraphicalCapabilityRecord.cs into GraphicalWindowBackendSelection.cs before the rest of that file was deleted. Test files with no surviving subject are deleted outright (GraphicalCapabilityRequirementsTests, ShaderProgramConstructionTests, PortalDepthShaderParityTests, TextureCacheBindlessTests, TextRendererFailureSafetyTests, ClipFrameUploadTests, every Gpu/Gl/*Tests, GlTextureOwnershipTests, RenderFrameGlStateControllerTests); others get their dead GL-only members trimmed while their live assertions stay (ClipFrameLayoutTests' MeshClipSsboBinding check now reads GpuBindingModel.StorageClipRegions, the same binding index under its new backend-neutral name; GpuResourceRetirementTransactionTests drops its OpenGLGraphicsDevice-subclassing test double and the two GL queue tests it existed for). EnvCellRendererTests' construction helper now builds a real ObjectMeshManager via VulkanMeshPipelineDevice instead of passing null through a null-forgiving operator, since the RHI constructor never tolerated a null mesh manager and the old GL constructor (which did) is gone. Deferred to the next two steps, deliberately not touched here: the Silk.NET.OpenGL/.Extensions.ARB package references, IMeshPipelineDevice.Gl (WbMeshAdapter's GL? threading stays in place), Chorizite.Core's stale csproj comment (the package itself is still load-bearing — TextureFormat and friends are used well beyond the deleted ManagedGLUniformBuffer), and the CI/gate scripts. Build: `dotnet build AcDream.slnx -c Release` — 0 warnings, 0 errors. Tests: full-solution `dotnet test` green across every project (App.Tests 3937/3940 + 3 skips, Core.Tests 3296/3298 + 2 skips, all others 100%); the 2 App.Tests names that flake under full-suite parallel execution (#250-family, documented pre-existing) pass in isolation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
303 lines
11 KiB
C#
303 lines
11 KiB
C#
using AcDream.App.Rendering;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
public sealed class GameWindowRenderLeafCompositionTests
|
|
{
|
|
[Fact]
|
|
public void ProductionRender_PreservesPrivatePresentationAndCaptureOrder()
|
|
{
|
|
string presentation = Source("PrivatePresentationRenderer.cs");
|
|
string orchestrator = Source("RenderFrameOrchestrator.cs");
|
|
|
|
AssertAppearsInOrder(
|
|
presentation,
|
|
"_portal.Draw(",
|
|
"_entityViewports?.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 = Source("RenderFramePreparationController.cs");
|
|
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"_resources.Prepare(input);",
|
|
"_devTools?.BeginFrame((float)input.DeltaSeconds);",
|
|
"_weather.Tick(input.DeltaSeconds);");
|
|
}
|
|
|
|
[Fact]
|
|
public void Composition_transfers_portal_tunnel_before_constructing_frame_borrowers()
|
|
{
|
|
string phase = File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"SessionPlayerComposition.cs"));
|
|
string source = GameWindowSource();
|
|
string framePhase = FrameRootSource();
|
|
|
|
AssertAppearsInOrder(
|
|
phase,
|
|
"d.PortalTunnelFallback.Transfer(",
|
|
"new LocalPlayerTeleportController(",
|
|
"new LocalPlayerTeleportPresentation(portalTunnel)",
|
|
"d.TeleportSink.BindOwned(localTeleport)",
|
|
"_publication.PublishSessionPlayer(result);");
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"new SessionPlayerCompositionPhase(",
|
|
"new FrameRootCompositionPhase(");
|
|
AssertAppearsInOrder(
|
|
framePhase,
|
|
"new LocalPlayerTeleportRenderStateSource(",
|
|
"new RenderFrameResourceController(",
|
|
"new PrivatePresentationRenderer(",
|
|
"new RenderFrameOrchestrator(");
|
|
}
|
|
|
|
[Fact]
|
|
public void ProductionComposition_RemovesLegacyLeafOwnership()
|
|
{
|
|
string source = GameWindowSource();
|
|
|
|
string[] removed =
|
|
[
|
|
"_imguiBootstrap",
|
|
"_panelHost",
|
|
"_paperdollDollDirty",
|
|
"RefreshPaperdollDoll",
|
|
"ApplyPaperdollPose",
|
|
"ResolvePaperdollPoseDid",
|
|
"EnumerateDebugPanel",
|
|
"ResetPanelLayout",
|
|
"SetPanelLayout",
|
|
"_lastRenderSignature",
|
|
"private void EmitRenderSignatureIfChanged(",
|
|
"private void EmitRetailPViewDiagnostics(",
|
|
"EmitGlStateTripwireIfChanged();",
|
|
"EmitClipRouteScissorProbe(scissor",
|
|
"_lastVisibleLandblocks",
|
|
"_perfAccum",
|
|
"_entityUploadTiming",
|
|
"_weatherAccum",
|
|
"TryGetLoginWorldCell",
|
|
"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);
|
|
|
|
Assert.Contains("new PaperdollFramePresenter(", LivePresentationSource());
|
|
string framePhase = FrameRootSource();
|
|
Assert.Contains("new RenderFrameResourceController(", framePhase);
|
|
Assert.Contains("new RenderWeatherFrameController(", framePhase);
|
|
Assert.Contains("new PrivatePresentationRenderer(", framePhase);
|
|
Assert.Contains("new RenderFrameOrchestrator(", framePhase);
|
|
Assert.Contains("new DisplayFramePacingController(", source);
|
|
string pointerSource = File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Input",
|
|
"CameraPointerInputController.cs"));
|
|
Assert.Contains("_capture.WantCaptureMouse", pointerSource);
|
|
}
|
|
|
|
[Fact]
|
|
public void Shutdown_DrainsGpuBeforeFrontendsAndPreservesFrameBorrowerOrder()
|
|
{
|
|
// Campaign V slice V11 removed the ImGui developer-tools frontend and
|
|
// its "developer tools" shutdown stage entry along with it; this test
|
|
// used to pin that entry's position and is now renamed to pin what
|
|
// survives it.
|
|
string source = GameWindowLifetimeSource();
|
|
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"new ResourceShutdownStage(\"submitted GPU work\"",
|
|
"new ResourceShutdownStage(\"render frontends\"",
|
|
"Hard(\"portal tunnel\"",
|
|
"Hard(\"paperdoll viewport\"",
|
|
"new ResourceShutdownStage(\"graphics API context\"");
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"new ResourceShutdownStage(\"frame borrowers\"",
|
|
"frame.FrameGraphPublication?.Dispose()",
|
|
"frame.FrameBindings?.Dispose()",
|
|
"new ResourceShutdownStage(\"session dependents\"");
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"Hard(\"frame pacing\", render.FramePacing.Dispose)",
|
|
"Hard(\"frame profiler\", render.FrameProfiler.Dispose)");
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"frame.FrameGraphPublication?.Dispose()",
|
|
"new ResourceShutdownStage(\"render frontends\"",
|
|
"new ResourceShutdownStage(\"input context\"",
|
|
"platform.Input?.Dispose()",
|
|
"new ResourceShutdownStage(\"graphics API context\"");
|
|
}
|
|
|
|
[Fact]
|
|
public void ProductionOutcome_UsesObservedWorldAndScreenshotFacts()
|
|
{
|
|
string presentation = Source("PrivatePresentationRenderer.cs");
|
|
string orchestrator = Source("RenderFrameOrchestrator.cs");
|
|
|
|
AssertAppearsInOrder(
|
|
presentation,
|
|
"_foundation.Foundation.PortalViewportVisible;",
|
|
"_portal.Draw(",
|
|
"bool screenshotCaptured = _screenshots?.CapturePending(",
|
|
"portalViewportVisible,",
|
|
"screenshotCaptured);");
|
|
AssertAppearsInOrder(
|
|
orchestrator,
|
|
"_gpuMeasurement.BeginFrame();",
|
|
"world = _world.Render(input);",
|
|
"_presentation.Render(input, world);",
|
|
"_gpuMeasurement.EndFrame();",
|
|
"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 void OnFramebufferResize(",
|
|
start,
|
|
StringComparison.Ordinal);
|
|
Assert.True(start >= 0 && end > start);
|
|
string body = source[start..end];
|
|
|
|
Assert.Equal(1, CountOccurrences(body, "_frameGraphs.Render("));
|
|
Assert.DoesNotContain("_gpuFrameFlights", body);
|
|
Assert.DoesNotContain("_worldScene", body);
|
|
Assert.DoesNotContain("_devToolsFramePresenter", body);
|
|
Assert.DoesNotContain("_retailUiRuntime", body);
|
|
Assert.DoesNotContain("_frameScreenshots", body);
|
|
}
|
|
|
|
[Fact]
|
|
public void PaperdollComposition_SkipsEitherMissingOptionalUiSurface()
|
|
{
|
|
string source = LivePresentationSource();
|
|
|
|
AssertAppearsInOrder(
|
|
source,
|
|
"PaperdollViewportWidget is { } viewport",
|
|
"InventoryFrame is { } inventoryFrame",
|
|
"new PaperdollFramePresenter(");
|
|
Assert.DoesNotContain("Paperdoll inventory frame is required.", source);
|
|
}
|
|
|
|
[Fact]
|
|
public void TerrainAndFrameDiagnostics_AreComposedAsOneFocusedOwner()
|
|
{
|
|
string source = FrameRootSource();
|
|
|
|
Assert.Contains(
|
|
"new TerrainDrawDiagnosticsController(",
|
|
source);
|
|
Assert.Contains("new WorldScenePassExecutor(", source);
|
|
Assert.DoesNotContain("_terrainDrawDiagnostics!.Begin();", source);
|
|
Assert.DoesNotContain("_terrainDrawDiagnostics.Complete();", source);
|
|
}
|
|
|
|
private static string GameWindowSource() => File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Rendering",
|
|
"GameWindow.cs"));
|
|
|
|
private static string GameWindowLifetimeSource() => File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Rendering",
|
|
"GameWindowLifetime.cs"));
|
|
|
|
private static string LivePresentationSource() => File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"LivePresentationComposition.cs"));
|
|
|
|
private static string FrameRootSource() => File.ReadAllText(Path.Combine(
|
|
FindRepoRoot(),
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"FrameRootComposition.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;
|
|
foreach (string needle in needles)
|
|
{
|
|
int next = source.IndexOf(needle, cursor + 1, StringComparison.Ordinal);
|
|
Assert.True(next >= 0, $"Missing expected source fragment: {needle}");
|
|
Assert.True(next > cursor, $"Out-of-order source fragment: {needle}");
|
|
cursor = next;
|
|
}
|
|
}
|
|
|
|
private static string FindRepoRoot()
|
|
{
|
|
DirectoryInfo? directory = new(AppContext.BaseDirectory);
|
|
while (directory is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx")))
|
|
return directory.FullName;
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
throw new DirectoryNotFoundException("Could not find AcDream.slnx.");
|
|
}
|
|
}
|