shader: lower direct MTBUF packed half stores #3353
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3353"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-28T12:23:28Z.
Refs #2935 and #3302.
The direct gfx1013 Compute path accepts packed D16 buffer stores through MUBUF, but rejected the corresponding MTBUF instructions. On clean main
052abe6fall six source-built MTBUF requests stopped atMTBUF requires a non-D16 load without index, cache modifiers or TFE, before DXIL or manifest publication.Admit
tbuffer_store_format_d16_x,_xyand_xyzwwhen the instruction carries the exact-width FLOAT format. Both an element index and element zero reuse the existing packed-half lowering and published typed buffer UAV binder. Keep unsupported widths, other numeric formats, byte offsets, cache modifiers and TFE refused. The explicit instruction format follows the AMD RDNA 2 ISA MTBUF contract.At
6a7923c232a742e7ef08db7dff94f3e0ede8021d, all six MTBUF combinations assembled and validated as DXIL, published their typed manifest, created a PSO, and ran through the ordinary slot 67/14 path with fenced output readback. Each run compares all 320 dwords. The indexed tests write 13 distinct records at byte 8. The element-zero tests use a single writer and a nonzero value in the unused address VGPR. They match the packed binary16 reference and preserve the guards. Toggling only IDXEN in a one-writer control moved the stored pair from output word 2 to word 5 on both adapters. The existing three MUBUF widths still match. Negative inputs cover byte-offset forms, SLC, a mismatched numeric format, and XYZ, plus mismatched or out-of-range runtime views that leave the output untouched.RTX 4070 and app-local WARP passed 9/9 CTest cases in Debug and 9/9 in Release, with no skips. Windows 26300.10075, NVIDIA driver 32.0.16.2124, DXC 1.9.2602.17, Agility 1.620.2 and WARP 1.0.22. Both adapters had the D3D12 debug layer enabled.
The results cover the source-built Compute fixtures. I used Codex to prepare the change and ran the verification locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-28T14:03:56Z.
Review: COMMENTED
Commit
6a7923c232a742e7ef08db7dff94f3e0ede8021d(shader: lower direct MTBUF packed half stores).Verified on Windows 11 Pro 26H2, NVIDIA GeForce RTX 5080 (driver 32.0.16.2140,
nvidia-smi), MSVC 19.44, DXC10.0.26100.0/x64, CMake/Ninja dev+release builds inout/build/devandout/build/release.Built targets before testing:
cmd /c ""C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 >nul && cmake --build --preset dev --target offscreen_check compile_dxil startup_stream_consumer d3d12_xs_shim native_store_replay"cmd /c ""C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 >nul && cmake --build --preset release --target offscreen_check compile_dxil startup_stream_consumer d3d12_xs_shim native_store_replay"CTest (dev):
ctest --preset dev --no-tests=error -j 1 -V -R "^(startup_compute_(half_buffer_uav_.*|dispatch_(entry|output)_(warp|hardware))|native_(mtbuf_hardware|direct_container))$"-> 8 passed, 1 skipped out of 9.startup_compute_half_buffer_uav_warpskipped (77): WARP adapter lacks SM 6.6/WaveOps/32-lane wave required by the shader-wave32 fixture on this machine; not a pass/fail.CTest (release): same pattern -> 8 passed, 1 skipped out of 9, same WARP capability skip.
Passed tests include
native_mtbuf_hardware,native_direct_container,startup_compute_dispatch_entry_warp/hardware,startup_compute_dispatch_output_warp/hardware,startup_compute_half_buffer_uav_controls, andstartup_compute_half_buffer_uav_hardware.Targeted mutations (reverted cleanly with
git checkout -- src/gfx1013_compute_native.cppafter each): (1) removed MTBUF D16 format-equality check (format != half_formats[count]) ->startup_compute_half_buffer_uav_controlsfailed as expected (bad store accepted/compiled). (2) replaced MTBUF D16 addressing/modifier guard withif (false)->startup_compute_half_buffer_uav_controlsfailed as expected. No blocking defect found in the PR as-is.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-28T20:09:22Z.
For the "tests already fail on main" note:
startup_compute_half_buffer_uav_{controls,hardware}fail onmainwithout this PR. I bisected it locally betweenee3347d3(pass) andf5a6f6ba(fail). The first bad commit is86cf5aa8("shader: merge main3926a289into the native shader stack"), from the native shader stack that came in with #3091. There a one-channel D16 store compiles topacked_d16_x_uav, which has no manifest line, socompile_dxilprintsUAV kind unknownand nothing is published. Not-Saii described the same cause on #3224. SimSalabimse has claimed publishing that kind there, and #3395 names it in the reason.startup_compute_dispatch_output_{warp,hardware}fail onf5a6f6batoo ("an output token does not identify a slot-19 UAV"). My bisect checked both tests together, so I can't say whether that one broke at the same commit. As far as I can see, nobody has claimed it yet.So this PR's own MTBUF cases can't be checked through that file on main until the
packed_d16_x_uavpublishing lands.Windows 11 26200, RTX 3080 (32.0.16.2124), WARP. AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:54:42Z.
Review: APPROVED
LGTM — clean MTBUF D16 store lowering.
Parses explicit buffer_store_format_d16_x/xy/xyzw MTBUF opcodes (0x0c-0x0f), validates exact-width FLOAT formats (13, 29, 71), enforces index or element-zero with zero byte offsets, and reuses the MUBUF typed buffer UAV path. The test extension covers indexed, element-zero, and 4 invalid descriptor shapes via compile refusal.
Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:35Z.
Review: APPROVED
LGTM — clean MTBUF D16 store lowering.
Parses explicit buffer_store_format_d16_x/xy/xyzw MTBUF opcodes (0x0c-0x0f), validates exact-width FLOAT formats (13, 29, 71), enforces index or element-zero with zero byte offsets, and reuses the MUBUF typed buffer UAV path. The test extension covers indexed, element-zero, and 4 invalid descriptor shapes via compile refusal.
Ready to land.