Shaders: track per-lane export state across mixed pixel-shader joins #1473
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1473
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1473"
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?
@Texbirds on GitHub · 2026-11-24 18:17 UTC · original
Texbirds:fix/shader-mixed-export-discard→main· +201 −19 · 2 files · 1 commits · openProblem
In
crates/victory-shader/src/emit/lower.rs, pixel-shader exit lowering trackedexported[b]as a single boolean (preds.all(exported_out)). When an exporting branch and a killed/non-exporting branch merge into a shareds_endpgmblockb,exported[b]evaluates tofalse, andLaneExit::Endemitsdx.op.discard(true)unconditionally—discarding pixels that already exported valid color. Single-pass RPO evaluation can also under-approximateexported[b]across loop back-edges.Fix
exported: Vec<bool>withExportState::{Never, Always, Dynamic(V)}computed via a fixpoint over reachable blocks (allandanypaths having executed adoneexport).Always) and uniformly killed (Never) exit blocks emit the exact same DXIL as before with zero extra overhead.Dynamic(phi)) allocate ani1phi filled infill_phisand emitdx.op.discard(!exported)atLaneExit::End, discarding only the lanes that never exported.@sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head 826a97f onto
mainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 120, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 03:28 UTC · original · edited 2026-11-25 16:44 UTC
Automated triage for the maintainers.
Merge candidate.
In
emit/lower.rs, theexported: Vec<bool>per block becomesExportState::{Never, Always, Dynamic(i1 phi)}. It is computed by two fixpoints over reachable blocks: a greatest fixpoint for "every path exported" and a least one for "some path exported".LaneExit::Endnow discards only the lanes whose phi says they never exported, so it no longer kills every lane at a mixed join. Uniform exits emit the same DXIL as before. The phi incomings infill_phisuse the sametail/edgespattern as the other phis there. The two points from the earlier review are addressed: there is noxoron the kill value, and the new testmixed_export_join_discards_only_non_exporting_lanesdraws on hardware and on WARP. It checks that skipped lanes are discarded and that exporting lanes keep their colour. The rebase onto67e8ae1only keptEntryAddressnext to the new enum.CI (
check): passing.Generated by Claude Code
@Texbirds on GitHub · 2026-11-25 12:14 UTC · original
Rebased onto
main(940d32f) and addressed both triage points in836ce81(CIcheckis now passing):xoron the kill condition:ExportState::Dynamic(V)now trackskilled: i1directly (falsefromhas_done_export/Alwayspredecessors,truefromNeverpredecessors) and passes the phi straight todx.op.discard.mixed_export_join_discards_only_non_exporting_lanes): Models the console pattern wherev_cmpx_lt_f32narrowsEXECands_cbranch_execzjumps pastexp mrt0 ... donestraight to a shareds_endpgm, creating a mixed join at the exit block. The test lowers the pixel shader, validates the DXIL withdxil.dll, and renders a 16×16 target on hardware + WARP verifying that lanes skipping the export (x < 4) are discarded ([0.0; 4]) while exporting lanes (x >= 4) keep their exported color ([1.0, 0.5, 0.0, 1.0]).@Texbirds on GitHub · 2026-11-25 16:31 UTC · original
Rebased onto
main(67e8ae1) in6d80495. The only conflict was the newEntryAddresstype alias next toExportState, and I kept both.ExportState, the kill phi andmixed_export_join_discards_only_non_exporting_lanesare unchanged from836ce81.@catminou4 on GitHub · 2026-11-24 18:42 UTC · original · approved these changes
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e),cargo test -p victory-shader --locked→ 96 passed, 0 failed. Execution/valu tests are#[cfg(all(test, windows))]and were not run here; lowering/structure coverage only.Per-lane export state for mixed pixel-shader joins:
exportedbecomesNever/Always/Dynamic(i1 phi)computed byall/anyfixpoints over reachable preds (loop-safe, unlike the old single RPO pass), andLaneExit::Enddiscards withxor(exported, true)so only non-exported lanes are killed at a mixed join. The phi is filled from each pred's state (has_done_export→ true). Static review checks out; the behavior is only observable in execution tests (Windows-only) — please confirm with the valu suite before merge.@fuzeofficlal on GitHub · 2026-11-26 18:47 UTC · original · approved these changes
Verified
6d804953989fef73d22430d43c58a4a67084e509cleanly merged ontomain(63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP + Windows SDKdxil.dll):ExportState::{Never, Always, Dynamic(V)}(crates/victory-shader/src/emit/lower.rs:188-195, 1336-1392) computes the per-block export state via greatest/least fixpoints across reachable predecessors (including back-edges), fillskilled: i1PHIs directly throughtail/edgeswithout anxor, and emits no duplicate output stores atLaneExit::End.emit/lower.rsreaches 523,916 B on63bcca43(only 372 B below the 524,288 B cap, so merge ordering with otherlower.rsPRs or splitting tests out should be kept in mind).cargo test -p xtask --locked policy::tests::repository_passes_policy:1 passed(asset policy: 191 files ok).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) is clean;emit::tests::mixed_export_join_discards_only_non_exporting_lanes(0.32son RTX 5090),emit::tests::(18 passed, 0 failedon both RTX 5090 and WARP), andemit::lower::tests::(33 passed, 0 failedon both RTX 5090 and WARP) all pass.Ready to merge (noting the tight 372 B headroom on
emit/lower.rs).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.