Files
Triforce-Source/scripts/vkprof.py
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

63 lines
2.5 KiB
Python

"""The renderer's threads from an all-thread sample (host/mkw_glue.c HOS_SAMPLE_ALL): for the threads whose name starts
with a prefix (default mkw_vk), the share of samples running, and the functions by inclusive and self share of the
running samples (leaf in hookshot_vk.dll, hookshot.exe or the driver; on Linux hookshot_vk.so, hookshot or the driver).
python -I scripts/vkprof.py work/runs/<run>_all.txt [top 40] [prefix mkw_vk]
(RX_MAPS=<folder>: another build's linker maps, or on Linux the game folder)
"""
import bisect, collections, os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import prof # noqa: E402
top = int(sys.argv[2]) if len(sys.argv) > 2 else 40
prefix = sys.argv[3] if len(sys.argv) > 3 else "mkw_vk"
maps = prof.load_symbols()
cache = {}
def name(f):
if f in cache:
return cache[f]
mod, _, off = f.rpartition("+")
r = mod
if mod in maps:
a, n = maps[mod]
i = bisect.bisect_right(a, int(off, 16)) - 1
if i >= 0:
r = prof.module_name(mod) + ":" + prof.demangle(n[i])[:70]
cache[f] = r
return r
RUN = prof.RUN_MODS + ("nvoglv64.dll", "amdvlk64.dll", "amdxc64.dll", "amdxx64.dll", "igvk64.dll", "igxelpicd64.dll") # ((Triforce) AMD's and Intel's Windows drivers too
DRIVERS = ("libnvidia-glcore.so", "libvulkan_radeon.so", "libvulkan_intel.so") # (Linux: the driver's file has its version after .so)
seen, running = collections.Counter(), collections.Counter()
incl, self_ = collections.Counter(), collections.Counter()
nrun = 0
for line in open(sys.argv[1], encoding="utf-8", errors="replace"):
head, _, st = line.rstrip("\n").partition("|")
th = head.split(" ", 1)[-1]
if not st or not th.startswith(prefix):
continue
frames = st.split(";")
seen[th] += 1
leafmod = frames[0].rpartition("+")[0]
if leafmod not in RUN and not leafmod.startswith(DRIVERS):
continue
running[th] += 1
nrun += 1
names = [name(f) for f in frames]
self_[names[0]] += 1
for n in set(names):
incl[n] += 1
print("-- running share by thread")
for th in sorted(seen, key=lambda t: -running[t]):
print(" %5.1f%% %s (%d samples)" % (100.0 * running[th] / seen[th], th, seen[th]))
print("-- inclusive (share of %d running samples)" % nrun)
for k, c in incl.most_common(top):
print(" %5.1f%% %s" % (100.0 * c / max(1, nrun), k))
print("-- self")
for k, c in self_.most_common(top):
print(" %5.1f%% %s" % (100.0 * c / max(1, nrun), k))