mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:38:37 +00:00
docs/d3d12_vulkan.md section 3.5 infers where root arguments arrive from the user SGPRs the shaders read and calls the graphics bases (s8 for VS/PS/GS, s16 for mesh) a hypothesis: the SGPR census cannot see root-parameter indices or a spill. Each native program's FSSM record names two tables that state it directly: a root-layout table (root type, user-data dwords, first user-data dword and root parameter index per parameter) and a used-resource table. The record layout is the one VIctory reads (Marvisak/VIctory, GPL-3.0, crates/victory-shader/src/native.rs). The parser is written for this repository from that layout and contains no VIctory code. tools/fssm_root_layout.py is a new module on its own. root_tables(fssm) returns the programs of one blob with both tables. It raises FssmLayoutError (a ValueError) for a header that is not version 0x101 with a matching payload size, a record or code range outside the payload, records that overlap each other or the slot table, and a table that runs past the payload or overlaps a record, its program's code or the program's other table. Unnamed types and non-zero reserved fields are kept so they can be counted. Its command line prints the tables of a file or a folder as JSON, or writes them with --out, one file in memory at a time. tools/root_layout_census.py reads the user's own .fssm blobs or carved containers and prints counts per hardware stage: the lowest SGPR a parameter arrives in, the dwords each root type takes, root types and used-resource kinds, compute programs with a spilled parameter and the first spilled dword, and how many programs agree with the section 3.5 hypothesis, with the reasons for the rest. It also counts what would show the reading to be wrong (unread blobs by reason, record offsets, reserved fields, unnamed types). With no input it says so. No retranslation: tools/fssm_unpack.py and every other file in make_game's TRANSLATION_SOURCES are untouched, and neither new file is imported by the translator or make_game.py, so a translated shader library stays valid. A test holds the two new names out of make_game.py, translator_deps.cmake, fssm_unpack.py, rdna2spirv.py and shader_meta.py. Nothing here was run on real shader data. Which fields are VIctory's reading and which this corpus's earlier measurements already support (the two table offsets are the header's `code_end` and `meta_ptr`) is in section 3.5, with the commands and the open questions. The runtime does not use the tables yet. Tested: tests/test_fssm_root_layout.py (32 tests: hand-built records with constants, a root descriptor, tables, an immediate sampler, a heap and a spilled compute layout; truncated, overlapping and overflowing tables; every prefix and 4,000 seeded corruptions of a three-program blob; both command lines) and the fssm_unpack, pal_stages, fssm_header, fssm_crosscheck, missing-input, line-ending and CI-registration tests pass. The repository-consistency set gives 578 passed, 5 skipped. No game files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
"""BUILD-1046: a missing input path is a usage error (exit 2), not a failed run (exit 1).
|
|
|
|
Each tool is run with a nonexistent positional input. All of them build their inputs themselves in this test;
|
|
no game file or asset is used. `image_query_probe.py --help` is bounded so its argument parsing cannot grow the
|
|
hardware-oracle startup cost back in.
|
|
"""
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import unittest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = os.path.dirname(HERE)
|
|
TOOLS = os.path.join(ROOT, "tools")
|
|
|
|
MISSING_INPUT_TOOLS = (
|
|
"analyze_4240_full",
|
|
"audio_config",
|
|
"bary_fallback_gs",
|
|
"content_definitions",
|
|
"cpu_ref",
|
|
"gamedata_maps",
|
|
"gamedata_sps1",
|
|
"navmesh_index",
|
|
"pe_inspect",
|
|
"rtti_scan",
|
|
"shader_disasm",
|
|
"tile_probe",
|
|
"d3d12_guid_sites",
|
|
"gamedata_blobs",
|
|
"navmesh_cell_fit",
|
|
"psin_psch",
|
|
"root_spill_census",
|
|
"root_layout_census",
|
|
"fssm_root_layout",
|
|
)
|
|
|
|
# One process per tool; a hung import is a failure, not an infinite test.
|
|
TIMEOUT = 120
|
|
|
|
|
|
def run_tool(tool, *args, timeout=TIMEOUT):
|
|
return subprocess.run([sys.executable, "-I", os.path.join(TOOLS, tool + ".py"), *args],
|
|
capture_output=True, text=True, timeout=timeout, errors="replace")
|
|
|
|
|
|
class MissingInputExitCodeTests(unittest.TestCase):
|
|
def test_missing_input_is_exit_2_with_one_error_line(self):
|
|
missing = os.path.join(HERE, "no-such-input-for-build-1046")
|
|
self.assertFalse(os.path.exists(missing), "the fixture path must not exist")
|
|
for tool in MISSING_INPUT_TOOLS:
|
|
with self.subTest(tool=tool):
|
|
p = run_tool(tool, missing)
|
|
self.assertEqual(p.returncode, 2, p.stderr)
|
|
self.assertNotIn("Traceback", p.stderr)
|
|
lines = p.stderr.strip().splitlines()
|
|
self.assertEqual(len(lines), 1, p.stderr)
|
|
self.assertTrue(lines[0].strip())
|
|
self.assertTrue(lines[0].startswith("ERROR:"), p.stderr)
|
|
self.assertIn(missing, p.stderr)
|
|
|
|
|
|
class ImageQueryProbeHelpTests(unittest.TestCase):
|
|
def test_help_returns_promptly_without_the_hardware_oracle(self):
|
|
p = run_tool("image_query_probe", "--help", timeout=2)
|
|
self.assertEqual(p.returncode, 0, p.stderr)
|
|
self.assertIn("--self-test", p.stdout)
|
|
self.assertNotIn("Traceback", p.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|