mesh: preserve a scalar shift across a wave64 EXEC-zero branch #2593
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2601"
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 RavenCurseBurg on 2026-11-25T22:44:44Z.
Refs #2413. This implements the scalar-shift slice from the tracking issue.
The slot 57 mesh translator now recognizes the first post-count branch when a full-EXEC unsigned compare selects threads below a literal limit, an adjacent save narrows EXEC, and
s_cbranch_execzskips ones_lshl_b32to the full-EXEC restore. For that contiguous prefix, the 64-lane guest wave is empty exactly when its first thread is at or above the limit. The generated branch therefore takes the same path for all 64 guest lanes regardless of the desktop wave size.The fixture makes six threads active in the first wave and none in the second. After EXEC widens, thread 39 must see the shifted value from the first wave. Vertices in the second wave must still see the previous, nonzero scalar. The CPU checks the full 32×32 image. A separately compiled per-lane branch changes exactly 66 pixels and matches its independently predicted image. Source-built controls also reject a scalar memory load, an unproven thread register, a path entering the shift and a delayed full-EXEC restore.
The GPU results below use
e9346b1a. The final assembly spelling is verified at847109a2.All 80 related Python and documentation checks passed at the GPU build. The initial local LLVM wrapper used the target default. Upstream LLVM 15 correctly refused the explicit
vcc_lospelling under wave64. Commit847109a2usesvcc; it encodes the same instruction bytes (86 00 88 7d). The full guest program now matches in explicit wave64 mode and all three upstream CI jobs passed, includingpython -B tests/startup_mesh57_skeleton_check.py binary llvm-mc-15.ctest --preset release --no-tests=error -R '^startup_mesh57_skeleton' -V. The new cases arestartup_mesh57_skeleton_wave_shift_warpandstartup_mesh57_skeleton_wave_shift_hardware. The original draw, request exchange and skeleton controls use the same filter.The exact-head Windows Server 2025 Release build passed the host test and all three WARP tests. On Windows 11 build 26100.9711 I verified the artifact digests and relocated the original seven CTest registrations. With an RTX 4060 (32.0.15.9579) all seven passed. With Intel UHD 770 (32.0.101.5973) the host and three WARP tests passed, and all three hardware tests skipped on mesh tier (77). The desktop debug layer was unavailable. Both WARP and RTX produced exactly 66 differing pixels for the per-lane mutation, and zero against the mutation's own CPU prediction.
An additional source-built check assembled thread limits 0, 1, 63, 64, 65, 70 and 128 and enumerated the active threads on the CPU. The seven full images matched on both WARP and RTX using the earlier verified renderer from #2576.
AI-assisted with Codex (GPT-6.2 Astra, xhigh).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:53:17Z.
Review: COMMENTED
Review of head
847109a2against origin/main (8 commits behind, no conflict).Findings: none blocking.
tools/startup/gfx2hlsl.py: the shift branch is only accepted as the first post-count branch,s_cbranch_execzover exactly ones_lshl_b32to a full-EXEC restore, with the precedingv_cmp_gt_u32on the proven thread register under full EXEC. For a contiguous prefix, a 64-lane guest wave is empty exactly when its first thread is at or above the limit, so(tid & ~63u) >= limitis the right wave-level condition.startup_mesh57_skeleton_wave_shift_{warp,hardware}is registered next to its sibling draw tests and checks the full image against a CPU reference. It also compiles a per-lane branch and checks that it gives a different image.docs/experiments.md. No other open or merged PR covers this slice.Commands run:
python3 -B tests/startup_mesh57_skeleton_check.py: passedpython3 tests/docs_links_check.py: passedpython3 tests/bidi_controls_check.py: passedgit diff --check origin/main...HEAD: clean(tid & ~63u)bytidis not caught on Linux. Only the GPU draw test can catch it, so the Win2025 readback is the real guard here. Result to follow.Fixture and code review only; no executable results are claimed.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T22:56:16Z.
Additional hardware run at head
847109a2(build exit code 0), with the debug layer enabled. The PR body reports an RTX 4060 run (7/7) without the desktop debug layer; this adds a second NVIDIA GPU with the layer on.Environment: NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101 (NVIDIA 621.01) and Windows 11 Pro build 26300.9974 as reported by the system,
devpreset (MSVC). The runs were serial (-j1).Command:
ctest --preset dev --no-tests=error -j1 -V -R '^startup_mesh57_skeleton'Result: 7/7 passed, 0 failed (
startup_mesh57_skeleton, three_hardwaretests:draw,wave_shift,exchange, and three_warptests). 0 failures (***), 0 capability skips (77).startup_mesh57_skeleton_exchange_hardware(test 1479) printsadapter: NVIDIA GeForce RTX 3070 Ti, debug layer enabledanddriver: 32.0.16.2101, thencovered=259: ['debug_errors=0 debug_warnings=0'].startup_mesh57_skeleton_draw_hardware(test 1476) does not print the adapter. Its five lines end in['debug_errors=0 debug_warnings=0'], for examplevertices=12 primitives=1 first=0 flags=[] covered=66. A direct run of the same command under the wrapper reportsadapter=NVIDIA GeForce RTX 3070 Tifor its firstoffscreen_checkcall.startup_mesh57_skeleton_wave_shift_hardware(test 1477) does not print the adapter. It prints:d98327ecde9a6d5d.ms57.cso: 0 pixels differ from the referenceper-lane.cso: 66 pixels differ from the referenceper-lane.cso: 0 pixels differ from the referenceThe first line is the translated shader against the expected image. The second is a mutant that replaces the wave predicate
(tid & ~63u) >= 6uwith a per-lane(exec & 1) == 0, against the expected image (it must differ). The third is the same mutant against its per-lane CPU prediction (it must match).To identify the adapter for
wave_shift, I rantests/startup_mesh57_skeleton_check.py shift ... hardwaredirectly with the firstoffscreen_checkcall's stdout printed. That call reportsbackend=hardware debug_layer=enabled,adapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482,driver=32.0.16.2101anddebug_errors=0 debug_warnings=0. The debug line covers that first call only. The script then prints the same three lines andok.This run covers NVIDIA and WARP only. Not covered: any test outside the filter above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:01:52Z.
Win2025 WARP receipt for head
847109a2.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
847109a227fd5ecb91aed81d1ea1ddf86a712483:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):0.36s(configure0.00s)ctest --preset dev -R '^startup_mesh57_skeleton.*_warp$' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (2.73s:startup_mesh57_skeleton_wave_shift_warp0.62s,startup_mesh57_skeleton_draw_warp2.14s,startup_mesh57_skeleton_exchange_warp1.87s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):2.74s(configure0.00s)ctest --preset release -R '^startup_mesh57_skeleton.*_warp$' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (2.80s:startup_mesh57_skeleton_wave_shift_warp0.53s,startup_mesh57_skeleton_draw_warp2.09s,startup_mesh57_skeleton_exchange_warp2.01s)tests/mesh_heap_sampler_check.pyok (0.9s),tests/startup_buffer_address_check.pyok (0.6s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.6s),tests/startup_compute_translate_check.pyok (0.3s),tests/startup_flat_param_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.9s),tests/startup_gfx2hlsl_capture_check.pyok (2.8s),tests/startup_gfx2hlsl_cmp16_check.pyok (1.9s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.2s),tests/startup_gfx2hlsl_compute_check.pyok (0.6s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.7s),tests/startup_gfx2hlsl_f32_nan_check.pyok (6.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.1s),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.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.4s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (3.2s),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.8s),tests/startup_gfx2hlsl_root_check.pyok (0.9s),tests/startup_gfx2hlsl_sad_check.pyok (0.5s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.3s),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.9s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.2s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.4s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (6.0s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.8s),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.7s),tests/startup_image_load_d16_check.pyok (1.2s),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.3s),tests/startup_image_sample_l_check.pyok (0.3s),tests/startup_image_sample_lod_check.pyok (0.8s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_skeleton_check.pyok (0.5s),tests/startup_run_ps1_check.pyok (14.0s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (2.5s),tests/startup_smem_address_check.pyok (0.1s),tests/startup_stream_fetch_check.pyok (0.3s),tests/startup_stream_interface_check.pyok (0.6s),tests/startup_translator_check.pyok (0.6s)sccache: 12/134 hits; wall82.7sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T23:06:09Z.
Post-merge audit of
cece3a36: six mutations, four caught — and the two survivors are the emitted wave predicate, which the fixture never looks atThe change lets a scalar shift survive a wave64 EXEC-zero branch, but only under a proof: the branch must be the first one
after the count block, its target exactly two instructions later, the next instruction an
s_lshl_b32, the target a fulls_mov_b64 exec, -1, and immediately before it av_cmp_gt_u32_e32 vcc_lo, <limit>, v<thread>whose mask is the branchitself. If all of that holds, the branch is re-emitted as
(tid & ~63u) >= <limit>.source + 2→source + 3s_lshl_b32s_mov_b64 exec, -1threadterm = ('branch', '(tid & ~63u) >= N', …)→pass)cond_uniformno longer acceptsoff in wave_limitsThe four catches are the proof's structural conditions, and each has a refusal case in the fixture. That is the part that
matters for correctness of the decision.
The two survivors are the same gap: the emitted text is unconstrained
Both of them change what gets emitted, not whether the shape is accepted:
passleaves the branch as the original guest condition instead of(tid & ~63u) >= <limit>. The skeleton still accepts, the HLSL still compiles, and the guest lane mask is simplywrong — a scalar shift proceeds on lanes it should not.
or off in wave_limitsfromcond_uniformdemotes the branch back to divergent, which changes the shape ofthe emitted control flow.
The fixture asserts the refusal messages (seven of them, quoted by text) and that the accepted shape translates; it does
not compare the emitted predicate or the block's uniformity. So a regression in either would pass CI.
The cheap fix is to assert the translated text for the accepted case contains
(tid & ~63u) >= <the limit from the compare>— the same waystartup_gfx2hlsl_sload_s104_check.pyassertsu('vcc_lo') == 'vcc'for its accepted case.Note on one of my own rows
My first attempt at the target-offset mutation was a no-op: I wrote the same string for both sides of the replacement, so
ReplOncereturned unchanged text and the row read as "survived". Re-run withsource + 2→source + 3it is caught.The table above reports the corrected row; the earlier no-op said nothing about this PR.
AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.