Skip to content

Shaders: lane masks a traversal keeps as numbers - #1883

Open
powplusplus wants to merge 1 commit into
Marvisak:mainfrom
powplusplus:shader/traversal-lane-masks
Open

powplusplus wants to merge 1 commit into
Marvisak:mainfrom
powplusplus:shader/traversal-lane-masks

Conversation

@powplusplus

@powplusplus powplusplus commented Nov 25, 2026 •

Copy link
Copy Markdown

The ray-tracing shadow passes keep the lanes still walking the BVH in a lane mask, and push that mask on an LDS stack as a number. On main they stop at "a register joining a lane mask and data, read as data" (a register that holds the mask on one path and a popped number on the other, read as a number) or at "a lane-mask join of an untracked mask".

In compute, with console lanes (fill_phis):

  • a mask joined with a number is the mask's number (its ballot, or mask_number for one holding lanes elsewhere), as the console holds it;
  • a number joined with masks is a mask, each lane taking its own bit;
  • an edge along which no lane reads the register (never_taken, dead_on_edge) joins any mask, as data joins already take any number there.

Results

translate --validate over shaders.rpf against 70564ae: 45 more compute programs emit and validate (2,621 to 2,666), none lost.

  • RT shadows (32): CS_RTShadowTrace32HQ and its temporal, 1/2, 1/4 and 1/8 RPP, FarOnly and tiled variants (20), CS_RTDistantShadowTrace*_Tiled (4), CS_RTDistantLODLightShadow, CS_TraceShadowRays_* (Checkerboard, Eighth, Quarter, Half, FullAdaptive), CS_RaytraceShadows_Shared, CS_LaserLightShadowRaytracing.
  • Other traversals: CS_RaytraceVBuffer_ShaderBinning and _RayBinning_ShaderBinning_Shared (with and without far), CS_ScreenProbes_TraceRays_RayBinning_BVH_Shared_ShaderBinning (2), CS_DeferredGather_Shared_Wave32, CS_ComputeClosestDepth.
  • CS_Subdivision_* (5).

Under vkd3d-proton (RTX 3080, Proton), 35 of the 45 hang pipeline creation, each created on its own with a 120 s limit; 10 create pipelines. #1885 fixes the hang (one back edge per loop header, a larger stack for pipeline threads): with both, the 35 of the 45 run so far all create pipelines, 30 of them ones that hung.

Testing

  • A VALU test: a register holds vcc on one path and a number on the other and is read after the join; hardware adapter and WARP. main refuses it.
  • cargo test -p victory-shader under Proton (RTX 3080 and WARP): 205 passed. The 5 that fail (stub_pipeline_is_created, three in semantics_tests, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros) fail on main there too.
  • clippy, default and all features.
  • Not run in the title.

The ray-tracing passes keep the lanes still walking the BVH in a lane
mask, and push it on an LDS stack as a number. A register that holds a
mask on one path and a popped number on the other stopped the program
when it was read as a number, and a mask join with a number coming in
stopped it too.

In compute, with console lanes:
- a mask joined with a number is the mask's number, the console's own;
- a number joined with masks is a mask, each lane taking its bit;
- an edge along which no lane reads the register (one the compiler
  reuses) joins any mask, as it already joins any number.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Lane masks kept as numbers through traversal — extends the masks-as-data work (#1788); no regressions.

@zed6000

zed6000 commented Nov 25, 2026

Copy link
Copy Markdown

Measured offline on the title's shaders (the method in #1247): merged onto main 940d32f (a clean merge) and compared program by program (victory translate --validate --list, shaders.rpf 1.0.2.1, dxil.dll 1.8.2502).

+21 programs, 0 lost. On main they failed with "a register joining a lane mask and data, read as data" (16 of the 40 still failing for that reason) and "a lane-mask join of an untracked mask" (5). It also merges cleanly together with #1989, #1065 and #1971: the four together give +1,683 programs and 0 lost, and cargo test -p victory-shader --lib passes (252/0) on an RX 7900 XTX. Offline counts only; no program names or data.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

An independent offline count, with one addition to @zed6000's: what the programs this PR does not finish stop at next, and the result together with #2027.

Method: victory translate <shaders.rpf> --validate --list --jobs 6, release builds, Windows SDK 10.0.26100.0 dxil.dll, compared program by program (25,889 programs). CPU only; nothing was run on a GPU or in the title.

build not validated change against main
main 940d32f 1,971
+ this PR (a31d8cc, clean merge) 1,950 +21 compute, 0 lost
+ this PR + #2027 (34d0b4e, clean merge of both) 1,191 +780 compute, 0 lost

The 40 programs main refuses with a register joining a lane mask and data, read as data:

The 5 programs at a lane-mask join of an untracked mask that this PR clears are in the +21; one program is left at that reason after both PRs.

Not checked here: the value a joined mask reads on a GPU (the PR's own VALU test covers that; I ran no test), and pipeline creation.

A local copy of the title's shader archive was used for these counts, offline; only counts, program names and refusal reasons are given. AI-assisted.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate.

In crates/victory-shader/src/emit/lower.rs fill_phis, this handles two joins that main refuses, compute only. When a tracked lane mask meets a number and is read as data, it reads the mask's own number through the existing mask_dword (a ballot at the end of the block that writes the mask, which is why cur_ir is reset). When a mask join gets a number, each lane takes its own bit through lane_bit (console lanes, wave32 only). Edges that never_taken/dead_on_edge show nobody reads now take any mask, the same as data joins already do. I checked this against main: the new arms come after the dead-edge arm and the plain I32 arm, so joins that already worked are unchanged. With console lanes the ballot is the console's SGPR value bit for bit, because a VOPC write clears inactive lanes and the ballot sees only active ones. The new VALU test works out its expected value by hand (lane 0's bit vs. 0x55), not from the output.

Notes:

CI: no check runs on this head.


Generated by Claude Code

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants