Skip to content

Post: exact instruction cuts in the history and filter passes - #270

Merged
phantoslayer21 merged 2 commits into
mainfrom
post-exact-cuts
Nov 17, 2026
Merged

phantoslayer21 merged 2 commits into
mainfrom
post-exact-cuts

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Three exact instruction cuts in Model M's post kernel (clean/dx12/kernels/post.hlsl). The output is byte-identical to before.

  • History interior base: hist_prev + (ix - 1) 8 + (iy - 1) pitch is computed as one mad_u24(iy, pitch, ix 8 + C) with C = hist_prev - 8 - pitch kept opaque. Otherwise the driver splits the constant back into its parts. This saves one VALU per Catmull-Rom sample. The two expressions are equal mod 2^32, so the buffer offset and its range check are the same.
  • Horizontal 5-tap pass: the four outputs read the tap windows t0-4, t2-6, t3-7 and t5-9, so their ranges now share the min / max of t2-4 and t5-7 (6 + 6 three-input min / max instead of 8 + 8). Every tap is a display value clamped by max_num(kEncK * log2(x), +0) with x >= 1e-4 and kEncK > 0. NaN gives the +0 bound, log2 is +-0 only at x = 1 (where it is +0), and +inf gives the 2.45 bound. So no NaN and no -0 reaches the min / max, and the grouping cannot change a bit.
  • Staging fetch: the wave-uniform footprint row is computed as mad(.., -0), which equals the product exactly. The driver then keeps it on the scalar unit (s_mul_f32 in the ISA) instead of v_mul_f32 + v_cvt + v_readfirstlane.

The cuts apply to the 3 x f32 row form and the direct forms (WG_POST_CUTS). The RGBA16F row forms (post_tf_p12_diet_vsit, _tex) compile to the same DXIL as before. OP_POST_MUTANT is a test-only define holding the mutants used below.

RGA (gfx1201), the direct kernel's hot path for one row pair: -11 VALU / -20 issue slots. VGPRs are at or below the previous count in every post kernel (direct 94), LDS is unchanged, and there are no SGPR spills.

Measured

Interleaved timing: fresh process per run, order reversed on odd rounds, 9 rounds, 1500 frames per run, synthetic Model M, direct route, D3D12 timestamps.

post stage, paired median rounds faster
1440p Quality -2.0 us 9 of 9
1080p Quality -1.0 us 9 of 9

At 1440p Quality the frame median went from 2.1175 to 2.1155 ms (paired median -2.0 us, 7 of 9 rounds faster). At 1080p Quality the frame delta is within noise, so no frame gain is claimed there. Every timing run's 1500-frame output hash equals the previous build's.

Tested

  • Previous vs new post kernels in one process (same runtime, two contexts), 6 frames each, 0 differing values, with the post kernel named by the launch trace in every leg:
    • direct, 8 waves (post_tf_f32_p12_diet_vsit_direct): 1440p Q, 1080p Q, 4K Performance, 3440x1440 ultrawide, 1001x563 -> 1501x845 (odd size). A leg with padded input textures (WG_TEST_TEX_PAD=3) also ran identical, but the pad's effect was not verified: the harness prints no texture size;
    • direct, 4 waves (post_tf4_dl_f32_p12_diet_vsit_direct): native AA 2560x1440, ratio 1.33 (1920x1080 -> 2560x1440), native AA 1501x845;
    • motion at output resolution: pmo/post_tf_f32_p12_mo_direct (1440p Q) and pmo/post_tf4_dl_f32_p12_mo_direct (native AA);
    • analytic output filter (output_filter=analytic): 1440p Q, native AA, odd size.
  • Pre-exposure 1.375 (the direct body's copy for a pre-exposure other than 1): output hash equal to the previous build's over 600 frames.
  • The 3 x f32 row forms against their HIP code objects (clean/dx12/compare.py, every stage and state buffer): post_tf_f32_p12_diet_vsit (1706x960 -> 2560x1440 and 853x481 -> 1279x721) and pmo/post_tf_f32_p12_mo (motion at output resolution), all identical.
  • Mutants, each caught: the horizontal range with tap 6 left out (every original-filter leg above, and both compare.py runs), a history base offset by 8 bytes (every leg above, the analytic ones included), and a mutant only in the pre-exposure copy (at pre-exposure 1.375).
  • public_gates.py: must-pass gates pass.

Not tested

  • The direct body's copy for a render rectangle that differs from the port's: no shipped route reaches it. The D3D12 executor refuses such frames (executor_d3d12.cpp, "render rectangle differs from the frame's render size"), and a mutant only in that copy is not caught. It shares the cut code with the tested copies.
  • The 4-wave and analytic 3 x f32 row forms on the hybrid backend: game builds do not select them (native D3D12 external I/O requires the direct route, runtime.cpp).
  • In-game timing.

Record: RESULT-POST-EXACT-B1 (team notes).

…entical

- history interior base as one mad_u24 with an opaque constant (-1 VALU per Catmull-Rom sample)
- horizontal 5-tap pass: the four outputs share the min / max of their overlapping tap windows (6 + 6 three-input
  min / max instead of 8 + 8; the ring taps are finite FP16 values >= +0, so the grouping does not matter)
- staging fetch: the wave-uniform footprint row as mad(.., -0) so it stays on the scalar unit
- OP_POST_MUTANT (test-only define): mutants of the horizontal range for the byte check

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…for the byte check

WG_POST_CUTS limits the history base fold and the shared horizontal min / max to the 3 x f32 row form and the
direct forms, whose bytes the checks cover; post_tf_p12_diet_vsit and its texture-output form compile to the same
DXIL as before. OP_POST_MUTANT=4 (test-only) offsets the history base so the byte check can show it reaches
every form, the analytic output filter included.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 17, 2026 04:47
@phantoslayer21
phantoslayer21 merged commit 527f21a into main Nov 17, 2026
10 checks passed
@phantoslayer21
phantoslayer21 deleted the post-exact-cuts branch November 17, 2026 11:49
phantoslayer21 added a commit that referenced this pull request Nov 17, 2026
…s) into release-0.6.1

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant