Repository navigation
shader: lower compute buffer_store_format_xyzw in gfx2hlsl - #2530
Conversation
Refs R0Y00#2274. Adds compute-stage MUBUF buffer_store_format_d16_x (opcode 0x84) lowering to tools/startup/gfx2hlsl.py: - Validates four untouched descriptor words from a fixed native table entry (refusing modified descriptors including stride clears, shared load/store descriptors, missing local table provenance after branches, non-compute stages, lane-mask soffset, illegal binary lds/reserved MUBUF bits, bad operand shapes, and unsupported modifiers glc/slc/dlc/tfe/lds). - Emits uav <slot> table <param> <offset> plus udsrc entries uav_descword3, uav_stride (unmasked DW1 >> 16, so stride > 0x3fffu rejects DW1[31:30] CACHE_SWIZZLE/SWIZZLE_ENABLE) and uav_numrecords, under an if (exec & 1) guard when EXEC is not proven entry-full. - Supports 1-channel formats BUF_FMT_32_FLOAT (22), BUF_FMT_16_FLOAT (13), BUF_FMT_16_UNORM (7), BUF_FMT_16_SNORM (8), BUF_FMT_16_UINT (11) and BUF_FMT_16_SINT (12) in both GFX10 unified and legacy DFMT/NFMT encodings, checking DST_SEL_X == 4, zero reserved/swizzle/ADD_TID_ENABLE/TYPE flags, and RDNA 2 ISA §8.1.5 Table 35 bounds modes: OOB_SELECT 0 (structured, stride != 0, rec_off = voff + imm_off checked against stride while soffset adds to base) and OOB_SELECT 3 (raw, stride == 0, soffset + rec_off + elem_bytes <= num_records). OOB_SELECT 1/2, mismatched stride/OOB_SELECT, 32-bit overflow, misaligned addresses, unsupported formats/flags and OOB lanes are no-ops. - Uses 4-byte aligned Store for BUF_FMT_32_FLOAT and a lock-free InterlockedCompareExchange CAS loop for 2-byte aligned 16-bit formats. Adds tests/startup_compute_store_d16_x_check.py wired in CMakeLists.txt, .github/workflows/windows.yml and docs/experiments.md. AI-assisted: implementation and tests drafted and verified with an AI coding assistant.
…-d16-x # Conflicts: # tools/startup/gfx2hlsl.py
…-d16-x # Conflicts: # tests/compute_check.cpp # tools/startup/gfx2hlsl.py
Refs R0Y00#2274. Depends on R0Y00#2478, whose descriptor, entry-constant, bounds and EXEC handling this reuses. Lowers compute MUBUF buffer_store_format_xyzw (0x07) in the idxen form with a non-negative inline soffset and optional offset:. FORMAT, stride and num_records are read at dispatch from uav_descword3, uav_stride and uav_numrecords, with the OOB_SELECT 0/3 bounds of buffer_store_format_d16_x (the bounds lines are checked identical). Only the 4-channel formats of tools/compute_store_aot.py write (32x4 UINT/FLOAT, 16x4 FLOAT through pack16_rne, 8_8_8_8 and 2_10_10_10 UNORM, unified and legacy encodings, identity DST_SEL); as in that tool, a format of another channel count writes nothing. offen, off, register soffset, cache/tfe/lds modifiers and non-compute stages are refused by name. Adds tests/startup_compute_store_format_xyzw_check.py, registered in CMakeLists.txt, .github/workflows/windows.yml and AGENTS.md, and a docs/experiments.md entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Outside a compute stage buffer_store_format_xyzw keeps the bare mnemonic, as buffer_store_format_d16_x and buffer_store_dword do. The index and data are evaluated before the UAV and its entry constants are registered. The experiments entry drops a claim about captured programs and names the prebuilt WARP runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The xyzw helper now takes the host-view check that R0Y00#2478 added to the d16_x helper: after the guest bounds and the alignment check it reads the bound view size with GetDimensions and drops an element that would pass its end. The expected helper text and the experiments entry follow; the entry also corrects the case count to 19. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helper reads the bound view size with GetDimensions, which has no defined result on a root descriptor. Dispatch through --compute-store-sized-case, as the d16_x check does. The experiments entry records which runner mode produced the local WARP result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I built
The local machine ran build 26100.9711, DXC 1.9.2609.5, debug layer unavailable. Each passing original case compared all 320 words. The two mutation controls that passed on RTX were I also measured the previously untested shorter host view. The existing The source-built programs also matched LLVM 15 assembly (four programs and ten snippets). For the hosted run I used |
Six mutations of the two descriptor validators: all six caught. And one hardware-only failure I want to place before youControl modes run clean here (device-free)Both no-argument modes are the controls run and need neither DXC nor an adapter, which is the right split — that half Mutations
All six caught, each by the check that owns it. The legacy-format one is the one I most expected to survive, since it Worth writing down because it cost me a silent no-op: The failure I want you to see
My adapter: Intel Arc 140T GPU, driver 32.0.101.8132, Windows build 26300. A second adapter (NVIDIA RTX 5080 I am not calling this a defect in your change.
Everything above the hardware line is measured and reproducible here; this paragraph is a request for your adapter's AI-assisted. |
|
#2478 has landed at |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head 5e364b5 (comment only, no approval). The PR's own diff is unchanged after the later update with main (new head 841f04f).
What I checked:
- Dependency #2478 is merged; the diff is limited to this slice (gfx2hlsl lowering, one new check, CMake, workflow list, docs, AGENTS.md line).
- Lowering follows the d16_x sibling (same bounds, descriptor provenance and
exec & 1guard); 4-channel format set matchescompute_store_aot.py; other shapes get named refusals. - Tests: new
startup_compute_store_format_xyzw_{controls,warp,hardware}plus 9 dispatch mutation controls per adapter, registered like the d16_x tests; thebinaryllvm-mc check is added towindows.ymlin both lists, so the PR's own CI exercises it. - No other open or merged PR covers
buffer_store_format_xyzw.
Commands run in a clean worktree of this head:
python3 -B tests/startup_compute_store_format_xyzw_check.py-> passpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> clean- Mutation: removing the EXEC guard in
op_buffer_store_format_xyzwmakes the check fail (call Eassertion).
Not a startup/game claim. The Windows WARP dispatch receipt will follow from the pipeline.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head 841f04f after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
Refs #2274. Depends on #2478 (
buffer_store_format_d16_x): this branch is built on its head commitd96ffa28and reuses its descriptor provenance checks, itsuav_descword3/uav_stride/uav_numrecordsentry constants, its RDNA 2OOB_SELECT0/3 bounds and itsif (exec & 1)guard. Only the last four commits belong to this PR. It does not change #2478's code.What changes
tools/startup/gfx2hlsl.pynow lowers compute MUBUFbuffer_store_format_xyzw(0x07) in one shape:idxen, a non-negative inlinesoffsetand an optionaloffset:. Before this change the translator refused it with the bare mnemonic.Format at dispatch. FORMAT, stride and
num_recordsare read when the shader runs, from the same entry constants shader: lower compute buffer_store_format_d16_x in gfx2hlsl #2478 adds. The bounds lines of the new helper are the d16_x helper's lines, and the check asserts the two are identical. The helper also has shader: lower compute buffer_store_format_d16_x in gfx2hlsl #2478's host-view guard:GetDimensionson the bound UAV, and an element that would pass its end is dropped.Formats that write. Only the 4-channel formats of
tools/compute_store_aot.py, using that tool's conversions:BUF_FMT_32_32_32_32_UINT/FLOAT(75/77): written withStore4.BUF_FMT_16_16_16_16_FLOAT(71): binary32 to binary16, round to nearest even, through the existingpack16_rnehelper.BUF_FMT_8_8_8_8_UNORM(56) andBUF_FMT_2_10_10_10_UNORM(50, x in bits 9:0): UNORM rounds half away from zero, as in Direct3D, and NaN gives 0.Both the unified and the legacy
DFMT/NFMTencodings are accepted, andDST_SELmust be the identity0xfac. Every write is a whole aligned dword, so no read-modify-write is needed.Other channel counts write nothing. This is the rule
compute_store_aot.pyfollows anddocs/experiments.mddocuments for formatted loads. What the format unit does with the extra components is not established in this repository.Named refusals. Each unmodelled shape now gets its own refusal instead of the bare mnemonic:
offenandidxen offen(address form),off(noidxen), registersoffset, theglc/slc/dlc/tfe/ldsmodifiers, illegal encoding bits, and the descriptor cases shader: lower compute buffer_store_format_d16_x in gfx2hlsl #2478 refuses (modified descriptor, one descriptor used for both a load and a store, no local table load after a branch). Outside compute the opcode keeps the bare-mnemonic unknown-op refusal, asbuffer_store_format_d16_xdoes.Word 3 validator.
validate_store_format_xyzw_word3mirrors shader: lower compute buffer_store_format_d16_x in gfx2hlsl #2478'svalidate_store_d16_x_word3and names a channel-count mismatch.Measured on local compute requests (counts only)
Inputs are 30 locally captured compute requests whose first refusal, under a local translator with extra unmerged changes, was this instruction. 20 of them were dispatched in a local census: 604,487 of 7,954,222 compute dispatches.
Store shape. All 164 stores in those programs have the same shape:
buffer_store_format_xyzw v[n:n+3], vI, s[d:d+3], 0 idxen. There is no immediate offset and no modifier. The descriptor comes from ans_load_dwordx4off a root table pointer, so FORMAT, stride,num_recordsandOOB_SELECTare known only at run time. Nothing in the requests records them.First refusal (scratch copy of the 30 requests; before = #2478 head
d96ffa28, after = this branch at41879f06; the later commit changes only the test runner mode):buffer_store_format_xyzwbuffer_store_format_xyzw requires descriptor words proven in the entry block or a local table loaddescriptor ... used for a load and a stores_mov_b64/s_mov_b32writes inside ans_cbranch_execzblock,s_bitset1_b32)buffer_store_format_xyzwThe 11 requests that stopped earlier stop at the same refusals after the change.
Measured vs hypothesis. In 128 of the 164 stores the four data registers hold the same value. That pattern suggests a typed store to a format with fewer than four channels. This is a hypothesis: the descriptor words were not observed. If it holds, those stores write nothing at dispatch, because other channel counts are a no-op here. "Translates" is a first-refusal count, not verified output. Whether two threads can write the same element was not classified.
Tests
The head is
3014c7b7. Windows 11 build 26300, Python fromout/pe-env, DXC 10.0.22621 (Windows SDK). No CMake build, ctest or hardware run was done.Runner mode, read this. The committed check dispatches through
--compute-store-sized-case(descriptor-table views), as #2478's check does, becauseGetDimensionshas no defined size on a root descriptor. That mode needs #2478's per-case root constants, so it needs anoffscreen_checkbuilt from #2478 or later. The only local runner predates #2478: in its sized mode both this check and #2478's own check read back the sentinel (case constants not passed). The WARP results below therefore come from the previous commit41879f06, whose check used the root-descriptor--compute-store-casemode with an identical shader; on that path WARP happened to report a large enough size. The sized-mode dispatch is first exercised by CI or a reviewer's build.What the no-argument mode covers:
compute_store_aot.py, in both encodings. The word 3 validator is run over every FORMAT field in both encodings.Dispatch cases:
OOB_SELECT1 and 2;DST_SEL;SWIZZLE_ENABLE;soffsetandoffset:under raw and structured bounds.Not checked
binarymode againstllvm-mc-15: no local llvm-mc, so it is left to CI.OOB_SELECT1 (no-op, as in shader: lower compute buffer_store_format_d16_x in gfx2hlsl #2478).🤖 Generated with Claude Code