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:
authoraslan2142 <jan.trencansky@protonmail.com>2026-11-25 23:23:29 +0100
committerGitHub <noreply@github.com>2026-11-25 23:23:29 +0100
commiteaa3792fd896c9b975713dd5b3e9acf4cbb9882a (patch)
tree4bd44fb26f0ee0be387ca499079e4b7a58b0df7b /scripts
parent7359f21b2bf77b243b7ba78526ab3ff3fb12a036 (diff)
parent165402ddebb9f3a7e0cfc26b5223d9add488071b (diff)
Merge pull request #713 from aslan2142/audit-shader4-limit-zero
OLD-7087: restore old upstream PR 7087 - audit_shader4_regs: --limit must be at least 1; 0 audited nothing and printed a zero report
Diffstat (limited to 'scripts')
-rw-r--r--scripts/audit_shader4_regs.py19
1 files changed, 14 insertions, 5 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.