upleb.uk

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

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-23 02:39:02 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-23 02:39:02 +0100
commit1674b1be5225f4be7d80d3a5c3b8f2d906fff5c3 (patch)
tree18581d33d15f5becf1769e51a5f1998d016209f5 /scripts
parent536e98768163b3cee4b7617f4002fc61a4a61b49 (diff)
parent03b09a086592a197db64d91655c6e65c30764d96 (diff)
Merge origin/main into buffer-formats-all-v2
Conflicts: tools/rdna2spirv.py (main's x_round state next to this branch's fmt_enc_fn, and the function types of both: both kept), docs/design.md (main's rows, our Typed buffer loads sentence re-applied), tests/test_shader_checks.py (TOTAL: main's 13 plus cs_fmt_all = 14, and both mock branches kept; 75 tests pass). Main's typed-buffer work that overlaps (aa2988cc: byte size of the format from one table, SHADER-429: DST_SEL=1 on out-of-bounds typed loads) merged without conflict and takes this branch's formats from Gen.FORMATS. Ten tests in test_mutations, test_cmp_class_f64, test_loop_ballot_barrier and test_vcmp16_opsel fail on origin/main itself, with and without this branch. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/audit_shader4_regs.py39
-rw-r--r--scripts/build_llvm_mc.ps131
-rw-r--r--scripts/build_runtime.ps19
-rw-r--r--scripts/check_no_game_data.py118
-rw-r--r--scripts/first_look.ps12
-rw-r--r--scripts/run_gpu_tests.py68
-rw-r--r--scripts/run_wine_tests.py24
-rw-r--r--scripts/shader_stats.py9
8 files changed, 260 insertions, 40 deletions
diff --git a/scripts/audit_shader4_regs.py b/scripts/audit_shader4_regs.py
index b9a39b43a..e8d0d0cfd 100644
--- a/scripts/audit_shader4_regs.py
+++ b/scripts/audit_shader4_regs.py
@@ -25,8 +25,8 @@ from shader_meta import SGPR_RMW # noqa: E402
25 25
26NO_DEST_OPS = ("s_cmp", "s_bitcmp", "v_cmpx", "s_set", "s_rfe", "s_branch", "s_cbranch", 26NO_DEST_OPS = ("s_cmp", "s_bitcmp", "v_cmpx", "s_set", "s_rfe", "s_branch", "s_cbranch",
27 "s_waitcnt", "s_barrier", "s_nop", "s_endpgm", "s_sendmsg", "s_sleep", 27 "s_waitcnt", "s_barrier", "s_nop", "s_endpgm", "s_sendmsg", "s_sleep",
28 "exp", "buffer_store", "global_store", "flat_store", "scratch_store", 28 "exp", "buffer_store", "tbuffer_store", "global_store", "flat_store", "scratch_store",
29 "image_store", "ds_write") 29 "s_store", "s_buffer_store", "image_store", "ds_write")
30WAVE64_RE = re.compile(r"exec_hi|v_mbcnt_hi_u32_b32|_saveexec_b64|_wrexec_b64") 30WAVE64_RE = re.compile(r"exec_hi|v_mbcnt_hi_u32_b32|_saveexec_b64|_wrexec_b64")
31 31
32 32
@@ -142,7 +142,9 @@ def _fmt_s3_arg(a, is_dst=False):
142 if a["r"] == 3 and a.get("n", 1) == 1: 142 if a["r"] == 3 and a.get("n", 1) == 1:
143 return "s3" 143 return "s3"
144 return "sN" 144 return "sN"
145 if k == "vgpr": 145 if k == "slist":
146 return "s3" if 3 in a["r"] else "sN"
147 if k in ("vgpr", "vlist"):
146 return "vN" 148 return "vN"
147 if k == "imm": 149 if k == "imm":
148 v = a["v"] 150 v = a["v"]
@@ -157,6 +159,8 @@ def rbw_registers(insns):
157 s3_patterns = [] 159 s3_patterns = []
158 160
159 def expand_reg(a): 161 def expand_reg(a):
162 if a["k"] in ("vlist", "slist"):
163 return [r for r in a["r"] if isinstance(r, int)]
160 return range(a["r"], a["r"] + a.get("n", 1)) 164 return range(a["r"], a["r"] + a.get("n", 1))
161 165
162 for ins in insns: 166 for ins in insns:
@@ -164,15 +168,26 @@ def rbw_registers(insns):
164 args = ins["args"] 168 args = ins["args"]
165 if not args: 169 if not args:
166 continue 170 continue
167 is_no_dest = op.startswith(NO_DEST_OPS) 171 mods = ins.get("mods", ())
172 is_gf_atomic = op.startswith(("global_atomic_", "flat_atomic_"))
173 is_bi_atomic = op.startswith(("buffer_atomic_", "image_atomic_"))
174 is_no_dest = (
175 op.startswith(NO_DEST_OPS)
176 or (is_gf_atomic and "glc" not in mods)
177 or (is_bi_atomic and "glc" not in mods)
178 )
168 reads_imm_dst = op in SGPR_RMW 179 reads_imm_dst = op in SGPR_RMW
169 # Instructions that read their destination too. 180 # Instructions that read their destination too (buffer/image atomics with glc read and write vdata at args[0];
181 # global/flat atomics with glc write vdst at args[0] and read vaddr/vdata/saddr from args[1:]).
170 dst_also_read = ( 182 dst_also_read = (
171 reads_imm_dst or "fmac" in op or "mac_" in op or op == "v_writelane_b32" 183 reads_imm_dst or "fmac" in op or "mac_" in op or op == "v_writelane_b32"
172 or op == "v_swap_b32" or "_atomic_" in op 184 or op == "v_swap_b32" or (not is_gf_atomic and "_atomic_" in op)
185 )
186 is_dual_dst = op.startswith("v_") and (
187 "_co_" in op or op.startswith(("v_mad_u64_u32", "v_mad_i64_i32", "v_div_scale_f32", "v_div_scale_f64"))
173 ) 188 )
174 # Carry-out forms write the VGPR and scalar mask first, even when they also take a carry-in source. 189 # Carry-out / scale-out forms write the VGPR and scalar mask first, even when they also take a carry-in source.
175 if not is_no_dest and op.startswith("v_") and "_co_" in op and len(args) >= 2: 190 if not is_no_dest and is_dual_dst and len(args) >= 2:
176 dsts = args[:2] 191 dsts = args[:2]
177 srcs = args[2:] 192 srcs = args[2:]
178 elif is_no_dest: 193 elif is_no_dest:
@@ -184,13 +199,13 @@ def rbw_registers(insns):
184 199
185 reads_s3_rbw = False 200 reads_s3_rbw = False
186 for a in srcs: 201 for a in srcs:
187 if a["k"] == "sgpr": 202 if a["k"] in ("sgpr", "slist"):
188 for r in expand_reg(a): 203 for r in expand_reg(a):
189 if r not in written_s: 204 if r not in written_s:
190 rbw_s.add(r) 205 rbw_s.add(r)
191 if r == 3: 206 if r == 3:
192 reads_s3_rbw = True 207 reads_s3_rbw = True
193 elif a["k"] == "vgpr": 208 elif a["k"] in ("vgpr", "vlist"):
194 for r in expand_reg(a): 209 for r in expand_reg(a):
195 if r not in written_v: 210 if r not in written_v:
196 rbw_v.add(r) 211 rbw_v.add(r)
@@ -200,9 +215,9 @@ def rbw_registers(insns):
200 s3_patterns.append(f"{op} {fmt_args}".strip()) 215 s3_patterns.append(f"{op} {fmt_args}".strip())
201 216
202 for a in dsts: 217 for a in dsts:
203 if a["k"] == "sgpr": 218 if a["k"] in ("sgpr", "slist"):
204 written_s.update(expand_reg(a)) 219 written_s.update(expand_reg(a))
205 elif a["k"] == "vgpr": 220 elif a["k"] in ("vgpr", "vlist"):
206 written_v.update(expand_reg(a)) 221 written_v.update(expand_reg(a))
207 222
208 return sorted(rbw_s), sorted(rbw_v), s3_patterns 223 return sorted(rbw_s), sorted(rbw_v), s3_patterns
diff --git a/scripts/build_llvm_mc.ps1 b/scripts/build_llvm_mc.ps1
index 657820154..0e016463e 100644
--- a/scripts/build_llvm_mc.ps1
+++ b/scripts/build_llvm_mc.ps1
@@ -60,6 +60,15 @@ if (-not (Test-Path (Join-Path $src "llvm\CMakeLists.txt"))) {
60 if ($LASTEXITCODE -ne 0) { throw "git sparse-checkout failed." } 60 if ($LASTEXITCODE -ne 0) { throw "git sparse-checkout failed." }
61} 61}
62 62
63# -Keep (or an interrupted build) can leave sources from another -Version.
64# Refuse that checkout rather than silently rebuilding the wrong release or resetting user files.
65$versionError = "Cannot reuse '$src' for LLVM $Version. Choose a fresh -Temp directory for this version; existing files were kept."
66if (-not (Test-Path -LiteralPath (Join-Path $src '.git'))) { throw $versionError }
67$wantedCommit = & git -C $src rev-parse --verify --quiet "refs/tags/llvmorg-$Version^{commit}"
68if ($LASTEXITCODE -ne 0 -or -not $wantedCommit) { throw $versionError }
69$sourceCommit = & git -C $src rev-parse --verify --quiet HEAD
70if ($LASTEXITCODE -ne 0 -or $sourceCommit -ne $wantedCommit) { throw $versionError }
71
63# DIA SDK off: its headers need ATL, which the C++ build tools don't always include, and llvm-mc doesn't use it. 72# DIA SDK off: its headers need ATL, which the C++ build tools don't always include, and llvm-mc doesn't use it.
64$body = @" 73$body = @"
65"$cmake" -S "$src\llvm" -B "$out" -G Ninja "-DCMAKE_MAKE_PROGRAM=$ninja" -DCMAKE_BUILD_TYPE=Release ^ 74"$cmake" -S "$src\llvm" -B "$out" -G Ninja "-DCMAKE_MAKE_PROGRAM=$ninja" -DCMAKE_BUILD_TYPE=Release ^
@@ -70,9 +79,24 @@ $body = @"
70"@ 79"@
71New-Item -ItemType Directory -Force $out | Out-Null 80New-Item -ItemType Directory -Force $out | Out-Null
72# A .cmd file avoids cmd.exe's quote stripping on paths with spaces. 81# A .cmd file avoids cmd.exe's quote stripping on paths with spaces.
73# Switch cmd.exe to UTF-8 before it reads the paths in the batch file. 82# Switch cmd.exe to UTF-8 before reading paths, then restore the shared console even if the build fails.
74$bat = Join-Path $Temp "_build.cmd" 83$bat = Join-Path $Temp "_build.cmd"
75$batchText = "@echo off`r`nchcp 65001 >nul`r`nset `"PATH=$installer;%PATH%`"`r`ncall `"$vcvars`" >nul || exit /b 1`r`n$body`r`n" 84$batchText = @(
85 '@echo off'
86 'setlocal'
87 'set "_leonida_cp="'
88 'for /f "tokens=2 delims=:." %%c in (''chcp'') do set "_leonida_cp=%%c"'
89 'chcp 65001 >nul'
90 'call :build'
91 'set "_leonida_exit=%errorlevel%"'
92 'if defined _leonida_cp chcp %_leonida_cp% >nul'
93 'exit /b %_leonida_exit%'
94 ':build'
95 "set `"PATH=$installer;%PATH%`""
96 "call `"$vcvars`" >nul || exit /b 1"
97 $body
98 ''
99) -join "`r`n"
76[System.IO.File]::WriteAllText($bat, $batchText, [System.Text.UTF8Encoding]::new($false)) 100[System.IO.File]::WriteAllText($bat, $batchText, [System.Text.UTF8Encoding]::new($false))
77 101
78$p = Start-Process cmd.exe -ArgumentList "/c", "`"$bat`"" -NoNewWindow -PassThru 102$p = Start-Process cmd.exe -ArgumentList "/c", "`"$bat`"" -NoNewWindow -PassThru
@@ -90,7 +114,8 @@ $probe = & $exe --disassemble -triple=amdgcn -mcpu=gfx1013 $probeFile
90if ($LASTEXITCODE -ne 0 -or -not ($probe -match "s_endpgm")) { throw "the built llvm-mc didn't disassemble an s_endpgm" } 114if ($LASTEXITCODE -ne 0 -or -not ($probe -match "s_endpgm")) { throw "the built llvm-mc didn't disassemble an s_endpgm" }
91 115
92New-Item -ItemType Directory -Force $Dest | Out-Null 116New-Item -ItemType Directory -Force $Dest | Out-Null
93$final = Join-Path $Dest "llvm-mc.exe" 117# LLVM_MC is saved for future terminals, whose working directory can differ from this one.
118$final = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $Dest "llvm-mc.exe"))
94Copy-Item -Force $exe $final 119Copy-Item -Force $exe $final
95if (-not $Keep) { 120if (-not $Keep) {
96 try { 121 try {
diff --git a/scripts/build_runtime.ps1 b/scripts/build_runtime.ps1
index abc8c3f05..46dc10291 100644
--- a/scripts/build_runtime.ps1
+++ b/scripts/build_runtime.ps1
@@ -1,8 +1,12 @@
1# Builds runtime\build\gta6rt.exe with MSVC at BelowNormal priority, on half the cores. 1# Builds runtime\build\gta6rt.exe with MSVC at BelowNormal priority, on half the cores by default.
2# Uses VS's CMake + Ninja when the "C++ CMake tools" component is installed, otherwise calls cl.exe directly. 2# Uses VS's CMake + Ninja when the "C++ CMake tools" component is installed, otherwise calls cl.exe directly.
3# The GameInput controller shim (SDL3, docs/gameinput.md) is built only on the CMake path: with an installed SDL3, or 3# The GameInput controller shim (SDL3, docs/gameinput.md) is built only on the CMake path: with an installed SDL3, or
4# with -FetchSdl3, which lets CMake download the pinned SDL3 release. The cl.exe fallback never builds it. 4# with -FetchSdl3, which lets CMake download the pinned SDL3 release. The cl.exe fallback never builds it.
5param([switch]$Debug, [switch]$FetchSdl3) 5param(
6 [switch]$Debug,
7 [switch]$FetchSdl3,
8 [ValidateRange(1, 2147483647)][int]$jobs = [Math]::Max(1, [int]([Environment]::ProcessorCount / 2))
9)
6$ErrorActionPreference = "Stop" 10$ErrorActionPreference = "Stop"
7 11
8$root = Split-Path $PSScriptRoot -Parent 12$root = Split-Path $PSScriptRoot -Parent
@@ -10,7 +14,6 @@ $installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
10$vs = & "$installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath 14$vs = & "$installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
11if (-not $vs) { throw "Visual Studio with the C++ x64 tools wasn't found." } 15if (-not $vs) { throw "Visual Studio with the C++ x64 tools wasn't found." }
12$vcvars = Join-Path $vs "VC\Auxiliary\Build\vcvars64.bat" 16$vcvars = Join-Path $vs "VC\Auxiliary\Build\vcvars64.bat"
13$jobs = [Math]::Max(1, [int]([Environment]::ProcessorCount / 2))
14 17
15$src = Join-Path $root "runtime" 18$src = Join-Path $root "runtime"
16$out = Join-Path $src "build" 19$out = Join-Path $src "build"
diff --git a/scripts/check_no_game_data.py b/scripts/check_no_game_data.py
new file mode 100644
index 000000000..0cf71cee9
--- /dev/null
+++ b/scripts/check_no_game_data.py
@@ -0,0 +1,118 @@
1"""Fail when a tracked file starts like game data, whatever its name.
2
3 python3 -I scripts/check_no_game_data.py # every file `git ls-files` lists
4 python3 -I scripts/check_no_game_data.py PATH... # only these files
5
6The extension check in .github/workflows/no-game-data.yml misses a renamed file: a DDS saved as .bin, an executable
7as .txt. This reads the first bytes of each file and matches the magic numbers of the package's formats and the
8files the build extracts from it: RPF9 archives, TTPF texture pools, RAGE resources, XBCH/FSSM/DXBC shader
9containers, SPIR-V, DDS, AWC audio, Ogg, RIFF WAVE, Bink, glTF binaries, PE executables and XVD images. The magics are
10the ones docs/ measures (docs/gamedata.md and the shader and audio notes). Text formats (disassembly, .obj, .spvasm)
11have no magic and stay with the extension check.
12
13Prints one line per match, `<path>: <format>`, and exits 1 if there is any. Standard library only, no game files.
14"""
15import os
16import subprocess
17import sys
18
19HEAD = 0x208 # enough for the XVD magic at 0x200
20
21# (format, offset, magic). Matched at the start of the file only, so the same bytes inside text don't count.
22MAGICS = (
23 ("RPF9 archive", 0, b"9FPR"),
24 ("RPF9 archive", 0, b"RPF9"),
25 ("TTPF texture pool", 0, b"TTPF"),
26 ("RAGE resource", 0, b"RSC7"),
27 ("RAGE resource", 0, b"RSC8"),
28 ("RAGE resource", 0, b"RSCC"),
29 ("RAGE page directory", 0, b"0DRP"),
30 ("RBF0 tree", 0, b"RBF0"),
31 ("XBCH shader container", 0, b"XBCH"),
32 ("FSSM shader", 0, b"FSSM"),
33 ("DXBC container", 0, b"DXBC"),
34 ("SPIR-V module", 0, b"\x03\x02\x23\x07"),
35 ("SPIR-V module", 0, b"\x07\x23\x02\x03"),
36 ("DDS texture", 0, b"DDS "),
37 ("AWC audio bank", 0, b"ADAT"),
38 ("AWC audio bank", 0, b"TADA"),
39 ("Ogg stream", 0, b"OggS"),
40 ("Bink 2 video", 0, b"KB2"),
41 ("Bink video", 0, b"BIK"),
42 ("glTF binary", 0, b"glTF"),
43 ("XVD image", 0x200, b"msft-xvd"),
44)
45
46
47def is_pe(head):
48 """MZ header whose e_lfanew points at a PE signature inside the bytes read."""
49 if not head.startswith(b"MZ") or len(head) < 0x40:
50 return False
51 offset = int.from_bytes(head[0x3C:0x40], "little")
52 return head[offset:offset + 4] == b"PE\0\0"
53
54
55def classify(head):
56 """The format `head` (the first bytes of a file) starts like, or None."""
57 for name, offset, magic in MAGICS:
58 if head[offset:offset + len(magic)] == magic:
59 return name
60 if head.startswith(b"RIFF") and head[8:12] == b"WAVE":
61 return "RIFF WAVE audio"
62 if is_pe(head):
63 return "PE executable"
64 return None
65
66
67def read_head(path):
68 with open(path, "rb") as f:
69 head = f.read(HEAD)
70 if head.startswith(b"MZ") and len(head) >= 0x40:
71 offset = int.from_bytes(head[0x3C:0x40], "little")
72 if HEAD <= offset < 1 << 20: # the PE signature sits past the first bytes read
73 f.seek(offset)
74 head += b"\0" * (offset - len(head)) + f.read(4)
75 return head
76
77
78def tracked_files(root):
79 out = subprocess.run(["git", "ls-files", "-z"], cwd=root, check=True, capture_output=True).stdout
80 return [os.path.join(root, p) for p in out.decode("utf-8", "surrogateescape").split("\0") if p]
81
82
83def check(paths):
84 """[(path, format)] for every regular file in `paths` that starts like game data."""
85 found = []
86 for path in paths:
87 if os.path.islink(path) or not os.path.isfile(path):
88 continue # submodules, symlinks, files deleted in the working tree
89 name = classify(read_head(path))
90 if name:
91 found.append((path, name))
92 return found
93
94
95def display(path):
96 try:
97 return os.path.relpath(path)
98 except ValueError: # Windows: another drive than the working directory
99 return path
100
101
102def main(argv):
103 paths = argv or tracked_files(os.getcwd())
104 found = check(paths)
105 for path, name in found:
106 print(f"{display(path)}: {name}")
107 if found:
108 print(f"{len(found)} file(s) start like game data. Remove them; see CONTRIBUTING.md.", file=sys.stderr)
109 return 1
110 return 0
111
112
113if __name__ == "__main__":
114 try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
115 sys.stdout.reconfigure(errors="replace")
116 except (AttributeError, ValueError, OSError):
117 pass
118 sys.exit(main(sys.argv[1:]))
diff --git a/scripts/first_look.ps1 b/scripts/first_look.ps1
index 5871cbc67..79ec0ed8d 100644
--- a/scripts/first_look.ps1
+++ b/scripts/first_look.ps1
@@ -39,7 +39,7 @@ $dryRunExitCode = $LASTEXITCODE
39$report = Get-Content (Join-Path $out "$([IO.Path]::GetFileName($Exe)).json") -Raw | ConvertFrom-Json 39$report = Get-Content (Join-Path $out "$([IO.Path]::GetFileName($Exe)).json") -Raw | ConvertFrom-Json
40$todo = $report.imports | Where-Object { $_.where -eq "shim" } | Sort-Object { -$_.functions.Count } 40$todo = $report.imports | Where-Object { $_.where -eq "shim" } | Sort-Object { -$_.functions.Count }
41$lines = foreach ($t in $todo) { "{0,-40} {1,5}" -f $t.dll, $t.functions.Count } 41$lines = foreach ($t in $todo) { "{0,-40} {1,5}" -f $t.dll, $t.functions.Count }
42$lines | Set-Content (Join-Path $out "shim-todo.txt") 42Set-Content -LiteralPath (Join-Path $out "shim-todo.txt") -Value $lines
43Write-Host "`n== Shim to-do (DLL, function count)" 43Write-Host "`n== Shim to-do (DLL, function count)"
44$lines 44$lines
45$enc = $report.sections | Where-Object { $_.looks_encrypted } | ForEach-Object { $_.name } 45$enc = $report.sections | Where-Object { $_.looks_encrypted } | ForEach-Object { $_.name }
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 7cd0e9dbf..94de20f26 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -25,13 +25,15 @@ sys.path.insert(0, os.path.join(ROOT, "tools"))
25import mc_command # noqa: E402 25import mc_command # noqa: E402
26sys.path.insert(0, SHADER_DIR) 26sys.path.insert(0, SHADER_DIR)
27from build import CLIP_CASES, clip_container, shader_source 27from build import CLIP_CASES, clip_container, shader_source
28from check import Skip, clip_test, fmt_1010102_test, fmt_int_narrow_test, fmt_sint32_test, fmt_xy_xyz_test, tbuffer_store_test 28from check import (Skip, clip_test, fmt_1010102_test, fmt_d16_xyz_test, fmt_int_narrow_test, fmt_sint32_test,
29 fmt_xy_xyz_test, tbuffer_store_test)
29from compute_fixture import compute_header 30from compute_fixture import compute_header
30from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test) 31from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test)
31from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES, 32from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES,
32 TEXTURE_MIP_TEST, GATHER_LOD_TEST, MIP_TEST_PASSES, TEXTURE_CONSTANTS, USER_SGPRS_ENV, USER_SGPRS_WORDS, Skip, mesh_v5_test, not_found_message, 33 TEXTURE_MIP_TEST, GATHER_LOD_TEST, MIP_TEST_PASSES, TEXTURE_CONSTANTS, USER_SGPRS_ENV, USER_SGPRS_WORDS, Skip, mesh_v5_test, not_found_message,
33 pick_build_dir, start_failure, texture_gradient_a16_test, texture_mip_test) 34 pick_build_dir, start_failure, texture_gradient_a16_test, texture_mip_test)
34from check import SIGNED_MIP_TEST 35from check import SIGNED_MIP_TEST
36from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT
35from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan) 37from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan)
36from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py 38from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py
37from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8 39from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8
@@ -40,8 +42,10 @@ from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shader
40from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip, 42from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip,
41 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py 43 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py
42from check import PIXEL_VERTEX, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks 44from check import PIXEL_VERTEX, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks
45from check import barycentric_problem
43from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries 46from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries
44from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide 47from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide
48from check import FMA_FUSED_ENV, judge_fma_fused # cs_fma_fused: strict under LEONIDA_FMA=khr, fused/split under glsl
45 49
46 50
47def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes: 51def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes:
@@ -370,17 +374,8 @@ def frame_problem(px) -> str:
370 374
371 375
372def check_bary(raw_path: str) -> tuple[bool, str]: 376def check_bary(raw_path: str) -> tuple[bool, str]:
373 px = read_raw_rgba32f(raw_path) 377 problem = barycentric_problem(read_raw_rgba32f(raw_path), 1e-4)
374 if problem := frame_problem(px): 378 return not problem, problem or "4096/4096 pixels match"
375 return False, problem
376 bad = 0
377 first = ""
378 for i, (ax, ay, bi, bj) in enumerate(px):
379 if abs(ax * 0.5 - bi) > 1e-4 or abs(ay * 0.5 - bj) > 1e-4:
380 if not bad:
381 first = f"at ({i%64},{i//64}): attr/2=({ax*0.5:.5f},{ay*0.5:.5f}) raw=({bi:.5f},{bj:.5f})"
382 bad += 1
383 return (bad == 0), (first if bad else "4096/4096 pixels exact")
384 379
385 380
386def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]: 381def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]:
@@ -420,7 +415,14 @@ PIXEL_ENV = {"ps_vcc_x2": {"VKH_SGPRS": "0x1000,0,16,0", "VKH_HEAP": "0x1000=0x1
420 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000," 415 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000,"
421 "0x100c=0x7fc10001,0x1010=0x40600000,0x1014=0xc0200000"}, 416 "0x100c=0x7fc10001,0x1010=0x40600000,0x1014=0xc0200000"},
422 "ps_fnan_fract": {"VKH_SGPRS": "0x1000,0,16,0", 417 "ps_fnan_fract": {"VKH_SGPRS": "0x1000,0,16,0",
423 "VKH_HEAP": "0x1000=0xaedbe6ff,0x1004=0x00008800,0x1008=0x7fc10001,0x100c=0xc0200000"}} 418 "VKH_HEAP": "0x1000=0xaedbe6ff,0x1004=0x00008800,0x1008=0x7fc10001,0x100c=0xc0200000"},
419 # f32 VOPC with a NaN, 64-bit integer VOPC: inputs from memory (derivations in the .asm headers)
420 "ps_vcmp_f32_nan": {"VKH_SGPRS": "0x1000,0,16,0",
421 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x3f800000,0x1008=0x40000000"},
422 "ps_vcmp_64": {"VKH_SGPRS": "0x1000,0,64,0",
423 "VKH_HEAP": "0x1000=0x80000000,0x1004=0,0x1008=1,0x100c=0,0x1010=0xffffffff,"
424 "0x1014=0xffffffff,0x1018=1,0x101c=0,0x1020=1,0x1024=0,0x1028=0x80000000,"
425 "0x102c=0,0x1030=7,0x1034=5,0x1038=7,0x103c=5"}}
424 426
425 427
426def check_flat(raw_path: str) -> tuple[bool, str]: 428def check_flat(raw_path: str) -> tuple[bool, str]:
@@ -879,6 +881,10 @@ def run_suite(a, work: str) -> int:
879 elif name == "cs_tbuffer_store": 881 elif name == "cs_tbuffer_store":
880 # tbuffer_store_format_*: the instruction's format, words measured natively on a Radeon 680M (the .asm header) 882 # tbuffer_store_format_*: the instruction's format, words measured natively on a Radeon 680M (the .asm header)
881 problem = tbuffer_store_test(a.build, spirv_dir, cs_env) 883 problem = tbuffer_store_test(a.build, spirv_dir, cs_env)
884 elif name == "cs_fmt_d16_xyz":
885 # d16_xyz / d16_xy typed-buffer loads and d16_xyz stores (cs_fmt_d16_xyz.asm header)
886 problem = fmt_d16_xyz_test(a.build, spirv_dir, cs_env)
887 results.append((name, not problem, problem or "80/80 dumped words exact"))
882 results.append((name, not problem, problem or "128/128 dumped words exact")) 888 results.append((name, not problem, problem or "128/128 dumped words exact"))
883 elif name == "cs_global_neg_offset": 889 elif name == "cs_global_neg_offset":
884 # Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups give a 0x2800-byte 890 # Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups give a 0x2800-byte
@@ -887,6 +893,13 @@ def run_suite(a, work: str) -> int:
887 want = [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 0x9E, 0xFFFF8BAD, 0x57023FFC, 0xEEEEEEEE] 893 want = [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 0x9E, 0xFFFF8BAD, 0x57023FFC, 0xEEEEEEEE]
888 ok, detail = judge_cs_dump(rc, msg, want, wave64=False, partial=False, emulated=False, hexwords=True) 894 ok, detail = judge_cs_dump(rc, msg, want, wave64=False, partial=False, emulated=False, hexwords=True)
889 results.append((name, ok, detail)) 895 results.append((name, ok, detail))
896 elif name == "cs_heap_init":
897 # vk_compute_test copies VKC_HEAP_INIT's file into the heap; the shader copies its words at 0x100 to 0.
898 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **heap_init_env()))
899 words = dump_words(msg)
900 vals = words[:len(HEAP_INIT_EXPECTED)] if words else []
901 results.append((name, rc == 0 and vals == HEAP_INIT_EXPECTED,
902 " ".join(hex(x) for x in vals) if vals else msg))
890 elif name == "cs_user_sgprs": 903 elif name == "cs_user_sgprs":
891 # vk_compute_test seeds s4..s7 from VKC_SGPRS; the shader stores them back. 904 # vk_compute_test seeds s4..s7 from VKC_SGPRS; the shader stores them back.
892 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **USER_SGPRS_ENV)) 905 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **USER_SGPRS_ENV))
@@ -915,11 +928,23 @@ def run_suite(a, work: str) -> int:
915 n = len(CVT_F32_SAT_CASES) 928 n = len(CVT_F32_SAT_CASES)
916 results.append((name, not wrong, f"{n}/{n} inputs exact" if not wrong 929 results.append((name, not wrong, f"{n}/{n} inputs exact" if not wrong
917 else f"{len(wrong)}/{n} inputs wrong, first {wrong[0]}")) 930 else f"{len(wrong)}/{n} inputs wrong, first {wrong[0]}"))
931 elif name == "cs_fma_fused":
932 # Single-rounded f32 FMA (+ f16 round-to-odd): strict under LEONIDA_FMA=khr (OpFmaKHR, exit 77 if
933 # unsupported), fused-or-split f32 allowed under default --fma glsl (e.g. Mesa RADV splits 5/7).
934 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **FMA_FUSED_ENV))
935 if rc == UNSUPPORTED:
936 results.append((name, None, unsupported_skip(msg)))
937 elif rc != 0:
938 results.append((name, False, msg))
939 else:
940 khr = os.environ.get("LEONIDA_FMA") == "khr"
941 ok, detail = judge_fma_fused(dump_words(msg), khr=khr)
942 results.append((name, ok, detail))
918 elif name == "cs_wavemask": 943 elif name == "cs_wavemask":
919 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 944 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
920 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 945 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
921 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 946 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
922 elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", 947 elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half",
923 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 948 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
924 "cs_dpp_bound", "cs_dpp_w64", 949 "cs_dpp_bound", "cs_dpp_w64",
925 "cs_w64_mask_detect", 950 "cs_w64_mask_detect",
@@ -928,7 +953,7 @@ def run_suite(a, work: str) -> int:
928 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 953 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
929 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", 954 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
930 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", 955 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end",
931 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst", 956 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst", "cs_w32_andn2_exec",
932 "cs_mask_vgpr_exec"): 957 "cs_mask_vgpr_exec"):
933 cs_dump_wants = { 958 cs_dump_wants = {
934 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], 959 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000],
@@ -951,6 +976,9 @@ def run_suite(a, work: str) -> int:
951 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], 976 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE],
952 # SHADER-85: ds_read_u8/i8_d16[_hi] (cs_w32_lds_u8_d16.asm header) 977 # SHADER-85: ds_read_u8/i8_d16[_hi] (cs_w32_lds_u8_d16.asm header)
953 "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234], 978 "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234],
979 # 8/16-bit and 64/96/128-bit LDS accesses (cs_w32_lds_subdword.asm / cs_w32_lds_wide.asm headers)
980 "cs_w32_lds_subdword": [0x11B2D444, 0xA1B2C3D4, 0xFFFFFFB2, 0x000000B2, 0x00000011, 0xFFFFA1B2, 0x0000A1B2, 0xFFFFC3D4],
981 "cs_w32_lds_wide": [0xCAFEF00D, 0xFEEDFACE, 0x600DD00D, 0x00000000, 0x8BADF00D, 0xDEADC0DE, 0x12345678, 0x9ABCDEF0],
954 # ds_cmpst_b32 and the b64 2-address forms (cs_lds_b64_cmpst.asm header) 982 # ds_cmpst_b32 and the b64 2-address forms (cs_lds_b64_cmpst.asm header)
955 "cs_lds_b64_cmpst": [0x11110001, 0x22220002, 0x33330003, 0x44440004, 983 "cs_lds_b64_cmpst": [0x11110001, 0x22220002, 0x33330003, 0x44440004,
956 0xCCCC000C, 0x44440004, 0xBBBB000B, 0x3579BADC], 984 0xCCCC000C, 0x44440004, 0xBBBB000B, 0x3579BADC],
@@ -997,6 +1025,7 @@ def run_suite(a, work: str) -> int:
997 "cs_w64x_partial": [40, 40, 528, 0, 0, 532, 539, 524820], 1025 "cs_w64x_partial": [40, 40, 528, 0, 0, 532, 539, 524820],
998 "cs_w64x_partial_scmp": [0, 1, 0, 1, 1, 1, 1, 0], # s_cmp mask, -1 in a partial wave 1026 "cs_w64x_partial_scmp": [0, 1, 0, 1, 1, 1, 1, 0], # s_cmp mask, -1 in a partial wave
999 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32 1027 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32
1028 "cs_w32_andn2_exec": [1, 8, 16, 2064, 2068, 3, 20, 1544], # s_andn2_saveexec/wrexec_b32 (.asm header)
1000 "cs_w32_sincos": [1, 1, 1, 1, 1, 1], # SHADER-88 (cs_w32_sincos.asm): angles in turns 1029 "cs_w32_sincos": [1, 1, 1, 1, 1, 1], # SHADER-88 (cs_w32_sincos.asm): angles in turns
1001 "cs_w64x_sbarrier": [605, 605, 686, 686, 3032, 3013, 3032, 3031], 1030 "cs_w64x_sbarrier": [605, 605, 686, 686, 3032, 3013, 3032, 3031],
1002 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32], 1031 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32],
@@ -1028,10 +1057,11 @@ def run_suite(a, work: str) -> int:
1028 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 1057 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
1029 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 1058 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
1030 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 1059 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
1060 "cs_w32_lds_subdword", "cs_w32_lds_wide",
1031 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", 1061 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos",
1032 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", 1062 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
1033 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1063 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
1034 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial 1064 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial
1035 if partial and not emulated: 1065 if partial and not emulated:
1036 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") 1066 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64")
1037 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774) 1067 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774)
@@ -1048,6 +1078,7 @@ def run_suite(a, work: str) -> int:
1048 want = judged_words(name, msg, want) # cs_signed_zero_nan on Apple and llvmpipe (check.py) 1078 want = judged_words(name, msg, want) # cs_signed_zero_nan on Apple and llvmpipe (check.py)
1049 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated, 1079 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated,
1050 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16", 1080 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16",
1081 "cs_w32_lds_subdword", "cs_w32_lds_wide",
1051 "cs_lds_b64_cmpst", "cs_signed_zero_nan")) 1082 "cs_lds_b64_cmpst", "cs_signed_zero_nan"))
1052 if ok and None in want: 1083 if ok and None in want:
1053 unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None) 1084 unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None)
@@ -1166,6 +1197,8 @@ def run_suite(a, work: str) -> int:
1166 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000), 1197 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000),
1167 "ps_sdwa_dword_hi": (0x00004000, 0x00000003, 0x00004700, 0x0000C000), # 16-bit SDWA, dst_sel:DWORD 1198 "ps_sdwa_dword_hi": (0x00004000, 0x00000003, 0x00004700, 0x0000C000), # 16-bit SDWA, dst_sel:DWORD
1168 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py 1199 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py
1200 "ps_mul_legacy_denorm": (0, 0, 0, 0x80000000), # mode0 input FTZ + DX9 +0 override; output FTZ keeps sign
1201 "ps_mul_legacy_denorm_mods": (0, 0, 0, 0x40400000), # product FTZ before omod; omod -0 -> +0
1169 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers 1202 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers
1170 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0), 1203 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0),
1171 "ps_ops7": (0x00FF8077, 0xFF0000FF, 0x89ABCDEF, 0x00070003), 1204 "ps_ops7": (0x00FF8077, 0xFF0000FF, 0x89ABCDEF, 0x00070003),
@@ -1179,6 +1212,7 @@ def run_suite(a, work: str) -> int:
1179 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16), 1212 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16),
1180 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000), 1213 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000),
1181 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64 1214 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64
1215 "ps_f64_round": (0xC12AF665, 0x3FE7FFFF, 0xBFFFFFFF, 0xC12AF666), # needs shaderFloat64
1182 "ps_outmods_f16": (0xAAAA3C00, 0xAAAA3E00, 0x7C000000, 0x3C000000), 1216 "ps_outmods_f16": (0xAAAA3C00, 0xAAAA3E00, 0x7C000000, 0x3C000000),
1183 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers) 1217 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers)
1184 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555), 1218 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555),
@@ -1209,6 +1243,8 @@ def run_suite(a, work: str) -> int:
1209 # v_mad_u32_u16 / v_mad_i32_i16 and v_subrev_f16, which had CPU checks only (.asm headers) 1243 # v_mad_u32_u16 / v_mad_i32_i16 and v_subrev_f16, which had CPU checks only (.asm headers)
1210 "ps_valu16_mad": (0x00000002, 0x00030002, 0x00008000, 0x00000004), 1244 "ps_valu16_mad": (0x00000002, 0x00030002, 0x00008000, 0x00000004),
1211 "ps_valu16_subrev": (0xAAAABC00, 0xAAAAC000, 0xAAAA3C00, 0x42003800), 1245 "ps_valu16_subrev": (0xAAAABC00, 0xAAAAC000, 0xAAAA3C00, 0x42003800),
1246 "ps_vcmp_f32_nan": (0x0000376C, 0x0000FD5B, 0x0000D36C, 0x00000FE7), # from the .asm headers
1247 "ps_vcmp_64": (0x0000B3C4, 0x000091E6, 0x00006787, 0x00007C93),
1212 "ps_w64x_readlane": (0x40000079, 0x40000010, 0x40000064, 0x400000BE), # same expectation as check.py 1248 "ps_w64x_readlane": (0x40000079, 0x40000010, 0x40000064, 0x400000BE), # same expectation as check.py
1213 } 1249 }
1214 if skip := wide_pixel_skip(name, msg): # a 64-wide pixel stage the device could not give: nothing to judge 1250 if skip := wide_pixel_skip(name, msg): # a 64-wide pixel stage the device could not give: nothing to judge
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index 9154dea48..3e90e9ab4 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -14,10 +14,12 @@ runtime/build/generated). For those, the drive of --windows-root is pointed at -
14 14
15Every test is run and reported. The exit code is 1 if a test named by --require fails or is missing, else 0: the 15Every test is run and reported. The exit code is 1 if a test named by --require fails or is missing, else 0: the
16others show what does and doesn't work under Wine yet without failing the job. 16others show what does and doesn't work under Wine yet without failing the job.
17--timeout caps each process; a shorter positive CTest TIMEOUT takes precedence for that test.
17""" 18"""
18import argparse 19import argparse
19import json 20import json
20import math 21import math
22import ntpath
21import os 23import os
22import re 24import re
23import shlex 25import shlex
@@ -38,7 +40,7 @@ def _make_parent(path: str) -> None:
38 40
39 41
40def norm(path: str) -> str: 42def norm(path: str) -> str:
41 return path.replace("\\", "/").rstrip("/") 43 return ntpath.normpath(path).replace("\\", "/").rstrip("/")
42 44
43 45
44def map_path(arg: str, windows_root: str, root: str) -> str | None: 46def map_path(arg: str, windows_root: str, root: str) -> str | None:
@@ -149,13 +151,23 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
149 if not key or not equals or "\0" in assignment: 151 if not key or not equals or "\0" in assignment:
150 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value" 152 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value"
151 env[key] = value 153 env[key] = value
154 timeout = args.timeout
155 if "TIMEOUT" in props:
156 try:
157 ctest_timeout = float(props["TIMEOUT"])
158 except (TypeError, ValueError):
159 return "fail", "invalid CTest TIMEOUT"
160 if not math.isfinite(ctest_timeout) or ctest_timeout < 0:
161 return "fail", "invalid CTest TIMEOUT"
162 if ctest_timeout > 0:
163 timeout = min(timeout, ctest_timeout)
152 start = time.monotonic() 164 start = time.monotonic()
153 try: 165 try:
154 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 166 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
155 timeout=args.timeout) 167 timeout=timeout)
156 except subprocess.TimeoutExpired as e: 168 except subprocess.TimeoutExpired as e:
157 out = (e.stdout or b"").decode("utf-8", "replace") 169 out = (e.stdout or b"").decode("utf-8", "replace")
158 return "fail", f"timed out after {args.timeout} s\n{out}" 170 return "fail", f"timed out after {timeout} s\n{out}"
159 except OSError as e: # a mistyped --wine, or a missing one: report the test, do not abort the run 171 except OSError as e: # a mistyped --wine, or a missing one: report the test, do not abort the run
160 return "fail", f"could not start {argv[0]}: {e.strerror or e}" 172 return "fail", f"could not start {argv[0]}: {e.strerror or e}"
161 elapsed = time.monotonic() - start 173 elapsed = time.monotonic() - start
@@ -169,10 +181,13 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
169 if skip_code is not None and code == int(skip_code): 181 if skip_code is not None and code == int(skip_code):
170 return "skip", f"exit {code} (skip) in {elapsed:.1f} s\n{out}" 182 return "skip", f"exit {code} (skip) in {elapsed:.1f} s\n{out}"
171 detail = f"exit {code} in {elapsed:.1f} s\n{out}" 183 detail = f"exit {code} in {elapsed:.1f} s\n{out}"
184 skip_patterns = regex_list(props.get("SKIP_REGULAR_EXPRESSION", []))
172 required = regex_list(props.get("PASS_REGULAR_EXPRESSION", [])) 185 required = regex_list(props.get("PASS_REGULAR_EXPRESSION", []))
173 forbidden = regex_list(props.get("FAIL_REGULAR_EXPRESSION", [])) 186 forbidden = regex_list(props.get("FAIL_REGULAR_EXPRESSION", []))
174 # A required match takes the place of the exit code. A forbidden match overrides either kind of success. 187 # A required match takes the place of the exit code. A forbidden match overrides either kind of success.
175 try: 188 try:
189 if any(re.search(pattern, out, re.DOTALL) for pattern in skip_patterns):
190 return "skip", f"matched CTest SKIP_REGULAR_EXPRESSION: {detail}"
176 passed = any(re.search(pattern, out, re.DOTALL) for pattern in required) if required else code == 0 191 passed = any(re.search(pattern, out, re.DOTALL) for pattern in required) if required else code == 0
177 if any(re.search(pattern, out, re.DOTALL) for pattern in forbidden): 192 if any(re.search(pattern, out, re.DOTALL) for pattern in forbidden):
178 passed = False 193 passed = False
@@ -230,7 +245,8 @@ def main() -> int:
230 ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"), 245 ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"),
231 help="Wine command (default: $WINE or wine)") 246 help="Wine command (default: $WINE or wine)")
232 ap.add_argument("--require", action="append", default=[], help="a test that must pass (repeatable)") 247 ap.add_argument("--require", action="append", default=[], help="a test that must pass (repeatable)")
233 ap.add_argument("--timeout", type=positive_seconds, default=120.0, help="seconds per test (default 120)") 248 ap.add_argument("--timeout", type=positive_seconds, default=120.0,
249 help="maximum seconds per test; a shorter CTest TIMEOUT applies (default 120)")
234 ap.add_argument("--summary", help="append a Markdown table to this file (e.g. $GITHUB_STEP_SUMMARY)") 250 ap.add_argument("--summary", help="append a Markdown table to this file (e.g. $GITHUB_STEP_SUMMARY)")
235 ap.add_argument("--label", help="named in the summary's heading, e.g. the Wine version") 251 ap.add_argument("--label", help="named in the summary's heading, e.g. the Wine version")
236 args = ap.parse_args() 252 args = ap.parse_args()
diff --git a/scripts/shader_stats.py b/scripts/shader_stats.py
index e7c7eb450..d3a18c3ff 100644
--- a/scripts/shader_stats.py
+++ b/scripts/shader_stats.py
@@ -165,7 +165,10 @@ def main():
165 for (name, stage), st in sorted(stats.items()): 165 for (name, stage), st in sorted(stats.items()):
166 src = os.path.join(disasm, name + ".s") 166 src = os.path.join(disasm, name + ".s")
167 if os.path.isfile(src): 167 if os.path.isfile(src):
168 rows.append(shader_row(name, stage, st, src)) 168 try:
169 rows.append(shader_row(name, stage, st, src))
170 except OSError as e:
171 sys.exit(f"{src}: {e.strerror or e}")
169 if not rows: 172 if not rows:
170 sys.exit("no shader is in both the statistics and the disasm folder") 173 sys.exit("no shader is in both the statistics and the disasm folder")
171 if "--details" in sys.argv: 174 if "--details" in sys.argv:
@@ -199,4 +202,8 @@ def main():
199 202
200 203
201if __name__ == "__main__": 204if __name__ == "__main__":
205 try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
206 sys.stdout.reconfigure(errors="replace")
207 except (AttributeError, ValueError, OSError):
208 pass
202 sys.exit(main()) 209 sys.exit(main())