startup: spill descriptors, pointers and lane masks to VGPR lanes in compute #2751
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2759"
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 Ybucaille on 2026-11-26T06:30:19Z.
Part of #1723. Refs #2022 (claim and counts: https://github.com/R0Y00/Xbox2Windows/issues/2022#issuecomment-7184304033)
Builds on #2712 (@tedin7, wave64 and vertex-stage spills), now merged.
mainis merged into this branch (16471bef); the change is the two commits6bbc8e4e(descriptors and pointers) and1ce4ae91(lane masks).Change
gfx2hlslnow accepts constant-lane SGPR spills (v_writelane_b32/v_readlane_b32) in compute stages when the spilled word is a descriptor or pointer word.csjoinsSPILL_STAGESand may branch likeps. The same proof applies: a write on every path before the read, the existing rules for non-uniform regions, and the refusal of a read carried by a loop. Av_writelane_b32inside ans_cbranch_execzblock was already refused byexecz_refusals, so writes stay outside those regions; only reads enter them.desc,ptr,ptrhi) have no run-time value to store. The lane slot carries the tracked symbol, nothing is emitted, and the reload restores the same symbol. Refused, by name: a symbol that does not name one value (a modified word, a pointer with a non-numeric offset), and different symbols joined at one read.formatted_descriptor_from_blockfollows av_readlane_b32back to those writes, and accepts the reload only if every write passed it. So a reloaded descriptor is accepted exactly when the original would have been.v_cmpstoresw, orexec & wwhen EXEC is unknown, so an inactive lane's bit is already 0).v_writelane_b32/v_readlane_b32ignore EXEC and copy the whole wave mask, so when the reloaded value is only read as a mask the spill is the identity on each invocation's bit: the slot takes the mask variable and the reload copies it back, re-marked as a mask (or intovccfor avcc_lodestination).reject_lane_mask_datacovers only some ops (av_add_nc_u32on a mask is accepted today, spill or not), so a newrequire_mask_reads_onlyrefuses the reload if any instruction reachable before its next write reads it other than as a lane select or carry-in, bys_cbranch_vccz/vccnz, as a copy intoexec_lo/vcc_lo, or by another spill. Also refused: several writes of which one is a mask, sourcesexec*,vcc_hi,m0, and a mask not proven on every path.Test
New
tests/startup_gfx2hlsl_compute_spill_check.py(registered in CMake, both Linux CI lists andAGENTS.md), with source-built gfx1013 programs assembled byllvm-mc:buffer_load_format_xyzwand a store.s_loadthrough it.v_cmpinto an SGPR), wrong lane, unproven descriptor (spilled in the arms), write inside an execz region, loop.csrefused, loop, write-before-read.startup_gfx2hlsl_sgpr_spill_check.pyandstartup_gfx2hlsl_spill_wave64_check.py: the "csis refused" control becomes "csis accepted", and agscontrol takes its place.Linux: all
tests/startup_gfx2hlsl_*_check.pygive 111 passed and 2 failed (export_null_draw,mul24_align_draw). Those two fail the same way on #2712's head (110 passed), so this adds no regression. After mergingmain(16471bef): the four spill checks andstartup_gfx2hlsl_compute_check.pypass, same two usage-only failures in the sweep, and CI is green.dc8e0f34records the fixture words in the LLVM 15 encoding the CI assembler emits (the unused src2 field of VOP3v_readlane_b32/v_writelane_b32/v_cmp*_e64is 0 there, inline constant 0 in newer LLVM; the comparison masks only that field). Atdc8e0f34, Windows 11 26200 Release build,ctest -R "startup_gfx2hlsl_(compute_spill|compute_mask_spill|sgpr_spill|spill_wave64)": 24/24 passed on WARP and the RTX 2070.Windows 11 26200, Release build, debug layer per
offscreen_checkdefaults,ctest -R startup_gfx2hlsl_compute_spill: 9/9 passed. On WARP and on an RTX 2070 (driver 32.0.16.1088), the dispatches of S and P read back all 320 expected words, and the three dispatch mutations (s-arm-swapped,s-store-dropped,p-store-dropped) are rejected on both adapters.Second commit: new
tests/startup_gfx2hlsl_compute_mask_spill_check.py. Fixtures M (vcc_loand an SGPR mask spilled, a branch, reload into an SGPR,v_cndmask_b32_e64,s_and_saveexec_b32) and V (reload intovcc_lo,v_cndmask_b32_e32,s_cbranch_vccz); 12 refused controls (m0, exec, vcc_hi, numeric reads of an SGPR and of vcc, two masks joined, a mask joined with a number, reload before write, a number reloaded intovcc_lo, a mask computed in one arm only, write in an execz block, loop) plus a pixel-stage probe; 14 translator mutations, each caught. Linux: 112 passed, the same 2 failures. Windows:ctest -R startup_gfx2hlsl_compute_(mask_)?spill18/18 on WARP and the RTX 2070, M and V read back 320 exact words, and the dispatch mutationsm-saveexec-dropped,m-mask-inverted,v-branch-invertedare rejected on both.Note: fixture V branches on a
vccthat is uniform per group, becauses_cbranch_vccz/vccnzis translated per invocation as(vcc & 1); on avccthat differs between lanes the wave should follow one path. That is independent of spills and I am checking it separately.Effect on run-time requests
On a local run (
main0827f43c), 68 slot-67 compute requests stop atv_writelane_b32 is lowered in pixel and mesh stages only. With #2712 and both commits, none stops at a spill any more: 33 next stop atv_or_b32_dpp(DPP in compute outside the straight-line pixel case), 32 ats_nand_b32on a lane mask (#2030), 2 at a resource-heap records_load(#2580), and 1 at lanes k and k+32 of one VGPR. None translates fully yet; these programs need those other forms too.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:38:55Z.
Review: COMMENTED
Review of head
dc8e0f34(comment review, no approval).What I checked
tools/startup/gfx2hlsl.py):csjoinsSPILL_STAGES. Descriptor/pointer words travel as symbols and the reload only passes the formatted-load proof if every supplying write passed it (formatted_descriptor_from_block). Thefirst[3] + 4tofirst[3] + widthchange is consistent with the new width. Lane masks are refused unless only read as masks (require_mask_reads_only). I found no bug.dispatchmode, warp and hardware adapters) that compare readback against the expected output, plus refused-reason controls and translator mutations. Both CMake and the Linux CI lists andAGENTS.mdare updated consistently..github/workflows/windows.yml, +4): the PR's own CI run executed both new checks (startup_gfx2hlsl_compute_spill_check.py (ok),startup_gfx2hlsl_compute_mask_spill_check.py (ok)), so the workflow edit is exercised.Commands run locally
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py: passpython3 -B tests/startup_gfx2hlsl_compute_spill_check.py,..._compute_mask_spill_check.py,..._sgpr_spill_check.py,..._spill_wave64_check.py: all PASS'cs'fromSPILL_STAGES: compute_spill check fails (rc=1)Windows WARP results follow in a separate receipt. Real-GPU run not available (RunPod stopped).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:36:36Z.
Review of head
dc8e0f34(comment review, no approval).What I checked
tools/startup/gfx2hlsl.py):csjoinsSPILL_STAGES. Descriptor/pointer words travel as symbols and the reload only passes the formatted-load proof if every supplying write passed it (formatted_descriptor_from_block). Thefirst[3] + 4tofirst[3] + widthchange is consistent with the new width. Lane masks are refused unless only read as masks (require_mask_reads_only). I found no bug.dispatchmode, warp and hardware adapters) that compare readback against the expected output, plus refused-reason controls and translator mutations. Both CMake and the Linux CI lists andAGENTS.mdare updated consistently..github/workflows/windows.yml, +4): the PR's own CI run executed both new checks (startup_gfx2hlsl_compute_spill_check.py (ok),startup_gfx2hlsl_compute_mask_spill_check.py (ok)), so the workflow edit is exercised.Commands run locally
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py: passpython3 -B tests/startup_gfx2hlsl_compute_spill_check.py,..._compute_mask_spill_check.py,..._sgpr_spill_check.py,..._spill_wave64_check.py: all PASS'cs'fromSPILL_STAGES: compute_spill check fails (rc=1)Windows WARP results follow in a separate receipt. Real-GPU run not available (RunPod stopped).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:38:51Z.
Win2025 WARP receipt for head
dc8e0f34(real-GPU run not available, RunPod stopped).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
dc8e0f34b167f9367cb1b6e24603de5eeb844bf0:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):1.63s(configure2.67s)ctest --preset dev -R 'startup_gfx2hlsl_(compute_spill|compute_mask_spill)' --parallel 3 --no-tests=error --output-on-failure): 18/18 passed (5.10s:startup_gfx2hlsl_compute_spill_s-arm-swapped_warp0.40s,startup_gfx2hlsl_compute_spill_s-store-dropped_warp0.37s,startup_gfx2hlsl_compute_spill_warp0.94s,startup_gfx2hlsl_compute_spill_p-store-dropped_warp0.36s,startup_gfx2hlsl_compute_spill_s-arm-swapped_hardware0.38s,startup_gfx2hlsl_compute_spill_hardware0.92s,startup_gfx2hlsl_compute_spill_s-store-dropped_hardware0.34s,startup_gfx2hlsl_compute_spill_p-store-dropped_hardware0.30s,startup_gfx2hlsl_compute_spill_controls2.72s,startup_gfx2hlsl_compute_mask_spill_warp0.67s,startup_gfx2hlsl_compute_mask_spill_m-saveexec-dropped_warp0.29s,startup_gfx2hlsl_compute_mask_spill_m-mask-inverted_warp0.31s,startup_gfx2hlsl_compute_mask_spill_v-branch-inverted_warp0.31s,startup_gfx2hlsl_compute_mask_spill_m-saveexec-dropped_hardware0.30s,startup_gfx2hlsl_compute_mask_spill_hardware0.72s,startup_gfx2hlsl_compute_mask_spill_m-mask-inverted_hardware0.33s,startup_gfx2hlsl_compute_mask_spill_v-branch-inverted_hardware0.28s,startup_gfx2hlsl_compute_mask_spill_controls3.03s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):5.11s(configure2.47s)ctest --preset release -R 'startup_gfx2hlsl_(compute_spill|compute_mask_spill)' --parallel 3 --no-tests=error --output-on-failure): 18/18 passed (4.80s:startup_gfx2hlsl_compute_spill_s-arm-swapped_warp0.29s,startup_gfx2hlsl_compute_spill_s-store-dropped_warp0.28s,startup_gfx2hlsl_compute_spill_warp0.68s,startup_gfx2hlsl_compute_spill_p-store-dropped_warp0.26s,startup_gfx2hlsl_compute_spill_s-arm-swapped_hardware0.30s,startup_gfx2hlsl_compute_spill_hardware0.69s,startup_gfx2hlsl_compute_spill_s-store-dropped_hardware0.27s,startup_gfx2hlsl_compute_spill_p-store-dropped_hardware0.27s,startup_gfx2hlsl_compute_spill_controls2.24s,startup_gfx2hlsl_compute_mask_spill_warp0.60s,startup_gfx2hlsl_compute_mask_spill_m-saveexec-dropped_warp0.27s,startup_gfx2hlsl_compute_mask_spill_m-mask-inverted_warp0.30s,startup_gfx2hlsl_compute_mask_spill_v-branch-inverted_warp0.33s,startup_gfx2hlsl_compute_mask_spill_m-saveexec-dropped_hardware0.37s,startup_gfx2hlsl_compute_mask_spill_hardware0.78s,startup_gfx2hlsl_compute_mask_spill_m-mask-inverted_hardware0.36s,startup_gfx2hlsl_compute_mask_spill_v-branch-inverted_hardware0.34s,startup_gfx2hlsl_compute_mask_spill_controls3.22s)tests/mesh_heap_sampler_check.pyok (0.6s),tests/startup_buffer_address_check.pyok (0.4s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_global_load_check.pyok (0.2s),tests/startup_compute_request_offline_check.pyok (0.5s),tests/startup_compute_store_format_xyzw_check.pyok (0.2s),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_bfm_b64_check.pyok (1.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.6s),tests/startup_gfx2hlsl_capture_check.pyok (1.1s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_cmp_class_f16_sdwa_check.pyok (28.7s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.8s),tests/startup_gfx2hlsl_compute_mask_spill_check.pyok (2.5s),tests/startup_gfx2hlsl_compute_spill_check.pyok (2.0s),tests/startup_gfx2hlsl_const_copy_join_check.pyok (0.1s),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_heap_record_check.pyok (0.2s),tests/startup_gfx2hlsl_heap_word_check.pyok (0.2s),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.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.2s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_data_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.4s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (2.2s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_load_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.1s),tests/startup_gfx2hlsl_refusals_check.pyok (0.6s),tests/startup_gfx2hlsl_root_check.pyok (0.8s),tests/startup_gfx2hlsl_s_abs_check.pyok (0.1s),tests/startup_gfx2hlsl_s_bitset_check.pyok (0.1s),tests/startup_gfx2hlsl_s_ff0_check.pyok (0.1s),tests/startup_gfx2hlsl_s_ff1_check.pyok (0.1s),tests/startup_gfx2hlsl_s_flbit_check.pyok (0.1s),tests/startup_gfx2hlsl_s_quadmask_b64_check.pyok (0.1s),tests/startup_gfx2hlsl_s_quadmask_check.pyok (0.1s),tests/startup_gfx2hlsl_sad_check.pyok (0.3s),tests/startup_gfx2hlsl_sad_hi_msad_check.pyok (0.3s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_null_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_sdwa_cndmask_check.pyok (0.2s),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 (5.1s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.1s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.1s),tests/startup_gfx2hlsl_spill_branches_check.pyok (0.9s),tests/startup_gfx2hlsl_swap_check.pyok (0.3s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (3.9s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.5s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.1s),tests/startup_image_gather_lz_check.pyok (0.5s),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.5s),tests/startup_inline_sampler_check.pyok (0.1s),tests/startup_mesh57_depth_only_check.pyok (0.2s),tests/startup_mesh57_lane_spill_check.pyok (0.2s),tests/startup_mesh57_loop_check.pyok (0.2s),tests/startup_mesh57_loop_refusal_check.pyok (0.1s),tests/startup_mesh57_skeleton_check.pyok (1.0s),tests/startup_run_ps1_check.pyok (11.1s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (2.4s),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.4s)sccache: 9/27 hits; wall112.5sAI-assisted; commands listed were executed locally.