Shaders: one back edge per block, for the dxil-spirv in Proton #2975
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2977"
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 neonbyte1 on 2026-11-26T02:03:59Z.
A latch block that branches back to both its own loop's header and the outer loop's makes dxil-spirv recurse until its stack runs out in
LoopMergeTracer::trace_from_parent, when the shader also reads other lanes. The pipeline creation never returns. I reported it as HansKristian-Work/dxil-spirv#380; the fix there (#381) isn't in any vkd3d-proton release yet, and the vkd3d-proton GE-Proton ships pins the affected dxil-spirv.DXC never emits this shape, because its loops get a latch per back edge. So the translator now does the same:
Translation over the whole shader pack: the emitted counts per stage are unchanged, and 9 programs emit different DXIL. Those are the 9 that had such blocks:
InstanceCulling:CS_Prop_BatchNoCull,CS_Prop_BatchCullReflect,CS_Tree_BatchNoCull,CS_Tree_BatchCullReflectShallowWaterSim:CS_PreSim,CS_PreSimWithDisturb,CS_SurfaceWaveSimUpdateWaterSimMgr:CS_UpdateDynamicFoamindirect_light_probes:CS_IrradianceCache_SpatialFilter_SeparableByte-identical everywhere else.
Pipelines (RTX 5090, driver 620.73.04, Wine 11.22, vkd3d-proton 3.1-83 from GE-Proton11-14,
victory translate --pipelinesonCS_Prop_BatchNoCull's container, shader cache off):mainthese programs are 64-lane waves, which a 32-lane host refuses before the converter runs. The hang appears once they're allowed in the console flow, as with #233/#439.mainwith #233/#320/#439 and this change), every instance-culling pipeline the title asks for is made.Tests: two new ones,
a_latch_branches_back_to_one_header(lowering) andan_inner_latch_keeps_the_outer_latch(writer).victory-shaderunder Wine: 300 passed and 4 failed, against 298/4 onmain; the same 4 Wine failures, fixed by #2968, #2973 and #1266. Clippy (with and withoutdiagnostics) andcargo xtask policyare clean.Not tested on Windows. There, DXC-shaped loops are simply what the driver usually sees, so I don't expect a change beyond the 9 programs.
AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:26:32Z.
Review: COMMENTED
Verified both layers of the dxil-spirv#380 fix. Lowering: when a conditional has back edges to two different headers, the outer (lower rpo) edge goes through a dedicated latch block that counts the iteration itself — so the inner edge keeps normal counting and no block branches back twice. The plan() pass is the safety net: any written block that would still reach two back-edge headers un-folds the extra successors. Both the unit test (folded empty outer latch stays a block) and the real GCN nest test assert <=1 back header everywhere.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:26:51Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 (RTX 5090 + WARP +dxil.dll,VICTORY_D3D12_DEBUG=1) — clean CFG transformation and ready to merge:lower.rs:10197-10239, 10320-10334vialatch(b, to)updatesself.edges,fill_phis,pending_masks, andcountersconsistently, andbitcode.rs:738-756prevents empty-block folding from re-creating multi-back-edge headers without breakingplan.srcPHI mappings or irreducible-loop splits.63bcca43,emit/lower.rsreaches 523,660 B (only 628 B below524,288 B), so merging after any otherlower.rsPR will require moving helpers to a submodule.Local verification:
victory-shader(ir::,structure::,emit::bitcode::,emit::lower::tests,emit::flow_tests,emit::crosslane_tests,emit::synthetic_tests,emit::semantics_tests): 119 passed (only failure is pre-existing RTX 5090 baselinegathers_at_a_level_match_the_hardware), including both new latch testscargo clippy --locked -p victory-shader --tests -- -D warnings(default &--all-features) +cargo xtask policy(191 files ok): 0 warningsImported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T03:38:06Z.
Thanks, good catch on the size. For whoever merges: this PR and #2968 both grow
emit/lower.rs. On63bcca43the file is 520,563 bytes; #2968 adds 601 and this one 3,097, which together leaves about 27 bytes under the 512 KiB limit. Any furtherlower.rschange after both will need the file split (moving itsmod testsout, as some branches already do). If you'd rather have that split in this PR, I can add it.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:33:19Z.
Automated triage for the maintainers.
Needs work; needs the maintainer's decision. This gives an inner latch that also continues the outer loop its own counted latch (
Lower::latchinlower.rs). Inbitcode.rs, the plan's folding no longer folds that latch back in, so no written block branches back to two headers. The code reads consistently, and the two tests check that shape.On your reply:
d9f1861differs froma9ad776only in that line's indentation oncount_iteration.lower.rssize: settled by #3097, which moves the tests out oflower.rs. With #3097 this PR no longer needs to split the file itself.What would still help: a pipeline run of the 9 changed programs on a Windows host (native D3D12), from anyone who has one, to show the new shape costs nothing there.
CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T07:26:48Z.
Fixed the doc comment's indentation on
count_iteration(amended, same single commit).On the other points:
CS_Prop_BatchNoCulland the other instance-culling pipelines never finish building under Proton, and the game waits on them.lower.rssize: happy to move itsmod testsintolower_tests.rs(#[path], as some branches do) in a separate PR, so this one stays reviewable. Say if you'd prefer it here.Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T07:46:44Z.
The
lower.rstest move is now its own PR, #3097:lower.rsgoes to 468,320 bytes, so this PR and #2968 both fit with room to spare. The tests are unchanged, 33 before and after.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:26:46Z.
Review: APPROVED
Re-reviewed at
d9f18613fa942025faa5f77f5be6a17fff04841eagainstmain(63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP + Windows SDKdxil.dll) — thecount_iterationdoc-comment indentation fix is clean and the PR is ready to approve.Verified locally on
d9f18613fa:crates/victory-shader/src/emit/lower.rsis 523,664 B (624 B below the 524,288 B cap, so coordinating merge order with #3097 or splitting tests remains important if anotherlower.rschange lands first).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): clean.VICTORY_WARP=0, skipping the pre-existingheap_direct_texture_reads_mark_their_heap_indexcrash):300 passed; 3 failed; 3 ignored; 1 filtered out(the same 3 pre-existing RTX 5090 failures asmain;emit::flow_tests,emit::diff_tests,emit::tests::constant_color_validates,a_latch_branches_back_to_one_header, andan_inner_latch_keeps_the_outer_latchall pass).VICTORY_WARP=1):300 passed; 4 failed; 3 ignored(the exact 4 pre-existing WARP wave-of-32/gather failures asmain).One minor non-blocking note on
lower.rs:10208-10226: when an inner-loop back edge reachesLOOP_LIMIT, theAnd/Orgate sends those lanes intoLower::latchfor the outer header, which re-enters the outer loop if the outer counter is still belowLOOP_LIMIT(still bounded by outerLOOP_LIMIT, and an improvement overmainwhere anot_takenback edge was uncounted).Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T23:14:32Z.
Status note: #2309 (one back edge per loop header,
single_latches/redirectin the writer) covers the same case more generally, on the #439 stack. In game it let six ray-traced shadow pipelines build that overflowed dxil-spirv's recursion before (details on #2309). This PR stays useful as the standalone fix formainwithout #439: on its own it changes 9 programs, none of those six. If #2309 lands, I'll close this one; if a maintainer prefers, I can fold it into #2309 instead.AI-assisted (Claude); no game data shared.
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.