Repository navigation
RT-340: Resolve relative native launcher paths in Lanterns - #4898
kacper-serewis wants to merge 16 commits into
Conversation
…ssembly
runtime/test/lanterns/fssm_pack.py assembles .asm with llvm-mc and packs the code
into an FSSM program in the layout docs/design.md and tools/fssm_header.py
describe (code section at 0xC0/0xC8 with the code 0x28 in, the wave flag at
0xD4, the code end at 0xE8, the 0x120/0x12C/0x130 directory, the PS input table
or the CS thread-group header at 0x138, the binding-table tail). It wraps the
program in the container the title ships (DXBC { DXIL { XDAT { 0x0D: XBCH +
zlib(FSSM) } } }, plus an ISG1 part when a pixel shader reads SV_Position).
With --translate it runs fssm_unpack.py, shader_disasm.py and rdna2spirv.py on
the folder, as make_game.py's shaders stage does, and fails unless every shader
comes back: same blob, decoded from the header with no invalid word, and a row
in spirv/index.json keyed by the packed program's SHA-256.
It is a test helper, so it does not live in tools/: make_game.py's
translator_digest() hashes every file there, and a new one would make a resumed
shaders stage throw away its finished shards.
tests/test_fssm_pack.py (standard library, the check job) reads the packed
fields back with fssm_header.py, the code range with shader_disasm.py and the
container with fssm_unpack.py, and checks the refusals. tests/test_fssm_pack_chain.py
(pytest, the translator-tests job, which has llvm-mc 21 and spirv-tools) runs
the whole offline chain on three small programs.
The runtime workflow's path filter gains tools/rdna2_decode.py and
tools/rdna2_isa_tables.py: shader_disasm.py imports them, and
tests/test_runtime_paths.py requires every tool a runtime/ script runs to be
listed there.
…2_isa_tables.py runtime/test/lanterns/fssm_pack.py runs shader_disasm.py, which imports them, and tests/test_runtime_paths.py requires every tool a runtime/ script reaches to be in the runtime workflow's path filter.
…yloads The packer wrote one narrow container layout: every PS input's slot byte was position + 1, the tail had no binding records, and XDAT had one 0x0D entry. A reader that took the slot byte for the attr number, or the first of two payloads, would still pass on what it packed. - "; input: ... slot=N" sets byte 6 of the record; the attr number stays the table position. - "; binding: W0 W1 W2 W3 W4" adds a 20-byte record to the tail (fssm_header.binding_table reads them back in order). - "; first-payload: NAME" puts a second program (the same code under NAME, so another hash) in a first 0x0D entry, as 195 of the title's containers have two. fssm_unpack.py and the runtime take the last. Tests: the slot bytes, records and both payloads read back (test_fssm_pack.py), and through the offline chain a PS with slot 9, a binding record and a first payload is keyed by its own blob with its flat input at position 0 (test_fssm_pack_chain.py; the old packer fails it).
Every output is named after its shader (<name>.dxbc, fssm/<name>.fssm, disasm/<name>.s, the SPIR-V). Two inputs such as a/ps_tile.asm and b/ps_Tile.asm, or a native variant named like its shader in another case, wrote one file on a case-insensitive volume (Windows, macOS) while index.json listed two rows, and the packer exited 0. The first row then read the second shader's container. pack_file() now only packs; main() compares all names after casefold() and refuses a clash, naming both inputs, before it creates the output folder or writes any file.
…gta6rt --run Lanterns is an x64 guest that goes through the chain a title would: its hand-written RDNA2 shaders are packed into FSSM programs inside DXBC/XDAT/XBCH containers (runtime/test/lanterns/fssm_pack.py) and translated by fssm_unpack.py, shader_disasm.py and rdna2spirv.py; gta6rt --run maps it and answers d3d12_xs.dll!D3D12XboxCreateDevice with the Vulkan device; the guest builds its pipelines from the containers through the D3D12 API. lanterns.cpp is the guest's checks, lanterns_gpu.cpp/.h its D3D12 side and lanterns_d3d12.h the shared helpers, the layout later stages extend. Stage 1: five DrawIndexedInstanced calls (prisms, cubes, octahedra, pyramids, a checker floor) into a 384x256 RGBA32F target with D32 depth. Vertex, index and instance buffers sit in DEFAULT heaps, filled by upload copies; the VS fetches through two V#s in two descriptor tables, the model matrix and tint come from root constants, the camera from a root CBV, and the floor PS reads its colours through the code base. Interior pixels must match the CPU reference bit for bit; edge, depth-tie and checker-border pixels must be one of their candidate colours. A container whose FSSM program the index does not know must be refused, and with the depth test off exactly the pixels the reference predicts must change. run_lanterns.py passes a run only on exit 0, the PASS line once and the shim's complete factory line, and kills the whole process group when its timeout expires (tests/test_run_lanterns.py, with a launcher that never ends). Opt-in with -DLEONIDA_TEST_LANTERNS=ON; nothing is built or run by default. The guest links tiny_frame's failing d3d12_xs stub (test/fixtures, ItsNotRexed#3488) instead of a copy. docs/lanterns.md says what it covers, how to run it and its limits.
…cleanup fails - The PASS line must match its stage's full pattern, with numbers that fit together; "PASS" followed by anything else no longer passes. - Each run writes into a new folder under --out, so an old run's dumps or pictures cannot stand in for a missing one. - On Linux the runner becomes a child subreaper and also kills descendants that left the launcher's session. taskkill and killpg results are checked; anything left alive fails the run with exit code 4. - With --wine it stops the prefix's wineserver (-k, then -w, 10 s each) before the launch: a launch under a new virtual X server while the last run's explorer.exe is alive can hang in winevulkan's device creation. - The docstring's Windows path no longer has an invalid escape (SyntaxWarning, fatal under -W error). tests/test_run_lanterns.py: a grandchild that calls setsid() must die too, each run gets its own folder, three malformed PASS lines are refused, and the wineserver stop runs before the launch (fake wineserver and wine on PATH; a hanging wineserver fails the run within its timeout).
The translator imports many files in tools/ (fssm_header, shader_ir, shader_meta, mc_command, rdna2_decode, ...). Listing four of them let an incremental build keep a stale spirv/index.json. Depend on the whole tools/*.py glob, the set make_game.py's translator_digest() hashes.
…d bounds its fence waits - Lookup control: both vertex-shader containers come from the same writer. The unmodified one must give a pipeline; the second differs in one byte of the program's name, so its FSSM hash is unknown and the layer must refuse it. Before, the refused container differed in padding only. - A wave64 VS/PS pair (vs_lanterns_w64, ps_lanterns_lit_w64, "; wave: 64") draws the octahedra, so the native wave64 graphics path is checked too. - The floor PS's inputs carry slot bytes 6 and 3 (the attr number is the table position), and vs_lanterns.asm's container has a first 0x0D payload before the real one. - Reference: near an edge two faces of one solid share, one of the two must cover the pixel; the background is no longer a candidate there, so a crack along the edge fails. - Every fence wait is bounded (30 s) and fails with a line naming it.
The lookup control, the shared-edge rule, the runner's strict line, run folders, cleanup exit code and wineserver stop, the failures each fix was shown to catch, output under the build folder, and which CI jobs run the CPU tests.
… the title's s8 table The title's VS and PS read their first table pointer at s8 (docs/d3d12_vulkan.md 3.5). The layer packs root arguments from s0 in root-signature order, so a second draw's root signature starts with eight 32-bit constants (s0..s7) and then a table of two buffer SRVs (s[8:9]). vs_lanterns_edges and ps_lanterns_edges are wave64 and read exactly that: constants from s0..s3, vertices through table slot 0, the PS's alpha through slot 1. The draw is a fan of eight triangles around one vertex, every vertex on a pixel centre, inner edges horizontal, vertical and at 1:1, 1:2, 3:2 and 1:4, so 673 pixel centres lie exactly on a shared edge. Each triangle has its own flat colour from its provoking vertex; additive blending counts the draws. lanterns_edges.h applies D3D's top-left rule in exact integers. Every pixel must match: each shared-edge centre drawn once by the triangle the rule names, nothing drawn twice, no gaps. The PASS line and the runner's pattern gain this part; the sheet gains the fan. Mutations on the RTX 5080: the PS reading slot 0 instead of 1 leaves 31884 of 98304 exact; a bottom-right reference leaves 0 of 673 (319 gaps).
rdna2spirv.py and rdna2_decode.py read tools/gfx10_formats.json, so a change to the format table left spirv/index.json and the SPIR-V stale. The shader rule now depends on tools/*.json as well as tools/*.py.
- wineserver -k/-w run through Popen with their output discarded; on overrun the process group is SIGKILLed and reaped within 5 s, and the run fails naming what was left. Before, a child of a hung wineserver survived the run. - On Linux the runner does not launch unless prctl(PR_SET_CHILD_SUBREAPER) succeeds (exit 4): without it an escaped grandchild cannot be found, and the runner would claim a full cleanup it cannot check. - Windows: taskkill failing for a launcher that already exited (128) is no longer reported as a survivor. Tests: a wineserver that ignores SIGTERM and leaves a child (the child must be dead after the run), and prctl mocked to fail (no launch, exit 4). Both fail on the runner before this commit.
The shared-edge draw read its vertices and the pixel shader's alpha word straight from UPLOAD-heap buffers. On native Windows with an Intel UHD 770, PingasMech found every covered pixel empty (31,884 of 98,304 exact, 0 of 673 edge centres). Both buffers now live in DEFAULT heaps, filled from one UPLOAD staging buffer by CopyBufferRegion and moved to NON_PIXEL_SHADER_RESOURCE / PIXEL_SHADER_RESOURCE, with the staging buffer kept alive until the copy's fence has passed, as the main scene's buffers already are. This is the change PingasMech tested on that machine.
|
Checked the launcher commit
No GPU or game data used; the test uses a synthetic empty executable and shader index. AI-assisted. |
|
Tested 640572b merged with main 3faac55 on Linux (Python 3.12.16) and native Windows (Python 3.13.1): pass Linux: tests/test_fssm_pack.py 10 OK, tests/test_run_lanterns.py 6 OK, tests/test_fssm_pack_chain.py is pytest-style (imports conftest) and run with pytest -I gave 6 skipped (spirv-as missing, known baseline), so the chain test was not exercised. Windows: test_fssm_pack 10 OK, test_run_lanterns 6 OK (4 POSIX-only skipped). No GPU used. Negative control: reverting only the run_lanterns.py hunk of 640572b (the launcher abspath) makes NativeLauncher.test_relative_launcher_uses_the_checked_file fail on both Linux and Windows (1 failure); restored, it passes. (run_lanterns.py is not on main yet, this PR stacks on #4863/#4820, so the control is the commit's own hunk.) Review covered the launcher-path commit, the runner and the tests that were run; the C++ stage and the shader asm were not built or read in depth. No issues found. |
|
Verified on Linux with current main (3faac55, merges cleanly): compileall clean; tests/test_fssm_pack.py (10, re-run here), tests/test_run_lanterns.py (6) and tests/test_fssm_pack_chain.py (6, pytest) all pass, and the fssm/shader_disasm neighbours (header 42, unpack 45, wave_size 7, disasm 20, crosscheck 6) show no regressions. The shaders are hand-written listings and the no-game-data rule holds; the launcher tests stub wine, so nothing wine-based ran here. Note the GPU/C++ half (lanterns.cpp, cmake) is not buildable on this box, and the new workflow triggers for tools/rdna2_decode.py will pull in test_rdna2_decode, which is red on main via #4421 — attribute any such CI failure to main, not this PR. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested
|
|
Tested 3bbf3d1 merged with main 8575d36 on native Windows 11, MSVC 14.51, Ninja RelWithDebInfo (-DLEONIDA_TEST_LANTERNS=ON), plus Linux (WSL2) Python 3.12.16: pass |
|
Tested
Synthetic inputs only, no game files. AI-assisted (Claude Code). |
|
Hardware: AMD Radeon Graphics gfx1036 (Raphael iGPU, Windows driver 32.0.11024 / 24.10.24, wave64, maxPushConstantsSize 128, run with Baseline on main AI-assisted (Claude Code). |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
RT-340, Lanterns runner follow-up, coordination item 7092998946. Claim
Depends on: #4863
Depends on: #4820
On native Windows, a relative
bin/gta6rt.exepassed the runner's file check and then raised WinError 2 at process creation. Resolve the checked path against the caller's working directory before launching. The regression exercises a forward-slash relative argument through the runner's CLI.Tested on Windows CPU with a synthetic executable. After the fix both relative and absolute paths launched the stub and returned its expected exit code 23. The focused regression, transcript test and three line-ending checks passed. Four POSIX-only cases skipped on Windows. The patch also merged cleanly with the tested stage 6 head. GPU and driver were outside this launcher check. AI-assisted.