Files
retroDE_ps2/docs/ch403_authentic_vertex_modulation_closeout.md
T
thejayman77 ba74bbd5aa Snapshot: fog implementation + fidelity tooling baseline (pre bilinear-clamp fix)
Per-vertex GS fog end-to-end (gs_stub emit incl. persp_emit5, gs_prim_list_feeder
XYZ2->XYZF2 on PRIM.FGE, gs_make_sh3_scheduler_fixture.py F/FGE packing), new fog
TBs, fidelity attribution tooling. Functional baseline before removing the dead
bilinear lerp8 clamps (Codex: 161-node comb loop -> -0.042ns setup fail).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 19:56:46 -04:00

92 lines
4.0 KiB
Markdown

# Ch403 — authentic vertex-color modulation
## Objective
Make the 224139 static-frame fixture use the captured GS lighting state instead
of drawing every texture at raw DECAL brightness. Geometry, draw order,
runtime CLUT handling, persistent Z, and the Ch402 40-epoch staging partition
remain unchanged.
## Finding
The selected draws carry `TEX0.TFX=MODULATE` and non-unity per-vertex RGB.
Ch402 deliberately forced `TFX=DECAL` and emitted zero placeholder RGB, which
made the composite much brighter than the PCSX2 frame.
The first Ch403 fixture proved a second, narrower gap: the existing MODULATE
implementation was only connected to the combined affine texture path. These
SH3 triangles use the five-cycle perspective path, whose emit was explicitly
hardwired to the raw texel. Consequently the live board completed every gate
but produced a framebuffer byte-identical to Ch402.
## Implementation
- `tools/gs_make_sh3_scheduler_fixture.py`
- adds opt-in `--auth-color-tfx`;
- preserves authentic `TEX0.TFX` and per-vertex RGB;
- interpolates RGB when clipping triangles;
- applies the same GS `texel * vertex / 128` saturation rule in the
independent reference.
- `rtl/gif_gs/gs_stub.sv`
- aligns the already-computed S2 Gouraud color with the perspective texel by
four registers;
- applies MODULATE at the perspective S1+5 emit;
- shares the existing three-channel modulation datapath between affine and
perspective paths, avoiding a duplicate multiplier set;
- leaves DECAL output byte-identical.
- `sim/tb/top/tb_top_psmct32_sh3_zint640_shared.sv`
- verifies the full 64-bit staged header and committed TEX0 state;
- fixes late-epoch diagnostic fill accounting.
## Fixture
`zsrt139a9` retains all 68 Ch402 draws in 40 staging-safe epochs. The largest
list is 1844 of 2048 words (204 words headroom).
The independent modulated reference is:
`captures/gs/silenthill3/extracted/recon/sh3_zsrt139a9_ref.png`
Against the PCSX2 224139 image resized to the same 640x480 comparison grid,
the fixture-only reference improves RGB MAE from 31.34 to 23.31 and RMSE from
45.94 to 33.61. This does not claim full fidelity: missing draws/fog and the
perspective/XY precision deficit remain visible.
## Verification
- Generator preflight: 40 epochs, max 1844 words, no staging overflow.
- Focused epoch 39 MODULATE proof:
- old DECAL hash: `37401414dd6ee3b2888d4ddb4aff98903900475e6cf2a47d973959ee05d05fb8`
- MODULATE hash: `c85edea3d42e983a31f630b7fffc1457c26233492c332860b7913c20ad7613c0`
- average nonblack RGB sum: 258.49 -> 113.23; geometry remains present.
- Focused Ch402 DECAL regression remains byte-identical at the old hash.
- Full 40-epoch RTL:
- 649,189 fragments fed; 332,984 passed persistent Z;
- 40 markers, 40 rises / 39 falls, zero drops/overflows/BRESP errors;
- Z mismatch `0/307200`; color mismatch `0/131618`;
- framebuffer SHA-256
`d286e9d5839fc7ab63ae6bc1aa3c26fa867397171ad3d1a5e5edc3b6c5b14964`;
- PASS.
- The final shared-multiplier implementation reproduces the focused MODULATE
hash exactly and its late-epoch diagnostic passes with zero errors.
- Owner Quartus 26.1 GUI fit:
- setup worst slack `+0.080 ns`, TNS `0`;
- hold passes, worst reported slack `0.000 ns`, TNS `0`;
- 37,353 / 46,800 ALMs, 53,238 registers, 284 / 358 RAM blocks,
4,177,064 memory bits, and 153 / 376 DSP blocks;
- core RBF SHA-256
`28659ebfccb19f03478fcd105904cc1b03195e8cc0907fad3903f56d7821975b`.
- Live-board acceptance:
- all 40 epochs completed with every texture CRC, palette checksum, staged
word/record count, fresh-drain, fragment-drop, and bus-response gate clean;
- host runner returned `0`;
- the 307,200-word board framebuffer compares byte-for-byte with RTL;
- board and RTL framebuffer SHA-256
`d286e9d5839fc7ab63ae6bc1aa3c26fa867397171ad3d1a5e5edc3b6c5b14964`.
## Status
Complete and accepted on silicon. The current HDMI image is the authentic
vertex-color-modulated 40-epoch composite; the next fidelity work is geometry
precision and remaining GS effects/draw coverage, not Ch403 correctness.