mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:38:53 +00:00
A pixel shader with an ordered section (POPS) reads the hardware's collision word, which sits in the SGPR after the user SGPRs and the primitive mask: collision wave id in bits 0-9, this wave's id in bits 16-25, overlap in bit 31. The program waits until wave_id + ~collision_id is below src_pops_exiting_wave_id + ~collision_id (unsigned). The translator orders the section with fragment-shader interlock and reads the exiting id as 0, and the word was whatever the push constants held at that dword, usually 0. With wave id == collision id the test is 0xffffffff < 0xffffffff, never true, so a wave that reached the loop ran it until the loop guard (65,536 rounds). The overlap test before the loop skips it whenever a lane is on in EXEC, so it is a wave (a host subgroup) with EXEC all off there; on 32-wide subgroups that is either half of a wave64 program whose lanes are all off. The SGPR is now the source of the program's wave-id extract (s_bfe_u32 with field 0x000a0010) when the program reads that SGPR's entry value (shader_meta's user_sgpr_reads), and it is set at entry to 0x00010000 (no overlap, wave id 1, collision id 0): the loop leaves after one round. A program without that extract keeps the old behaviour. - tools/rdna2spirv.py: pops_collision_sgpr and the entry store. - tests/semantic/test_pops_collision_seed.py: subgroups of 64 and 32 lanes, with and without the seed, and the SGPR search; the GPU fixture runtime/test/shaders/ps_pops_wait_loop.asm (check.py, run_gpu_tests.py) and its llvm-mc listing. - tests/semantic/spirv_wave_interp.py: the interlock instructions run as no-ops (a run has no other primitive). - runtime/test/vk_harness.cpp: a fragment shader that needs pixel interlock on a device without it is unsupported (77), as for barycentrics. - docs/design.md, docs/d3d12_vulkan.md: the POPS rows. GPU: on an RTX 4070 SUPER the fixture gives 4096 of 4096 pixels as expected; with the seed taken out every pixel's round count is 0x00010000. Idea from Marvisak/VIctory 7ac1f54, written anew. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
48 lines
3.7 KiB
ArmAsm
48 lines
3.7 KiB
ArmAsm
; ps_pops_wait_loop llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding output for runtime/test/shaders/ps_pops_wait_loop.asm (the branches need the instruction encodings; test_pops_collision_seed.py checks this listing against the .asm)
|
|
s_mov_b64 s[20:21], exec ; encoding: [0x7e,0x04,0x94,0xbe]
|
|
s_mov_b32 s12, 0 ; encoding: [0x80,0x03,0x8c,0xbe]
|
|
s_mov_b32 s13, 0 ; encoding: [0x80,0x03,0x8d,0xbe]
|
|
s_mov_b64 exec, 0 ; encoding: [0x80,0x04,0xfe,0xbe]
|
|
s_bfe_u32 s2, s18, 0xa0000 ; encoding: [0x12,0xff,0x82,0x93,0x00,0x00,0x0a,0x00]
|
|
s_bfe_u32 s5, s18, 0xa0010 ; encoding: [0x12,0xff,0x85,0x93,0x10,0x00,0x0a,0x00]
|
|
s_not_b32 s4, s2 ; encoding: [0x02,0x07,0x84,0xbe]
|
|
s_lshr_b32 s0, s18, 31 ; encoding: [0x12,0x9f,0x00,0x90]
|
|
s_add_i32 s5, s5, s4 ; encoding: [0x05,0x04,0x05,0x81]
|
|
s_cmp_eq_u32 s0, 0 ; encoding: [0x00,0x80,0x06,0xbf]
|
|
s_cselect_b64 s[0:1], exec, 0 ; encoding: [0x7e,0x80,0x80,0x85]
|
|
s_add_i32 s2, src_pops_exiting_wave_id, s4 ; encoding: [0xef,0x04,0x02,0x81]
|
|
s_cmp_gt_u32 s2, s5 ; encoding: [0x02,0x05,0x08,0xbf]
|
|
s_cselect_b64 s[2:3], exec, 0 ; encoding: [0x7e,0x80,0x82,0x85]
|
|
s_or_b64 s[0:1], s[0:1], s[2:3] ; encoding: [0x00,0x02,0x80,0x88]
|
|
s_and_b64 vcc, exec, s[0:1] ; encoding: [0x7e,0x00,0xea,0x87]
|
|
s_cbranch_vccnz 5 ; encoding: [0x05,0x00,0x87,0xbf]
|
|
s_sleep 0xffff ; encoding: [0xff,0xff,0x8e,0xbf]
|
|
s_add_i32 s12, s12, 1 ; encoding: [0x0c,0x81,0x0c,0x81]
|
|
s_add_i32 s0, src_pops_exiting_wave_id, s4 ; encoding: [0xef,0x04,0x00,0x81]
|
|
s_cmp_lt_u32 s5, s0 ; encoding: [0x05,0x00,0x0a,0xbf]
|
|
s_cbranch_scc0 -5 ; encoding: [0xfb,0xff,0x84,0xbf]
|
|
s_mov_b64 exec, s[20:21] ; encoding: [0x14,0x04,0xfe,0xbe]
|
|
s_bfe_u32 s2, s18, 0xa0000 ; encoding: [0x12,0xff,0x82,0x93,0x00,0x00,0x0a,0x00]
|
|
s_bfe_u32 s5, s18, 0xa0010 ; encoding: [0x12,0xff,0x85,0x93,0x10,0x00,0x0a,0x00]
|
|
s_not_b32 s4, s2 ; encoding: [0x02,0x07,0x84,0xbe]
|
|
s_lshr_b32 s0, s18, 31 ; encoding: [0x12,0x9f,0x00,0x90]
|
|
s_add_i32 s5, s5, s4 ; encoding: [0x05,0x04,0x05,0x81]
|
|
s_cmp_eq_u32 s0, 0 ; encoding: [0x00,0x80,0x06,0xbf]
|
|
s_cselect_b64 s[0:1], exec, 0 ; encoding: [0x7e,0x80,0x80,0x85]
|
|
s_add_i32 s2, src_pops_exiting_wave_id, s4 ; encoding: [0xef,0x04,0x02,0x81]
|
|
s_cmp_gt_u32 s2, s5 ; encoding: [0x02,0x05,0x08,0xbf]
|
|
s_cselect_b64 s[2:3], exec, 0 ; encoding: [0x7e,0x80,0x82,0x85]
|
|
s_or_b64 s[0:1], s[0:1], s[2:3] ; encoding: [0x00,0x02,0x80,0x88]
|
|
s_and_b64 vcc, exec, s[0:1] ; encoding: [0x7e,0x00,0xea,0x87]
|
|
s_cbranch_vccnz 5 ; encoding: [0x05,0x00,0x87,0xbf]
|
|
s_sleep 0xffff ; encoding: [0xff,0xff,0x8e,0xbf]
|
|
s_add_i32 s13, s13, 1 ; encoding: [0x0d,0x81,0x0d,0x81]
|
|
s_add_i32 s0, src_pops_exiting_wave_id, s4 ; encoding: [0xef,0x04,0x00,0x81]
|
|
s_cmp_lt_u32 s5, s0 ; encoding: [0x05,0x00,0x0a,0xbf]
|
|
s_cbranch_scc0 -5 ; encoding: [0xfb,0xff,0x84,0xbf]
|
|
v_mov_b32_e32 v0, s12 ; encoding: [0x0c,0x02,0x00,0x7e]
|
|
v_mov_b32_e32 v1, s13 ; encoding: [0x0d,0x02,0x02,0x7e]
|
|
v_mov_b32_e32 v2, 1.0 ; encoding: [0xf2,0x02,0x04,0x7e]
|
|
exp mrt0, v0, v1, v2, v2 done vm ; encoding: [0x0f,0x18,0x00,0xf8,0x00,0x01,0x02,0x02]
|
|
s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
|