Shaders: track per-lane export state across mixed pixel-shader joins #1472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-24T18:17:49Z.
Problem
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.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T18:42:13Z.
Review: APPROVED
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.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:13:36Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
826a97fontomainffe310e(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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:28:32Z.
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
upstream-sync referenced this pull request2026-11-25 06:02:40 +00:00
Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-25T12:14:44Z.
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]).Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-25T16:31:45Z.
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.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:47:26Z.
Review: APPROVED
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).Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T00:32:12Z.
Review: APPROVED
LGTM — verified on Windows (RTX 5090 + WARP):
cargo test -p victory-shader --lib emit::tests::passed (18/18, including the newmixed_export_join_discards_only_non_exporting_lanes)cargo test -p victory-shader --lib emit::lower::tests::passed (33/33)ExportState::{Never, Always, Dynamic(phi)}dataflow tracking cleanly avoids discarding already-exported lanes at mixed pixel-shader joins intos_endpgmcargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.