shader: lower compute buffer_store_format_xyzw in gfx2hlsl #2522
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2530"
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 NiiRoZz on 2026-11-25T20:10:13Z.
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 #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 #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 #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 #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 #2478).🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T20:22:49Z.
I built
offscreen_checkfrom the exact head3014c7b78b28d209b954b1924bf5e18d3e1fc220, including #2478, and ran the committed descriptor-table path.X-f32failed creating the PSOThe 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
x-drop-storeandr-drop-soffset. On this driver the originalX-f32failed withCreate compute pipeline failed (HRESULT 0x8007000e)before a readback. The originalR-rawcompleted with 320/320 words. I repeated that pair with default optimization and-Gis, strict-O1and-Od, then without-Gisat default optimization and-O1. Every pair gave the same result. These measurements identify the failing stage on this driver.I also measured the previously untested shorter host view. The existing
R-rawprogram writes bytes 16–31. On Intel, RTX and WARP a 7-word UAV view left all 320 words untouched. Both 8- and 9-word views wrote exactly words 4–7. Changing the upper-bound comparison from>to>=dropped the exact-fit 8-word write on all three adapters. Readback against the original reference differed in four words, and the all-sentinel reference matched all 320. Runnable short-view fixtureThe source-built programs also matched LLVM 15 assembly (four programs and ten snippets). For the hosted run I used
ctest --preset dev -V -j 1 --no-tests=error -R '^startup_compute_store_(format_xyzw|d16_x)_(controls|warp|.*_warp)$'. All 23 CTests passed without skips. Locally I used the committeddispatchand each namedcontrolentry with--compute-store-sized-case. Hosted build and full CTest receiptsImported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T21:28:56Z.
Six mutations of the two descriptor validators: all six caught. And one hardware-only failure I want to place before you
Control 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
of the PR is verifiable on any machine.
Mutations
tools/startup/gfx2hlsl.pyDST_SELaccepted (!= 0xfac→False)OOB_SELECT not in (0, 3)guard removedSTORE_D16_X_WORD3_ZERO_MASKflag guard removedSTORE_FORMAT_XYZW_LEGACY_FORMATS.get(field)→field)DST_SEL_XacceptedOOB_SELECTguard widened to accept every valueAll six caught, each by the check that owns it. The legacy-format one is the one I most expected to survive, since it
only matters for a descriptor whose format word has bit 24 clear — the fixture does assemble that case.
Worth writing down because it cost me a silent no-op:
tools/startup/gfx2hlsl.pyis CRLF. A multi-line anchorwritten with
\nnever matches, and my first pass reported "anchor miss" for all three rather than a false catch. Anypatch script here needs the read-
\r\n→\n, patch, write-back-\r\ndance.The failure I want you to see
0x8007000eisE_OUTOFMEMORY, raised at pipeline creation, withdebug_errors=0 debug_warnings=0. It reproduces whenthose two cases are run alone, so it is not VRAM exhaustion from the 200-case batch. WARP passes every xyzw case on the
same fixture.
My adapter: Intel Arc 140T GPU, driver 32.0.101.8132, Windows build 26300. A second adapter (NVIDIA RTX 5080
Laptop, driver 32.0.15.8142) is also present; the harness picks what it picks, and I did not pin one, so I cannot yet say
whether the same case passes on the NVIDIA part.
I am not calling this a defect in your change.
E_OUTOFMEMORYout ofCreateComputePipelineStateis the shape of adriver-side PSO compile failure wearing the wrong HRESULT, and it is happening for one case (
X-f32,desc_word3(77), 16 bytes, offset 12) whose UTF-8/format combination may be newer than this iGPU driver. But it is ahardware failure that reproduces, so it should not be left as "my machine". Two things would settle it:
startup_compute_store_format_xyzw_hardwarepass on your adapter? If it does, the case is driver-specific and aSKIP_RETURN_CODE 77capability check before creating the pipeline would report it honestly instead of failing.CreateComputePipelineStatewould let the next person see whether it is the descriptor layout or the shader.
Everything above the hardware line is measured and reproducible here; this paragraph is a request for your adapter's
result, not a claim.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:53:00Z.
#2478 has landed at
8d5f3d78, so the sized UAV runner is available on main. Please update this PR against that landed version and keep its diff limited to thexyzwbehavior. Re-run the exact multi-component readback and out-of-range/near-end controls on the updated head. Keep the older debug-layer-unavailable and small-resource guard checks from the parent.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:03:46Z.
Review: COMMENTED
Review of head
5e364b55(comment only, no approval). The PR's own diff is unchanged after the later update with main (new head841f04fb).What I checked:
exec & 1guard); 4-channel format set matchescompute_store_aot.py; other shapes get named refusals.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.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-> cleanop_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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:10:10Z.
Win2025 WARP receipt for head
841f04fbafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
841f04fb839013baed3c63fa25392f95319dd9a0:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):34.89s(configure2.31s)ctest --preset dev -R 'startup_compute_store_format_xyzw_(controls|warp|.*_warp)|startup_compute_store_d16_x.*warp' --parallel 2 --no-tests=error --output-on-failure): 22/22 passed (6.96s:startup_compute_store_d16_x_f32-drop-store_warp0.32s,startup_compute_store_d16_x_f32-wrong-half_warp0.35s,startup_compute_store_d16_x_f32-drop-oob_warp0.37s,startup_compute_store_d16_x_unorm16-trunc_warp0.35s,startup_compute_store_d16_x_p-drop-soffset_warp0.36s,startup_compute_store_d16_x_p-drop-keep_warp0.35s,startup_compute_store_d16_x_s-fold-soff-stride_warp0.37s,startup_compute_store_d16_x_warp2.53s,startup_compute_store_d16_x_e-drop-exec_warp0.35s,startup_compute_store_d16_x_b-short-binding_warp0.37s,startup_compute_store_d16_x_b-tight-host-guard_warp0.35s,startup_compute_store_format_xyzw_controls0.37s,startup_compute_store_format_xyzw_x-drop-store_warp0.34s,startup_compute_store_format_xyzw_x-swap-xy_warp0.40s,startup_compute_store_format_xyzw_x-drop-index-oob_warp0.43s,startup_compute_store_format_xyzw_unorm8-trunc_warp0.44s,startup_compute_store_format_xyzw_unorm10-w-scale_warp0.43s,startup_compute_store_format_xyzw_f16-drop-odd_warp0.43s,startup_compute_store_format_xyzw_mismatch-writes_warp0.45s,startup_compute_store_format_xyzw_warp3.12s,startup_compute_store_format_xyzw_r-drop-soffset_warp0.43s,startup_compute_store_format_xyzw_e-drop-exec_warp0.44s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):70.53s(configure2.59s)ctest --preset release -R 'startup_compute_store_format_xyzw_(controls|warp|.*_warp)|startup_compute_store_d16_x.*warp' --parallel 2 --no-tests=error --output-on-failure): 22/22 passed (5.29s:startup_compute_store_d16_x_f32-drop-store_warp0.24s,startup_compute_store_d16_x_f32-wrong-half_warp0.27s,startup_compute_store_d16_x_f32-drop-oob_warp0.27s,startup_compute_store_d16_x_unorm16-trunc_warp0.26s,startup_compute_store_d16_x_p-drop-soffset_warp0.27s,startup_compute_store_d16_x_p-drop-keep_warp0.28s,startup_compute_store_d16_x_s-fold-soff-stride_warp0.27s,startup_compute_store_d16_x_warp1.95s,startup_compute_store_d16_x_e-drop-exec_warp0.26s,startup_compute_store_d16_x_b-short-binding_warp0.26s,startup_compute_store_d16_x_b-tight-host-guard_warp0.29s,startup_compute_store_format_xyzw_controls0.28s,startup_compute_store_format_xyzw_x-drop-store_warp0.45s,startup_compute_store_format_xyzw_x-swap-xy_warp0.29s,startup_compute_store_format_xyzw_x-drop-index-oob_warp0.30s,startup_compute_store_format_xyzw_unorm8-trunc_warp0.29s,startup_compute_store_format_xyzw_unorm10-w-scale_warp0.28s,startup_compute_store_format_xyzw_f16-drop-odd_warp0.27s,startup_compute_store_format_xyzw_mismatch-writes_warp0.27s,startup_compute_store_format_xyzw_warp2.46s,startup_compute_store_format_xyzw_r-drop-soffset_warp0.29s,startup_compute_store_format_xyzw_e-drop-exec_warp0.26s)tests/mesh_heap_sampler_check.pyok (0.8s),tests/startup_buffer_address_check.pyok (0.5s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.4s),tests/startup_compute_translate_check.pyok (0.2s),tests/startup_flat_param_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.1s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.7s),tests/startup_gfx2hlsl_capture_check.pyok (0.9s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.4s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.2s),tests/startup_gfx2hlsl_f32_nan_check.pyok (4.5s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.1s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.1s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.2s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.1s),tests/startup_gfx2hlsl_interp_p2_hi_check.pyok (0.3s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.3s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.3s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (2.8s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (0.7s),tests/startup_gfx2hlsl_root_check.pyok (0.9s),tests/startup_gfx2hlsl_sad_check.pyok (0.3s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.4s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.3s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.2s),tests/startup_gfx2hlsl_shift64_check.pyok (0.2s),tests/startup_gfx2hlsl_sload_const_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (7.4s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.3s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.4s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (5.9s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.2s),tests/startup_gfx2hlsl_watch_check.pyok (2.9s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.2s),tests/startup_image_gather_lz_check.pyok (0.6s),tests/startup_image_load_d16_check.pyok (0.9s),tests/startup_image_sample_a16_check.pyok (0.2s),tests/startup_image_sample_b_check.pyok (0.2s),tests/startup_image_sample_c_check.pyok (0.2s),tests/startup_image_sample_l_check.pyok (0.2s),tests/startup_image_sample_lod_check.pyok (0.6s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_skeleton_check.pyok (0.5s),tests/startup_run_ps1_check.pyok (11.2s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (1.9s),tests/startup_smem_address_check.pyok (0.1s),tests/startup_stream_fetch_check.pyok (0.2s),tests/startup_stream_interface_check.pyok (0.2s),tests/startup_translator_check.pyok (0.5s)sccache: 22/131 hits; wall183.7sAI-assisted; commands listed were executed locally.