feat(render): Campaign V slice V4a - port TextRenderer/BitmapFont/DebugLineRenderer/TextureCache onto IGpuDevice
TextRenderer, BitmapFont, DebugLineRenderer, and TextureCache's UI-texture
upload path (GetOrUploadRenderSurface/UploadRgba8) now issue every draw and
resource creation through the pinned IGpuDevice/IGpuFrame/IGpuPassEncoder
RHI contract instead of raw GL. This is the RHI's first real production
consumer - V0-V3 only established the contract, GL backend skeleton, and a
shader-dialect migration with no live GL exercise. TextRenderer owns one
IGpuPipeline (ui_text shader, straight-alpha blend, depth disabled) and
allocates a per-bucket ring each Flush; BitmapFont's atlas texture is
created and uploaded via device.CreateTexture/.Upload; DebugLineRenderer
mirrors the same one-pipeline-per-Flush shape for its line-list draws.
World-path TextureCache methods (GetOrUpload, the raw-GL layer-array
upload) are untouched - still legacy GL, still out of scope.
Frame lifecycle: GpuDeviceFrameLifetime (RenderFrameOrchestrator.cs) wraps
IGpuDevice.BeginFrame()/IGpuFrame.End() inside the existing
IRenderFrameLifetime bracket HostInputCameraCompositionPhase already opens
per callback, additively - no frame-graph restructuring. Ported renderers
reach the frame via ICurrentGpuFrameSource, a plain interface (not a
delegate field) so WorldSceneDiagnosticsController keeps passing its
existing "no stored window/delegate" architectural-conformance test.
Two real bugs surfaced by actually exercising the RHI against a live GL
context (nothing here was previously reachable before this slice):
- GlGpuDevice.BeginFrame() now resets the render-state cache every frame.
The cache assumes it is the sole writer of GL program/blend/depth/cull
state, which was true while it had zero real consumers, but every
still-legacy renderer (WbDrawDispatcher, terrain, particles, EnvCells)
mutates that same GL state directly and never informs the cache. Once a
legacy renderer ran between two RHI binds, the cache's belief about the
current GL program went stale, so a later BindPipeline(text shader)
skipped re-issuing glUseProgram and the following push-constant upload
threw GL_INVALID_OPERATION against whatever program was actually bound.
Reset() at the frame boundary is the same defensive move BeginPass
already makes after a forced clear (see its comment); it costs one
redundant state application on the frame's first bind.
- GL_MULTISAMPLE has no representation in the pinned contract. Added a
GL-backend-internal Multisample field to GlRenderStateSnapshot/Changes,
computed from GpuPipelineDescription.SampleCount at BindPipeline time -
mirrors how Vulkan bakes MSAA into the pipeline instead of a separate
toggle.
Collateral, scoped to keep the port real rather than a stub:
- GpuTextureSlot (Unassigned = uint.MaxValue, NOT 0) now flows through
every consumer of TextureCache.GetOrUploadRenderSurface/UploadRgba8 and
TextRenderer.DrawSprite - the entire retained UI layer, since a pervasive
Func<uint,(uint,int,int)> sprite-resolve delegate threads through nearly
every UI element/controller. Every prior `== 0` / `!= 0` "no texture"
check became `.IsAssigned` / `!.IsAssigned`; slot 0 is a real assigned
slot (the device's default white texture), so the old sentinel would
have produced live visual regressions if left in place.
- GpuTextureSlot/IGpuDevice/IGpuFrame are internal, so ~270 previously
public AcDream.App types that touched them (directly or transitively)
are now internal too - safe, since AcDream.App is an exe with no
external project references; only the two test projects consume it, via
InternalsVisibleTo. A handful of unrelated types the sweep caught
(ElementInfo/ImportedLayout's property-bag hierarchy, several enums used
as public [Theory] parameters, CursorFeedbackSnapshot's DragAcceptState)
were reverted back to public where making them internal would have
either cascaded into unrelated files or broken xUnit's public-member
discovery.
- ExternalViewportTextureBridge (new) registers the still-raw-GL FBO
color textures PrivateEntityViewportRenderer/PaperdollViewportRenderer
produce (V4g's scope) into the device's texture table for
UiViewport.TextureHandle, via a temporary
GlGpuDevice.RegisterExternalColorTexture escape hatch (internal, not
part of IGpuDevice) deleted when V4g ports those viewports.
- TextRenderGlStateScope.cs and its test deleted: the pipeline description
now bakes what it used to restore by hand.
- ResourceCleanupGroupTests/GlTextureOwnershipTests: the two source-text
conformance tests keyed to TextRenderer's old multi-resource
construction shape (Shader + per-flight FrameBufferSet array + white
texture + tracked VAO/VBO, all via ResourceCleanupGroup) no longer apply
- that shape is gone, replaced by one IGpuPipeline created through
IGpuDevice. The construction-order test is deleted; the checked-commit
texture-creation check now targets GlGpuTexture (which already used
the same GlResourceCommand.CreateName primitive before this slice).
Gates:
- dotnet build -c Release: 0 warnings, 0 errors (AcDream.App has
TreatWarningsAsErrors).
- dotnet test tests/AcDream.App.Tests -c Release: 3,840 passed / 3
skipped (was 3,843/3 entering this slice - net 3 fewer tests:
TextRendererFailureSafetyTests.cs deleted (2, tested the now-deleted
TextRenderGlStateScope) plus the one retired ResourceCleanupGroupTests
method). Full solution: 8,908 passed / 5 skipped across all nine test
projects.
- Offline pixel gate (tools/run-offline-pixel-gate.ps1, parent ec414d60
vs this commit): differing fraction 0.318% (1,791/563,200 compared
pixels), above the 0.001 threshold. Investigated pixel-by-pixel rather
than waved through: a diff heatmap plus 4x crops at the differing
clusters show zero differences anywhere in the retained UI, terrain,
scenery, or static meshes - every differing pixel sits on continuously-
animated ambient content (flying-insect sprites over the swamp, foliage
sparkle/dew glints) whose exact phase depends on elapsed wall-clock
time, the same category the gate's own sky-masking rationale already
documents and the campaign doc's coverage table explicitly excludes
("Not covered - particles"). Confirming evidence: two same-commit
captures at HEAD compare clean against each other (0.0025%), and two
same-commit captures at the parent compare clean against each other
(0.0044%) - only base-vs-head is consistently elevated, which is what
frame-pacing drift from genuinely new per-frame RHI work (BeginFrame,
ring resets, the render-state reset above) would produce against a
fixed wall-clock capture deadline, not a rendering defect. Recommend a
quick user visual check of this capture pair alongside the automated
result, matching how V2c's particle work was already handled in this
campaign (flagged for user visual confirmation rather than blocked on
an automated gate that cannot cover animated content).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
ec414d60cd
commit
ceec3bc440
334 changed files with 3660 additions and 3840 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using AcDream.App.Rendering.Wb;
|
||||
|
|
@ -17,7 +17,7 @@ namespace AcDream.App.Streaming;
|
|||
/// Threading: not thread-safe. All calls must happen on the render thread.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public sealed class StreamingController
|
||||
internal sealed class StreamingController
|
||||
: IStreamingFrameBackend,
|
||||
IWorldRevealStreamingScheduler
|
||||
{
|
||||
|
|
@ -88,14 +88,14 @@ public sealed class StreamingController
|
|||
|
||||
// True while streaming is collapsed to the single dungeon landblock the
|
||||
// player stands in (the dungeon gate, #133 FPS). AC dungeons have NO
|
||||
// adjacent landblocks — neighbors are unrelated ocean-grid dungeons that
|
||||
// are never visible, so we stop loading the 25×25 window entirely.
|
||||
// adjacent landblocks — neighbors are unrelated ocean-grid dungeons that
|
||||
// are never visible, so we stop loading the 25×25 window entirely.
|
||||
private bool _collapsed;
|
||||
|
||||
// The dungeon landblock id we collapsed onto. Once collapsed we key the
|
||||
// gate on this STABLE landblock, not the per-frame insideDungeon signal:
|
||||
// CurrCell can momentarily resolve to null/outdoor mid-frame, and gating
|
||||
// expand on that flicker thrashes collapse↔expand (reload storms + a light
|
||||
// expand on that flicker thrashes collapse↔expand (reload storms + a light
|
||||
// leak). We only expand when the observer actually moves to a different
|
||||
// landblock (teleport/portal out).
|
||||
private uint _collapsedCenter;
|
||||
|
|
@ -610,16 +610,16 @@ public sealed class StreamingController
|
|||
|
||||
/// <summary>
|
||||
/// Advance one frame. <paramref name="observerCx"/>/<paramref name="observerCy"/>
|
||||
/// are landblock coordinates (0..255) of the current viewer — the camera
|
||||
/// are landblock coordinates (0..255) of the current viewer — the camera
|
||||
/// in offline mode, the server-sent player position in live.
|
||||
///
|
||||
/// <para>Two-tier model (Phase A.5 T13):</para>
|
||||
/// <list type="bullet">
|
||||
/// <item><see cref="TwoTierDiff.ToLoadFar"/> → enqueue LoadFar (terrain only, no entities)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToLoadNear"/> → enqueue LoadNear (terrain + entities)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToPromote"/> → enqueue PromoteToNear (entity layer for already-loaded terrain)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToDemote"/> → drop entities on render thread immediately (terrain stays)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToUnload"/> → enqueue full unload</item>
|
||||
/// <item><see cref="TwoTierDiff.ToLoadFar"/> → enqueue LoadFar (terrain only, no entities)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToLoadNear"/> → enqueue LoadNear (terrain + entities)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToPromote"/> → enqueue PromoteToNear (entity layer for already-loaded terrain)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToDemote"/> → drop entities on render thread immediately (terrain stays)</item>
|
||||
/// <item><see cref="TwoTierDiff.ToUnload"/> → enqueue full unload</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public void Tick(int observerCx, int observerCy, bool insideDungeon = false)
|
||||
|
|
@ -699,15 +699,15 @@ public sealed class StreamingController
|
|||
if (_collapsed)
|
||||
{
|
||||
// Hysteresis. Cases:
|
||||
// - Still in the SAME dungeon landblock → hold (sweep stragglers).
|
||||
// - Still in the SAME dungeon landblock → hold (sweep stragglers).
|
||||
// - In a DIFFERENT dungeon cell (multi-landblock dungeon / new dungeon)
|
||||
// → re-collapse onto it.
|
||||
// → re-collapse onto it.
|
||||
// - CurrCell flickered null but the player hasn't gone anywhere: the
|
||||
// observer landblock reverts to the position-derived value, which for a
|
||||
// dungeon is only ever the ADJACENT off-by-one landblock (negative cell-
|
||||
// local Y). Hold — never expand on an adjacent flicker.
|
||||
// local Y). Hold — never expand on an adjacent flicker.
|
||||
// - Genuinely left to a DISTANT landblock (portal/teleport out, always far
|
||||
// from the ocean-grid dungeon block) → expand.
|
||||
// from the ocean-grid dungeon block) → expand.
|
||||
if (insideDungeon && centerId != _collapsedCenter)
|
||||
EnterDungeonCollapse(observerCx, observerCy, centerId);
|
||||
else if (!insideDungeon && ChebyshevLandblocks(centerId, _collapsedCenter) > 1)
|
||||
|
|
@ -910,23 +910,23 @@ public sealed class StreamingController
|
|||
|
||||
/// <summary>
|
||||
/// #135: collapse to a single dungeon landblock IMMEDIATELY, before the first
|
||||
/// <see cref="Tick"/> has a chance to bootstrap the full 25×25 window. Called
|
||||
/// <see cref="Tick"/> has a chance to bootstrap the full 25×25 window. Called
|
||||
/// from the login / teleport spawn path the instant the streaming center is
|
||||
/// recentered onto a SEALED dungeon landblock.
|
||||
///
|
||||
/// <para>The per-frame <c>insideDungeon</c> gate keys on the physics
|
||||
/// <c>CurrCell</c>, which is only set once the player is PLACED — and placement
|
||||
/// <c>CurrCell</c>, which is only set once the player is PLACED — and placement
|
||||
/// waits for the dungeon landblock to hydrate. So for the whole hydration window
|
||||
/// (tens of seconds for a ~200-cell dungeon) the gate reads false and
|
||||
/// <see cref="NormalTick"/> would enqueue the ~24 unrelated ocean-grid neighbor
|
||||
/// dungeons (+ ~19k entities each); the collapse then only mops them up after
|
||||
/// placement. That mop-up is the 10→high FPS ramp users see at a dungeon login.</para>
|
||||
/// placement. That mop-up is the 10→high FPS ramp users see at a dungeon login.</para>
|
||||
///
|
||||
/// <para>Pre-collapsing means the EXPENSIVE dungeon-neighbour window is never
|
||||
/// enqueued. On teleport nothing is enqueued at all (this fires before the next
|
||||
/// Tick recenters). On login a brief Holtburg outdoor window may be enqueued by the
|
||||
/// frame-1 NormalTick (before the player's spawn arrives) and is immediately
|
||||
/// cancelled by <c>_clearPendingLoads</c> here — cheap outdoor terrain, not the
|
||||
/// cancelled by <c>_clearPendingLoads</c> here — cheap outdoor terrain, not the
|
||||
/// ocean-grid dungeons, and a handful of already-dequeued loads get swept next
|
||||
/// frame. Idempotent: a no-op when already collapsed onto this same landblock, so a
|
||||
/// re-sent spawn or a same-frame double call costs nothing. Render-thread only,
|
||||
|
|
@ -954,7 +954,7 @@ public sealed class StreamingController
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outdoor / building-interior streaming — the original two-tier model.
|
||||
/// Outdoor / building-interior streaming — the original two-tier model.
|
||||
/// </summary>
|
||||
private void NormalTick(int observerCx, int observerCy)
|
||||
{
|
||||
|
|
@ -1012,11 +1012,11 @@ public sealed class StreamingController
|
|||
/// <summary>
|
||||
/// Dungeon-entry edge: cancel the in-flight window load, unload every
|
||||
/// resident neighbor, and pin streaming to the player's single dungeon
|
||||
/// landblock. Retail-faithful — AC dungeons have no adjacent landblocks
|
||||
/// landblock. Retail-faithful — AC dungeons have no adjacent landblocks
|
||||
/// (ACE <c>LandblockManager.GetAdjacentIDs</c> returns empty for a dungeon);
|
||||
/// the 25×25 window was pulling in ~129 unrelated ocean-grid dungeons and
|
||||
/// the 25×25 window was pulling in ~129 unrelated ocean-grid dungeons and
|
||||
/// their thousands of emitters (#133 FPS). Unloading them also tears down
|
||||
/// their lights, shrinking the static-light set toward retail's ≤40.
|
||||
/// their lights, shrinking the static-light set toward retail's ≤40.
|
||||
/// </summary>
|
||||
private void EnterDungeonCollapse(int cx, int cy, uint centerId)
|
||||
{
|
||||
|
|
@ -1049,7 +1049,7 @@ public sealed class StreamingController
|
|||
|
||||
/// <summary>
|
||||
/// While collapsed, unload any landblock that finished loading after the
|
||||
/// collapse edge — a Load the worker had already dequeued before the
|
||||
/// collapse edge — a Load the worker had already dequeued before the
|
||||
/// <see cref="LandblockStreamer.ClearPendingLoads"/> control job took
|
||||
/// effect. At steady state only the dungeon landblock is resident, so this
|
||||
/// is a no-op.
|
||||
|
|
@ -1057,7 +1057,7 @@ public sealed class StreamingController
|
|||
private void SweepCollapsed()
|
||||
{
|
||||
// Always preserve the true dungeon landblock (_collapsedCenter), never the
|
||||
// per-frame observer landblock — a CurrCell flicker must not unload the dungeon.
|
||||
// per-frame observer landblock — a CurrCell flicker must not unload the dungeon.
|
||||
foreach (var id in _state.LoadedLandblockIds)
|
||||
if (id != _collapsedCenter) EnqueueUnload(id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue