Repository navigation
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.
|
Native Windows on Intel UHD 770 (driver The fix that passed here was to put the edge vertices and the pixel shader's alpha word in DEFAULT-heap buffers. I filled one UPLOAD staging buffer, copied both ranges with
The edge fixture source was identical on the two heads. With the fix, the registered Two other stages on the original #4873 stack passed on this Intel device. Stage 6 (#4869) put all 98,144 certain pixels within the BC1/BC7 bounds and the mip control changed all 10,221 predicted pixels. Stage 8 (#4871) matched all 95,699 single-colour pixels exactly and clearing the shadow map changed the predicted 9,539 pixels. Stages 3 and 5 stopped at creation of the second queue, before producing frames. This adapter exposes one graphics/compute queue and two video-decode queues. AI-assisted, synthetic fixtures only. |
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.
|
Thanks @PingasMech, adopted as you did it, in On the RTX 5080: 98,304 of 98,304 exact and 673 of 673 shared-edge centres. Both mutations still fail: slot 0 gives 31,884 and 0/673, and the bottom-right rule gives 0/673 with 319 gaps. #4865, #4869 and #4871 are restacked on it. What your two findings say about the layer:
|
|
Tested the current head
AI-assisted (Claude Code). |
|
Native Windows RTX 4080 comparison for Lanterns stage 1. Windows 11 build 26200, NVIDIA 621.01, MSVC 19.44 Release, Khronos validation 1.4.357 with synchronization validation enabled. Both guest revisions used the same
All six runs also matched 97,926 exact scene pixels and 378 plausible edge pixels. The depth-off control changed 11,610 pixels each time. Every run used the Vulkan factory proxy and reported zero Vulkan validation diagnostics. The current revision also passed its registered The old path passed on this RTX 4080 with Resizable BAR and UPLOAD heaps in host-visible VRAM. This adds a native Windows NVIDIA result alongside the Intel and AMD comparisons. Synthetic inputs only. AI-assisted (Codex). |
|
Verified head 89127f0 against main 3faac55 at check time: merges cleanly; all CPU-runnable tests pass (run_lanterns 5/5 including bounded wineserver-stop via shell stubs, fssm_pack 10/10, chain 6/6 under pytest), shaders are hand-written listings and the docs guards pass. The D3D12 GPU half (frame-exactness, shared-edge draws) is unverifiable on a CPU-only host. This is the base of a stack — #4865 sits directly on top of it (verified ancestry). No CI checks were scheduled on this branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested
|
Claimed in the coordination issue as: TEST-1063, #4816 (comment) (the Lanterns proposal; this is piece 2)
Depends on: #4820 (
fssm_pack.py). Its three commits appear here until it lands. This PR's commits are the last eight: the guest, the fixes from two reviews (runner, CMake dependencies, guest checks), the docs, the draw with the title's s8 table layout, then two more fixes from review (the shaders also depend ontools/*.json; the runner's wineserver stop is hard-bounded and it needs the subreaper on Linux).Checked against #313: this stage only uses methods already on
main(it passes onmainas it is); it does not implement or duplicate a layer method.What and why
Lanterns is a synthetic, title-shaped guest. It goes through the chain a title would, end to end:
DXBC { DXIL { XDAT { XBCH + zlib(FSSM) } } }container.fssm_unpack.py,shader_disasm.pyandrdna2spirv.pytranslate them offline.gta6rt --runmaps the guest and answersd3d12_xs.dll!D3D12XboxCreateDevicewith the Vulkan device.The milestone gates in
docs/d3d12_vulkan.mdsection 6 each check one capability from a host program:d3d12_draw_test(M1),d3d12_translated_draw_test(M1.5),d3d12_m2_textured_test,d3d12_m3_frame_testandd3d12_m4_compute_test. #1865 is the M5 gate. Lanterns runs them together in one guest, through the real container path andgta6rt --run. Later stages add compute queues, ExecuteIndirect, fp16 post-processing, BC textures and shadow maps. This PR is stage 1 only.Stage 1: five
DrawIndexedInstancedcalls (prisms, cubes, octahedra, pyramids, a checker floor) into a 384x256 RGBA32F target with D32 depth.CopyBufferRegionfrom an upload buffer.; wave: 64), so the native wave64 graphics path runs too.The checks:
vs_lanternstovs_lanternS), so its hash is unknown, and it must be refused withE_INVALIDARG.run_lanterns.pypasses a run only when three things hold: exit 0, the whole PASS line exactly once with numbers that fit together, and the shim's complete factory lineD3D12XboxCreateDevice -> proxy 0x... (Vulkan device 0x...). Each run writes into a new folder under--out. With--wineit first stops the prefix'swineserver(-k, then-w, 10 s each): a launch under a new virtual X server while the last run'sexplorer.exelives can hang in winevulkan's device creation. On timeout it kills everything the run started (on Linux also a process that left the session, as a child subreaper; if the kernel refuses the subreaper, the runner does not launch and exits 4), so a stalled guest, Wine or GPU fails with exit 3 instead of hanging; if something survives, ortaskkillfails, the run fails with exit 4. The guest bounds each fence wait at 30 s.The title's register layout (s8). The title's VS and PS read their first table pointer at s8 (
docs/d3d12_vulkan.md3.5). The layer packs root arguments from s0 in root-signature order, so a second draw uses a root signature that starts with eight 32-bit constants (s0..s7) and then a table (s[8:9]). Its wave64 VS and PS (vs_lanterns_edges,ps_lanterns_edges) read exactly that. The draw is a fan of eight triangles around one vertex with every vertex on a pixel centre, so 673 pixel centres lie exactly on a shared edge; each triangle has its own flat colour and additive blending counts the draws. The CPU applies D3D's top-left rule in exact integers, and every pixel must match: each shared-edge centre drawn once, by the triangle the rule names, no pixel twice, no gap.Opt-in:
-DLEONIDA_TEST_LANTERNS=ON, off by default. Default CI builds and runs no part of the GPU guest. The CPU test of the runner (tests/test_run_lanterns.py) does run, in the check job's stdlib loop. The shader rule depends on everytools/*.pyandtools/*.json(the translator imports the scripts and readsgfx10_formats.json), so an incremental build cannot keep a stalespirv/index.json. Checked on the pod: before, touchingtools/gfx10_formats.jsonleft the shaders as they were (the index rule did not list it); after, the next build packs and translates again. The ctestlanterns_stage1exists only in an opt-in native Windows build.No port of #3913 needed. The guest links
d3d12_xs_stub, the failing link-time stub already on main for tiny_frame (runtime/test/fixtures/d3d12_xs_stub.cpp, #3488). It is byte-for-byte the function #3913 carries. The include sits right after that target inruntime/CMakeLists.txt. Nothing else came from #3913's code. The factory-line guard in the runner is #3913's idea.docs/lanterns.mdsays what it is, what stage 1 proves, the check line, both controls, how to build and run it (native Windows ctest, and Linux + Wine), and its limits. It is linked fromdocs/README.md, with a short paragraph after the milestone table indocs/d3d12_vulkan.mdsection 6.Tested
RunPod, RTX 5080, Linux, Wine 11.0, clang-cl 21 + xwin cross-build (
runtime/cmake/clang-cl-xwin.cmake), Vulkan SDK 1.4.363,-DLEONIDA_TEST_LANTERNS=ON, targetsgta6rt lanterns.run_lanterns.py --wine --stage 1: exit 0 in about 3 s:Lanterns stage 1: PASS, 97926 of 98304 pixels exact, 378 edge pixels plausible, depth-off control changed 11610 pixels; shared edges through a wave64 VS/PS with the title's s8 table: 98304 of 98304 pixels exact, 673 centres on shared edges each drawn once.wineserver -kbetween them, only the runner's own stop. All passed.a fence stayed at 2 for 30000 ms, waiting for 3. Before, the run hung until the runner killed it at 120 s (exit 3).tests/test_run_lanterns.py(stdlib, about 12 s): a stalled launcher, its child and a grandchild that calledsetsid()are all killed, exit 3; each run gets its own folder; twelve incomplete or malformed transcripts are refused (among them PASS followed by other words, counts that do not add up, no depth-off change, one wrong edge-fan pixel, the line without its shared-edge part); the wineserver stop runs before the launch, and a hangingwineserver, or one that ignores SIGTERM and leaves a child, fails the run with exit 4 within its bound, with that child dead; withprctlrefused, nothing is launched and the exit is 4. Against the runner before the last fix: 2 failures (the child survived; the launch went ahead). The new tests against the runner before the fixes: 5 failures (counted before the wineserver test was added).test_fssm_pack,test_fssm_pack_chain(pytest, 6 passed),test_runtime_paths,test_ci_registration,test_docs_links,test_docs_repo_paths,test_docs_list_items,test_docs_table_rows,test_text_encoding,test_text_write_line_endings, all under-W error;compileallclean.Not covered
lanterns_stage1ctest and the runner'staskkillpath are untested. No AMD or Intel GPU yet.wineserverhang did not reproduce on this machine (back-to-back runs passed with the stop removed). The fix rests on another setup's report (20 of 20 hung without it, 20 of 20 passed with it) and on the runner test with a fakewineserver.Credits
gta6rt --runand the stub this guest links.d3d12_translated_draw_test(M1.5): the heap-handle calls through slots 9/10, the V# encoding and the upload-to-DEFAULT pattern.AI-assisted (Claude Code). No game files.