Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Sync upstream 75065df

sync-bot92b91c0d5438
diff --git a/.upstream-ref b/.upstream-ref
index c0bf940f..4c006036 100644
--- a/.upstream-ref
+++ b/.upstream-ref
@@ -1 +1 @@
-4fc7f51401e07f9492dc2f90c730068e7e9ce99f
+75065df74762d8277c4a93277d560429c2d43a7e
diff --git a/dm/gfx/tools/c1_guard.py b/dm/gfx/tools/c1_guard.py
index e7a50abd..2c97b149 100755
--- a/dm/gfx/tools/c1_guard.py
+++ b/dm/gfx/tools/c1_guard.py
@@ -9,6 +9,7 @@
# masks wider than the data passed, and compute shaders (cp_c1) were never checked.
import datetime
import json
+import multiprocessing
import os
import re
import sys
@@ -200,25 +201,28 @@ def proven(index, definitions, span):
return span is not None and known(low, high) and low >= 0 and 16 * (high + 1) <= span
+def unproven(job):
+ """(version dir, a .metal file name) → the shader's key when one of its c1 reads is not proven bounded, else None. Each shader is checked on its own, so main()
+ spreads them over every core, as cb_extent.py does (Breath of the Wild's 19,592 libraries, FINAL FANTASY RESONANCE's 73,496: minutes on one core)"""
+ version_dir, name = job
+ with open(os.path.join(version_dir, name), encoding="utf-8") as stream:
+ source = stream.read()
+ accesses = set(ACCESS.findall(source))
+ if not accesses:
+ return None
+ key = name[:-len("_b.metal")] if name.endswith("_b.metal") else name[:-6]
+ definitions = definitions_of(source)
+ span = c1_span(os.path.join(version_dir, key + "_b.json"))
+ return None if all(proven(index, definitions, span) for index in accesses) else key
+
+
def main():
if len(sys.argv) != 3:
raise SystemExit(f"usage: {sys.argv[0]} <dmsh_b version dir> <output tsv>")
version_dir, output = map(os.path.abspath, sys.argv[1:])
- keys = []
- for name in sorted(os.listdir(version_dir)):
- if not name.endswith(".metal"):
- continue
- path = os.path.join(version_dir, name)
- with open(path, encoding="utf-8") as stream:
- source = stream.read()
- accesses = set(ACCESS.findall(source))
- if not accesses:
- continue
- key = name[:-len("_b.metal")] if name.endswith("_b.metal") else name[:-6]
- definitions = definitions_of(source)
- span = c1_span(os.path.join(version_dir, key + "_b.json"))
- if not all(proven(index, definitions, span) for index in accesses):
- keys.append(key)
+ jobs = [(version_dir, name) for name in sorted(os.listdir(version_dir)) if name.endswith(".metal")]
+ with multiprocessing.Pool() as pool: # map keeps the sorted order, so the list is the same as one core's
+ keys = [key for key in pool.map(unproven, jobs, chunksize=64) if key]
os.makedirs(os.path.dirname(output), exist_ok=True)
with open(output, "w", encoding="utf-8", newline="") as stream:
stamp = datetime.datetime.now().astimezone().isoformat(timespec="seconds")