Files
Triforce-Source/tests/test_recorded_wait_flush.py
ruckus7382sfgsgdf b527e29adb Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
2026-11-28 10:54:41 -06:00

46 lines
2.7 KiB
Python

"""A wait on the recordings' timeline sends the held batch first (gpu/vk/vk_replay.cpp's wait_recorded).
With batched submits (RX_VK_BATCH, on with RADV) a recording's signal on rec_timeline goes to the GPU only when the batch
does. invalidate's readback wait called wait_recorded without a flush: the game job that read the value back waited for
a signal nothing would send, the main thread waited for that job, and its progress polls (the other flush) stopped. The
game hung loading a save. Reads the source: wait_recorded flushes before vkWaitSemaphores, and invalidate reaches it.
python -I -B tests/test_recorded_wait_flush.py
"""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def body(src, signature):
"""the text of the function that starts with signature, up to its closing brace at column 0"""
start = src.index(signature)
return src[start:src.index("\n}\n", start)]
def main():
replay = (ROOT / "gpu" / "vk" / "vk_replay.cpp").read_text(encoding="utf-8")
wait = body(replay, "bool wait_recorded(uint64_t f, uint64_t timeout_ns, int* ok) {")
if "vkWaitSemaphores(" not in wait:
raise SystemExit("wait_recorded no longer waits on the recordings' timeline: update this test")
flush = wait.find("queue_flush_for(")
if flush < 0 or flush > wait.index("vkWaitSemaphores("):
raise SystemExit("wait_recorded waits without sending the held batch: a batched recording's signal never comes")
# ((Triforce, 11-27) invalidate reaches it through readback_recorded_wait, kept out of invalidate for its renderer profile)
inv = body(replay, "void invalidate(uint64_t gpu, uint64_t size) {")
rrw = body(replay, "bool readback_recorded_wait(uint64_t v, int* ok) {")
if "readback_recorded_wait(v, &ok)" not in inv or "wait_recorded(v, UINT64_MAX, ok)" not in rrw:
raise SystemExit("invalidate's readback wait no longer goes through wait_recorded: update this test")
# ((Triforce, 11-27) RX_VK_RB_REC_END: the readback's wait by its own rule, readback_rec_wait, flushes the same way)
rb = body(replay, "bool readback_rec_wait(uint64_t v, int* ok) {")
rw = rb[rb.index("int rec_wait(uint64_t seq) {"):]
flush = rw.find("queue_flush_for(")
if "vkWaitSemaphores(" not in rw or flush < 0 or flush > rw.index("vkWaitSemaphores("):
raise SystemExit("readback_rec_wait waits without sending the held batch: a batched recording's signal never comes")
if "readback_rec_wait(v, ok)" not in rrw:
raise SystemExit("invalidate's readback wait no longer goes through readback_rec_wait: update this test")
print("PASS: wait_recorded and readback_rec_wait send the held batch before they wait")
if __name__ == "__main__":
main()