PortalTunnelPresentation was the last raw-GL world-adjacent renderer. It now
draws on both arms, and the composition that used to hand the Vulkan arm a
portal-less teleport presentation is gone with it.
Nothing about the scene changed. Same synthetic DAT Setup resolved through the
same client-enum mapping, same 40 fps CSequence, same retail rotation cadence,
same distant light, drawn through the same already-dual-arm WbDrawDispatcher.
What forked is only where the draw is recorded:
* GL keeps its GLStateScope, its viewport/scissor/depth/cull/blend statements
and its depth-only glClear, untouched.
* The RHI arm opens a backbuffer pass of its own and publishes it on
IWorldPassScope for the span of the draw - the shape V6l gave the two
offscreen viewports, and required for the same reason: the dispatcher's RHI
arm borrows its pass rather than opening one. Publication comes after
BeginPass and before UploadRetailLight, because publishing resets the
frame-global sections and this scene wants its own light, not the world's.
The one substantive decision is the pass's COLOUR load op, and it is a Clear
rather than a Load. Retail preserves the colour target and only clears depth
(UIViewportObject::DrawContent @ 0x006950A5 -> Clear(4) = D3DCLEAR_ZBUFFER), and
so does the GL arm. A Vulkan pass cannot inherit an image the way a bound
framebuffer can: under MSAA the frame's world pass RESOLVES into the swapchain
image and stores DontCare into the multisampled scratch, so a second
multisampled pass declaring Load would load undefined contents - plan section
5.5.12 item 5, the same hazard that merged the clear into the world pass.
Re-clearing is exact rather than approximate because of an invariant the frame
graph already enforces. RenderFrameFoundation.PortalViewportVisible and this
scene's IsVisible are the same value, read once at the top of the frame, and
WorldSceneRenderer returns without drawing when it is set. So whenever portal
space draws, the backbuffer holds exactly the opaque black
SceneTool::BeginScene @ 0x0043DAD0 establishes and nothing else, and clearing to
that same black changes no pixel. The alternative - a single-sampled Load pass
over the resolved image - would have been both a silent MSAA divergence and
invalid, since the backbuffer's depth attachment is multisampled.
The pass takes IWorldPassScope.SampleCount, so WbDrawDispatcher's sample-count
pipeline variants (V6l) select the backbuffer set, and depth matches the
attachment.
CreateRequired becomes internal: its two new seams are internal RHI contracts
and composition is its only caller. The TYPE keeps its visibility - plan section
7.1 rule 3.
Gates. Release build green. App tests 4,132 / 3 skips against the 4,129
baseline (three new: the retail black constant, the RHI arm's composition
precondition, and the both-arms composition assertion). Complete Release suite
9,195 / 5; one AcDream.Content failure in the solution-wide run that passes
124/124 rerun alone - the documented rerun-singly flake class, not carried
forward as a claim. Strict GL offline pixel gate against 280f3b3f: 28 px of
563,200, fraction 4.97e-05, inside the documented 9-31 band, with a same-commit
control pair at 20 px / 3.55e-05 taken immediately afterwards. GL connected
-Runs 3: 3/3 RENDERED on the desktop witness and 3/3 on the client capture. One
offline Vulkan run with VK_LAYER_KHRONOS_validation proven inserted by the
loader: zero validation errors, zero warnings.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
260 lines
8.7 KiB
C#
260 lines
8.7 KiB
C#
using AcDream.App.Composition;
|
|
using AcDream.App.Physics;
|
|
using AcDream.App.Streaming;
|
|
using AcDream.App.World;
|
|
using AcDream.Core.Net;
|
|
using AcDream.Core.Physics.Motion;
|
|
using AcDream.Core.World;
|
|
|
|
namespace AcDream.App.Tests.Composition;
|
|
|
|
public sealed class LivePresentationCompositionTests
|
|
{
|
|
[Fact]
|
|
public void RuntimeBindingsReleaseInReverseAndRetryOnlyFailedEdges()
|
|
{
|
|
var calls = new List<string>();
|
|
var bindings = new LivePresentationRuntimeBindings();
|
|
var first = new RetryBinding("first", calls, failures: 0);
|
|
var second = new RetryBinding("second", calls, failures: 1);
|
|
bindings.Adopt("first", first);
|
|
bindings.Adopt("second", second);
|
|
|
|
Assert.Throws<AggregateException>(bindings.Dispose);
|
|
Assert.Equal(["second", "first"], calls);
|
|
|
|
bindings.Dispose();
|
|
bindings.Dispose();
|
|
|
|
Assert.Equal(["second", "first", "second"], calls);
|
|
Assert.Throws<ObjectDisposedException>(() =>
|
|
bindings.Adopt("late", new RetryBinding("late", calls, 0)));
|
|
}
|
|
|
|
[Fact]
|
|
public void TransferableAdoptionRollsBackExactlyAndRetriesFailure()
|
|
{
|
|
var calls = new List<string>();
|
|
var bindings = new LivePresentationRuntimeBindings();
|
|
bindings.Adopt("stable", new RetryBinding("stable", calls, 0));
|
|
IDisposable adoption = bindings.AdoptOwned(
|
|
"candidate",
|
|
new RetryBinding("candidate", calls, 1));
|
|
|
|
Assert.Throws<InvalidOperationException>(adoption.Dispose);
|
|
adoption.Dispose();
|
|
adoption.Dispose();
|
|
bindings.Dispose();
|
|
|
|
Assert.Equal(["candidate", "candidate", "stable"], calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanonicalRuntimeSlotUsesExactOwnerBinding()
|
|
{
|
|
var slot = new LiveEntityRuntimeSlot();
|
|
LiveEntityRuntime first = Runtime();
|
|
LiveEntityRuntime second = Runtime();
|
|
|
|
IDisposable stale = slot.BindOwned(first);
|
|
Assert.Same(first, slot.Current);
|
|
Assert.Throws<InvalidOperationException>(() => slot.BindOwned(second));
|
|
|
|
stale.Dispose();
|
|
IDisposable current = slot.BindOwned(second);
|
|
stale.Dispose();
|
|
Assert.Same(second, slot.Current);
|
|
current.Dispose();
|
|
Assert.Null(slot.Current);
|
|
}
|
|
|
|
[Fact]
|
|
public void MotionBindingCannotBeClearedByAStaleOwner()
|
|
{
|
|
var source = new DeferredLiveEntityMotionRuntimeBindings();
|
|
var first = new MotionRuntime(1f);
|
|
var second = new MotionRuntime(2f);
|
|
var entity = new WorldEntity
|
|
{
|
|
Id = 1u,
|
|
SourceGfxObjOrSetupId = 1u,
|
|
Position = System.Numerics.Vector3.Zero,
|
|
Rotation = System.Numerics.Quaternion.Identity,
|
|
MeshRefs = Array.Empty<MeshRef>(),
|
|
};
|
|
|
|
IDisposable stale = source.BindOwned(first);
|
|
Assert.Equal(1f, source.GetSetupCylinder(1u, entity).Radius);
|
|
Assert.Throws<InvalidOperationException>(() => source.BindOwned(second));
|
|
|
|
stale.Dispose();
|
|
IDisposable current = source.BindOwned(second);
|
|
stale.Dispose();
|
|
Assert.Equal(2f, source.GetSetupCylinder(1u, entity).Radius);
|
|
current.Dispose();
|
|
Assert.Throws<InvalidOperationException>(() =>
|
|
source.GetSetupCylinder(1u, entity));
|
|
}
|
|
|
|
[Fact]
|
|
public void LandblockLoadedBridgeIsInertUntilBoundAndDeactivationIsTerminal()
|
|
{
|
|
var source = new DeferredLiveEntityLandblockLoadedSink();
|
|
var first = new LandblockSink();
|
|
var second = new LandblockSink();
|
|
|
|
source.OnLandblockLoaded(1u);
|
|
IDisposable stale = source.Bind(first);
|
|
source.OnLandblockLoaded(2u);
|
|
Assert.Equal([2u], first.Landblocks);
|
|
Assert.Throws<InvalidOperationException>(() => source.Bind(second));
|
|
|
|
stale.Dispose();
|
|
IDisposable current = source.Bind(second);
|
|
stale.Dispose();
|
|
source.OnLandblockLoaded(3u);
|
|
Assert.Equal([3u], second.Landblocks);
|
|
|
|
source.Deactivate();
|
|
current.Dispose();
|
|
source.OnLandblockLoaded(4u);
|
|
Assert.Equal([3u], second.Landblocks);
|
|
Assert.Throws<ObjectDisposedException>(() => source.Bind(first));
|
|
}
|
|
|
|
[Fact]
|
|
public void GameWindowUsesLivePhaseAndContainsNoPhaseSixConstructionBody()
|
|
{
|
|
string root = FindRepoRoot();
|
|
string window = File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Rendering",
|
|
"GameWindow.cs"));
|
|
string phase = File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"LivePresentationComposition.cs"));
|
|
|
|
Assert.Contains("new LivePresentationCompositionPhase(", window);
|
|
Assert.DoesNotContain("new AcDream.App.World.LiveEntityRuntime(", window);
|
|
Assert.DoesNotContain("new AcDream.App.Rendering.Wb.WbDrawDispatcher(", window);
|
|
Assert.DoesNotContain("new AcDream.App.Streaming.LandblockRenderPublisher(", window);
|
|
Assert.DoesNotContain("_portalTunnelFallback.AcquirePrepared(", window);
|
|
Assert.Contains("new LiveEntityRuntime(", phase);
|
|
Assert.Contains("new WbDrawDispatcher(", phase);
|
|
Assert.Contains("new LandblockRenderPublisher(", phase);
|
|
Assert.Contains("d.PortalTunnelFallback.AcquirePrepared(", phase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Campaign V slice V6m: portal space is composed on BOTH arms. It was the
|
|
/// last renderer this phase built only when a GL context existed, and the
|
|
/// Vulkan arm's portal-less teleport presentation went with the condition —
|
|
/// so both the gate and the stand-in are asserted absent here.
|
|
/// </summary>
|
|
[Fact]
|
|
public void PortalSpaceIsComposedOnBothBackendArms()
|
|
{
|
|
string root = FindRepoRoot();
|
|
string phase = File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"LivePresentationComposition.cs"));
|
|
string session = File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Composition",
|
|
"SessionPlayerComposition.cs"));
|
|
|
|
Assert.Contains(
|
|
"if (dispatcherLease.Resource is { } portalDispatcher)",
|
|
phase);
|
|
Assert.DoesNotContain(
|
|
"if (gl is not null && dispatcherLease.Resource is { } portalDispatcher)",
|
|
phase);
|
|
Assert.DoesNotContain("NullLocalPlayerTeleportPresentation", session);
|
|
Assert.DoesNotContain(
|
|
"NullLocalPlayerTeleportPresentation",
|
|
File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Rendering",
|
|
"Gpu",
|
|
"Vk",
|
|
"VulkanCompositionFramePhases.cs")));
|
|
}
|
|
|
|
private static LiveEntityRuntime Runtime() => LiveEntityRuntimeFixture.Create(
|
|
new GpuWorldState(),
|
|
new DelegateLiveEntityResourceLifecycle(static _ => { }, static _ => { }));
|
|
|
|
private sealed class MotionRuntime(float radius)
|
|
: ILiveEntityMotionRuntimeBindings
|
|
{
|
|
public (float Radius, float Height) GetSetupCylinder(
|
|
uint serverGuid,
|
|
WorldEntity entity) => (radius, 1f);
|
|
|
|
public bool RouteServerMoveTo(
|
|
MovementManager movement,
|
|
uint cellId,
|
|
WorldSession.EntityMotionUpdate update) => false;
|
|
|
|
public void StickToObjectFromWire(
|
|
IPhysicsObjHost? host,
|
|
uint targetGuid)
|
|
{
|
|
}
|
|
|
|
public void ClearTargetForHiddenEntity(uint serverGuid)
|
|
{
|
|
}
|
|
|
|
public IPhysicsObjHost? ResolvePhysicsHost(
|
|
uint serverGuid) => null;
|
|
}
|
|
|
|
private sealed class LandblockSink : ILiveEntityLandblockLoadedSink
|
|
{
|
|
public List<uint> Landblocks { get; } = [];
|
|
public void OnLandblockLoaded(uint landblockId) => Landblocks.Add(landblockId);
|
|
}
|
|
|
|
private sealed class RetryBinding(
|
|
string name,
|
|
List<string> calls,
|
|
int failures) : IDisposable
|
|
{
|
|
private int _failures = failures;
|
|
|
|
public void Dispose()
|
|
{
|
|
calls.Add(name);
|
|
if (_failures > 0)
|
|
{
|
|
_failures--;
|
|
throw new InvalidOperationException("retry");
|
|
}
|
|
}
|
|
}
|
|
|
|
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.");
|
|
}
|
|
}
|