Shaders: one back edge per block, for the dxil-spirv in Proton #2977
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!2977
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@neonbyte1 on GitHub · 2026-11-26 02:03 UTC · original
neonbyte1:pr/one-back-edge→main· +163 −5 · 2 files · 1 commits · openA 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.
a9ad7769detod9f18613fa@kotekompotek on GitHub · 2026-11-26 02:26 UTC · original · reviewed
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.
@fuzeofficlal on GitHub · 2026-11-26 02:26 UTC · original · reviewed
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 warnings@neonbyte1 on GitHub · 2026-11-26 03:38 UTC · original
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.@Marvisak on GitHub · 2026-11-26 05:33 UTC · original · edited 2026-11-26 08:26 UTC
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
@neonbyte1 on GitHub · 2026-11-26 07:26 UTC · original
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.@neonbyte1 on GitHub · 2026-11-26 07:46 UTC · original
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.
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.