X2w compute store format #1676
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1683"
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 SimSalabimse on 2026-11-24T17:00:41Z.
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)
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:17:55Z.
Review: COMMENTED
Review of head
19c19eb6eb(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.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.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.descriptor_format_word(code, legacy=True)uses the table the shader decodes; only legacy words 74 and 29 are pinned to independent constants.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
s[20:23]. Is that contract enforced elsewhere?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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:34:43Z.
This PR currently has merge conflicts with
main. Could you please rebase it onto the latestmainso it can be checked for merge?AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:54:22Z.
Review: COMMENTED
Review of head
9ff8ee1a80ad388104e86215e14ab02a936c39ef.Scope:
CMakeLists.txt(only registerscompute_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.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.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).(13, 7)remapped from 74 to 77: killed (StopIterationon the round trip lookup).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.pycites 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_xyzwreservation width (16 bytes, not the two data VGPRs) is not pinned by the Python controls (the mutation survived them). A direct control thatlowerrefuses a d16_xyzw store overlapping the next element would pin it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:21:31Z.
Review: COMMENTED
Review of head
f37fe7b8e8Scope: 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.--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):LEGACY_DESCRIPTOR_FORMATS: assertion failure indescriptor_store_controls.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:27:24Z.
Review: COMMENTED
Hardware-source check for head
f37fe7b8e8(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:
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").src/amd/registers/gfx6.jsonlines 9878-9893. This matchesDESCRIPTOR_FIXED_MASK = 0xFFF80FFFand the shifts in the code and doc.0x01000FACand legacy identity0x00000FACin the doc are right.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+.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.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.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T23:15:52Z.
Thanks for the run. Head is now
f37fe7b8e855c9b035739b6f66ba979b1d447fee.descriptor_store_controlsevaluates the generated store helper and compares the 28 UAV dwords to literal constants (PINNED_THREAD0), not to values taken fromDESCRIPTOR_STORE_FORMATS. All 18 legacy V# word 3 values are pinned the same way, including 32 UINT0x00024FAC(DFMT 4, NFMT 4). A d1616_UINTstore and a d1616_SINTstore must leave the sentinel; that is what fails if thed16 == 0uguard is removed.params[3].xis still a source check, because that is the b0 binding.round()is ties-to-even and disagreed on an exact tie. The fixture's unorm8 blue channel is binary320x3C20A0A1, whose product with 255 is exactly 2.5. This path stores 3 (0x0003BF40). Ties-to-even would store 2. The Direct3D rule is documented at https://learn.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-data-conversion. I did not find the MUBUF format unit's tie break in the RDNA ISA. LLVM's packed conversions (v_cvt_pk_*,SIInstrInfo.td) are ties-to-even on a different unit. The gfx1013 buffer-format tie break is unverified.docs/experiments.mdno longer says gfx1030 for this path. The only fixture is gfx1013.Mutations in
tools/compute_store_aot.py, each restored withgit checkout --:descriptor_store_controls()3.0→7.04→632767.0→32768.0python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1exited 0 (LLVM 15.0.7).On Windows 11 (MSVC 19.42, RTX 4070 Ti, driver 621.35), dev build at
f37fe7b8:ctest --preset dev --no-tests=error --output-on-failure -R "^compute_store_aot_descriptor_store_format"passed 2/2 (_hardwareand_warp), exit 0.Answers:
--descriptor-format-constantindex, already loaded withs_buffer_loadand waited.s[20:23]is checked only as the u0 UAV descriptor. FORMAT is not read from those registers, and nothing else in this repository compares the b0 word to word 3 of that descriptor. The contract is the caller's.RESOURCE_LEVEL=0on gfx1013 is unverified. Mesa's GFX10SQ_BUF_RSRC_WORD3definition marks bit 24RESOURCE_LEVELas "must be 1". I did not find an RDNA ISA sentence that a cleared bit is still decoded as DFMT/NFMT. The lowering accepts0x00000FAC.f16tof32, then the same packer). For 32-bit FLOAT that is the numeric conversion, and f16 to f32 is exact. I did not find an RDNA ISA or LLVM AMDGPU statement that the format unit widens through f32 before a 32-bit UINT or UNORM store. Unverified for those formats. The fixture's d16 32-bit store is32_32_32_FLOAT.AI-assisted (Cursor)