diff options
| author | Diesel <dev.diesel@proton.me> | 2026-11-21 22:44:07 +0100 |
|---|---|---|
| committer | Diesel <dev.diesel@proton.me> | 2026-11-21 22:44:07 +0100 |
| commit | 5c1a1fbb6bf6f609eb4e61baa4961ce382743a4e (patch) | |
| tree | ac8ad90058b97ab241fdc65edae3d4628d20ee1e /runtime/test/shaders | |
| parent | c45309e29f21c1d5b75678db0e2dc2dd11cff25b (diff) | |
| parent | 4e390e0871d7265e629b51aca8ff99a15a6a6845 (diff) | |
Merge main to include the compute Y/Z harness test fix
Diffstat (limited to 'runtime/test/shaders')
| -rw-r--r-- | runtime/test/shaders/build.py | 24 | ||||
| -rw-r--r-- | runtime/test/shaders/check.py | 6 | ||||
| -rw-r--r-- | runtime/test/shaders/cs_smem_soffset_imm.asm | 61 |
3 files changed, 81 insertions, 10 deletions
diff --git a/runtime/test/shaders/build.py b/runtime/test/shaders/build.py index 180d48ec5..09730a2b0 100644 --- a/runtime/test/shaders/build.py +++ b/runtime/test/shaders/build.py | |||
| @@ -3,8 +3,9 @@ | |||
| 3 | python3 -I runtime/test/shaders/build.py <out dir> [name ...] | 3 | python3 -I runtime/test/shaders/build.py <out dir> [name ...] |
| 4 | 4 | ||
| 5 | Each .asm is RDNA2 assembly. It is assembled with llvm-mc (LLVM 21+ with the AMDGPU target; set LLVM_MC to its | 5 | Each .asm is RDNA2 assembly. It is assembled with llvm-mc (LLVM 21+ with the AMDGPU target; set LLVM_MC to its |
| 6 | path, as for the shaders stage). Listings, synthetic FSSM headers and DXBC containers are staged in a temporary | 6 | path or to a whole command, as for the shaders stage). Listings, synthetic FSSM headers and DXBC containers are |
| 7 | directory. After validation, the build writes <out>/spirv/<name>.spv and the translator metadata. | 7 | staged in a temporary directory. After validation, the build writes <out>/spirv/<name>.spv and the translator |
| 8 | metadata. | ||
| 8 | 9 | ||
| 9 | Compute shaders can override the default header with leading "; group: X,Y,Z" and "; rsrc2: 0x..." comments. | 10 | Compute shaders can override the default header with leading "; group: X,Y,Z" and "; rsrc2: 0x..." comments. |
| 10 | The stage comes from the name's prefix. Mesh and geometry shaders (ms_, gs_) also need a DXBC container with | 11 | The stage comes from the name's prefix. Mesh and geometry shaders (ms_, gs_) also need a DXBC container with |
| @@ -20,10 +21,15 @@ import tempfile | |||
| 20 | from pathlib import Path | 21 | from pathlib import Path |
| 21 | 22 | ||
| 22 | HERE = os.path.dirname(os.path.abspath(__file__)) | 23 | HERE = os.path.dirname(os.path.abspath(__file__)) |
| 23 | TRANSLATOR = os.path.join(HERE, "..", "..", "..", "tools", "rdna2spirv.py") | 24 | TOOLS = os.path.join(HERE, "..", "..", "..", "tools") |
| 24 | LLVM_MC = os.environ.get("LLVM_MC", "llvm-mc") | 25 | TRANSLATOR = os.path.join(TOOLS, "rdna2spirv.py") |
| 26 | sys.path.insert(0, TOOLS) | ||
| 27 | import mc_command # noqa: E402 | ||
| 28 | |||
| 29 | MC = mc_command.mc_command() | ||
| 30 | RSRC2, GROUP = 0x8088, (64, 1, 1) | ||
| 25 | sys.path.insert(0, HERE) # this script is also run with python -I | 31 | sys.path.insert(0, HERE) # this script is also run with python -I |
| 26 | from compute_fixture import compute_header | 32 | from compute_fixture import compute_header # noqa: E402 |
| 27 | 33 | ||
| 28 | 34 | ||
| 29 | def asm_mattr(path): | 35 | def asm_mattr(path): |
| @@ -45,12 +51,14 @@ def translate_tests(work, names): | |||
| 45 | fssm.mkdir() | 51 | fssm.mkdir() |
| 46 | for n in names: | 52 | for n in names: |
| 47 | asm_path = os.path.join(HERE, n + ".asm") | 53 | asm_path = os.path.join(HERE, n + ".asm") |
| 54 | raw = Path(asm_path).read_text(encoding="utf-8") | ||
| 48 | mattr = asm_mattr(asm_path) | 55 | mattr = asm_mattr(asm_path) |
| 49 | cmd = [LLVM_MC, "-triple=amdgcn--amdpal", "-mcpu=gfx1013"] | 56 | cmd = MC + ["-triple=amdgcn--amdpal", "-mcpu=gfx1013"] |
| 50 | if mattr: | 57 | if mattr: |
| 51 | cmd.append(f"-mattr={mattr}") | 58 | cmd.append(f"-mattr={mattr}") |
| 52 | cmd += ["-show-encoding", asm_path] | 59 | cmd.append("-show-encoding") |
| 53 | r = subprocess.run(cmd, capture_output=True, text=True) | 60 | # Feed the text on stdin: an LLVM_MC command that runs in WSL cannot open a Windows path argument. |
| 61 | r = subprocess.run(cmd, input=raw, capture_output=True, text=True) | ||
| 54 | if r.returncode or "error:" in r.stderr: | 62 | if r.returncode or "error:" in r.stderr: |
| 55 | sys.exit(f"{n}.asm did not assemble:\n{r.stderr}") | 63 | sys.exit(f"{n}.asm did not assemble:\n{r.stderr}") |
| 56 | # rdna2spirv.py rejects assembler directives such as the "\t.text" llvm-mc prints first. | 64 | # rdna2spirv.py rejects assembler directives such as the "\t.text" llvm-mc prints first. |
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 15c2a0c60..75f9a2d50 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py | |||
| @@ -29,7 +29,9 @@ UNSUPPORTED = 77 # a test tool exits with | |||
| 29 | COMPUTE = [("cs_lds", "4", "mirror64"), ("cs_exec64", "1", "exec64"), ("cs_bvh", "1", "bvh"), | 29 | COMPUTE = [("cs_lds", "4", "mirror64"), ("cs_exec64", "1", "exec64"), ("cs_bvh", "1", "bvh"), |
| 30 | ("cs_workgroup_yz", "2x3x4", "workgroup_yz")] | 30 | ("cs_workgroup_yz", "2x3x4", "workgroup_yz")] |
| 31 | CS_STORE = [0x400080ff, 0xe00003ff, 0x3c004000, 0xeeeeeeee, 0x40003c00, 0xbc003800] | 31 | CS_STORE = [0x400080ff, 0xe00003ff, 0x3c004000, 0xeeeeeeee, 0x40003c00, 0xbc003800] |
| 32 | CS_DUMPS = [("cs_store", CS_STORE), ("cs_wave64_ballot", [32, 16, 24, 40, 8, 48]), | 32 | CS_SMEM = [0x5eed0024, 0x5eed0028, 0x5eed002c, 0x5eed0030, 0x5eed0010, 0x5eed0014, 0x5eed0018, 0x5eed001c] |
| 33 | WAVE32_DUMPS = ("cs_store", "cs_smem_soffset_imm") | ||
| 34 | CS_DUMPS = [("cs_store", CS_STORE), ("cs_smem_soffset_imm", CS_SMEM), ("cs_wave64_ballot", [32, 16, 24, 40, 8, 48]), | ||
| 33 | ("cs_wm_half_ops", [32, 16, 16, 0, 16]), ("cs_wm_half_cmp", [1, 0, 1, 1]), | 35 | ("cs_wm_half_ops", [32, 16, 16, 0, 16]), ("cs_wm_half_cmp", [1, 0, 1, 1]), |
| 34 | ("cs_wm_bfm64", [16, 8, 8, 40]), ("cs_wm_scc_rfl", [55, 48])] | 36 | ("cs_wm_bfm64", [16, 8, 8, 40]), ("cs_wm_scc_rfl", [55, 48])] |
| 35 | # Cross-half wave64 tests (x = cross-half): exact results need 64 lanes, or an emulation of them on narrower subgroups. | 37 | # Cross-half wave64 tests (x = cross-half): exact results need 64 lanes, or an emulation of them on narrower subgroups. |
| @@ -229,7 +231,7 @@ def main(): | |||
| 229 | require_wave64=not W64_EMULATED))) | 231 | require_wave64=not W64_EMULATED))) |
| 230 | for name, want in CS_DUMPS: # all but cs_store need a 64-wide subgroup unless wave64 is emulated | 232 | for name, want in CS_DUMPS: # all but cs_store need a 64-wide subgroup unless wave64 is emulated |
| 231 | results.append((name, compute_test(tools, spirv, name, "1", "dump", | 233 | results.append((name, compute_test(tools, spirv, name, "1", "dump", |
| 232 | require_wave64=name != "cs_store" and not W64_EMULATED, | 234 | require_wave64=name not in WAVE32_DUMPS and not W64_EMULATED, |
| 233 | expected_words=want))) | 235 | expected_words=want))) |
| 234 | for name, want in W64X_DUMPS: # without --require-wave64 when LEONIDA_W64_EMULATE=1 | 236 | for name, want in W64X_DUMPS: # without --require-wave64 when LEONIDA_W64_EMULATE=1 |
| 235 | results.append((name, compute_test(tools, spirv, name, "1", "dump", require_wave64=not W64_EMULATED, | 237 | results.append((name, compute_test(tools, spirv, name, "1", "dump", require_wave64=not W64_EMULATED, |
diff --git a/runtime/test/shaders/cs_smem_soffset_imm.asm b/runtime/test/shaders/cs_smem_soffset_imm.asm new file mode 100644 index 000000000..399de1860 --- /dev/null +++ b/runtime/test/shaders/cs_smem_soffset_imm.asm | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | ; SMEM loads that carry a register offset AND an immediate (llvm-mc: "sOFF offset:IMM"): address = base + soffset + imm. | ||
| 2 | ; Measured on an AMD Radeon RX 6800 (gfx1030) by running s_buffer_load_dword/x2/x4/x8 as a raw compute kernel: | ||
| 3 | ; soffset 8 + imm 4 reads the dword at +12. s_load_dword shares the SMEM encoding; applying the rule to it is an inference. | ||
| 4 | ; Thread 0 seeds heap bytes 0x10..0x30 with 0x5eed0000 + byte offset, then loads with s8 = 0x10: | ||
| 5 | ; s_buffer_load_dword s9, s[0:3], s8 offset:0x14 -> byte 0x24 (imm dropped: 0x10, s8 dropped: 0x14) | ||
| 6 | ; s_load_dword s10, s[4:5], s8 offset:0x18 -> byte 0x28 (imm dropped: 0x10, s8 dropped: 0x18) | ||
| 7 | ; s_buffer_load_dwordx2 s[12:13], s[0:3], s8 offset:0x1c -> bytes 0x2c, 0x30 (imm dropped: 0x10, 0x14; s8 dropped: 0x1c, 0x20) | ||
| 8 | ; and writes s9, s10, s12, s13 to out[0..3]; out[4..7] keep the seeds of bytes 0x10..0x1c. | ||
| 9 | ; All offsets are multiples of 4 and inside the buffer, so alignment and num_records play no part. | ||
| 10 | ; Run: vk_compute_test cs_smem_soffset_imm.spv 1 dump -> out[0..7] = 0x5eed0024 0x5eed0028 0x5eed002c 0x5eed0030 | ||
| 11 | ; 0x5eed0010 0x5eed0014 0x5eed0018 0x5eed001c (1592590372 1592590376 1592590380 1592590384 1592590352 1592590356 | ||
| 12 | ; 1592590360 1592590364). Same FSSM header as cs_lds. | ||
| 13 | v_cmpx_eq_u32_e32 0, v0 | ||
| 14 | v_mov_b32 v1, 0x5eed0010 | ||
| 15 | v_mov_b32 v2, 0x10 | ||
| 16 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 17 | v_mov_b32 v1, 0x5eed0014 | ||
| 18 | v_mov_b32 v2, 0x14 | ||
| 19 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 20 | v_mov_b32 v1, 0x5eed0018 | ||
| 21 | v_mov_b32 v2, 0x18 | ||
| 22 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 23 | v_mov_b32 v1, 0x5eed001c | ||
| 24 | v_mov_b32 v2, 0x1c | ||
| 25 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 26 | v_mov_b32 v1, 0x5eed0020 | ||
| 27 | v_mov_b32 v2, 0x20 | ||
| 28 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 29 | v_mov_b32 v1, 0x5eed0024 | ||
| 30 | v_mov_b32 v2, 0x24 | ||
| 31 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 32 | v_mov_b32 v1, 0x5eed0028 | ||
| 33 | v_mov_b32 v2, 0x28 | ||
| 34 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 35 | v_mov_b32 v1, 0x5eed002c | ||
| 36 | v_mov_b32 v2, 0x2c | ||
| 37 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 38 | v_mov_b32 v1, 0x5eed0030 | ||
| 39 | v_mov_b32 v2, 0x30 | ||
| 40 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 41 | s_waitcnt vmcnt(0) | ||
| 42 | s_mov_b32 s4, 0 | ||
| 43 | s_mov_b32 s5, 0 | ||
| 44 | s_mov_b32 s8, 0x10 | ||
| 45 | s_buffer_load_dword s9, s[0:3], s8 offset:0x14 | ||
| 46 | s_load_dword s10, s[4:5], s8 offset:0x18 | ||
| 47 | s_buffer_load_dwordx2 s[12:13], s[0:3], s8 offset:0x1c | ||
| 48 | s_waitcnt lgkmcnt(0) | ||
| 49 | v_mov_b32 v1, s9 | ||
| 50 | v_mov_b32 v2, 0 | ||
| 51 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 52 | v_mov_b32 v1, s10 | ||
| 53 | v_mov_b32 v2, 4 | ||
| 54 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 55 | v_mov_b32 v1, s12 | ||
| 56 | v_mov_b32 v2, 8 | ||
| 57 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 58 | v_mov_b32 v1, s13 | ||
| 59 | v_mov_b32 v2, 12 | ||
| 60 | buffer_store_dword v1, v2, s[0:3], 0 offen | ||
| 61 | s_endpgm | ||