Skip to content

tests: read back s_pack_ll/lh/hh and s_absdiff_i32 on D3D12 WARP and hardware (follow-up to #2512) - #2523

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:pack-absdiff-dispatch
Nov 25, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
Leyukaka:pack-absdiff-dispatch

Conversation

@Leyukaka

Copy link
Copy Markdown
Contributor

Follow-up to #2512, which merged before I pushed this. It adds the D3D12 readback @tedin7 asked for in his review of s_pack_ll_b32_b16, s_pack_lh_b32_b16, s_pack_hh_b32_b16 and s_absdiff_i32. Part of #1723.

tests/startup_gfx2hlsl_pack_absdiff_check.py dispatch <dxc> <offscreen_check> <adapter> (the no-argument mode is unchanged):

  • For each op, it builds one cs_6_0 shader with DXC from the lines gfx2hlsl actually emits, and runs it through offscreen_check --raw-uav-dump.
  • The sources are loaded from the UAV fill pattern and XORed, so DXC cannot fold them.
  • D is stored, and SCC too for s_absdiff_i32. Both are compared with the integer references already in the file.
  • The operand region must come back unchanged.
  • The dump size is padded to whole 16-byte rows, as --raw-uav-dump requires.
  • Registered as startup_gfx2hlsl_pack_absdiff_dispatch_warp and _hardware, with SKIP_RETURN_CODE 77, next to the existing test.

Cases (8 absdiff + 3 x 9 pack = 35 per adapter), covering the edges named in the review:

  • absdiff: (0x80000000, 1) and its reverse, (0x7fffffff, 0x80000000) and its reverse, (5, 5), (0, 0), (0xffffffff, 0), (3, 10);
  • packs: 0xffffffff, 0x0000ffff, 0xffff0000, 0x00010000/0x0000ffff, 0x12345678/0x9abcdef0 and 0/0xffffffff, in both orders where they differ, covering << 16 and & 0xffff0000.

Results at this branch's head (main 396e7e2 plus this commit), Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100, debug layer not enabled:

  • python -B tests/startup_gfx2hlsl_pack_absdiff_check.py: ok.
  • ... dispatch <dxc> <offscreen_check> warp: 35/35 cases, Microsoft Basic Render Driver.
  • ... dispatch <dxc> <offscreen_check> hardware: 35/35 cases, NVIDIA GeForce RTX 5080 (driver 32.0.16.2101).

Mutations in tools/startup/gfx2hlsl.py. Each made both dispatch runs fail; the mismatch counts are per adapter:

  • s_absdiff_i32 without asint: 4;
  • s_absdiff_i32 SCC inverted: 8;
  • s_pack_ll shifting by 15: 7;
  • s_pack_lh masking 0x7fff0000: 4;
  • s_pack_hh shifting by 15: 7.

AI-assisted.

…hardware

Review request on R0Y00#2512: compile the HLSL that gfx2hlsl emits for each op
into one cs_6_0 shader with DXC and run it through offscreen_check
--raw-uav-dump. The sources are loaded from the UAV fill pattern and XORed,
so DXC cannot fold them; D and, for s_absdiff_i32, SCC are stored and
compared with the integer references. Cases: absdiff (0x80000000, 1) and
its reverse, (0x7fffffff, 0x80000000) and its reverse, equal sources, 0 and
0xffffffff; packs with the <<16 and 0xffff0000 edges, both orders. The
operand region must come back unchanged. Registered as
startup_gfx2hlsl_pack_absdiff_dispatch_warp and _hardware (skip 77).

AI-assisted.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 0aa0986 (comment only).

Checked:

  • The new dispatch mode builds a cs_6_0 shader from the lines gfx2hlsl really emits, XORs the loaded sources so DXC cannot fold them, and compares D (and SCC for s_absdiff_i32) with the integer references already in the file. The operand region is checked unchanged. Real D3D12 readback, not a string check.
  • Edge cases from the #2512 review are covered (INT_MIN, 0x7fffffff/0x80000000 both orders, equal, zero, 0xffff0000/0x0000ffff masks, both orders for packs).
  • Dump size is padded to 16-byte rows as --raw-uav-dump requires. Exit 77 maps to SKIP in CMake for both adapters. Sibling check is registered next to the existing test.
  • No other open or merged PR covers this readback slice (searched s_absdiff_i32 / pack).

Commands run (Linux, worktree of the exact head):

  • python3 -B tests/startup_gfx2hlsl_pack_absdiff_check.py: ok
  • python3 tests/docs_links_check.py: ok
  • python3 tests/bidi_controls_check.py: ok
  • git diff --check origin/main...HEAD: clean

Not run here: the dispatch test needs DXC and D3D12, so it is verified in the Win2025 WARP run that follows.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 18f3d72 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 18f3d720de85565ff8f02c7d1368131a8e840354:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 163.64s (configure 2.82s)
    • Test (ctest --preset dev -R 'startup_gfx2hlsl_pack_absdiff' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (3.00s: startup_gfx2hlsl_pack_absdiff_dispatch_warp 0.57s, startup_gfx2hlsl_pack_absdiff_dispatch_hardware 0.56s, startup_gfx2hlsl_pack_absdiff 2.88s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 86.72s (configure 2.01s)
    • Test (ctest --preset release -R 'startup_gfx2hlsl_pack_absdiff' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (4.03s: startup_gfx2hlsl_pack_absdiff_dispatch_warp 1.09s, startup_gfx2hlsl_pack_absdiff_dispatch_hardware 0.72s, startup_gfx2hlsl_pack_absdiff 3.81s)
  • Windows Python checks: tests/startup_gfx2hlsl_pack_absdiff_check.py ok (4.2s)
  • sccache hits/wall omitted

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit be9ad0c into R0Y00:main Nov 25, 2026
5 checks passed
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.

2 participants