Skip to content

shader: lower direct MTBUF packed half stores - #3353

Open
RonLogic wants to merge 1 commit into
R0Y00:mainfrom
RonLogic:shader/mtbuf-packed-half-store
Open

RonLogic wants to merge 1 commit into
R0Y00:mainfrom
RonLogic:shader/mtbuf-packed-half-store

Conversation

@RonLogic

Copy link
Copy Markdown
Contributor

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 052abe6f all six source-built MTBUF requests stopped at MTBUF requires a non-D16 load without index, cache modifiers or TFE, before DXIL or manifest publication.

Admit tbuffer_store_format_d16_x, _xy and _xyzw when 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.

cmake --build --preset <dev-or-release> --target offscreen_check compile_dxil startup_stream_consumer d3d12_xs_shim native_store_replay
ctest --preset <dev-or-release> --no-tests=error -j 1 -V -R '^(startup_compute_(half_buffer_uav_.*|dispatch_(entry|output)_(warp|hardware))|native_(mtbuf_hardware|direct_container))$'

The results cover the source-built Compute fixtures. I used Codex to prepare the change and ran the verification locally.

@R0D4X R0D4X left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, DXC 10.0.26100.0/x64, CMake/Ninja dev+release builds in out/build/dev and out/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_warp skipped (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, and startup_compute_half_buffer_uav_hardware.

Targeted mutations (reverted cleanly with git checkout -- src/gfx1013_compute_native.cpp after each): (1) removed MTBUF D16 format-equality check (format != half_formats[count]) -> startup_compute_half_buffer_uav_controls failed as expected (bad store accepted/compiled). (2) replaced MTBUF D16 addressing/modifier guard with if (false) -> startup_compute_half_buffer_uav_controls failed as expected. No blocking defect found in the PR as-is.

AI-assisted; commands listed were executed locally.

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