Inventory grid parity: the masked check keeps the masked grid enabled and compares a fresh grid in the same render

Disabling and re-enabling the masked grid between steps rebuilt its stencil clone and hid a stale one; the modified-material-unpushed mutant now dies (231 against 0).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-30 23:55:30 +01:00
commit d1c3a7a2e8

View file

@ -357,17 +357,8 @@ public static class InventoryGridParityCapture
var masked = MakeGrid((RectTransform) holder.transform, 20, 20, 300, 1f);
((RectTransform) masked.transform).sizeDelta = new Vector2(300, 300);
Color32[] Reference(Action<InventoryGrid> configure)
{
var side = NewObject("Reference", rig.Page, 100, 100, 500);
var grid = MakeGrid((RectTransform) side.transform, 20, 20, 300, 1f);
((RectTransform) grid.transform).sizeDelta = new Vector2(300, 300);
configure(grid);
grid.Flush();
var drawn = rig.Render();
UnityEngine.Object.DestroyImmediate(side);
return drawn;
}
// The masked grid stays enabled through every step (disabling and enabling it would rebuild its clone and hide a stale one); a fresh
// unmasked grid with the same configuration sits 700 canvas units to its right in the same render, and the two regions are compared.
void Fill(InventoryGrid grid, int w, int h)
{
for (var y = 0; y < h; y++)
@ -378,16 +369,26 @@ public static class InventoryGridParityCapture
{
configure(masked);
masked.Flush();
var side = NewObject("Reference", rig.Page, 800, 100, 500);
var reference = MakeGrid((RectTransform) side.transform, 20, 20, 300, 1f);
((RectTransform) reference.transform).sizeDelta = new Vector2(300, 300);
configure(reference);
reference.Flush();
var drawn = rig.Render();
// The reference page holds the masked grid too, so hide it for the reference render.
masked.gameObject.SetActive(false);
var expected = Reference(configure);
masked.gameObject.SetActive(true);
UnityEngine.Object.DestroyImmediate(side);
var worst = 0;
for (var i = 0; i < drawn.Length; i++) worst = Mathf.Max(worst, MaxDifference(drawn[i], expected[i]));
Log($"masked {name}: max8bitDiff against a fresh unmasked grid = {worst}");
var lit = 0;
for (var y = 100; y < 600; y++)
for (var x = 100; x < 600; x++)
{
worst = Mathf.Max(worst, MaxDifference(drawn[y * rig.Width + x], drawn[y * rig.Width + x + 700]));
if (drawn[y * rig.Width + x].r > 30) lit++;
}
var clone = masked.canvasRenderer.GetMaterial() != masked.material;
Log($"masked {name}: max8bitDiff against a fresh unmasked grid = {worst}, {lit} lit pixels; drawn through a stencil clone of the material: {clone}");
_maskedWorst = Math.Max(_maskedWorst, worst);
if (worst > 1) Breaches.Add($"masked {name}: {worst} > 1");
if (lit == 0 || !clone) Breaches.Add($"masked {name}: the check drew nothing or not through a stencil clone, so it proves nothing");
}
// The reference helper configures a fresh grid with the same calls, so each step is a full configuration, not a delta.
var steps = new List<Action<InventoryGrid>>();