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.
- cs_lanterns_rise.asm (wave32) runs on a COMPUTE queue. It moves 256 points of light in integer fixed point and writes their instance records into a DEFAULT UAV buffer. The direct queue waits on the compute fence and draws them as a sixth DrawIndexedInstanced whose instance V# points at that buffer. - Frame 1: compute, then the frame. Frame 2: the frame is submitted first and waits for a fence value a later compute submission signals. - Checks: the point states and instance records equal the CPU's simulation word for word, both frames are exact where certain, and between the two frames the points change exactly the 14839 pixels the reference predicts. Control: a frame without the Wait is reported (not required). - run_lanterns.py: a panel per stage; mask values for bounded pixels (used from stage 6).
- lanterns_bc.h makes two patterns from integer formulas (a 256x256 mosaic, 64x64 nested squares), box-filters them down to 1x1 and compresses them with its own encoders: BC1 four-colour, and BC7 mode 6. It decodes them back for the reference. - The textures go up the D3D12 way: GetCopyableFootprints, an upload buffer, one CopyTextureRegion per level (lanterns_textures_gpu.cpp). No tiled layout is written or assumed. - ps_lanterns_tex_floor samples the mosaic with image_sample (trilinear, implicit LOD). ps_lanterns_tex_solid samples the squares with image_sample_l at the mip level in each draw's tint.a. The root signature gains an SRV table and a sampler table (s[22:23], s[24:25]). - lanterns_sampling.h bounds every pixel: the exact bilinear sample +-4/255 on the solids; on the floor the trilinear sample over the whole LOD range Vulkan allows, +-4/255. lanterns_reference.h's rasterizer is split into fragments() and a shading function; stages 1 and 3 keep their shading. - Control: the solids two mips down must leave the main bounds wherever the two references cannot overlap (10221 of 10221 pixels).
- A depth-only pass (vs_lanterns, no pixel shader, no render target, DepthBias 1000 and SlopeScaledDepthBias 3 in the PSO) draws the solids from a directional light into a 512x512 R32_TYPELESS map: a D32_FLOAT DSV, an R32_FLOAT SRV. - ps_lanterns_shadow moves the world position into light space (three rows after the camera matrix in the root CBV). It takes four comparison taps half a texel apart with image_sample_c (LESS_EQUAL, point; translated since ItsNotRexed#2965) and scales the face colour by 3/8 + 5/32 per lit tap. - lanterns_shadow.h rasterizes the map on the CPU (fragments() now takes a target size). It bounds each texel's stored depth (coverage, tolerance, bias anywhere D3D12/Vulkan allow) and each tap's texel (1/64 texel). A pixel whose four taps are all certain has one exact colour. - Checks: 95699 of 95699 single-colour pixels exact, 98144 of 98144 certain pixels within bounds, each pixel within one surface's own bounds. Control: the map left cleared to 1 changes exactly the predicted 9539 pixels.
|
TEST-1100 independent check at 8e52711 on native Windows, RTX 5070 driver 616.56. All 98,144 certain and 160 uncertain pixels met the CPU oracle bounds. Clearing D32 changed all 9,539 pixels predicted to change. Changing the PCF base from 3/8 to 1/2 left only 46,632 certain pixels in bounds; zeroing both depth-bias terms left 93,250. Both mutations exited 1. Restoring the source reproduced the pass. Synthetic inputs, AI-assisted. |
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.
|
Tested the current head
The same build also passes the earlier stages of the stack: AI-assisted (Claude Code). |
|
Verified merge with main 3faac55 (clean): the three Python tests the stack adds (test_fssm_pack, test_fssm_pack_chain under pytest, test_run_lanterns) all pass on the merged tree; the C++ shadow-map stage needs GPU and was not run here. Verified on the graph: this branch is literally #4869 plus the stage commit 8e52711 (its head is an ancestor of #4873 content-wise), so worth merging in stack order. No CI checks reported on this branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested 4f22615 merged onto main 3faac55 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Tested
|
…layout main's ItsNotRexed#4312 (D3D-448) gives a D3D12 compute PSO its root arguments from s4, a descriptor table as one 32-bit dword. cs_lanterns_rise.asm now count those user SGPRs in RSRC2 and start with moves that rebuild the layout the code was written for (the table as s[0:1] or s[4:5] with a zero high half).
Claimed in the coordination issue as: TEST-1063, #4816 (comment) (the Lanterns proposal; this is piece 5)
Depends on: #4869 (Lanterns stage 6, and through it #4865, #4863 and #4820). Their commits appear here until they land. This PR's commit is the last one.
Checked against #313: this stage only uses methods already on
main(it passes onmainwith the pieces before it): a depth-only PSO withDepthBiasandSlopeScaledDepthBias, anR32_TYPELESSmap with aD32_FLOATDSV and anR32_FLOATSRV, a comparison sampler, andimage_sample_c(#2965, merged). It does not implement or duplicate a layer method. It does not useRSSetDepthBias(D3D-164), D24/D16 depth (D3D-325, D3D-309) or a depth-only clear with a stencil flag (D3D-437); its bounds accept any bias D3D12 and Vulkan allow on D32.What and why
Stage 8 of Lanterns: a shadow map, the way a title draws one.
vs_lanterns, no pixel shader, no render target,DepthBias1000 andSlopeScaledDepthBias3 in the PSO) draws the solids from a directional light into a 512x512R32_TYPELESSmap: aD32_FLOATDSV, anR32_FLOATSRV.ps_lanterns_shadowmoves the world position into light space (three rows after the camera matrix in the root CBV). It takes four comparison taps half a texel apart withimage_sample_c(LESS_EQUAL, point) and scales the face colour by 3/8 + 5/32 per lit tap.lanterns_shadow.hrasterizes the map on the CPU (fragments()now takes a target size). It bounds each texel's stored depth (coverage, tolerance, bias anywhere D3D12 and Vulkan allow) and each tap's texel (1/64 texel). A pixel whose four taps are all certain has one exact colour.docs/lanterns.mdgets the stage 8 section and its row in the stages table.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 Nfor every stage on the branch (each run in its own folder; the runner stops the prefix's wineserver before each launch).--stage 8: exit 0:Lanterns stage 8: PASS, 95699 of 95699 single-colour pixels exact and 98144 of 98144 certain pixels within bounds (D32 shadow map, PSO depth bias, 2x2 PCF with comparison samples), the map cleared to far changed 9539 pixels as predicted.ps_lanterns_shadow.asmrepacked with the PCF base factor 3/8 changed to 1/2: 45,501 of 95,699 single-colour pixels exact, 46,632 of 98,144 certain pixels within bounds;stage 8 FAILED, exit 1. Reverted afterwards.--stage 1on this branch: the same line as Lanterns (2/n): stage 1, a title-shaped guest through gta6rt --run with FSSM shaders, depth/stencil solids and shared edges (TEST-1063) #4863,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.97675 and 97664 of 98304 pixels exact ... points moved 14839 pixels; stage 6:98144 of 98144 ...).-W error:test_run_lanterns,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;compileallclean.Not covered
Credits
image_sample_cin the translator, which lets all four taps use the implicit-LOD comparison sample.AI-assisted (Claude Code). No game files.