Skip to content

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

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

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge candidate) was for an older state of main.


Generated by Claude Code

@powplusplus

Copy link
Copy Markdown
Author

Closing as superseded by e8e9f0c and 4a3166e on main, which cover this with stricter uniform_join / no_mask_lane_on_edge guards.

@powplusplus
powplusplus deleted the shader/traversal-lane-masks branch November 26, 2026 11:38
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