mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 17:48:40 +00:00
One squashed commit of a fork that was developed on a Linux/Proton machine and tested on two native Windows machines. On all of them the retail 1.0.2.1 package now launches, shows its launch movie, first-run pages and landing prompt, runs the story load to its end with the loading slideshow drawing its artwork, and enters the world phase. A first world frame is not verified yet. docs/linux_proton.md has the setup, a healthy boot's timeline, the machines and where it stops. Runtime: frames in the title's own window; DirectStorage pinned reads, page-list scatter/gather, BCPack and unshuffle with a locally generated predictor file; pooled, device-local and deferred image backing for streamed and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table that degrades instead of refusing a submission; a descriptor hash finalizer (off until a library carries it); directly indexed heap offsets for compute dispatches and VS/PS/GS draws; title buffer windows outside a fragmented arena; opt-in device-local copies of streamed buffer views; write-fault retries under the tracker lock, shared trackers and write-watched title memory for native Windows; device-loss, compute-input and memory probes. Translator: loop bounds at structured exits, the eight FidelityFX programs that use a packed-dot form the disassembler skips, buffer bounds modes per view kind, a compaction option, the hash finalizer option. Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows boot script, the paired compute translation script. No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted by people on the machines named in docs/linux_proton.md. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
59 lines
2.7 KiB
Python
59 lines
2.7 KiB
Python
"""Per-lane readback for terminating and unreachable loop bounds."""
|
|
from pathlib import Path
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from test_loop_ballot_barrier import _translate_cs, rdna2spirv
|
|
from spirv_mini_interp import run_workgroup
|
|
|
|
FIXTURE = Path(__file__).with_name("fixtures") / "loop_iteration_guard.asm"
|
|
|
|
|
|
def module(lanes, limit, structured=True):
|
|
lines = [s for s in FIXTURE.read_text().splitlines() if s and not s.startswith(";")]
|
|
lines.insert(0, "s_mov_b64 exec, -1" if lanes == 64 else "s_mov_b32 exec_lo, -1")
|
|
with patch.object(rdna2spirv, "LOOP_LIMIT", limit):
|
|
text, gen = _translate_cs("cs_guard", lines, threads=lanes, emulate=lanes == 64, structured=structured)
|
|
assert gen.wave64 == (lanes == 64) and gen.emulate == (lanes == 64)
|
|
return text
|
|
|
|
|
|
def execute(text, lanes, bound):
|
|
mem = run_workgroup(
|
|
text, lanes, 32,
|
|
inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0),
|
|
"%sg_lane": i % 32, "%local_index": i},
|
|
push_constants=[0, 0, lanes * 4, 0x31016FAC, bound] + [0] * 27, memory={})
|
|
return [mem[i * 4] for i in range(lanes)]
|
|
|
|
|
|
class LoopGuardTests(unittest.TestCase):
|
|
def test_finite_and_nonterminating(self):
|
|
for lanes in (32, 64):
|
|
with self.subTest(lanes=lanes):
|
|
plain, guarded = module(lanes, 0), module(lanes, 16)
|
|
self.assertNotIn("%loop_guard_", plain)
|
|
self.assertIn("%loop_guard_", guarded)
|
|
self.assertEqual(execute(plain, lanes, 6), [6] * lanes)
|
|
self.assertEqual(execute(guarded, lanes, 6), [6] * lanes)
|
|
self.assertEqual(execute(guarded, lanes, 1), [32] * lanes)
|
|
|
|
def test_dispatch_loop_also_stops(self):
|
|
for lanes in (32, 64):
|
|
with self.subTest(lanes=lanes):
|
|
guarded = module(lanes, 16, structured=False)
|
|
self.assertEqual(execute(guarded, lanes, 6), [6] * lanes)
|
|
words = execute(guarded, lanes, 1)
|
|
self.assertTrue(all(0 < v <= 32 and v % 2 == 0 for v in words))
|
|
|
|
|
|
def test_inner_budget_resets_on_each_entry(self):
|
|
lines = ["s_mov_b32 s8, 0", "s_mov_b32 s9, 0", "outer:", "s_mov_b32 s10, 0",
|
|
"inner:", "s_add_u32 s9, s9, 1", "s_add_u32 s10, s10, 1", "s_cmp_eq_u32 s10, 3",
|
|
"s_cbranch_scc0 inner", "s_add_u32 s8, s8, 1", "s_cmp_eq_u32 s8, 3", "s_cbranch_scc0 outer",
|
|
"v_mov_b32_e32 v1, s9", "v_lshlrev_b32_e32 v2, 2, v0",
|
|
"buffer_store_dword v1, v2, s[0:3], 0 offen", "s_endpgm"]
|
|
with patch.object(rdna2spirv, "LOOP_LIMIT", 3):
|
|
text, _ = _translate_cs("cs_guard_nested", lines, threads=32)
|
|
self.assertEqual(execute(text, 32, 0), [9] * 32)
|