Skip to content

Lanterns (6/n): stage 5, an fp16 render target with a two-pass compute bloom (TEST-1063) - #4873

Open
tedin7 wants to merge 33 commits into
ItsNotRexed:mainfrom
tedin7:lanterns-stage5
Open

tedin7 wants to merge 33 commits into
ItsNotRexed:mainfrom
tedin7:lanterns-stage5

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-1063, #4816 (comment) (the Lanterns proposal; this is piece 6)

Depends on: #4871 (Lanterns stage 8, and through it #4869, #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 on main with the pieces before it): an R16G16B16A16_FLOAT render target, compute on the direct queue with image_load from a T#, LDS and s_barrier in wave64 compute shaders (translated with --wave64-emulate), a pixel shader reading SV_Position, and an R32G32B32A32_FLOAT target. It does not implement or duplicate a layer method; it does not need the PSO subgroup-size control of D3D-58 (#609). This is the direct form: the points are drawn with the plain DrawIndexedInstanced of stage 3, not through ExecuteIndirect, so it does not wait for #1865.

What and why

Stage 5 of Lanterns: render to an fp16 target and post-process it, as a title's bloom does.

  • The stage-3 scene (the points after two rounds of compute steps, drawn with stage 3's direct DrawIndexedInstanced calls) is drawn into an R16G16B16A16_FLOAT target. A Post object then records on the same queue:
    • cs_lanterns_bloom_h (wave32, 4 waves; every summed sample is written by another wave, so s_barrier is the only ordering) and cs_lanterns_bloom_v (wave64, 128 lanes in two waves): sharing LDS (ds_write_b128 / ds_read_b128 across s_barrier, halos under s_and_saveexec_b64). They read the scene through a T# (image_load), threshold and quantize it, and run a 9-tap binomial blur along rows, then along columns.
    • ps_lanterns_composite (with vs_lanterns_full): reads SV_Position, the scene texel and the blur, and writes into an R32G32B32A32_FLOAT target.
  • lanterns_post.h is the CPU reference. It works in exact integer steps, checked against double. Where the scene is uncertain it carries per-pixel bounds through the monotone blur.
  • Checks: the points equal the CPU's after 48 steps; the fp16 scene is exact; the final frame is exact on certain pixels and inside the bounds elsewhere. Control: with the blur skipped, exactly the predicted pixels change. The row pass without s_barrier is measured and reported, not required.

docs/lanterns.md gets the stage 5 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, targets gta6rt lanterns, run_lanterns.py --wine --stage N for every stage on the branch (each run in its own folder; the runner stops the prefix's wineserver before each launch).

  • --stage 5: exit 0:
    Lanterns stage 5: PASS, fp16 scene 97664 of 97664 certain pixels exact, bloom composite 82563 of 82563 certain pixels exact and 15741 bounded pixels within bounds, skipping the blur changed 15113 pixels as predicted.
    • The points: 256 of 256 states and 256 of 256 instance records equal the CPU's after two rounds of steps.
    • The fp16 scene: 97,664 of 97,664 certain pixels exact, 640 of 640 uncertain pixels one of their candidates.
    • Control: with the blur skipped, 15,113 certain pixels differ, as the reference predicts.
    • Measured: the row pass without its s_barrier: 8,449 to 14,849 certain pixels differ across 6 runs (measured, not required). With the s_barrier deleted from the real row pass, the stage fails (3 of 3 runs).
  • Falsified: cs_lanterns_bloom_h.asm repacked with the threshold -0.625 changed to -0.5: final frame 67,182 of 82,563 certain pixels exact, 624 of 15,741 bounded pixels within bounds; stage 5 FAILED, exit 1. Reverted afterwards.
  • --stage 1 on 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.
  • The earlier stages on this branch pass with their own lines (stage 3: 97675 and 97664 of 98304 pixels exact ... points moved 14839 pixels; stage 6: 98144 of 98144 ...; stage 8: 95699 of 95699 ...).
  • From the branch head, all OK under -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; compileall clean.

Not covered

  • Tested on one machine only: RTX 5080, Linux, Wine 11. No native Windows run, no AMD or Intel GPU yet.
  • No validation claim. Vulkan validation layers under Wine on that machine are still being looked into.
  • Offscreen frames only. No present, no frame loop.
  • The FSSM programs are synthetic. They carry only the fields the tools read, and the code is ours.
  • The reference is computed on the CPU, not by another D3D12 implementation.
  • The column pass (wave64) runs translated with --wave64-emulate; the row pass is wave32. The native wave64 translation is not checked here.

Credits

AI-assisted (Claude Code). No game files.

…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.
…cess

- The stage-3 scene (the points after two rounds of compute steps, drawn
  with the direct DrawIndexedInstanced calls of stage 3) is drawn into an
  R16G16B16A16_FLOAT target. A Post object then records on the same queue:
  - cs_lanterns_bloom_h and cs_lanterns_bloom_v: wave64, 128 lanes in two
    waves sharing LDS (ds_write_b128 / ds_read_b128 across s_barrier, halos
    under s_and_saveexec_b64). They read the scene through a T#
    (image_load), threshold and quantize it, and run a 9-tap binomial blur
    along rows, then along columns.
  - ps_lanterns_composite (with vs_lanterns_full): reads SV_Position, the
    scene texel and the blur, and writes into an R32G32B32A32_FLOAT target.
- lanterns_post.h is the CPU reference. It works in exact integer steps,
  checked against double. Where the scene is uncertain it carries per-pixel
  bounds through the monotone blur.
- Checks: the points equal the CPU's after 48 steps; the fp16 scene is
  exact; the final frame is exact on certain pixels and inside the bounds
  elsewhere. Control: with the blur skipped, exactly the predicted pixels
  change. The row pass without s_barrier is measured and reported.
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.
@KubickNubick

Copy link
Copy Markdown

Tested 6836fe8 merged with main 3faac55 (clean merge) on native Windows 11 Pro 26300, MSVC 19.51, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6 (scripts/build_llvm_mc.ps1), -DLEONIDA_TEST_LANTERNS=ON: pass on both GPUs. No build warnings.

Stage NVIDIA RTX 4080 (621.01, subgroup 32..32) AMD Radeon iGPU, Ryzen 9 9950X3D (RDNA2, 32.0.21042.62, subgroup 32..64)
1 PASS, 97926 of 98304 exact, 378 edge pixels plausible, depth-off control 11610; shared edges 98304 of 98304 exact, 673 centres each drawn once same
3 PASS, 97675 and 97664 of 98304 exact, 256 points exact after 24 and 48 steps, points moved 14839 same
5 PASS, fp16 scene 97664 of 97664 exact, composite 82563 of 82563 exact and 15741 within bounds, blur skipped changed 15113 same
6 PASS, 98144 of 98144 within bounds, two mips down moved 10221 of 10221 same
8 PASS, 95699 of 95699 exact and 98144 of 98144 within bounds, map cleared to far changed 9539 same

Stage 5, measured: the row pass without s_barrier changed 0 certain pixels on both GPUs.

run_lanterns.py --stage N per stage, LEONIDA_VK_DEVICE=4080 / radeon; the device line confirmed the GPU in each run. tests/test_fssm_pack.py, test_fssm_pack_chain.py, test_run_lanterns.py: 17 passed, 4 skipped (POSIX-only launcher).

This also covers the stage 1 shared-edge draw of #4863 (13175c9 is in this stack): it passes on both GPUs here.

Baseline on main 3faac55, scripts/run_gpu_tests.py: RTX 4080 170/217 native and 201/217 with LEONIDA_W64_EMULATE=1, Radeon iGPU 201/217, 0 failures.

AI-assisted (Claude Code built and ran the tests).

@tupacfan04

Copy link
Copy Markdown
Contributor

Independent native Windows run at 6836fe8 (stage 5 only).

Environment: Windows 11 Pro 26300, MSVC 19.51.36260.0, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, NVIDIA RTX 5070 driver 621.24. llvm-mc was built with scripts/build_llvm_mc.ps1 (LLVM 21.1.8, AMDGPU-only); no Wine.

  • Configured -DLEONIDA_TEST_LANTERNS=ON and built gta6rt plus lanterns. The shader pack translated all 16 shaders (including vs_lanterns_w64 and the two bloom compute shaders).
  • run_lanterns.py --stage 5 native, exit 0, PASS: fp16 scene 97664 of 97664 certain pixels exact; composite 82563 of 82563 certain pixels exact and 15741 bounded pixels within bounds; the blur-skipped control changed 15113 pixels as predicted; the row pass without s_barrier changed 0 certain pixels.
  • Repeated with LEONIDA_VK_VALIDATION=1 (and VK_LOADER_DEBUG=layer): same PASS counts, exit 0, no VUID/validation messages. The loader log confirms VkLayer_khronos_validation.dll was loaded. The device reports subgroup sizes 32..32, so vs_lanterns_w64 and ps_lanterns_lit_w64 print the expected “cannot require 64” warnings; stage 5 still passes on this device.

Synthetic fixtures only; no game data. AI-assisted (Claude Code built and ran it).

KubickNubick ran the stack on an RTX 4080 and an AMD Radeon RDNA2 iGPU
under Windows and found that the row pass without its s_barrier changed
0 certain pixels on both: the stage could not catch a missing barrier.

Two reasons, both fixed in cs_lanterns_bloom_h:
- Each lane summed mostly samples its own wave had loaded. Now lane i
  loads sample (i + 64) mod 128 of the segment and the halos come from
  the other half too, so every sample a lane sums was written by another
  wave. The second half also walks four dependent fetches (each adding 0)
  before its write, so that write lands late.
- As a wave64 program translated with --wave64-emulate, the pass ran in
  rounds that already put every LDS write before a later LDS read, so
  the barrier could not matter. The row pass is now wave32 (four waves),
  where s_barrier is the workgroup barrier and nothing else orders them.

RTX 5080: stage 5 passes with the same line; the measured no-barrier
variant now changes 8,449 to 14,849 certain pixels (five runs, was 0),
and the row pass with its s_barrier deleted fails the stage in 3 of 3
runs. The column pass stays wave64.
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @KubickNubick, your no-barrier measurement found a real hole, and bb011b4d fixes it (credited in the commit).

The barrier could never matter as written, for two reasons:

  • Most summed samples came from the lane's own wave.
  • Under --wave64-emulate, the translator runs a wave64 workgroup in rounds, and the generated SPIR-V already orders each LDS write before later reads even with s_barrier removed. So no wave64 reshaping could expose it.

Now the row pass is wave32 with 4 waves. Every summed sample is written by another wave, and the writing half takes four dependent fetches before its write, so s_barrier is the only thing ordering them. The column pass stays wave64.

On the RTX 5080:

  • Stage 5 passes as before.
  • The measured no-barrier variant now changes 8,449 to 14,849 certain pixels over 6 runs, where it changed 0 before.
  • With s_barrier deleted from the real row pass, the stage fails 3 of 3 runs.

Stages 1, 3, 6 and 8 still pass on top.

@KubickNubick

Copy link
Copy Markdown

Re-tested at bb011b4 merged with main 3faac55 (clean merge), same machine and tools as before (Windows 11 Pro 26300, MSVC 19.51, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6), shaders rebuilt (cs_lanterns_bloom_h and _nobarrier now wave32, cs_lanterns_bloom_v wave64): pass on both GPUs, and the no-barrier variant now differs on both.

Stage 5, six runs per GPU, every run PASS with the same counts as before (fp16 scene 97664 of 97664 exact, composite 82563 of 82563 exact and 15741 within bounds, blur skipped changed 15113):

GPU Row pass without s_barrier, certain pixels that differ, runs 1 to 6
NVIDIA RTX 4080 (621.01, subgroup 32..32) 29783, 8177, 30151, 8321, 31937, 32263
AMD Radeon iGPU, Ryzen 9 9950X3D (RDNA2, 32.0.21042.62, subgroup 32..64) 28531, 29841, 29576, 30372, 29161, 30621

It was 0 on both at 6836fe8. The RTX 4080 goes above the 8,449 to 14,849 you measured on the RTX 5080.

Stages 1, 3, 6 and 8: PASS on both GPUs, same counts as in my first comment. No build warnings.

Not tested: deleting s_barrier from the real row pass (your 3 of 3 failing runs); I ran only what the branch builds.

AI-assisted (Claude Code built and ran the tests).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @gertify. Stage 1 passing on the UHD 770 confirms PingasMech's DEFAULT-heap fix.

Stage 5 stops at the second CreateCommandQueue ("no independent Vulkan queue available"). That is the layer gap, not Lanterns: the UHD 770's family exposes one queue, and the layer gives every D3D12 queue its own VkQueue. I claimed the fix (D3D12 queues sharing a VkQueue when none is free), and it is in review. I'll link it here when it is open, so you or PingasMech can rerun stage 5 on it.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The queue-sharing fix is open as #5110. @gertify, @PingasMech: on the UHD 770, stage 3 and stage 5 of this stack should now get past the second CreateCommandQueue with that PR merged in. A rerun of stage 5 there would confirm it on the hardware it was written for.

@lunarminus

Copy link
Copy Markdown

Tested bb011b4d merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: Lanterns stages not run (they need the Windows gta6rt); the offline checks and the GPU suite pass.

  • Merge: the merge was a fast-forward, so the tree I tested is bb011b4d itself. That includes main up to 0db7fed5.
  • Why the Lanterns stages didn't run: the Linux configure prints "gta6rt requires Windows; only Vulkan tools are available on Linux". This machine has no xwin SDK for the clang-cl cross-build. So run_lanterns.py --stage 1/3/5/6/8 and the stage 5 no-barrier control did not run here, and this is not a RADV data point for stage 5.
  • Linux runtime build (RelWithDebInfo): clean, 0 warnings.
  • PR tests:
    • tests/test_fssm_pack.py: 10 OK.
    • tests/test_run_lanterns.py: 5 OK.
    • pytest over test_fssm_pack_chain.py, test_fssm_pack.py and test_run_lanterns.py (llvm-mc 23.1.5): 21 passed, 24 subtests, 0 skipped.
  • Guard tests: compileall, test_runtime_paths, test_ci_registration, test_docs_links, test_docs_repo_paths, test_docs_list_items, test_docs_table_rows, test_text_encoding and test_text_write_line_endings all OK.
  • Shaders, offline only: packing and translating the 16 Lanterns shaders with the CMake rule's command (fssm_pack.py --translate --wave64-emulate, llvm-mc 23.1.5) gives 16/16 translated and 16/16 spirv-val (vulkan1.3) clean.
  • GPU suite: scripts/run_gpu_tests.py gives 202/217 passed, 15 skipped, 0 failed, both without and with LEONIDA_W64_EMULATE=1.
  • Per-test comparison with d0835dd9 without the PR (196/210, 14 skipped, both modes):
    • No test changed state in either mode.
    • The only differences are 7 fixtures the baseline doesn't have. Six pass (cs_smem_sconst_off, ps_far_branch, ps_sample_c, ps_sample_c_b, ps_texture_b_cl, ps_texture_cl) and ps_m2_literal is skipped (run by d3d12_m2_textured_test).
    • All 7 came in with main between d0835dd9 and 0db7fed5, not with this PR.

AI-assisted (Claude Code).

…differ, not only how many

The control compared only the count of certain pixels that differ with the
skipped blur against the count the reference predicts. A displaced mask of the
same size would have passed. The reference now keeps the mask of the pixels
the bloom changes, and misplaced_differences counts the certain pixels that
break it in either direction. The stage fails unless that count is 0.

Found by kacper-serewis in review of PR ItsNotRexed#4873.
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @kacper-serewis, you were right: stage 5's skipped-blur control compared only how many pixels differ, so a mask of the same size in the wrong place would have passed.

15648aed adds misplaced_differences. It counts the certain pixels the bloom should change but the frame leaves equal, plus the ones it should leave alone but the frame changes. The stage fails unless that count is 0.

  • RTX 5080 (Wine 11): stage 5 passes, with 15113 certain pixels differing (15113 predicted) and 0 in the wrong place. Stages 1 and 3 still pass.
  • Negative control: a 15113-pixel mask placed outside the predicted set matches the old count exactly. The new check scores it 30226 misplaced and the stage fails.

AI-assisted.

@Atomic258

Copy link
Copy Markdown

Tested 15648ae on Windows Server 2022, CPython 3.13.12: pass

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 15648ae on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass

  • Built runtime/ with -DLEONIDA_TEST_LANTERNS=ON (RelWithDebInfo, MSVC 19.44, llvm-mc 21.0 from ROCm 7.1, spirv-as from Vulkan SDK 1.4.363.1). 547 targets, no failure.
  • python -I runtime/test/lanterns/run_lanterns.py for stage 5 (three runs), then stages 1, 3, 6, 8 (one run each), absolute paths. Every run exit 0, 1.0 to 2.1 s.
  • Stage 5: PASS in all three runs. fp16 scene 97664 of 97664 certain pixels exact. Bloom composite 82563 of 82563 certain pixels exact, 15741 bounded pixels within bounds. Skipping the blur changed 15113 pixels, as the control predicts. This matches the figures in the PR.
  • Stages 1, 3, 6, 8 also PASS. The runtime reported the RX 9070 XT as the Vulkan device.
  • An RX 9070 XT result exists on this PR at the earlier head bb011b4; this one is on the current head.
  • Not done: other GPUs, Wine, ctest.

AI-assisted (Claude Code).

…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).
…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_bloom_h.asm, cs_lanterns_bloom_h_nobarrier.asm, cs_lanterns_bloom_v.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).
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Updated for main's #4312 (D3D-448): the Lanterns compute shaders follow the console compute layout now.

  • Main merged in, then one commit here: cs_lanterns_bloom_h.asm, cs_lanterns_bloom_h_nobarrier.asm, cs_lanterns_bloom_v.asm. Root arguments now start at s4. A descriptor table is one 32-bit dword. RSRC2's USER_SGPR counts 4 plus that span, and the thread-group ids follow it.
  • Each shader starts with a few s_mov_b32 that rebuild the layout its code was written for: the table as a 64-bit pair with a zero high half, then the constants and the group ids. The shader body itself is unchanged.
  • Without this, main's layout gave the old shaders a wrong table address, and the compute fence never signalled.
  • Checked on an RTX 5080 under Wine 11 from the top of the stack: stages 1, 3, 5, 9, 11, 20, 22, 23, 24 and 25 pass. The packer, runner and docs CPU tests pass on this branch.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants