upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authormilk4sale <53350507+milk4sale@users.noreply.github.com>2026-11-24 11:30:28 -0600
committermilk4sale <53350507+milk4sale@users.noreply.github.com>2026-11-24 11:47:35 -0600
commitf03418595c85cf0dd2a9dcf0d6bc76a50aa85f6d (patch)
treeb3b7e46362a5852a04477fd1986475993587e06c /runtime
parentbc7143b5f18ba8fbaaac8ece425d80893c9fa1bb (diff)
wave64_halves: a vote on a scalar compare under whole-quad EXEC is no lane vote (SHADER-W64-WQM-UVOTE)
A pixel shader that needs derivatives starts with s_wqm_b64 exec, exec, and LLVM branches on wave-uniform conditions inside that region as it does anywhere: v_cmp_* sN of scalars, s_and_b64 vcc, exec, s[N:N+1], s_cbranch_vccnz. SHADER-10 took that for no lane vote only while EXEC was the launch mask, so here it was unsafe-vote-branch. A compare of immediates and scalars is the same in every lane, so its mask is every lane of EXEC or none; the whole quads of the launch mask have a lane in every 32-lane half that runs (a quad never straddles the halves). The analysis carries "EXEC is the whole quads of the launch mask" as a dataflow fact, set by s_wqm_b64 exec, exec under the launch mask and dropped by every other EXEC write. VGPR sources stay refused there, and so does a path on which a scalar was read out of a uniform VGPR from a lane the launch mask may not have written. Corpus (1.0.2.1, all 26,503, on top of SHADER-W64-SDST-PAIR): 452 pixel shaders go from tier C to A, none moves the other way: C 7,741 to 7,289. Tests: tests/semantic/test_wave64_halves_wqm_uvote.py; GPU fixture ps_w64_a_wqm_uniform_vote (RTX 4070 Ti, 620.70.06). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm53
-rw-r--r--runtime/test/shaders/w64_graphics.py2
2 files changed, 55 insertions, 0 deletions
diff --git a/runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm b/runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm
new file mode 100644
index 000000000..51f320e8e
--- /dev/null
+++ b/runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm
@@ -0,0 +1,53 @@
1; SHADER-W64-WQM-UVOTE tier A: votes on a compare of scalars while EXEC is the whole quads of the launch mask
2; (docs/design.md, "Wave64 graphics: a uniform vote under whole-quad EXEC"). A pixel shader that needs derivatives
3; starts with s_wqm_b64 exec, exec: the helper lanes of every quad that has a covered pixel come on. A v_cmp of
4; scalars and constants there is the same in every lane, so its mask is every lane of EXEC or none, and EXEC has a
5; lane in every 32-lane half that runs (a quad never straddles the halves): each half votes as the whole wave does,
6; and both sides of the branch may have code of their own, scalars included. s4 is a user SGPR (the test sets it to
7; 9 with VKH_SGPRS=0,0,0,0,9). x = floor(u * 64) on the 64x64 target of vs_ids.
8; (1) s_cbranch_vccz if/else on 5 < s4 (yes), the compare written straight to VCC: the yes side sets v6 = 7 and
9; s20 = 11, the no side v6 = 5 and s20 = 22; both are read after the join. r0 = x + 7, r1 = 11.
10; (2) the LLVM form v_cmp_e64 s[14:15] + s_and_b64 vcc, exec, s[14:15] + s_cbranch_vccnz on 50 < s4 (no): the no
11; side sets v8 = 3 and s21 = 33, the yes side v8 = 4 and s21 = 44. r2 = s21 + v8 = 36.
12; (3) a loop whose back edge is s_cbranch_vccnz on s22 < s4 (s22 the trip count, an SGPR carried across the back
13; edge): s4 = 9 iterations of v9 += 2, then v9 += s22. r3 = 2 * 9 + 9 = 27.
14; EXEC goes back to the launch mask before the export. The words are those of ps_w64_a_uniform_vote, whose compares
15; read a VGPR under the launch mask; here no VGPR is compared, because one written under the launch mask is not
16; uniform over the helper lanes.
17; Run: VKH_SGPRS=0,0,0,0,9 vk_harness vs_ids.spv ps_w64_a_wqm_uniform_vote.spv out.raw with VKH_SUBGROUP_SIZE=64
18; and 32: equal, and equal to the expected words (x + 7, 11, 36, 27).
19; mattr: +wavefrontsize64,-wavefrontsize32
20v_interp_p1_f32_e32 v2, v0, attr0.x
21v_interp_p2_f32_e32 v2, v1, attr0.x
22v_mul_f32_e32 v2, 0x42800000, v2
23v_cvt_u32_f32_e32 v2, v2
24s_mov_b64 s[10:11], exec
25s_wqm_b64 exec, exec
26v_cmp_lt_u32_e64 vcc, 5, s4
27s_cbranch_vccz 3
28v_mov_b32_e32 v6, 7
29s_mov_b32 s20, 11
30s_branch 2
31v_mov_b32_e32 v6, 5
32s_mov_b32 s20, 22
33v_add_nc_u32_e32 v6, v6, v2
34v_mov_b32_e32 v7, s20
35v_cmp_lt_u32_e64 s[14:15], 50, s4
36s_and_b64 vcc, exec, s[14:15]
37s_cbranch_vccnz 3
38v_mov_b32_e32 v8, 3
39s_mov_b32 s21, 33
40s_branch 2
41v_mov_b32_e32 v8, 4
42s_mov_b32 s21, 44
43v_add_nc_u32_e32 v8, s21, v8
44s_mov_b32 s22, 0
45v_mov_b32_e32 v9, 0
46s_add_u32 s22, s22, 1
47v_add_nc_u32_e32 v9, 2, v9
48v_cmp_gt_u32_e64 vcc, s4, s22
49s_cbranch_vccnz -5
50v_add_nc_u32_e32 v9, s22, v9
51s_and_b64 exec, exec, s[10:11]
52exp mrt0 v6, v7, v8, v9 done vm
53s_endpgm
diff --git a/runtime/test/shaders/w64_graphics.py b/runtime/test/shaders/w64_graphics.py
index 649fc4630..e28d03d2f 100644
--- a/runtime/test/shaders/w64_graphics.py
+++ b/runtime/test/shaders/w64_graphics.py
@@ -187,6 +187,8 @@ FIXTURES = {
187 "ps_w64_a_swizzle": ("A", _a_swizzle, {}), 187 "ps_w64_a_swizzle": ("A", _a_swizzle, {}),
188 "ps_w64_a_bpermute": ("A", _a_bpermute, {}), 188 "ps_w64_a_bpermute": ("A", _a_bpermute, {}),
189 "ps_w64_a_uniform_vote": ("A", _a_uniform_vote, {"VKH_SGPRS": "0,0,0,0,9"}), 189 "ps_w64_a_uniform_vote": ("A", _a_uniform_vote, {"VKH_SGPRS": "0,0,0,0,9"}),
190 # SHADER-W64-WQM-UVOTE: the same votes on compares of scalars under s_wqm_b64 exec, exec (the same words)
191 "ps_w64_a_wqm_uniform_vote": ("A", _a_uniform_vote, {"VKH_SGPRS": "0,0,0,0,9"}),
190 192
191 "ps_w64_a_discard": ("A", _a_discard, {}), 193 "ps_w64_a_discard": ("A", _a_discard, {}),
192 "ps_w64_b_waterfall": ("B", _b_waterfall, {}), 194 "ps_w64_b_waterfall": ("B", _b_waterfall, {}),