shader: prove mesh scalar loads uniform inside an entered lane skip (Part of #3703) #3945
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3945"
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 mumba17 on 2026-12-03T16:06:00Z.
Part of #3703 (row E3,
VCC branch without a whole-wave mask, claimed in https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7383738427).Problem
All 152 E3 programs in our census refuse at
s_cbranch_vccnz. In 134 of them the mask is a VOP3 float compare of an SGPR against 0 (v_cmp_*_f32_e64 s[N:N+1], sM, 0), ANDed with EXEC into VCC (s_and_b64 vcc, exec, s[N:N+1]), andsMis as_buffer_load_dword/_dwordx4issued inside an entered EXECZ lane skip.The VCC path already accepts this AND when the compare's inputs are proven uniform for the current lanes (
mask_uniform). But a scalar load was recorded as uniform only underwhole_wave_execution(), which excludes per-lane skips. So the loaded word stayed unproven, the compare got no uniform predicate, VCC got no nonempty word, and the branch refused.Change
lower_mesh, scalar memory: a uniform-address scalar load also counts as uniform inside an entered EXECZ skip, i.e. while EXEC is still that skip's guard (exec_skip->guard == lane_active). The host threads that run the load are the guest's active lanes, and the guest wave runs the load once for all of them, so every running thread reads the same word. The value is recorded inactive_uniformfor the current lane set, as the existing narrowed-EXEC whole-wave case already does. The other conditions are unchanged: root address or buffer load, no open branch or pending forward edge, constant or uniform SGPR offset.Readers of
active_uniformmatch the lane set, so a value loaded under a narrower EXEC is still not uniform after a restore. VCC nonemptiness still needsexec_nonempty_known(), which holds inside an entered skip.Tests (
native_direct_mesh)scalar-buffer-vcc-under-lane-skip: before allocation,v_cmpx_eq_u32 1, v0plus EXECZ opens a lane skip. Inside it,s_buffer_load_dword s20,v_cmp_lt_f32_e64 s[4:5], s20, 0,s_and_b64 vcc, exec, s[4:5]ands_cbranch_vccnzover av_mov_b32 v3, 1.0. Translates and validates. The check requires that the skip body branches onfcmp oltof the loaded word alone.VCC branch without a whole-wave mask):scalar-buffer-vcc-narrowed-load: the load runs under a further CMPX narrowing and EXEC is restored to the guard before the compare.scalar-buffer-vcc-open-branch: the load sits under an open scalar branch (s_cmp_eq_u32 s21, 0+s_cbranch_scc1to the restore).scalar-buffer-vcc-under-lane-skipfails withVCC branch without a whole-wave mask. Dropping only theguard == lane_activeterm does not fail a test, because theactive_uniformlane-set match already rejects the narrowed form. The term stays as the statement that the skip was entered.Census
Native Mesh86 capture, 6,685 distinct programs, one
compile_dxil … gfx1013-container-ms-texture-heaprun each, release build, mainb78e10dfvs this branch:VCC branch without a whole-wave maskv_readfirstlane_b3274,s_load_dwordx4root mapping 29,mesh SAVEEXEC then arm depends on EXEC8,v_madak_f323,undefined on an incoming path3, group memory exchange 2.s_or_b64with VCC, pair ANDs), which needs a cross-lane vote and is not part of this PR; 15 load the scalar under an open scalar branch.Counts only; request bytes stay local.
Checks
ctest --preset pr -j 4(Windows, RTX 3090, debug): 345/347 passed,native_direct_meshincluded. The 2 failures,native_compute_implicit_lod_controlsandnative_wave_virtual_derivative_controls, also fail on main locally (this SDK's validator is 1.7, the modules declare 1.8). They fail the same way when rerun serially.native_direct_meshagainst the release build with and without the change, as above.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T16:21:43Z.
Review: APPROVED
Reviewed
386108a5. The additional uniform-load case requires the current EXEC to equal the entered skip guard, a uniform offset, and no open scalar branch. The new controls still refuse a load under narrower EXEC and a load inside an open branch. Independently rebuilt compile_dxil in MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1, no skips). Restoring the previous whole-wave-only condition made scalar-buffer-vcc-under-lane-skip fail at +0x34 with VCC branch without a whole-wave mask. This is source-built compile and emitted-DXIL evidence.