fix(render): correct foliage-wind classification, receiver/caster desync, and frame binding (Campaign VM VM6 review)
Opus dual-lens review of the three VM6 commits (0930c35d,39e8408c,6cc5e183) found two blockers and two should-fix issues; all landed here along with the review's nits and documentation corrections. Blockers: - A1: the procedural-scenery classifier tested bit 31 alone instead of the full top nibble (0xF000_0000 == 0x8000_0000), so it also matched LandblockStaticEntityIdAllocator's 0xC... namespace (fences/gates/ building shells with a cutout subset), the 0xDA11_D0xx paperdoll id, and the 0xFFFF_FF01 portal-tunnel id as procedural scenery — all three would have swayed. ProceduralSceneryIdAllocator.IsInNamespace now does the exact top-nibble test; FoliageWindClassification delegates to it. - A2: GroupKey (the receiver's instance-batching key) did not carry FoliageFlags while the caster's dedup key already did, so a scenery instance and a non-scenery instance sharing a mesh subset coalesced into one receiver InstanceGroup whose flags were last-writer-wins — disagreeing with the correctly-keyed caster. GroupKey now carries FoliageFlags, computed before key construction and set exactly once at group creation; the imperative re-stamp is gone, and CachedBatch's now-redundant FoliageFlags field is removed. Should-fix: - A3: the world receiver pass bound UniformAtmosphericFrame only by accident (leftover from the caster pass, which runs first each frame, since Vulkan binding state isn't reset between passes). DirectionalShadowFrameBinding now carries the caster's exact AtmosphericFrameBufferBinding and BindDirectionalShadowReceiver binds it explicitly. - A4: a Setup-composed tree's opaque trunk part never got the trunk flag because HasCutoutSubset is cached per GfxObj part, not per entity. FoliageWindClassification.ComputeEntityHasCutoutSubset now ORs HasCutoutSubset across an entity's resolved sibling parts once per entity, threaded into ClassifyBatches/AddDirectionalShadowBatches via a new optional override parameter. Nits: A5 hashes the per-vertex flutter seed relative to the instance origin instead of absolute world XY (fp32 sin() precision loss at far landblock corners), mirrored in both foliage_wind.glsl and FoliageWindModel; A7 documents the max(maxHeight, 0.5) divide-guard as a deliberate pseudocode divergence; A8 switches FoliageWindExclusions' construction to ToFrozenSet() and softens the "never stale" doc comment to "no slower than one frame behind." Tests added: top-nibble classification (0xFFFFFFFFu now correctly false), GroupKey inequality across entity-driven scenery/landblock- static classification, a caster-batch test proving the same pairing never coalesces, ComputeEntityHasCutoutSubset unit + end-to-end two-part-Setup tests, the caster→receiver AtmosphericFrame binding carry-through, flutter-hash translation invariance relative to instance origin, and a Storm-wind mid-height displacement floor guarding against a "no motion" regression. Docs: plan VM6 body corrected to the five-row WeatherKind table, "bits 1 and 2", "all four" caster shaders, and top-nibble wording throughout; the owner gate checklist's Rain/Storm step; the stale v1-only shader- interface compatibility entry; semantic-bindings-v1.md's v2 members folded into the main 192-byte block; the IA-25 register row's top- nibble wording; AtmosphericFrameInputs.cs's ABI size reference. foliage_wind.glsl's A5 change recompiled exactly the five shaders that include it (mesh_atmospheric.vert, the four directional_shadow_world_* casters) plus the manifest; no other .spv changed. Verify: Release build 0 warnings/0 errors. App hermetic-lane filter 6,041/0 failed (no environment-specific failures this run). RenderPackValidator 30/30. Full hermetic-filtered solution: 15,269/0 failed across 15 projects. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
27a446f05c
commit
43e3abed4d
28 changed files with 724 additions and 123 deletions
|
|
@ -129,6 +129,106 @@ public sealed class DirectionalShadowPreparedDrawTests
|
|||
Assert.Equal(1, product.Stats.RejectedFadedParts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Campaign VM VM6 review fix round (A2): two instances of the IDENTICAL
|
||||
/// mesh subset (same index range, texture, material, cull mode) — one a
|
||||
/// procedural-scenery entity (top nibble 0x8), one a
|
||||
/// LandblockStaticEntityIdAllocator entity (top nibble 0xC) sharing the
|
||||
/// SAME GfxObj — classify to different FoliageWindClassification flags
|
||||
/// (0x2 cutout vs 0x0) via the identical Classify call the world
|
||||
/// receiver uses, and must land as two SEPARATE prepared caster
|
||||
/// batches/commands rather than coalescing into one. This is the
|
||||
/// caster-side half of "casters and receivers agree by construction":
|
||||
/// DirectionalShadowDrawKey (the caster's sort/group key, unlike the
|
||||
/// pre-fix receiver GroupKey) already includes FoliageFlags, so this
|
||||
/// pins that it stays correct.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void SameSubsetDifferentFoliageClassificationNeverCoalescesIntoOneCasterBatch()
|
||||
{
|
||||
const uint sceneryEntityId = 0x80010203u; // ProceduralSceneryIdAllocator
|
||||
const uint landblockStaticEntityId = 0xC0010203u; // LandblockStaticEntityIdAllocator
|
||||
uint sceneryFlags = FoliageWindClassification.Classify(
|
||||
sceneryEntityId,
|
||||
isExcluded: false,
|
||||
TranslucencyKind.ClipMap,
|
||||
meshHasCutoutSubset: true);
|
||||
uint landblockStaticFlags = FoliageWindClassification.Classify(
|
||||
landblockStaticEntityId,
|
||||
isExcluded: false,
|
||||
TranslucencyKind.ClipMap,
|
||||
meshHasCutoutSubset: true);
|
||||
Assert.Equal(FoliageWindClassification.CutoutFoliageFlag, sceneryFlags);
|
||||
Assert.Equal(0u, landblockStaticFlags);
|
||||
|
||||
var product = new DirectionalShadowPreparedDraws();
|
||||
RenderSceneGeneration generation = RenderSceneGeneration.FromRaw(1);
|
||||
Assert.True(product.TryBegin(generation, 1, estimatedInstances: 2));
|
||||
Matrix4x4 sceneryTransform = Matrix4x4.CreateTranslation(1f, 2f, 3f);
|
||||
Matrix4x4 landblockStaticTransform = Matrix4x4.CreateTranslation(9f, 8f, 7f);
|
||||
GpuTextureSlot sharedTexture = new(42);
|
||||
|
||||
product.Add(
|
||||
firstIndex: 100,
|
||||
baseVertex: 5,
|
||||
indexCount: 12,
|
||||
sharedTexture,
|
||||
textureLayer: 0,
|
||||
CullMode.CounterClockwise,
|
||||
DirectionalShadowCasterMaterial.AlphaCutout,
|
||||
in sceneryTransform,
|
||||
sceneryFlags);
|
||||
product.Add(
|
||||
firstIndex: 100,
|
||||
baseVertex: 5,
|
||||
indexCount: 12,
|
||||
sharedTexture,
|
||||
textureLayer: 0,
|
||||
CullMode.CounterClockwise,
|
||||
DirectionalShadowCasterMaterial.AlphaCutout,
|
||||
in landblockStaticTransform,
|
||||
landblockStaticFlags);
|
||||
product.Complete(
|
||||
generation,
|
||||
1,
|
||||
new DirectionalShadowPreparationStats(
|
||||
SourceCasters: 2,
|
||||
SourceMeshRefs: 2,
|
||||
SourceParts: 2,
|
||||
SourceBatches: 2,
|
||||
PreparedInstances: 0,
|
||||
PreparedOpaqueCommands: 0,
|
||||
PreparedAlphaCutoutCommands: 0,
|
||||
RejectedTransparentBatches: 0,
|
||||
RejectedFadedParts: 0,
|
||||
MissingMeshes: 0,
|
||||
UnresolvedAlphaCutoutTextures: 0));
|
||||
|
||||
// Two distinct commands/batches, NOT one command with InstanceCount=2
|
||||
// — the identical geometry/texture/material would have coalesced
|
||||
// pre-fix, since only entity-level classification (which the caster
|
||||
// key did not carry before A2) tells them apart.
|
||||
Assert.Equal(2, product.Commands.Length);
|
||||
Assert.Equal(2, product.Batches.Length);
|
||||
Assert.All(product.Commands.ToArray(), command => Assert.Equal(1u, command.InstanceCount));
|
||||
|
||||
int sceneryIndex = product.Batches.ToArray()
|
||||
.ToList()
|
||||
.FindIndex(batch => batch.FoliageFlags == FoliageWindClassification.CutoutFoliageFlag);
|
||||
int landblockStaticIndex = product.Batches.ToArray()
|
||||
.ToList()
|
||||
.FindIndex(batch => batch.FoliageFlags == 0u);
|
||||
Assert.True(sceneryIndex >= 0, "expected one prepared batch carrying the cutout foliage flag");
|
||||
Assert.True(landblockStaticIndex >= 0, "expected one prepared batch carrying zero foliage flags");
|
||||
Assert.NotEqual(sceneryIndex, landblockStaticIndex);
|
||||
Assert.Equal(
|
||||
sceneryTransform,
|
||||
product.Transforms[(int)product.Commands[sceneryIndex].BaseInstance]);
|
||||
Assert.Equal(
|
||||
landblockStaticTransform,
|
||||
product.Transforms[(int)product.Commands[landblockStaticIndex].BaseInstance]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameCasterBuild_ReplaysWithoutReclassificationOrStorageGrowth()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue