The three world renderers' submission arms, both pass executors, and the
composition that reaches them. This is the unit three predecessors stopped at.
What it produces. ACDREAM_RENDER_BACKEND=vulkan on the offline scene renders
terrain with blended textures and road overlays, the water edge, static world
meshes, procedural scenery, and the complete retained UI - the same frame the GL
pixel gate captures, from the same camera, minus the sky. artifacts/v6j-vk2.
The shape, and why it is not V4c's. Section 5.5.6 chose option (B) after NVIDIA
rendered the V4c binary 10/10 where AMD's GL stack did not: GL keeps its raw
world path through to V10 as a documented fork confined to the submission seam,
and the RHI world path ships on Vulkan. So V4c's and V4d-2's content returns as a
SECOND arm rather than a replacement. The GL arm issues the same GL statements in
the same order against the same objects; the encoder arm lives in three .Rhi.cs
partials and is entered by one branch per submission site.
Three differences from V4c, each because the tree moved under it. There is no
binding-9 texture table - V4t put the slot on the device and Vulkan binds set 2,
so the arm that used to intern bindless handles simply has nothing to do. The
pipelines carry the device's sample count rather than 1, because Vulkan requires
rasterizationSamples to match the pass and alpha-to-coverage is a no-op at one
sample. And no renderer opens a pass.
That last one is structural, not tidiness. Under MSAA the frame's one backbuffer
pass resolves into the swapchain image and stores DONT_CARE into the multisampled
scratch, so a second pass declaring Load would load undefined contents; the
backend also permits one open pass per frame. VulkanWorldScenePhase therefore
opens the pass, publishes the encoder on VulkanWorldPassScope for exactly the
span of the inner WorldSceneRenderer, and every renderer borrows it.
Three sections are frame-global on GL and cannot be on Vulkan: the SceneLighting
UBO, the per-cell clip regions, and the terrain clip block. GL binds each to a
global binding point and every consumer inherits it. Vulkan binds a descriptor
set per draw, and a renderer's own binds are what select the scope those sections
must land in - so their writers PUBLISH into WorldFrameSections and each renderer
binds them inside the pass, after its own binds. SceneLightingUboBinding's
per-flight-slot buffer pool disappears with it: a ring allocation is already
distinct memory that lives until the frame retires, which is the property the
pool existed to provide.
Both pass executors became backend-neutral rather than gaining twins. Everything
they do is delegation to a renderer except four concerns - the clip-frame
publication, the doorway scissor, gl_ClipDistance enablement, and retail's
interior depth clear - so those four move behind IWorldPassSurface and retail's
ordering, which is what these classes are actually for, is written once. The GL
implementation issues the statements the executors used to issue inline.
Clip distances are no-ops on the Vulkan arm, and that is safe rather than a
divergence: Vulkan activates every element the shader declares, and all three
world vertex shaders already write 1.0 into every slot past the active count.
The interior depth clear becomes vkCmdClearAttachments, reached through the scope
so the pinned contract stays frozen and the backend-only verb stays in the
backend. The hook for it was already committed at V6i-3 with a cref to a type
that did not exist yet; it exists now.
The collision-wireframe DebugLineRenderer is composed as null on the Vulkan arm.
DrawAndPublish flushes it INSIDE the world phase and it opens its own pass, which
the one-pass rule forbids. The toggle is DevTools-only and DevTools is not
composed there, so nothing is lost - composing it would throw on the first
wireframe frame rather than silently misdraw.
Two seams widened rather than invented. GameWindowGraphics answers whether the
backend has a world-pass seam, because the three composition phases that need it
already borrow that handle and "does this backend work that way" is what the type
exists to answer. And MeshSourceReady replaces the anyVao != 0 gate with the same
question in backend-neutral form - V6i-3 published HasStores for exactly this -
so the predicate evaluates identically on GL.
What is NOT here, and is expected. Sky and weather are still raw GL (V4f), so the
Vulkan frame's sky is the atmosphere fog clear. Particles (V4e), the paperdoll and
appraisal viewports and the portal depth mask (V4g) likewise. The executors
already accepted all of them as absent.
Gates. Release build green. App tests 4,112 passed / 3 skipped, the unchanged
baseline; complete Release suite 9,175 / 5. Strict GL offline pixel gate against
847f14ae: 5.50e-05, 31 differing pixels of 563,200, inside the documented 9-31
band and 18x under the threshold. Characterised rather than accepted, because 31
is the band's top: cross-commit pairs measured 21, 29 and 31 while same-commit
controls measured 12 and 20, and maximumChannelDelta is 46-52 in every comparison
INCLUDING the pure controls - so the few large-delta pixels are a property of the
capture, and a cross-commit pair at 21 against a same-commit pair at 20 is not
what a systematic shift looks like. GL connected repeat gate at 3 runs: 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, a captured world frame, and a graceful close.
Coverage gap, stated rather than assumed. The offline scene is a fixed outdoor
view, so EnvCellRenderer's Vulkan arm draws nothing in it - dungeon interiors are
half of this slice and are unproven by anything automated, exactly as they were
for V4c. The deferred-alpha path and the doorway scissor are likewise untouched
by this scene. They join the accumulated user-gate debt in plan section 5.1.
No divergence-register row: no retail-facing behaviour changes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
315 lines
10 KiB
C#
315 lines
10 KiB
C#
using AcDream.App.Rendering.Sky;
|
|
using AcDream.App.Rendering.Wb;
|
|
using AcDream.Core.Rendering;
|
|
using AcDream.Core.Vfx;
|
|
using AcDream.Core.World;
|
|
|
|
namespace AcDream.App.Rendering;
|
|
|
|
internal interface IWorldScenePassExecutor
|
|
{
|
|
HashSet<uint>? TerrainVisibleCellIds { get; }
|
|
|
|
void BeginFrame();
|
|
|
|
void PrepareFlatWorldClip();
|
|
|
|
void DrawFlatSky(
|
|
in WorldCameraFrame camera,
|
|
in RenderFrameFoundation foundation,
|
|
DayGroupData? activeDayGroup,
|
|
float dayFraction);
|
|
|
|
void DrawFlatTerrain(in WorldCameraFrame camera, uint? playerLandblockId);
|
|
|
|
void DrawFlatEntities(
|
|
in WorldCameraFrame camera,
|
|
IEnumerable<(uint LandblockId, System.Numerics.Vector3 AabbMin,
|
|
System.Numerics.Vector3 AabbMax,
|
|
IReadOnlyList<WorldEntity> Entities,
|
|
IReadOnlyDictionary<uint, WorldEntity>? AnimatedById)> entries,
|
|
uint? playerLandblockId,
|
|
HashSet<uint> animatedEntityIds);
|
|
|
|
string DrawPostWorldParticles(
|
|
LoadedCell? clipRoot,
|
|
ClipFrameAssembly? clipAssembly,
|
|
in WorldCameraFrame camera,
|
|
IReadOnlySet<uint> outdoorOwnerIds,
|
|
string currentSignature);
|
|
|
|
void DrawFlatWeather(
|
|
in WorldCameraFrame camera,
|
|
in RenderFrameFoundation foundation,
|
|
DayGroupData? activeDayGroup,
|
|
float dayFraction);
|
|
|
|
void DisableClipDistances();
|
|
|
|
void AbortFrame();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Concrete leaf for the flat-world safety path and the post-world particle
|
|
/// and weather passes. Retail PView frames remain owned by
|
|
/// <see cref="RetailPViewRenderer"/> and <see cref="RetailPViewPassExecutor"/>.
|
|
///
|
|
/// <para>Campaign V slice V6j: backend-neutral. Everything it does is either
|
|
/// delegation to a renderer or one of the four concerns
|
|
/// <see cref="IWorldPassSurface"/> owns, so one implementation serves both
|
|
/// backends and the retail ordering is written once.</para>
|
|
/// </summary>
|
|
internal sealed class WorldScenePassExecutor : IWorldScenePassExecutor
|
|
{
|
|
private readonly IWorldPassSurface _surface;
|
|
private readonly IRenderFrameGlState _frameGlState;
|
|
private readonly ClipFrame _clipFrame;
|
|
private readonly WbDrawDispatcher _entities;
|
|
private readonly EnvCellRenderer _environmentCells;
|
|
private readonly TerrainModernRenderer? _terrain;
|
|
private readonly TerrainDrawDiagnosticsController _terrainDiagnostics;
|
|
private readonly SkyRenderer? _sky;
|
|
private readonly ParticleSystem? _particles;
|
|
private readonly ParticleRenderer? _particleRenderer;
|
|
private readonly HashSet<uint> _visibleParticleOwners = [];
|
|
private readonly HashSet<uint> _noExcludedParticleOwners = [];
|
|
|
|
public WorldScenePassExecutor(
|
|
IWorldPassSurface surface,
|
|
IRenderFrameGlState frameGlState,
|
|
ClipFrame clipFrame,
|
|
WbDrawDispatcher entities,
|
|
EnvCellRenderer environmentCells,
|
|
TerrainModernRenderer? terrain,
|
|
TerrainDrawDiagnosticsController terrainDiagnostics,
|
|
SkyRenderer? sky,
|
|
ParticleSystem? particles,
|
|
ParticleRenderer? particleRenderer)
|
|
{
|
|
_surface = surface ?? throw new ArgumentNullException(nameof(surface));
|
|
_frameGlState = frameGlState
|
|
?? throw new ArgumentNullException(nameof(frameGlState));
|
|
_clipFrame = clipFrame ?? throw new ArgumentNullException(nameof(clipFrame));
|
|
_entities = entities ?? throw new ArgumentNullException(nameof(entities));
|
|
_environmentCells = environmentCells
|
|
?? throw new ArgumentNullException(nameof(environmentCells));
|
|
_terrain = terrain;
|
|
_terrainDiagnostics = terrainDiagnostics
|
|
?? throw new ArgumentNullException(nameof(terrainDiagnostics));
|
|
_sky = sky;
|
|
_particles = particles;
|
|
_particleRenderer = particleRenderer;
|
|
}
|
|
|
|
public HashSet<uint>? TerrainVisibleCellIds => _terrain?.VisibleCellIds;
|
|
|
|
public void BeginFrame()
|
|
{
|
|
_visibleParticleOwners.Clear();
|
|
_clipFrame.Reset();
|
|
_entities.ClearClipRouting();
|
|
_environmentCells.SetClipRouting(null);
|
|
}
|
|
|
|
public void PrepareFlatWorldClip() => _surface.PrepareClipFrame(1);
|
|
|
|
public void DrawFlatSky(
|
|
in WorldCameraFrame camera,
|
|
in RenderFrameFoundation foundation,
|
|
DayGroupData? activeDayGroup,
|
|
float dayFraction)
|
|
{
|
|
_surface.BindTerrainClip();
|
|
_surface.EnableClipDistances();
|
|
Exception? drawFailure = null;
|
|
try
|
|
{
|
|
_sky?.RenderSky(
|
|
camera.Camera,
|
|
camera.Position,
|
|
dayFraction,
|
|
activeDayGroup,
|
|
foundation.Sky,
|
|
foundation.EnvironOverrideActive);
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
drawFailure = error;
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
try
|
|
{
|
|
DisableClipDistances();
|
|
}
|
|
catch (Exception closeFailure) when (drawFailure is not null)
|
|
{
|
|
throw new AggregateException(
|
|
"Sky drawing failed and its clip-distance bracket could not be closed.",
|
|
drawFailure,
|
|
closeFailure);
|
|
}
|
|
}
|
|
|
|
if (_particles is not null && _particleRenderer is not null)
|
|
{
|
|
_particleRenderer.Draw(
|
|
camera.Camera,
|
|
camera.Position,
|
|
ParticleRenderPass.SkyPreScene);
|
|
}
|
|
}
|
|
|
|
public void DrawFlatTerrain(
|
|
in WorldCameraFrame camera,
|
|
uint? playerLandblockId)
|
|
{
|
|
_surface.EnableClipDistances();
|
|
_terrainDiagnostics.Begin();
|
|
_terrain?.Draw(
|
|
camera.Camera,
|
|
camera.Frustum,
|
|
neverCullLandblockId: playerLandblockId);
|
|
_terrainDiagnostics.Complete();
|
|
}
|
|
|
|
public void DrawFlatEntities(
|
|
in WorldCameraFrame camera,
|
|
IEnumerable<(uint LandblockId, System.Numerics.Vector3 AabbMin,
|
|
System.Numerics.Vector3 AabbMax,
|
|
IReadOnlyList<WorldEntity> Entities,
|
|
IReadOnlyDictionary<uint, WorldEntity>? AnimatedById)> entries,
|
|
uint? playerLandblockId,
|
|
HashSet<uint> animatedEntityIds) =>
|
|
_entities.Draw(
|
|
camera.Camera,
|
|
entries,
|
|
camera.Frustum,
|
|
neverCullLandblockId: playerLandblockId,
|
|
visibleCellIds: null,
|
|
animatedEntityIds: animatedEntityIds);
|
|
|
|
public string DrawPostWorldParticles(
|
|
LoadedCell? clipRoot,
|
|
ClipFrameAssembly? clipAssembly,
|
|
in WorldCameraFrame camera,
|
|
IReadOnlySet<uint> outdoorOwnerIds,
|
|
string currentSignature)
|
|
{
|
|
if (_particles is null || _particleRenderer is null)
|
|
return currentSignature;
|
|
|
|
if (clipRoot is null)
|
|
{
|
|
if (clipAssembly is not null)
|
|
{
|
|
_particleRenderer.DrawForOwners(
|
|
camera.Camera,
|
|
camera.Position,
|
|
ParticleRenderPass.Scene,
|
|
_visibleParticleOwners,
|
|
includeUnattached: true,
|
|
excludedAttachedOwnerIds: _noExcludedParticleOwners);
|
|
return AppendSignature(currentSignature, "filtered");
|
|
}
|
|
|
|
_particleRenderer.Draw(
|
|
camera.Camera,
|
|
camera.Position,
|
|
ParticleRenderPass.Scene);
|
|
return AppendSignature(currentSignature, "global");
|
|
}
|
|
|
|
if (clipRoot.IsOutdoorNode)
|
|
{
|
|
_particleRenderer.DrawForOwners(
|
|
camera.Camera,
|
|
camera.Position,
|
|
ParticleRenderPass.Scene,
|
|
outdoorOwnerIds,
|
|
includeUnattached: true);
|
|
return AppendSignature(currentSignature, "unattached");
|
|
}
|
|
|
|
return currentSignature;
|
|
}
|
|
|
|
public void DrawFlatWeather(
|
|
in WorldCameraFrame camera,
|
|
in RenderFrameFoundation foundation,
|
|
DayGroupData? activeDayGroup,
|
|
float dayFraction)
|
|
{
|
|
_surface.BindTerrainClip();
|
|
_surface.EnableClipDistances();
|
|
Exception? drawFailure = null;
|
|
try
|
|
{
|
|
_sky?.RenderWeather(
|
|
camera.Camera,
|
|
camera.Position,
|
|
dayFraction,
|
|
activeDayGroup,
|
|
foundation.Sky,
|
|
foundation.EnvironOverrideActive);
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
drawFailure = error;
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
try
|
|
{
|
|
DisableClipDistances();
|
|
}
|
|
catch (Exception closeFailure) when (drawFailure is not null)
|
|
{
|
|
throw new AggregateException(
|
|
"Weather drawing failed and its clip-distance bracket could not be closed.",
|
|
drawFailure,
|
|
closeFailure);
|
|
}
|
|
}
|
|
|
|
if (_particles is not null && _particleRenderer is not null)
|
|
{
|
|
_particleRenderer.Draw(
|
|
camera.Camera,
|
|
camera.Position,
|
|
ParticleRenderPass.SkyPostScene);
|
|
}
|
|
}
|
|
|
|
public void DisableClipDistances() => _surface.DisableClipDistances();
|
|
|
|
public void AbortFrame()
|
|
{
|
|
List<Exception>? failures = null;
|
|
TryAbort(_frameGlState.RestoreFrameDefaults);
|
|
TryAbort(_clipFrame.Reset);
|
|
TryAbort(_entities.ClearClipRouting);
|
|
TryAbort(_entities.AbortCurrentRenderSceneObserverFrame);
|
|
TryAbort(() => _environmentCells.SetClipRouting(null));
|
|
_visibleParticleOwners.Clear();
|
|
if (failures is { Count: > 0 })
|
|
throw new AggregateException("World scene pass abort failed.", failures);
|
|
|
|
void TryAbort(Action operation)
|
|
{
|
|
try
|
|
{
|
|
operation();
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
(failures ??= []).Add(error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static string AppendSignature(string current, string value) =>
|
|
current == "none" ? value : current + "+" + value;
|
|
}
|