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:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 18:36:19 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 18:36:19 -0500
commit3a2820b3bff812ff3cff6a4d4087912edb0541bb (patch)
treeab2522760b3930781a3531f7ded56ba449041e77 /scripts
parent75f6890bb98214d5112c7eb1126f67f9e2948a0a (diff)
parentc1e1ef0b81234ac46ca25a810ab81219408ea6ba (diff)
Merge main c1e1ef0b8 into RT-POST-LOAD-GPU-MEMORY (#2098)
Two conflicts: - d3d12_com.cpp, note_direct_heap_indexing: main's console_descriptor_table_va(cbv_srv_uav_base_) for the tracked table, with this branch's per-site once() flag instead of note_once on every draw. - d3d12_vulkan_device.cpp, PipelineState::build_compute: this branch's body (build_compute_pipeline, journal, compile helper). main's dev_status::Build around the compute create moves into build_compute_pipeline, next to the pipeline_profile::DriverCall, so the status line still names the compute pipeline in the driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/audit_shader4_regs.py19
-rw-r--r--scripts/first_look.ps110
-rw-r--r--scripts/run_gpu_tests.py15
-rw-r--r--scripts/vs_layout_census.py40
4 files changed, 66 insertions, 18 deletions
diff --git a/scripts/audit_shader4_regs.py b/scripts/audit_shader4_regs.py
index 59aff3bc6..50fc5500e 100644
--- a/scripts/audit_shader4_regs.py
+++ b/scripts/audit_shader4_regs.py
@@ -263,8 +263,8 @@ def detect_wave64(insns):
263 263
264 264
265def audit(disasm_dir, fssm_dir=None, dxbc_dir=None, stages=("cs", "ms", "gs"), limit=None, *, report_path=None): 265def audit(disasm_dir, fssm_dir=None, dxbc_dir=None, stages=("cs", "ms", "gs"), limit=None, *, report_path=None):
266 if limit is not None and limit < 0: 266 if limit is not None and limit < 1:
267 raise ValueError("limit must be non-negative") 267 raise ValueError("limit must be at least 1")
268 parent = os.path.dirname(os.path.realpath(disasm_dir)) 268 parent = os.path.dirname(os.path.realpath(disasm_dir))
269 fssm_dir = fssm_dir or os.path.join(parent, "fssm") 269 fssm_dir = fssm_dir or os.path.join(parent, "fssm")
270 dxbc_dir = dxbc_dir or parent 270 dxbc_dir = dxbc_dir or parent
@@ -395,16 +395,25 @@ def print_report(rep):
395 print(f" {v:6d} {k}") 395 print(f" {v:6d} {k}")
396 396
397 397
398def shader_count(text):
399 """--limit: at least 1; 0 used to mean an audit of nothing that still printed a zero report."""
400 try:
401 value = int(text, 0)
402 except ValueError:
403 raise argparse.ArgumentTypeError("must be at least 1") from None
404 if value < 1:
405 raise argparse.ArgumentTypeError("must be at least 1")
406 return value
407
408
398def main(argv=None): 409def main(argv=None):
399 ap = argparse.ArgumentParser(description="Audit CS/MS/GS RSRC2/PSV0 headers and read-before-write registers.") 410 ap = argparse.ArgumentParser(description="Audit CS/MS/GS RSRC2/PSV0 headers and read-before-write registers.")
400 ap.add_argument("disasm_dir", help="directory of disassembled .s files") 411 ap.add_argument("disasm_dir", help="directory of disassembled .s files")
401 ap.add_argument("--fssm", default=None, help="directory of .fssm files (default: <disasm_dir>/../fssm)") 412 ap.add_argument("--fssm", default=None, help="directory of .fssm files (default: <disasm_dir>/../fssm)")
402 ap.add_argument("--dxbc", default=None, help="directory of .dxbc files (default: <disasm_dir>/..)") 413 ap.add_argument("--dxbc", default=None, help="directory of .dxbc files (default: <disasm_dir>/..)")
403 ap.add_argument("--json", dest="json_out", default=None, help="optional path to write full JSON report") 414 ap.add_argument("--json", dest="json_out", default=None, help="optional path to write full JSON report")
404 ap.add_argument("--limit", type=int, default=None, help="stop after N .s files") 415 ap.add_argument("--limit", type=shader_count, default=None, help="stop after N .s files (at least 1)")
405 a = ap.parse_args(argv) 416 a = ap.parse_args(argv)
406 if a.limit is not None and a.limit < 0:
407 ap.exit(2, f"{ap.prog}: error: --limit must be non-negative\n")
408 # A bad path is one ERROR line, not a traceback out of os.listdir: the audit of a whole corpus can 417 # A bad path is one ERROR line, not a traceback out of os.listdir: the audit of a whole corpus can
409 # run for minutes, and an explicit --fssm/--dxbc that does not exist would otherwise be counted as 418 # run for minutes, and an explicit --fssm/--dxbc that does not exist would otherwise be counted as
410 # "(missing fssm)" and print a report that looks right. 419 # "(missing fssm)" and print a report that looks right.
diff --git a/scripts/first_look.ps1 b/scripts/first_look.ps1
index 6fb7ca36b..f302d5701 100644
--- a/scripts/first_look.ps1
+++ b/scripts/first_look.ps1
@@ -105,9 +105,19 @@ $dryRunExitCode = $LASTEXITCODE
105$report = Get-Content -LiteralPath (Join-Path $out "$([IO.Path]::GetFileName($Exe)).json") -Raw | ConvertFrom-Json 105$report = Get-Content -LiteralPath (Join-Path $out "$([IO.Path]::GetFileName($Exe)).json") -Raw | ConvertFrom-Json
106$todo = $report.imports | Where-Object { $_.where -eq "shim" } | Sort-Object { -$_.functions.Count } 106$todo = $report.imports | Where-Object { $_.where -eq "shim" } | Sort-Object { -$_.functions.Count }
107$lines = foreach ($t in $todo) { "{0,-40} {1,5}" -f $t.dll, $t.functions.Count } 107$lines = foreach ($t in $todo) { "{0,-40} {1,5}" -f $t.dll, $t.functions.Count }
108# "unverified" only comes from a host that isn't Windows and has no Wine prefix (pe_inspect.py, classify_dll): most
109# are system DLLs, but a console DLL the shims don't serve yet is among them, so they follow the list, marked.
110$unverified = @($report.imports | Where-Object { $_.where -eq "unverified" } | Sort-Object { -$_.functions.Count })
111if ($unverified.Count -gt 0) {
112 $lines = @(foreach ($t in $todo) { "{0,-40} {1,5}" -f $t.dll, $t.functions.Count }) +
113 @(foreach ($t in $unverified) { "{0,-40} {1,5} system (unverified)" -f $t.dll, $t.functions.Count })
114}
108Set-Content -LiteralPath (Join-Path $out "shim-todo.txt") -Value $lines 115Set-Content -LiteralPath (Join-Path $out "shim-todo.txt") -Value $lines
109Write-Host "`n== Shim to-do (DLL, function count)" 116Write-Host "`n== Shim to-do (DLL, function count)"
110$lines 117$lines
118if ($unverified.Count -gt 0) {
119 Write-Warning "$($unverified.Count) DLLs could not be checked against system DLLs (no Wine prefix): set WINEPREFIX and run again"
120}
111$enc = $report.sections | Where-Object { $_.looks_encrypted } | ForEach-Object { $_.name } 121$enc = $report.sections | Where-Object { $_.looks_encrypted } | ForEach-Object { $_.name }
112if ($enc) { Write-Warning "High-entropy sections (still encrypted or packed): $($enc -join ', ')" } 122if ($enc) { Write-Warning "High-entropy sections (still encrypted or packed): $($enc -join ', ')" }
113Write-Host "`nReports: $out" 123Write-Host "`nReports: $out"
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index cff55f21d..f87290ec6 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -1211,7 +1211,7 @@ def run_suite(a, work: str) -> int:
1211 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw", 1211 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw",
1212 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 1212 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
1213 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", 1213 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
1214 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_barrier_early_end", 1214 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w64x_partial_swizzle", "cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_barrier_early_end",
1215"cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_w64x_cmp_sdst", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec", 1215"cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_w64x_cmp_sdst", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec",
1216 "cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_exec_computed"): 1216 "cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_exec_computed"):
1217 cs_dump_wants = { 1217 cs_dump_wants = {
@@ -1303,6 +1303,7 @@ def run_suite(a, work: str) -> int:
1303 "cs_w64x_lds_war": [1032, 1063, 1000, 1031, 2032, 2063, 2000, 2031], 1303 "cs_w64x_lds_war": [1032, 1063, 1000, 1031, 2032, 2063, 2000, 2031],
1304 "cs_w64x_partial": [40, 40, 528, 0, 0, 532, 539, 524820], 1304 "cs_w64x_partial": [40, 40, 528, 0, 0, 532, 539, 524820],
1305 "cs_w64x_partial_scmp": [0, 1, 0, 1, 1, 1, 1, 0], # s_cmp mask, -1 in a partial wave 1305 "cs_w64x_partial_scmp": [0, 1, 0, 1, 1, 1, 1, 0], # s_cmp mask, -1 in a partial wave
1306 "cs_w64x_partial_swizzle": [508, 523, 0, 0, 528, 0, 531, 0], # swizzle from a missing lane: 0
1306 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32 1307 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32
1307 # ds_permute_b32 in a 20-thread wave32: a never-launched source lane sends nothing (.asm header) 1308 # ds_permute_b32 in a 20-thread wave32: a never-launched source lane sends nothing (.asm header)
1308 "cs_w32_partial_permute": [0, 29, 127, 0, 1, 0, 134, 113], 1309 "cs_w32_partial_permute": [0, 29, 127, 0, 1, 0, 134, 113],
@@ -1338,10 +1339,12 @@ def run_suite(a, work: str) -> int:
1338 # as check.py does, where the device has none 1339 # as check.py does, where the device has none
1339 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were 1340 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were
1340 # translated with --wave64-emulate and run on any subgroup size. 1341 # translated with --wave64-emulate and run on any subgroup size.
1341 # cs_w64x_partial and cs_w64x_partial_scmp (40-thread groups) can't have full subgroups: they ask for 1342 # cs_w64x_partial, cs_w64x_partial_scmp and cs_w64x_partial_swizzle (40-thread groups) can't have full
1342 # size 64 without them. 1343 # subgroups: they ask for size 64 without them. With LEONIDA_W64_EMULATE=1 they ask for 32, the width the
1344 # emulation is for, as check.py's partial_wave_test does. RADV defaults compute to 64, and there
1345 # cs_w64x_partial_swizzle came out right even before its missing-lane reads were fixed; at 32 it did not.
1343 emulated = w64_emulated() 1346 emulated = w64_emulated()
1344 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp") 1347 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp", "cs_w64x_partial_swizzle")
1345 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 1348 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
1346 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 1349 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
1347 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 1350 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
@@ -1351,8 +1354,8 @@ def run_suite(a, work: str) -> int:
1351 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1354 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
1352 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_cmp", "cs_w32_andn2_exec", 1355 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_cmp", "cs_w32_andn2_exec",
1353 "cs_w32_exec_computed") and not emulated and not partial 1356 "cs_w32_exec_computed") and not emulated and not partial
1354 if partial and not emulated: 1357 if partial:
1355 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") 1358 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="32" if emulated else "64")
1356 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774) 1359 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774)
1357 cs_env = dict(os.environ, **WAVE32_LANE_ENV) 1360 cs_env = dict(os.environ, **WAVE32_LANE_ENV)
1358 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env) 1361 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env)
diff --git a/scripts/vs_layout_census.py b/scripts/vs_layout_census.py
index 249a9c74e..1d7174e77 100644
--- a/scripts/vs_layout_census.py
+++ b/scripts/vs_layout_census.py
@@ -31,6 +31,7 @@ sys.path.insert(0, os.path.join(ROOT, "scripts"))
31import fssm_unpack # noqa: E402 31import fssm_unpack # noqa: E402
32import pal_stages # noqa: E402 32import pal_stages # noqa: E402
33import shader_disasm # noqa: E402 33import shader_disasm # noqa: E402
34from report_paths import same_report_path # noqa: E402
34import shader_ir # noqa: E402 35import shader_ir # noqa: E402
35from vs_input_survey import (FETCH_CALL, MBCNT, PARAM_EXPORT, POS0_EXPORT, PRIM_EXPORT, SENDMSG, # noqa: E402 36from vs_input_survey import (FETCH_CALL, MBCNT, PARAM_EXPORT, POS0_EXPORT, PRIM_EXPORT, SENDMSG, # noqa: E402
36 read_before_write) 37 read_before_write)
@@ -87,10 +88,9 @@ def payloads_of(dxbc_path):
87 for i, blob in enumerate(blobs)] 88 for i, blob in enumerate(blobs)]
88 89
89 90
90def survey(dxbc_dir, disasm_fn=None, limit=None): 91def load_index(dxbc_dir):
91 """The census over <dxbc>: counts by stage, hardware id, markers and VS entry VGPRs.""" 92 """(stage by stem, stems in index order) from <dxbc>/index.json."""
92 index_path = os.path.join(dxbc_dir, "index.json") 93 with open(os.path.join(dxbc_dir, "index.json"), encoding="utf-8") as f:
93 with open(index_path, encoding="utf-8") as f:
94 index = json.load(f) 94 index = json.load(f)
95 if not isinstance(index, list) or not all(isinstance(e, dict) for e in index): 95 if not isinstance(index, list) or not all(isinstance(e, dict) for e in index):
96 raise ValueError("index.json is not a list of shader entries") 96 raise ValueError("index.json is not a list of shader entries")
@@ -102,6 +102,26 @@ def survey(dxbc_dir, disasm_fn=None, limit=None):
102 if stem not in stages: 102 if stem not in stages:
103 names.append(stem) 103 names.append(stem)
104 stages[stem] = e.get("stage") 104 stages[stem] = e.get("stage")
105 return stages, names
106
107
108def input_paths(dxbc_dir):
109 """Every file the census may read: index.json, then each indexed container and its disasm/<stem>.s listing.
110 An index that cannot be read names no more; survey() reports it."""
111 paths = [os.path.join(dxbc_dir, "index.json")]
112 try:
113 _stages, names = load_index(dxbc_dir)
114 except (OSError, ValueError):
115 return paths
116 for name in names:
117 paths.append(os.path.join(dxbc_dir, name + ".dxbc"))
118 paths.append(os.path.join(dxbc_dir, "disasm", name + ".s"))
119 return paths
120
121
122def survey(dxbc_dir, disasm_fn=None, limit=None):
123 """The census over <dxbc>: counts by stage, hardware id, markers and VS entry VGPRs."""
124 stages, names = load_index(dxbc_dir)
105 if limit is not None: 125 if limit is not None:
106 names = names[:limit] 126 names = names[:limit]
107 127
@@ -186,9 +206,15 @@ def main(argv=None):
186 ap.add_argument("--limit", type=int, help="stop after this many containers (index order)") 206 ap.add_argument("--limit", type=int, help="stop after this many containers (index order)")
187 a = ap.parse_args(argv) 207 a = ap.parse_args(argv)
188 index_path = os.path.join(a.dxbc, "index.json") 208 index_path = os.path.join(a.dxbc, "index.json")
189 if a.json and os.path.exists(a.json) and os.path.exists(index_path) and os.path.samefile(a.json, index_path): 209 if a.json:
190 print(f"vs_layout_census: error: --json would overwrite the input {index_path}", file=sys.stderr) 210 # Refuse before survey(): it reads the whole corpus and runs llvm-mc for every unlisted payload.
191 return 2 211 if os.path.isdir(a.json):
212 print(f"vs_layout_census: error: --json {a.json} is a directory, not a JSON file", file=sys.stderr)
213 return 2
214 for path in input_paths(a.dxbc):
215 if same_report_path(a.json, path):
216 print(f"vs_layout_census: error: --json would overwrite the input {path}", file=sys.stderr)
217 return 2
192 try: 218 try:
193 r = survey(a.dxbc, disasm_fn=default_disasm, limit=a.limit) 219 r = survey(a.dxbc, disasm_fn=default_disasm, limit=a.limit)
194 except (OSError, ValueError) as e: 220 except (OSError, ValueError) as e: