Repository navigation
X2w compute store format - #1683
Conversation
Read V# word 3 for each formatted store and pack the x, xy, xyz, and xyzw forms, including d16. An unknown format or a channel mismatch does not store.
Keep the COMPUTE_PGM_RSRC2 entry layout with the descriptor-format buffer stores.
Keep the scratch-base write, quad DPP OR, and image stores with the descriptor-format buffer stores.
tedin7
left a comment
There was a problem hiding this comment.
Review of head 19c19eb (comment only, not an approval).
No blocking defect found.
What I ran
python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1: exit 0. The focuseddescriptor_store_binaryrun printedDESCRIPTOR_OK.- Not run:
compute_store_aot_descriptor_store_format_{hardware,warp}(Windows, DXC, D3D12). Those are the only tests that compare the 320 UAV words, so the packing maths and the "100/100" claim are unconfirmed here. - Mutations in tools/compute_store_aot.py, each restored with
git checkout --: dropping the d16 guard on 16-bit UINT/SINT fails, but only on the source-text assert"d16 == 0u" in source; dropping bit 24 fromFIXED_MASKfails on a real behaviour assert; unorm10 alpha scale 3.0 -> 7.0, legacy 32_UINT NFMT 4 -> 6 and snorm scale 32767 -> 32768 all pass, so the Linux-runnable part does not catch them.
Non-blocking
descriptor_store_controlsin tests/compute_store_check.py asserts text in the generated HLSL (f"format == {code}u" in source,"InterlockedAnd" in source,"params[3].x" in source,"store_descriptor_format(" not in old). Those fail on a rename, not on a behaviour change, and the loops overaot.DESCRIPTOR_STORE_FORMATStake the expected values from the code under test. Pinning literal expected words would make the three mutations above visible.- The legacy mapping is checked against itself:
descriptor_format_word(code, legacy=True)uses the table the shader decodes; only legacy words 74 and 29 are pinned to independent constants. - docs/experiments.md says "gfx1013 and gfx1030", but the only fixture is gfx1013.
descriptor_unormuses HLSLround()(ties to even); the Python reference usesfloor(x + 0.5). No test value is a tie, so it is invisible today. NaN/Inf andf32tof16rounding are untested too.
Questions
- The format comes from a separate b0 constant word, not from the descriptor in
s[20:23]. Is that contract enforced elsewhere? - Is the legacy word (RESOURCE_LEVEL=0) valid on gfx1013 hardware?
- Is widening d16 halves to f32 before a 32-bit format store what the hardware does?
Overlap: #1684, #1675, #1673, #1649, #1596 and #1592 also edit tools/compute_store_aot.py, CMakeLists.txt, docs/experiments.md and/or tests/compute_store_check.py, so textual conflicts are likely. None implements the same descriptor-format store.
Linux limits: no Windows, MASM, MSVC, DXC or D3D12 device here; LLVM 19 only (CI uses LLVM 15). Anything that needs them was not run.
AI-assisted; commands listed were executed locally.
|
This PR currently has merge conflicts with AI-assisted. |
# Conflicts: # tools/compute_store_aot.py
tedin7
left a comment
There was a problem hiding this comment.
Review of head 9ff8ee1a80ad388104e86215e14ab02a936c39ef.
Scope: CMakeLists.txt (only registers compute_store_aot_descriptor_store_format_<adapter>), README.md, docs/experiments.md, tests/compute_store_check.py, tools/compute_store_aot.py. The change reads the buffer format from V# word 3 (GFX10 or legacy) and refuses unknown formats instead of writing raw dwords. Clean-room: the encodings come from public register documentation and the existing local tooling. No copied sources.
Commands executed locally:
git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.gh pr checks 1683: Windows build and test, Linux Python checks and gfx1013 fixtures all pass. The/O2Windows job is skipped in CI.python3 tests/docs_links_check.py: PASS (18 files, 388 links).python3 tests/bidi_controls_check.py: PASS.git diff --check origin/main...HEAD: clean.- Windows Server 2025,
x2w_pipe.py win2025 1683with--targets offscreen_check --regex '^compute_store_aot_(descriptor_store_format|mubuf_store_format)': Debug 6/6 pass, Release/O26/6 pass, docs link check ok. The WARP adapter rancompute_store_aot_descriptor_store_format_warp. - The Linux box has no LLVM 15 tools, so the
binaryround trip ran only in CI.descriptor_store_controls()ran locally and passed.
Mutations in the code under test, each reverted with git checkout -- .:
DESCRIPTOR_FIXED_MASKwidened to0xFFFFFFFF: killed bydescriptor_store_controls()(valid format rejected).- Legacy table entry
(13, 7)remapped from 74 to 77: killed (StopIterationon the round trip lookup). - Survived locally: the reservation
spanreduced to4 * count. The controls alone do not catch it. See the P3 note.
P1: 0. P2: 0.
P3 (non-blocking): a code comment in tools/compute_store_aot.py cites a third-party header for the bit layout. Only register field positions are used, no code is copied, but a pointer to the public ISA document would keep the clean-room record tidy.
P3 (non-blocking): the d16_xyzw reservation width (16 bytes, not the two data VGPRs) is not pinned by the Python controls (the mutation survived them). A direct control that lower refuses a d16_xyzw store overlapping the next element would pin it.
AI-assisted; commands listed were executed locally.
Compare the generated store helper with literal UAV words and legacy V# word 3 constants, so a changed unorm10 alpha scale, legacy 32 UINT NFMT, snorm scale, or d16 integer guard fails the Linux check. UNORM and SNORM follow the Direct3D half-away conversion, including one exact unorm8 tie. The store-format note names the gfx1013 fixture only. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
|
Thanks for the run. Head is now
Mutations in
On Windows 11 (MSVC 19.42, RTX 4070 Ti, driver 621.35), dev build at Answers:
AI-assisted (Cursor) |
tedin7
left a comment
There was a problem hiding this comment.
Review of head f37fe7b
Scope: CMakeLists.txt only registers the new compute_store_aot_descriptor_store_format_<adapter> test. README.md and docs/experiments.md document the descriptor-format store path. The logic is in tools/compute_store_aot.py and tests/compute_store_check.py. The unverified UNORM tie break is stated in the docs and in the code comment. No clean-room concerns found.
P1: 0. P2: 0.
Commands executed locally:
git merge-tree --write-tree --name-only origin/main HEAD: no conflicts. PR is MERGEABLE.gh pr checks 1683: Linux Python checks, fixture assembly and Windows build/test pass.python3 tests/docs_links_check.py: PASS (388 links).python3 tests/bidi_controls_check.py: PASS.git diff --check origin/main...HEAD: clean.python3 -B tests/compute_store_check.py binarywith the LLVM 19 mc/objcopy on this Linux host (LLVM 15 not installed here): PASS.- Win2025,
--targets offscreen_check --regex '^compute_store_aot_(descriptor_store_format|mubuf_store_format)'(the full auto-discovered command exceeded the cmd.exe length limit): Debug 6/6 passed, Release /O2 6/6 passed.
Mutations (both killed by tests/compute_store_check.py binary, then reverted):
- Swapped the legacy UINT16 and SINT16 format mapping in
LEGACY_DESCRIPTOR_FORMATS: assertion failure indescriptor_store_controls. - Dropped the d16-with-16-bit-integer guard in the generated store function: the skipped-store sentinel assertion failed.
AI-assisted; commands listed were executed locally.
tedin7
left a comment
There was a problem hiding this comment.
Hardware-source check for head f37fe7b (follow-up to the earlier review on this head: 0 P1, 0 P2, Linux pass, Win2025 Debug and Release /O2 6/6, 2 mutations killed). No P1, no P2.
Claims checked: the README row "Descriptor-format buffer stores" and docs/experiments.md#descriptor-format-buffer-stores, against tools/compute_store_aot.py (DESCRIPTOR_*, LEGACY_DESCRIPTOR_FORMATS).
Public sources, all match:
- GFX10 V# word 3, FORMAT bits 18:12, RESOURCE_LEVEL bit 24 ("must be 1"), INDEX_STRIDE 22:21, ADD_TID_ENABLE 23, OOB_SELECT 29:28, TYPE 31:30 ("must be 0"): Mesa
src/amd/registers/gfx10-rsrc.jsonlines 329-342 (SQ_BUF_RSRC_WORD3). The gfx103 variant (lines 343-357) adds LLC_NOALLOC 27:26. The code refuses any non-identity fixed bit, so a descriptor with LLC_NOALLOC set is skipped, not misread. That is conservative and matches the doc ("any other fixed bits skip the store"). - Legacy word 3, NUM_FORMAT bits 14:12, DATA_FORMAT bits 18:15, ELEMENT_SIZE 20:19, INDEX_STRIDE 22:21, ADD_TID 23: Mesa
src/amd/registers/gfx6.jsonlines 9878-9893. This matchesDESCRIPTOR_FIXED_MASK = 0xFFF80FFFand the shifts in the code and doc. - Identity DST_SEL X/Y/Z/W = 4/5/6/7: gfx6.json lines 601-604. 4 | 5<<3 | 6<<6 | 7<<9 = 0xFAC, so the GFX10 identity
0x01000FACand legacy identity0x00000FACin the doc are right. - Legacy DFMT values (16=2, 32=4, 16_16=5, 10_10_10_2=8, 8_8_8_8=10, 32_32=11, 16_16_16_16=12, 32_32_32=13, 32_32_32_32=14): LLVM 15.0.7
llvm/lib/Target/AMDGPU/SIDefines.henum DataFormat, lines 469-495. NFMT values (UNORM=0, SNORM=1, UINT=4, SINT=5, FLOAT=7): same file,enum NumFormat, lines 497+. - GFX10 unified format codes in
DESCRIPTOR_STORE_FORMATS: LLVM 15.0.7SIDefines.hnamespace UfmtGFX10(line 537), sequential enum with UFMT_INVALID=0. Counted by position: 16_UNORM=7, 16_SNORM=8, 16_UINT=11, 16_SINT=12, 16_FLOAT=13, 32_UINT=20, 32_FLOAT=22, 16_16_UNORM=23, 16_16_FLOAT=29, 10_10_10_2_UNORM=44, 8_8_8_8_UNORM=56, 32_32_UINT=62, 32_32_FLOAT=64, 16_16_16_16_FLOAT=71, 32_32_32_UINT=72, 32_32_32_FLOAT=74, 32_32_32_32_UINT=75, 32_32_32_32_FLOAT=77. All 18 codes match the table. All 18 legacy DFMT/NFMT pairs map to the same GFX10 codes. - The doc states the unorm8 tie break is unverified (not in the ISA text checked). That is an honest caveat, not an unverified claim, and the fixture pins the D3D rule it implements.
Commands executed locally: fetched the above files at those revisions and read the cited line ranges. Position of each UFMT name was counted with awk over SIDefines.h lines 539-632. No code was changed.
AI-assisted; commands listed were executed locally.
Conflict with R0Y00#1683 (descriptor-format stores) in the indexed raw-store branch of tools/compute_store_aot.py: this branch routes it through linear_uav_address, main sized the field as span instead of 4 * count. The helper now receives span, so descriptor stores reserve the same bytes as on main; main's descriptor-store program lowers to identical HLSL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compute: lower buffer_store_format_* from the descriptor format
Change
The compute translator lowers
buffer_store_format_x,_xy,_xyz, and_xyzw, and thed16_x,d16_xy,d16_xyz, andd16_xyzwforms, using V# word 3. Repeat--descriptor-format-constantonce per formatted store, in program order. Each index is a readys_buffer_loadfrom the constant descriptor.FORMAT is bits 18:12. The other bits must be the GFX10 identity
0x01000FACor the legacy DFMT/NFMT identity0x00000FAC. The handled GFX10 formats, and the legacy DFMT/NFMT pairs that name the same layouts, are:32,32_32,32_32_32,32_32_32_32)16_16_FLOATand16_16_16_16_FLOAT8_8_8_8_UNORM,16_16_UNORM, and10_10_10_2_UNORM16_UNORM,16_SNORM,16_UINT,16_SINT, and16_FLOATThe opcode width has to match the format. A d16 opcode converts each packed binary16 half with
f16tof32before packing. d16 combined with 16-bit UINT or SINT does not store. Any other format, selector, index stride,ADD_TID_ENABLE, OOB, or type bit skips the store. The lowering does not substitute raw dwords for an unknown format.A 32-bit result is a raw UAV store. Packed UNORM and FLOAT16 results occupy one or two dwords. A single 16-bit channel updates its half of the containing dword with
InterlockedAndandInterlockedOr. The indexed span reserved for a descriptor-format store is four bytes per channel.This path is separate from
--output-format. Supplying both is rejected. The existing gfx1030 UINT formatted stores are unchanged.The gfx1013 fixture stores thirteen values, covering all eight opcodes,
16_SNORM, and16_SINT, with both GFX10 and legacy words.compute_store_aot_descriptor_store_format_{hardware,warp}dispatches it, compares 320 UAV words, refusesBUF_FMT_8_SNORMand d16 plus16_UINT, and checks that a changed payload is reported.Merge
The branch is merged with
origin/main578d1e1c787e1118ad252940c76d126b7c738362. The merge commit is6ee522e41801bd4abf739285bff7e5a27729d238. Its parents are6177df41cfa8d66afce8095c816350866f2d0ee4and578d1e1c787e1118ad252940c76d126b7c738362.tools/compute_store_aot.pywas the only conflict.lower()and the container CLI call now take bothdescriptor_format_constantandrsrc2. Main's MED3, MIN3, MAX3, and XOR3 forms, theCOMPUTE_PGM_RSRC2entry layout and field widths, and the pixel SCC diamond stay as they are on main.CMakeLists.txt,README.md, anddocs/experiments.mdauto-merged with one descriptor-format test registration and one documentation row added. There is no second copy of those rows.Verification
Host: Windows 11 25H2, build 26200, UBR 8655. VS 2022 Community, MSVC 19.42.34435, CMake 3.29.5-msvc4. Python 3.12.10 at
out/pe-env. Hardware tests setXBOX2WINDOWS_ADAPTER=RTX 4070 Ti. Both ctest runs started with nvidia-smi reportingNVIDIA GeForce RTX 4070 Ti, 621.35.cmake --preset devandcmake --build --preset devexited 0.cmake --preset releaseandcmake --build --preset releaseexited 0. The full presets built. The DirectStorage file-read check fromorigin/mainis included, and the build did not stop onC2664.Exit code 0. 100 of 100 passed. Total time 666.99 sec.
Exit code 0. 100 of 100 passed. Total time 626.58 sec.
Tests brought in by
origin/main, plus the descriptor-format stores. Every row passed on WARP and on the RTX 4070 Ti.compute_entry_layout_hardwarecompute_entry_layout_warpcompute_store_aot_alu_minmax3_hardwarecompute_store_aot_alu_minmax3_warpcompute_store_aot_alu_med3_hardwarecompute_store_aot_alu_med3_warpcompute_store_aot_alu_xor3_hardwarecompute_store_aot_alu_xor3_warpcompute_store_aot_descriptor_store_format_hardwarecompute_store_aot_descriptor_store_format_warpEvery
^compute_test. Every row passed.compute_root_hardwarecompute_root_warpcompute_tables_hardwarecompute_tables_warpcompute_mesh_texture_hardwarecompute_mesh_texture_fallback_hardwarecompute_store_aot_hardwarecompute_entry_layout_hardwarecompute_store_aot_guard_read_hardwarecompute_store_aot_mubuf_subword_hardwarecompute_store_aot_f32_hardwarecompute_store_aot_mubuf_reduction_hardwarecompute_store_aot_alu_minmax3_hardwarecompute_store_aot_mubuf_reduction_x2_hardwarecompute_store_aot_mubuf_exchange_hardwarecompute_store_aot_mubuf_exchange-x2_hardwarecompute_store_aot_mubuf_counter_hardwarecompute_store_aot_mubuf_counter-x2_hardwarecompute_store_aot_mubuf_csub_hardwarecompute_store_aot_mubuf_vector_hardwarecompute_store_aot_alu_med3_hardwarecompute_store_aot_mubuf_d16_hardwarecompute_store_aot_alu_xor3_hardwarecompute_store_aot_mubuf_load_format_d16_hardwarecompute_store_aot_mtbuf_load_hardwarecompute_store_aot_mubuf_format_hardwarecompute_store_aot_mimg_load_hardwarecompute_store_aot_mimg_mip_hardwarecompute_store_aot_mimg_resinfo_hardwarecompute_store_aot_mimg_packed_hardwarecompute_store_aot_mimg_msaa_hardwarecompute_store_aot_mimg_store_hardwarecompute_store_aot_mimg_store_packed_hardwarecompute_store_aot_mimg_atomic_integer_hardwarecompute_store_aot_mimg_atomic_minmax_hardwarecompute_store_aot_mimg_atomic_exchange_hardwarecompute_store_aot_mimg_atomic_counter_hardwarecompute_store_aot_ds_route_hardwarecompute_store_aot_lds_private_hardwarecompute_store_aot_lds_packed_hardwarecompute_store_aot_lds_arithmetic_hardwarecompute_store_aot_lds_replacement_hardwarecompute_store_aot_lds_strided_hardwarecompute_store_aot_lds_wide_replacement_hardwarecompute_store_aot_lds_qword_hardwarecompute_store_aot_lds_f32_hardwarecompute_store_aot_mubuf_store_format_hardwarecompute_store_aot_mubuf_store_format_xyz_hardwarecompute_store_aot_descriptor_store_format_hardwarecompute_store_aot_mtbuf_store_hardwarecompute_store_aot_mubuf_store_subword_hardwarecompute_to_pixel_hardwarecompute_mesh_texture_warpcompute_mesh_texture_fallback_warpcompute_store_aot_warpcompute_entry_layout_warpcompute_store_aot_guard_read_warpcompute_store_aot_mubuf_subword_warpcompute_store_aot_f32_warpcompute_store_aot_mubuf_reduction_warpcompute_store_aot_alu_minmax3_warpcompute_store_aot_mubuf_reduction_x2_warpcompute_store_aot_mubuf_exchange_warpcompute_store_aot_mubuf_exchange-x2_warpcompute_store_aot_mubuf_counter_warpcompute_store_aot_mubuf_counter-x2_warpcompute_store_aot_mubuf_csub_warpcompute_store_aot_mubuf_vector_warpcompute_store_aot_alu_med3_warpcompute_store_aot_mubuf_d16_warpcompute_store_aot_alu_xor3_warpcompute_store_aot_mubuf_load_format_d16_warpcompute_store_aot_mtbuf_load_warpcompute_store_aot_mubuf_format_warpcompute_store_aot_mimg_load_warpcompute_store_aot_mimg_mip_warpcompute_store_aot_mimg_resinfo_warpcompute_store_aot_mimg_packed_warpcompute_store_aot_mimg_msaa_warpcompute_store_aot_mimg_store_warpcompute_store_aot_mimg_store_packed_warpcompute_store_aot_mimg_atomic_integer_warpcompute_store_aot_mimg_atomic_minmax_warpcompute_store_aot_mimg_atomic_exchange_warpcompute_store_aot_mimg_atomic_counter_warpcompute_store_aot_ds_route_warpcompute_store_aot_lds_private_warpcompute_store_aot_lds_packed_warpcompute_store_aot_lds_arithmetic_warpcompute_store_aot_lds_replacement_warpcompute_store_aot_lds_strided_warpcompute_store_aot_lds_wide_replacement_warpcompute_store_aot_lds_qword_warpcompute_store_aot_lds_f32_warpcompute_store_aot_mubuf_store_format_warpcompute_store_aot_mubuf_store_format_xyz_warpcompute_store_aot_descriptor_store_format_warpcompute_store_aot_mtbuf_store_warpcompute_store_aot_mubuf_store_subword_warpcompute_to_pixel_warpFixes #1542
AI-assisted (Grok Build)