feat(render): Campaign V slice V6h — the Vulkan composition host

ACDREAM_RENDER_BACKEND=vulkan now runs the real GameWindow composition rather
than a second main(). All nine phases execute: DAT load, streaming, camera,
entity table, session, and the real retained UiHost drawing through the RHI.
No world renderers — they are raw GL until V4t and the world arm behind it.

The offline log is the client's own (acdream.pak opened, 6266 spells, Region
0x13000000, "loading world view centered on 0xA9B4FFFF", fourteen retail
LayoutDesc lines, streaming radii), and the captured frame is the retail
retained UI: vitals, combat/spell bar with DAT scarab icons, the nine-slot
toolbar, chat with tabs and Send, radar/compass with dat-font glyphs. Sampled
against the GL capture the widgets agree — chat interior RGBA (25,24,27,158)
vs (22,21,23,158), vitals bar (117,1,0) and toolbar slot (0,11,17) identical.

Three seams, as §5.5.9 specified:

1. Platform acquisition — already generic — publishes GameWindowGraphics
   instead of a bare GL. Phases that still speak raw GL read Graphics.Gl and
   take their Vulkan arm when it is null; each branch names the slice that
   removes it.
2. VulkanHostInputCameraCompositionFactory is a new file and the whole of the
   Phase-1 fork: four graphics members differ, input/camera/pointer delegate.
   The default factory is chosen inside the phase from the platform result.
   HostInputCameraResult gained backend-neutral Retirement and FrameSlots.
3. The frame root forks on one condition. The GL world-scene assembly is
   unchanged, wrapped in `if (gl is not null)`; the Vulkan arm's graph is one
   backbuffer clear pass computing the same RenderFrameFoundation from the same
   clock and weather owners, then private presentation over it.

§5.5.9's three TextureCache couplings are unpicked: the constructor takes GL?
and rejects bindless without one, world entry points route through a Gl
property that throws naming V4t, and the (GlGpuTexture) VRAM-accounting cast
became a backend test. That cast's stated reason — DrawSprite's texture-unit
binding — was already stale, deleted at V6d.

VulkanBringUpHost is reduced to the capability-probe harness it is named for:
the instance/surface/device/swapchain sequence moved into VulkanGraphicsContext,
which the composition host and the harness now share. It is reached only with
ACDREAM_VULKAN_PROBE=1.

One latent Vulkan defect surfaced and is fixed here. The first composition-host
frame died with ErrorDeviceLost; validation named VUID-vkCmdDraw-None-08600 —
descriptor set 2 never bound. VulkanGpuPassEncoder bound sets 0/1/2 only as a
side effect of BindStorageBuffer/BindUniformBuffer, so a pass sampling the
texture table while binding no buffer — every retained-UI and debug-line pass —
drew with the table unbound. It survived V6c-V6g because the bring-up host
always drew VulkanRhiScene first and the UI pass inherited its binds; the
composition host has no 3-D scene. The fix is one line in the encoder's
constructor beside the viewport and scissor defaults, which exist for exactly
the same reason: a pass opens with complete binding state rather than depending
on what preceded it.

Gates: strict GL offline pixel gate against 46d893f7 measures 1.24e-05 (7 of
563,200 pixels), inside the documented 15-23 px / 4.1e-05 band, so GL behaviour
did not move. App tests 4,075/3 skips; complete Release suite 9,138/5 skips.
One full Vulkan run with VK_LAYER_KHRONOS_validation: zero errors, zero
warnings. Both Vulkan runs converged the ownership ledger — no [shutdown]
diagnostic on either stream. The reduced probe harness presented 34,811
validation-clean frames.

No divergence-register row: GL is the shipping backend and the pixel gate proves
it unmoved; the Vulkan arm is not a retail deviation but a backend under
construction.

Next is V4t, the texture stack, which the world arm cannot be written without.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-28 11:47:37 +02:00
parent 46d893f7c3
commit b16f820643
29 changed files with 2292 additions and 997 deletions

View file

