feat(render): Campaign V slice V6k commit 1 - the sky draws on Vulkan
V4f's content, landed as a SECOND arm per section 5.5.6: GL keeps its raw world
path through to V10 and the RHI world path ships on Vulkan. Every GL statement in
SkyRenderer is the one it always issued; the encoder arm lives in SkyRenderer.Rhi.cs
and runs only when there is no GL context.
What it produces. ACDREAM_RENDER_BACKEND=vulkan renders the sky: the dome
quadrants, the horizon band, the cloud sheet and the fog gradient, in the same
place and the same colours as the GL capture of the same scene (within a few
units on the channels sampled, which is the day-fraction drift between two
launches). Section 5.5.15's first V7 defect - "the sky is flat fog" - is closed.
Three things differ from the GL arm, each because Vulkan bakes what GL sets. The
per-submesh blend function becomes two PIPELINES, additive for sun/moon/stars and
straight alpha for everything else, because core Vulkan 1.3 does not make blend
dynamic. The SkyParams block becomes a ring slice taken per draw rather than one
buffer rewritten per draw, because a descriptor's contents are read at execution
time, not record time. And the pass is borrowed from IWorldPassScope, because the
frame's one backbuffer pass resolves and a second pass could not load what it
left.
The sky is the first Vulkan consumer of set 1 binding 4. Section 5.5.8 recorded
that UniformSkyParams was missing from the uniform set layout and V6i-2 added it;
until now nothing had ever bound it.
The stride bug, which is the fourth of its class this campaign. The first Vulkan
sky frame drew the dome as a field of blue-white noise. The RHI vertex layout
declared a 32-byte stride - position, normal, texcoord, exactly what sky.vert
reads - while AcDream.Core.Terrain.Vertex is 36 bytes: it carries a fourth
member, TerrainLayer, that no sky attribute names and that the GL arm never
described to a glVertexAttribPointer but did count, because it says
sizeof(Vertex). Nothing else in the frame looked wrong, no validation rule was
violated, and the offline pixel gate masks the sky band, so only a side-by-side
capture found it. SkyVertexLayoutTests now asserts the REQUIREMENT - the stride
is the uploaded record's footprint - rather than today's number.
The last interim handle table is gone. V4t retired the private
GlBindlessHandleTable in WbDrawDispatcher, EnvCellRenderer, TerrainModernRenderer
and ParticleRenderer and deliberately left the sky's, because the sky is the one
world path that mints its own resident handles from TextureCache's raw GL texture
names rather than interning someone else's. It now registers those handles
through V4t's RegisterWorldTextureHandle seam instead, which is the same
mechanical change the other four took, and the class and its tests are deleted
because nothing else ever used them.
TextureCache gains RegisterWorldSurface(surfaceId, repeat), the sky's RHI texture
source: the same DecodeFromDats the GL path uses, created through
IGpuDevice.CreateTexture and paired with a real sampler object rather than baked
into a bindless handle. Keyed by (surface, wrap) for the same reason the GL arm
keys its handles that way - a table entry is a combined image sampler, so the
dome sampled CLAMP_TO_EDGE and a scrolling cloud sheet sampled REPEAT are two
entries over one decoded texture.
Gates. Release build green. App tests 4,109 passed / 3 skipped - the 4,112
baseline less the six GlBindlessHandleTable tests that went with the class, plus
three vertex-layout tests. Strict GL offline pixel gate against 7ae796a1:
4.43e-05, 25 differing pixels of 563,200, inside the documented 9-31 band, with
maximumChannelDelta 48 in the same 46-52 range every control pair reports. GL
connected repeat gate at 3 runs: 3/3 RENDERED on the desktop witness and 3/3 on
the client capture. Seven-day-group before-and-after comparison on GL - the
method V6e used, because the pixel gate masks the sky band - matching in
gradient, cloud sheet, horizon band and fog on every group, including day group
2's salmon cloud band and day group 6's green band. One offline Vulkan run with
VK_LAYER_KHRONOS_validation proven inserted by the loader: zero validation
errors, zero warnings, a captured sky frame, graceful close.
Coverage gap, stated rather than assumed. The offline scene is a fixed outdoor
view at one time of day, so the sun, the moon and the rain cylinder are drawn by
neither arm's gate. They join the accumulated user-gate debt in plan section 5.1,
where V6e already filed them.
No divergence-register row: no retail-facing behaviour changes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
7ae796a110
commit
22aa2edc65
7 changed files with 618 additions and 293 deletions
|
|
@ -350,6 +350,78 @@ public sealed unsafe class TextureCache
|
|||
/// registered with a nearest SAMPLER or every retail icon and dat-font
|
||||
/// glyph would silently become bilinear.</para>
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Campaign V slice V6k: one world Surface as a device texture-table slot,
|
||||
/// sampled with the wrap mode the caller needs.
|
||||
///
|
||||
/// <para>The sky's RHI arm is the only consumer, and it exists because that
|
||||
/// arm has no GL texture name to intern a bindless handle from — a Vulkan
|
||||
/// draw cannot sample a GL handle. The decode is the same
|
||||
/// <see cref="DecodeFromDats"/> the GL path uses, so the pixels are
|
||||
/// identical; what differs is that the image is created through
|
||||
/// <see cref="IGpuDevice.CreateTexture"/> and paired with a real sampler
|
||||
/// object rather than baked into a handle.</para>
|
||||
///
|
||||
/// <para>Keyed by (surface, wrap) for the same reason the GL arm keys its
|
||||
/// handles that way: a table entry is a combined image sampler, so the dome
|
||||
/// sampled CLAMP_TO_EDGE and a scrolling cloud sheet sampled REPEAT are two
|
||||
/// entries even when they name one decoded texture.</para>
|
||||
/// </summary>
|
||||
internal GpuTextureSlot RegisterWorldSurface(uint surfaceId, bool repeat)
|
||||
{
|
||||
var key = (surfaceId, repeat);
|
||||
if (_worldSurfaceGpuTextures.TryGetValue(key, out GpuUiTextureEntry existing))
|
||||
return existing.Slot;
|
||||
|
||||
DecodedTexture decoded = DecodeFromDats(
|
||||
surfaceId,
|
||||
origTextureOverride: null,
|
||||
paletteOverride: null);
|
||||
GpuUiTextureEntry entry = UploadWorldSurfaceTexture(
|
||||
decoded,
|
||||
repeat,
|
||||
$"world-surface-0x{surfaceId:X8}{(repeat ? "-repeat" : "-clamp")}");
|
||||
_worldSurfaceGpuTextures[key] = entry;
|
||||
return entry.Slot;
|
||||
}
|
||||
|
||||
private readonly Dictionary<(uint SurfaceId, bool Repeat), GpuUiTextureEntry>
|
||||
_worldSurfaceGpuTextures = new();
|
||||
|
||||
private GpuUiTextureEntry UploadWorldSurfaceTexture(
|
||||
DecodedTexture decoded,
|
||||
bool repeat,
|
||||
string debugName)
|
||||
{
|
||||
IGpuTexture texture = _device.CreateTexture(new GpuTextureDescription(
|
||||
debugName,
|
||||
GpuTextureKind.Texture2D,
|
||||
GpuTextureFormat.Rgba8Unorm,
|
||||
Width: decoded.Width,
|
||||
Height: decoded.Height,
|
||||
LayerCount: 1,
|
||||
MipLevelCount: 1));
|
||||
try
|
||||
{
|
||||
texture.Upload(0, 0, decoded.Rgba8);
|
||||
uint glName = UploadAccountingName(texture);
|
||||
TrackUploadedTexture(glName, decoded.Width, decoded.Height);
|
||||
|
||||
// Linear/linear with a single level — the filtering
|
||||
// TextureCache's own GL uploads have always used for sky surfaces,
|
||||
// and the wrap mode SamplerCache's two objects express on GL.
|
||||
IGpuSampler sampler = _device.CreateSampler(
|
||||
repeat ? GpuSamplerDescription.WorldRepeat : GpuSamplerDescription.WorldClamp);
|
||||
GpuTextureSlot slot = _device.RegisterTexture(texture, sampler);
|
||||
return new GpuUiTextureEntry(texture, slot, glName, decoded.Width, decoded.Height);
|
||||
}
|
||||
catch
|
||||
{
|
||||
texture.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private GpuUiTextureEntry UploadUiTexture(DecodedTexture decoded, bool nearest, string debugName)
|
||||
{
|
||||
IGpuTexture texture = _device.CreateTexture(new GpuTextureDescription(
|
||||
|
|
@ -1150,6 +1222,17 @@ public sealed unsafe class TextureCache
|
|||
}
|
||||
_renderSurfaceGpuTextures.Clear();
|
||||
|
||||
// Campaign V slice V6k: world Surface textures created through the RHI
|
||||
// for the sky's backend-neutral arm. Same ownership shape as the UI
|
||||
// entries above — the device retires the image, this releases the slot.
|
||||
foreach (GpuUiTextureEntry entry in _worldSurfaceGpuTextures.Values)
|
||||
{
|
||||
entry.Texture.Dispose();
|
||||
_device.ReleaseTextureSlot(entry.Slot);
|
||||
UntrackUploadedTexture(entry.GlName);
|
||||
}
|
||||
_worldSurfaceGpuTextures.Clear();
|
||||
|
||||
// Ad-hoc textures from the public UploadRgba8(byte[],int,int,bool) wrapper
|
||||
// (IconComposer composited icons). Not stored in any keyed cache.
|
||||
foreach (GpuUiTextureEntry entry in _adhocGpuTextures)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue