Shaders: keep pixel helper lanes out of wave-first loops and quad permutes #895
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!895
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-895"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@sagouindupm on GitHub · 2026-11-25 12:07 UTC · original
sagouindupm:pixel-helper-lanes→main· +198 −3 · 3 files · 1 commits · openPorts two complementary pixel-shader helper-lane fixes onto
main(f85101b), both fromGPL-3.0-or-laterupstreams/forks:helpers_read): Inds_swizzle_b32and DPP instructions, pixel quad permutations (quad) now lower throughquad_pick(dx.op.quadReadLaneAt.i32) instead of wave-widewaveReadLaneAt, regardless of whether the shader hasdiscards. At triangle edges, neighboring lanes of a 2x2 quad are helper lanes that quad reads see cleanly whereas wave reads exclude them. (Adapted fromBelobug/VIctory-Belobug-AMDcommit03629f3f.)v_readfirstlane_b32(helper_reads_own): Guardv_readfirstlane_b32results in pixel shaders withdx.op.isHelperLane.i1(SM 6.6 opcode221) so helper lanes read their own value instead of spinning when only helper lanes remain in a waterfall loop (WaveReadLaneFirstignoring helper lanes). Computes remain unchanged. (Ported fromMarvisak/VIctoryPR#1733/ commit0601955byVax.)Summary of changes
crates/victory-shader/src/emit/lower.rs: Addhelpers_readandhelper_reads_own; applyhelpers_read(quad)inds_swizzle_b32anddpp, and wrapv_readfirstlane_b32results (includingVICTORY_FIRSTLANE_OWN=1path) withhelper_reads_own.crates/victory-shader/src/emit/bitcode.rs&crates/victory-shader/src/emit/mod.rs: Expose#[cfg(test)] Module::func_names()andLowered::funcs, and add unit testspixel_readfirstlane_uses_is_helper_lane_and_compute_does_notandpixel_quad_swizzle_without_discards_uses_quad_read_lane_atvalidated throughdxil.dll.Attribution
Vax/Marvisak/VIctoryPR#1733(0601955,GPL-3.0-or-later)Belobug/VIctory-Belobug-AMDcommit03629f3f(GPL-3.0-or-later)Verification
Run on Windows 11 Pro (x86_64-pc-windows-msvc, Rust 1.98.1,
dxil.dllpresent):cargo test --release -j 6 -p victory-shader -- barycentric_tests --test-threads=1-> 10 passed; 0 failed (including both new tests +dxil.dllvalidation).cargo test --release -j 6 -p victory-shader -- waterfall_tests --test-threads=1-> all passed; 0 failed.cargo test --release -j 6 -p victory-shader -- wave64_tests --test-threads=1-> 6 passed; 0 failed.cargo clippy -j 6 -p victory-shader --all-targets --no-deps -- -D warnings-> 0 warnings, exit 0.cargo run -j 6 -p xtask -- policy->asset policy: 175 files ok.AI-assisted: ported to
origin/main(f85101b), tested withdxil.dllvalidation, and written with AI assistance.@UwUCammie on GitHub · 2026-11-25 14:03 UTC · original
Ran this on AMD with 64-lane waves, since the description only has Windows test runs.
Setup: RX 7900 XT, RADV (Mesa 26.3.1), Wine 11.22 with vkd3d-proton from GE-Proton11-14, diagnostics build. Tree:
f85101bmerged into myokex/victory-amd, with #737 and #917, and this PR'sf1d44b2picked on top (no conflict).So nothing breaks on RADV with it; whether it fixes something visible I couldn't tell from these scenes.
@HailLucifer666 on GitHub · 2026-11-25 22:42 UTC · original
/keereview — the two fixes look right in isolation; what's missing is the measure of how much emission they change.Scope.
helpers_read(quad)returnsquad && self.s.pixel, somesh_quad || self.helpers_read(quad)now routes every pixel shader'sds_swizzle_b32and DPP quad reads throughquadReadLaneAt, not only shaders withdiscard. That is the intended fix, but it is a whole-pipeline change to emitted DXIL with no count of how many shaders change, and no before/after on a capture. #995 in this repo answers exactly this — "the emitted code changed for 18,136 of those previously valid shaders" — and that is the sentence this PR needs.Second path.
helper_reads_ownis applied at bothv_readfirstlane_b32sites, including the non-waterfall one, so a pixel shader whose helper lanes read first-lane values outside a loop also changes. The module comment explains the waterfall loop; say why the general path is also right, or narrow it to the loop.Tests. The body's
-- barycentric_testsfilter does match both new tests, so those counts are real. The oddity is the module name: quad swizzle and first-lane reads are not barycentric, sobarycentric_testsis now a grab bag that hides them from anyone looking for first-lane coverage. The assertions themselves are good:func_names()is a real check that the intrinsic was declared, andvalidatethroughdxil.dllis the right gate.Attribution to #1733/
03629f3fis clear.@gmankab on GitHub · 2026-11-26 08:01 UTC · original
I ported the original #1733 first-lane change to our Wine-free Linux branch, preserving Vax's author credit. The native regression translates a source-built pixel shader, checks for both the wave read and helper-lane test, and creates its host graphics pipeline. Microsoft’s DXIL validator and Vulkan validation accepted it on RADV and Lavapipe. This covers the first-lane change separately from the quad-read changes in this PR. Native test branch
In the headless Lavapipe title run, the last captured frame was 800 and still showed illustrated loading. Both the control and this build exited at the same title-side null write, roughly five minutes after launch. I have no open-world performance measurement from this experiment.
Tested-on: Radeon RX 6800 and Lavapipe, Fedora Linux 45, native vkd3d-proton with Vulkan validation
Assisted-by: gpt-6.2 sol xhigh
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.