Skip to content

D3D12: the analytic standalone output filter w64/post_filter_c1_s4 (post_w64.co), byte for byte against HIP - #147

Merged
phantoslayer21 merged 2 commits into
mainfrom
dx12/post-filter-analytic
Nov 14, 2026
Merged

phantoslayer21 merged 2 commits into
mainfrom
dx12/post-filter-analytic

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Refs #89

D3D12 port of the analytic standalone output filter w64/post_filter_c1_s4 of post_w64.co, byte for byte against HIP.

This is the runtime's default unbanded filter (kDefaultFilter). It runs after a reconstruction kernel that writes the display image when the model file has no output-filter weights. With it, the D3D12 frame can run Model L's own reconstruction l_post_recon_p12 (#141) followed by this filter.

What

  • clean/dx12/kernels/post_filter.hlsl (new): @wg-kernel w64/post_filter_c1_s4 co=post_w64.co block=64 wave=64, HIP's arguments (display, out, dw, dh, ow, oh, dec_scale, expo) and grid. It is a port of filter_strip_c1<4>:
    • lanes and window as HIP: lane 3 g + c of each 32-lane half, 4 row pairs per lane, a 7-row sliding window;
    • the analytic filter of D3D12: analytic-filter ports of the fused output kernels (post_w64.co), byte for byte against HIP #145 (FP32 Lanczos constants, v = w0 t0, then fused multiply-adds, clamp to the taps' range), then Dec, then times dec_scale;
    • dec_scale comes from the argument, or as (float)(0.01 / (double)e) from the exposure pair.
    • The window is kept in named vectors. A shifted local array was compiled into a block copy that broke the overlapping shift: every even output row came out wrong in the first run.
  • clean/dx12/tests/post_tf_d3d12_check.py: the filter's cases against HIP post_filter_c1_s4, on the same engine as D3D12: analytic-filter ports of the fused output kernels (post_w64.co), byte for byte against HIP #145.

GPU record

post_tf_d3d12_check.py --run --seeds 3 --kernels w64/post_filter_c1_s4,orig_w64/post_tf_f32_p12_diet_vsit, one GPU slot.

cases identical bytes compared differing
w64/post_filter_c1_s4 (analytic) vs HIP post_filter_c1_s4 (post_w64.co) 18 18 7,352,532 0
control: Model M w64/post_tf_f32_p12_diet_vsit (original filter) vs post_w64__orig.co 12 12 2,176,464 0
  • What is compared: the raw bytes of the FP32 output. The buffer is filled beforehand with HIP 0xA5 / D3D12 0x5A, and 64 slack bytes after it must keep each back end's own sentinel: 0 bad.
  • Frames, D = (3 O + 1) / 2:
    • O 96x54, 99x57, 40x16, 161x83, 7x5, 1281x140;
    • partly filled tile columns, a column group cut short, odd heights, several tile rows;
    • dec_scale from the argument or from the exposure pair (expo[0] = 0 in some draws).
  • Display images: E values in [0, 2.45], with exact zeros, the top value, and values below Dec's polynomial bound.
  • Negative control: w64_post_filter_c1_s4_s0_0 again with half its workgroups. Caught, 25,272 differing bytes.
  • Model M unchanged: this PR changes no existing D3D12 source (a new kernel file and the Python check), and no file includes post_filter.hlsl. Its name is new in the manifest.

Tested

  • GPU record above; public gates; leak scan 0 hits.

Not tested

  • A _direct form: HIP has none. The game route with Model L's reconstruction reads the colour from buffers (l_post_recon_p12 has no direct form either), so this filter runs on the staged route, with the converter's output pass after it. A direct form can follow if the frame needs it.
  • The _o16 / _h output forms (RGBA16F output copy).
  • A whole frame through the runtime.

…ost_w64.co), byte for byte against HIP

post_filter.hlsl ports filter_strip_c1<4> of post_w64.co (the runtime's default unbanded filter, run
after a reconstruction kernel that writes the display image, e.g. Model L's l_post_recon_p12, when
the model file has no output-filter weights): the analytic filter of post.hlsl, the 7-row window as
named vectors (a shifted local array compiled to a block copy that broke the overlapping shift).
post_tf_d3d12_check.py: its cases against HIP post_filter_c1_s4.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 04:59
@phantoslayer21
phantoslayer21 merged commit d08f841 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the dx12/post-filter-analytic branch November 14, 2026 05:00
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