@ -253,7 +253,7 @@ public sealed class ContentEffectsAudioCompositionTests
Poses = new EntityEffectPoseRegistry();
Factory = new Factory();
Publication = new Publication();
Platform = new GameWindowPlatformResult<GL, IInputContext>(null!, null!);
Platform = new GameWindowPlatformResult<GameWindowGraphics, IInputContext>(TestGameWindowGraphics.OpenGl, null!);
Host = (HostInputCameraResult)RuntimeHelpers.GetUninitializedObject(
typeof(HostInputCameraResult));
Dependencies = new ContentEffectsAudioDependencies(
@ -280,7 +280,7 @@ public sealed class ContentEffectsAudioCompositionTests
public Factory Factory { get; }
public Publication Publication { get; }
public ContentEffectsAudioDependencies Dependencies { get; }
public GameWindowPlatformResult<GL, IInputContext> Platform { get; }
public GameWindowPlatformResult<GameWindowGraphics, IInputContext> Platform { get; }
public HostInputCameraResult Host { get; }
public ContentEffectsAudioCompositionPhase Phase() => new(

View file

@ -95,7 +95,7 @@ public sealed class HostInputCameraCompositionTests
IKeyboard keyboard = DispatchProxy.Create<IKeyboard, NullDeviceProxy>();
IMouse mouse = DispatchProxy.Create<IMouse, NullDeviceProxy>();
Input = new InputContext(keyboard, mouse);
Platform = new GameWindowPlatformResult<GL, IInputContext>(null!, Input);
Platform = new GameWindowPlatformResult<GameWindowGraphics, IInputContext>(TestGameWindowGraphics.OpenGl, Input);
ViewportAspect = new ViewportAspectState();
Framebuffer = new FramebufferResizeController(ViewportAspect);
Capture = new CaptureSource();
@ -111,7 +111,7 @@ public sealed class HostInputCameraCompositionTests
public List<HostInputCameraCompositionPoint> Points { get; } = [];
public InputContext Input { get; }
public GameWindowPlatformResult<GL, IInputContext> Platform { get; }
public GameWindowPlatformResult<GameWindowGraphics, IInputContext> Platform { get; }
public ViewportAspectState ViewportAspect { get; }
public FramebufferResizeController Framebuffer { get; }
public CaptureSource Capture { get; }
@ -254,16 +254,30 @@ public sealed class HostInputCameraCompositionTests
private readonly MouseSurface _mouse = new();
private readonly RawPointerSurface _rawPointer = new();
public IFramebufferViewportTarget CreateViewportTarget(GL gl) => Viewport;
public IFramebufferViewportTarget CreateViewportTarget(
GameWindowGraphics graphics) => Viewport;
public GpuFrameFlightController CreateGpuFrameFlights(GL gl) =>
public GpuFrameFlightController? CreateGpuFrameFlights(
GameWindowGraphics graphics) =>
new(new FenceApi());
public IGpuDevice CreateGpuDevice(GL gl, GpuFrameFlightController frameFlights) =>
public IGpuDevice CreateGpuDevice(
GameWindowGraphics graphics,
GpuFrameFlightController? frameFlights) =>
new RecordingGpuDevice();
public WorldRenderDiagnostics CreateWorldRenderDiagnostics(
GL gl,
public IGpuResourceRetirementQueue CreateRetirement(
GameWindowGraphics graphics,
GpuFrameFlightController? frameFlights,
IGpuDevice device) => frameFlights!;
public IRenderFrameSlotSource CreateFrameSlots(
GameWindowGraphics graphics,
GpuFrameFlightController? frameFlights,
IGpuDevice device) => frameFlights!;
public WorldRenderDiagnostics? CreateWorldRenderDiagnostics(
GameWindowGraphics graphics,
IRenderFrameDiagnosticLog log) =>
new(new GlStateReader(), log);

View file

@ -188,7 +188,8 @@ public sealed class InteractionRetainedUiCompositionTests
new NoopSpellOperations());
Dependencies = new InteractionRetainedUiDependencies(
Options: options,
Gl: null!,
Graphics: null!,
BackbufferReader: static (_, _) => [],
Window: null!,
Input: null!,
ShadersDirectory: "shaders",

View file

@ -219,13 +219,15 @@ public sealed class SettingsDevToolsCompositionTests
null!,
null!,
null!,
null!,
null,
null,
null,
null,
_dispatcher,
camera,
null);
Platform = new GameWindowPlatformResult<GL, IInputContext>(null!, null!);
Platform = new GameWindowPlatformResult<GameWindowGraphics, IInputContext>(TestGameWindowGraphics.OpenGl, null!);
Content = (ContentEffectsAudioResult)RuntimeHelpers.GetUninitializedObject(
typeof(ContentEffectsAudioResult));
Dependencies = new SettingsDevToolsDependencies(
@ -258,7 +260,7 @@ public sealed class SettingsDevToolsCompositionTests
public RuntimeSettingsController Settings { get; }
public SettingsDevToolsDependencies Dependencies { get; }
public HostInputCameraResult Host { get; }
public GameWindowPlatformResult<GL, IInputContext> Platform { get; }
public GameWindowPlatformResult<GameWindowGraphics, IInputContext> Platform { get; }
public ContentEffectsAudioResult Content { get; }
public SettingsDevToolsResult Compose() =>

View file

@ -0,0 +1,61 @@
using AcDream.App;
using AcDream.App.Composition;
using Silk.NET.Core.Contexts;
using Silk.NET.OpenGL;
namespace AcDream.App.Tests.Composition;
/// <summary>
/// Campaign V slice V6h: the graphics handle composition tests hand to a phase.
///
/// <para>The phases now select their backend arm from
/// <see cref="GameWindowGraphics"/> rather than from a bare <c>GL</c> reference,
/// so a test that means "compose the OpenGL arm" has to say so. The GL instance
/// is never called: every composition test supplies a stub factory that ignores
/// its context argument, and the loader below would fault if anything did — which
/// is the point. It is a token identifying the arm, not a driver.</para>
/// </summary>
internal sealed class TestGameWindowGraphics : GameWindowGraphics
{
private readonly GL? _gl;
private TestGameWindowGraphics(RenderBackendKind backend, GL? gl)
{
Backend = backend;
_gl = gl;
}
/// <summary>Selects the OpenGL arm, with a context token no test dereferences.</summary>
public static TestGameWindowGraphics OpenGl { get; } =
new(RenderBackendKind.Gl, new GL(new UnusableNativeContext()));
/// <summary>Selects the Vulkan arm: no GL context exists.</summary>
public static TestGameWindowGraphics Vulkan { get; } =
new(RenderBackendKind.Vulkan, null);
public override RenderBackendKind Backend { get; }
public override GL? Gl => _gl;
public override void Dispose()
{
}
private sealed class UnusableNativeContext : INativeContext
{
public nint GetProcAddress(string proc, int? slot = null) =>
throw new InvalidOperationException(
$"A composition test called GL entry point '{proc}'. " +
"Test graphics are a backend token, not a driver.");
public bool TryGetProcAddress(string proc, out nint addr, int? slot = null)
{
addr = 0;
return false;
}
public void Dispose()
{
}
}
}

View file

@ -193,7 +193,7 @@ public sealed class WorldRenderCompositionTests
if (point == _failurePoint)
throw new InvalidOperationException($"fault at {point}");
}).Compose(
new GameWindowPlatformResult<GL, IInputContext>(null!, null!),
new GameWindowPlatformResult<GameWindowGraphics, IInputContext>(TestGameWindowGraphics.OpenGl, null!),
Content,
new SettingsDevToolsResult(
QualitySettings.From(QualityPreset.High),

View file

@ -51,7 +51,7 @@ public sealed class GameWindowSlice8BoundaryTests
AssertAppearsInOrder(
body,
"GameWindowPlatformResult<GL, IInputContext> platform = AcquirePlatform();",
"GameWindowPlatformResult<GameWindowGraphics, IInputContext> platform = AcquirePlatform();",
"GameWindowCompositionPipeline.Run<",
"new HostInputCameraCompositionPhase(",
"this).Compose(platformResult),",
@ -575,7 +575,7 @@ public sealed class GameWindowSlice8BoundaryTests
"d.PortalTunnelFallback.AcquirePrepared(",
"static tunnel => tunnel.PrepareResources());",
"d.RenderResourceLifetime.AcquireSkyShader(",
"() => new SkyRenderer(");
"new SkyRenderer(");
AssertAppearsInOrder(
load,
"new WorldRenderCompositionPhase(",
@ -597,7 +597,7 @@ public sealed class GameWindowSlice8BoundaryTests
"lifetime.AcquireTerrainAtlas(",
"TerrainAtlas.Build(gl, dats, bindless)",
"TerrainModernRenderer CreateTerrain(",
"TerrainModernRenderer terrain = AcquireAndPublish(");
"TerrainModernRenderer? terrain = AcquireAndPublishIf(");
AssertAppearsInOrder(
shutdown,
"frame.FrameGraphPublication?.Dispose()",
@ -610,7 +610,7 @@ public sealed class GameWindowSlice8BoundaryTests
"render.DedicatedResources.ReleaseSkyShader",
"render.DedicatedResources.ReleaseTerrainAtlas",
"render.ConstructionCleanup.Dispose",
"platform.Gl?.Dispose()");
"platform.Graphics?.Dispose()");
Assert.DoesNotContain(
"RetailUiRuntime.Mount(",