mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:18:38 +00:00
ms_w64x_wave_votes: two waves take different branches, each with its own ballot count (and a v_readfirstlane in the second), and the triangle's vertices come from threads 0 and 1 of the first wave and thread 64 of the second, so ms_tri's picture needs both waves to have run their own branch with their own votes. It passes in the side-by-side form and with --mesh-serial-waves on an RTX 4080 (NVIDIA 621.24). A program with a store or an atomic to memory keeps the side-by-side form, as one with LDS does: its waves could pass each other something. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
58 lines
2.2 KiB
NASM
58 lines
2.2 KiB
NASM
; Mesh shader (NGG, wave64, 128 threads = 2 waves): the two waves take different branches, each with its own
|
|
; wave-wide reads, and each wave contributes vertices to the one triangle.
|
|
; wave 0: ballot of (lane & 7) == 5, s_bcnt1 must be 8.
|
|
; wave 1: ballot of lane < 3, s_bcnt1 must be 3, plus v_readfirstlane of the lane number, which must be 0.
|
|
; A wave whose count is right sets the blue channel of param0 to 0.5 in the vertices it exports, else 0.
|
|
; The triangle is ms_tri's, but its vertices come from threads 0 and 1 (wave 0) and thread 64 (wave 1), so the
|
|
; picture is ms_tri's only when both waves ran their own branch with their own votes: a wave that saw the other
|
|
; wave's ballot, or ran the other branch, gets a different count. Only wave 0 sends the mesh allocation
|
|
; (1 primitive, 65 vertices: indices 0, 1 and 64 are used).
|
|
; Needs a DXBC with PSV0 (128 threads, 128/64 outputs, triangles; see scripts/run_gpu_tests.py):
|
|
; VKH_MESH=1 vk_harness ms_w64x_wave_votes.spv fs_passthru.spv out.raw
|
|
; -> every pixel = ((x+0.5)/64, (y+0.5)/64, 0.5, 1), identical to ms_tri.
|
|
; mattr: +wavefrontsize64,-wavefrontsize32
|
|
v_mbcnt_lo_u32_b32 v0, -1, 0
|
|
v_mbcnt_hi_u32_b32 v0, -1, v0
|
|
v_mov_b32_e32 v11, v0
|
|
s_bfe_u32 s4, s3, 0x40018
|
|
v_lshl_add_u32 v0, s4, 6, v0
|
|
s_cmp_eq_u32 s4, 0
|
|
s_cbranch_scc0 6
|
|
v_and_b32_e32 v12, 7, v11
|
|
v_cmp_eq_u32_e64 s[6:7], 5, v12
|
|
s_bcnt1_i32_b64 s10, s[6:7]
|
|
s_mov_b32 s14, 8
|
|
s_branch 6
|
|
v_cmp_gt_u32_e64 s[6:7], 3, v11
|
|
s_bcnt1_i32_b64 s10, s[6:7]
|
|
v_readfirstlane_b32 s15, v11
|
|
s_add_u32 s10, s10, s15
|
|
s_mov_b32 s14, 3
|
|
s_cmp_eq_u32 s10, s14
|
|
s_cselect_b32 s13, 1, 0
|
|
v_cvt_f32_u32_e32 v15, s13
|
|
v_mul_f32_e32 v15, 0.5, v15
|
|
v_cmp_eq_u32_e32 vcc, 1, v0
|
|
v_cndmask_b32_e64 v1, -1.0, 0x40400000, vcc
|
|
v_cndmask_b32_e64 v3, 0, 2.0, vcc
|
|
v_cmp_eq_u32_e32 vcc, 64, v0
|
|
v_cndmask_b32_e64 v2, -1.0, 0x40400000, vcc
|
|
v_cndmask_b32_e64 v4, 0, 2.0, vcc
|
|
v_mov_b32_e32 v6, 0
|
|
v_mov_b32_e32 v7, 1.0
|
|
v_mov_b32_e32 v8, v15
|
|
s_mov_b32 m0, 0x1041
|
|
s_cmp_lg_u32 s4, 0
|
|
s_cbranch_scc1 1
|
|
s_sendmsg sendmsg(MSG_GS_ALLOC_REQ)
|
|
v_cmp_gt_u32_e64 s[16:17], 2, v0
|
|
v_cmp_eq_u32_e64 s[18:19], 64, v0
|
|
s_or_b64 exec, s[16:17], s[18:19]
|
|
exp pos0 v1, v2, v6, v7 done
|
|
exp param0 v3, v4, v8, v7
|
|
s_mov_b64 exec, -1
|
|
v_cmpx_eq_u32_e32 0, v0
|
|
v_mov_b32_e32 v9, 0x4000400
|
|
exp prim v9, off, off, off done
|
|
s_endpgm
|