Files
retroDE_ps2/docs/ch432_perspective_bilinear_handshake_prefit.md
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

3.8 KiB

Ch432 — perspective palette-bilinear handshake repair (prefit)

Objective

Remove the regular missing-sample pattern from the authentic SH3 perspective scene without changing its fixture, chronology, Z state, textures, palettes, or accepted display mapping. The live f42 composition remains the input; this chapter is an RTL fidelity repair and therefore requires a new owner GUI fit.

Root cause

Dense perspective palette-bilinear epochs emitted almost exactly half of their independent software coverage. Representative f19 epoch 74 emitted 7,301 fragments against 14,371 independently rasterized covered pixels. Other dense epochs showed the same approximately 2:1 deficit. A GEQUAL-to-ALWAYS Z-only diagnostic added just 571 lit pixels and worsened PCSX2 score, ruling out Z as the broad missing-surface cause.

The serialized four-tap sampler launched an S1 pixel in PB_IDLE, held the pipeline in PB_WAIT, emitted the completed pixel, and then advanced again in PB_RELEASE. Because the launch cycle had already advanced the raster walker, the release advance skipped the next waiting S1 sample. This produced the regular screen-door population loss while all existing scoreboards still passed for the subset that was actually emitted.

RTL repair

The sampler now treats launch as the single normal pipeline advance, holds through PB_WAIT, and uses PB_RELEASE as a final hold cycle. The next S1 sample is therefore launched rather than overwritten. Perspective input valid is also qualified by the existing Z and texture-alpha advance enables, so a frozen beat cannot submit the held sample twice.

This sequencing deliberately keeps the 35-bit triangle-inside result off the high-fanout pipeline-enable path. The only added global gating term is the already-registered two-bit sampler state, minimizing timing risk after the timing-clean Ch431 baseline.

Regression gates

The PSMT8 perspective triangle test now enables the serialized palette-bilinear path and checks independent coverage. It passes 31/31 covered samples with no missing pixels, valid colors, correct alpha metadata, and correct MODULATE behavior. The affine palette-bilinear tile regression also passes unchanged.

The production isolated epoch-74 gate is now explicit through +EXPECT_FED=14341. It passes at 14,341 fragments (up from 7,301), with zero drops, exact Z/color comparisons, and complete marker/drain accounting. The 30-pixel difference from the independent 14,371 coverage map is the existing edge-rule/model boundary, not alternate-sample loss.

The complete unchanged f42 composition passes all 292 epochs:

  • 2,339,405 fragments fed and 2,285,783 passed;
  • 292 markers and drains;
  • zero fragment drops, color overflows, and AXI errors;
  • Z mismatch 0/307,200 and color mismatch 0/245,760;
  • framebuffer SHA-256 31d21fb5c38816ef99ace1d7b55186dc749720e874ecb055a68b21584ec27037.

Fidelity result

The repaired f19 opaque scene lights 173,354 pixels instead of 111,705. Its error against the independent f19 software reference improves from MAE 11.7491 / RMSE 24.6649 to MAE 8.7494 / RMSE 18.7008. Against the PCSX2 frame through the accepted display map it improves from MAE 20.9469 / RMSE 29.7626 to MAE 18.3393 / RMSE 25.8374.

On the complete f42 composition, 240,224 pixels are nonzero. The mapped PCSX2 score improves materially from Ch431's MAE 18.9405 / RMSE 27.6301 to MAE 15.0765 / RMSE 21.9717. The remaining visual noise is real follow-on work, but this chapter restores a large missing surface population rather than merely adding more draw capacity.

Fit boundary

The preceding owner GUI fit is clean and the runtime-fabric audit passes at 38,241 ALMs and 336 RAM blocks, with 310 MHz setup met. Those reports predate this RTL repair. Ch432 is simulation-complete and ready for the owner to run a new Quartus GUI compile; no command-line Quartus flow was used.