Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2309"
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 desplmfao on 2026-11-25T10:19:48Z.
Stacked on #439 (r4tedx; it contains #233 and #320). The two commits on top of it are the change. The first is powplusplus's
d48ec76from #1885, cherry-picked with its author kept; the second is ours.Problem
On NVIDIA (32-lane waves) under Wine/Proton, vkd3d-proton converts each pipeline's DXIL to SPIR-V with dxil-spirv, inside the title's process. Some of #439's console-flow programs have a block that branches back to two loop headers, e.g.
br c, 191, 126, where 191 is the inner loop's header and 126 the outer one's. Others have a loop header with three back edges.dxil-spirv's structurizer expects one back edge per block and per header ("DXIL seems to obey this",
forward_visit_resolve). It reads the extra edge as a forward edge, makes a cycle, and recurses until the stack runs out (LoopMergeTracer::trace_from_parent, about 100k frames). With a large stack it uses memory instead (40 GB before I killed it), or the pipeline thread hangs. In the title, the process ends while those pipelines are created, or no pipeline ever finishes.mainhas the same shapes in 7 programs. They convert because those programs have noWaveReadLaneAt, and dxil-spirv only walks the graph before fixing it up inflatten_subgroup_shuffles, which runs only when a shader reads other lanes. #439 adds the lane reads, and then the same shapes are fatal.How it was found
VICTORY_PIPELINE_JOURNAL=1). On #439 the title's process died during world load, with no crash log and no GPU fault. The journal's pending notes named the pipelines being created at that moment:b2ff2ef0d6c98dd7,fdd56d97a806bcca,32ed072b9f845048and others.shaders.rpfand were translated with #439. A native dxil-spirv build, capped in memory, then crashed on them the same way: it reached 40 GB uncapped and overflowed the stack when capped. gdb showed the recursion (LoopMergeTracer::trace_from_parent, about 100k frames).mainshowed the block that branches back to two loop headers.VICTORY_PIPELINE_SOFT_CRASH=1). Without this fix, the same two programs are caught as stack overflows (0xc00000fd) inside vkd3d-proton.Change
All in
crates/victory-shader/src/emit/bitcode.rs:364c1bc(powplusplus, from #1885):Module::single_latchesgives each loop header one back edge.91e3bdf: a block that branches back to two headers sends its edge to the outer header through a new block of its own, fixing that header's phis. The block stays the inner loop's exiting latch, as DXC makes them. The empty-latch fold at write time no longer folds a latch into a block that already branches back, which would undo the split.The change is generic:
lower.rsandwave.rsare untouched, so it should not conflict with #2214.Tested
fdd56d97a806bcca(InstanceCulling:CS_Prop_BatchNoCull) and32ed072b9f845048(deferred_tiled:CS_LaserLightShadowRaytracing).spirv-val, andvkCreateComputePipelinesreturnsVK_SUCCESSon native NVIDIA (RTX 5080, no Wine).*:CS_RaytracingResolveprograms, and the run goes past that point.cargo test -p victory-shader --lib: 151 passed on Linux, and 178 passed, 0 failed for the Windows build under Proton on the RTX 5080. That includes the newa_block_branching_back_to_two_headers_gets_one_back_edgeandempty_latches_to_two_headers_fold_once.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.Related
lower.rs.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:23:18Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP (focusing on top commit91e3bdfstacked on#439):single_latchesto split any block branching back to two loop headers into a dedicated outer-latch trampoline and preventing write-time empty-latch folding from re-introducing a dual-back-edge block cleanly enforces one back edge per block for vkd3d-proton /dxil-spirv.cargo test -p victory-shader emit::bitcode::tests: 9/9 passed on RTX 5090, 9/9 passed on WARP (includinga_block_branching_back_to_two_headers_gets_one_back_edgeandempty_latches_to_two_headers_fold_once).cargo test -p victory-shader lane_read_loop_tests: 2/2 passed on RTX 5090, 2/2 passed on WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 186 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:54:01Z.
Review: COMMENTED
One back edge per block so vkd3d-proton converts the DXIL (+3763, apps/docs/gpu/shader). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Big mixed PR; the shader lowering side is the portable part — worth splitting or at least a dedicated hardware pass. Extends the --host-lanes CLI from #2214.
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T11:18:33Z.
@catminou4 thanks. The size comes from the stacking: this PR's diff against
mainincludes all of #439 (and #320/#233 with it), and that's where the +3,763 lines, the docs and the--host-lanesCLI come from. The change itself is only the last two commits, both incrates/victory-shader/src/emit/bitcode.rs:364c1bc(powplusplus's commit from #1885) and91e3bdf. Compare against #439's head to see just those.r4tedx is taking both commits into #439 (see https://github.com/Marvisak/VIctory/pull/439#issuecomment-7160324713). Once they're in, I'll close this one as included.
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T11:32:05Z.
Update after r4tedx's note on #439: this stays its own PR. I've merged #439's current head (
3fab5a1) into it (no conflicts, merged rather than rebased). The change is still the two commits inbitcode.rs,364c1bc(powplusplus, from #1885) and91e3bdf. On the merge,cargo test -p victory-shader --lib(Linux) gives 151 passed, and clippy is clean. To review just the change, compare against #439's head.Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T15:43:02Z.
Thanks for the triage. On the three points:
mainright now, and this PR is stacked on it, so I'll follow #439's next head. Once #439 is in, I'll mergemainhere (no rebase or force-push, to keep the review history) so the diff comes down to the twobitcode.rscommits.364c1bc(from #1885): I'm asking @powplusplus on #1885 whether it lands there or here, so it doesn't land twice. If #1885 lands first, I'll drop it from here.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:22:20Z.
Automated triage for the maintainers.
Needs work.
ec845d6merges cleanly and CIcheckpasses, but the diff againstmain(+4,971 / -1,457, 28 files) is almost entirely #439 (r4tedx's wave64 console flow, merged withmainonupdate/439-main), plus this PR's own rule inModule::plan(crates/victory-shader/src/emit/bitcode.rs: one back edge per block, commits364c1bc/91e3bdf) and the move oflower.rs's tests toemit/lower/tests.rs. Merging it would land #439 in a rebased form that #439's own thread has not reviewed; #439 itself still conflicts withmain(marked needs-rebase for3fab5a1).What would move this forward: #439 rebased and decided on its own (or the maintainer choosing to take it through this branch), and then this PR reduced to its own commits on top, so the back-edge rule can be reviewed by itself.
On your replies: the
planplacement and theModule::termuse for constant branches sound right, and the tests move fixes the policy failure, but they do not change the stacking problem above. Also note #2084 and #2117 add tolower.rsas well; once the tests move lands, they will need to follow it.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-26T01:18:28Z.
#439 has conflicted with
mainsince this morning, so this PR now sits onupdate/439-main(f7d4feb). That branch is #439's head3fab5a1withmain(63bcca4) merged in, and r4tedx's commits are unchanged.f93574amerges it here.mainmoved block layout and folding intoModule::plan, so this PR's rule now sits there. An empty latch is not folded into a block that already branches back, counted over the edgesplanwrites.successors()usesModule::term, so a branch on a constant doesn't count its dead edge.mainfails there.empty_latches_to_two_headers_fold_once.When #439 is updated upstream, this PR follows its head again.
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-26T01:30:10Z.
The
checkfailure onf93574awas the asset policy's file size limit: with #439 merged intomain,crates/victory-shader/src/emit/lower.rsreached 559,370 bytes, past the 524,288-byte limit (xtaskrepository_passes_policy).68ba2deonupdate/439-mainmoveslower.rs's inline test module unchanged intoemit/lower/tests.rs, leavinglower.rsat 506,198 bytes.ec845d6merges it here.Anything that changes
lower.rs's tests (this PR, #439, or another PR stacked on them) now has to editemit/lower/tests.rs. A PR that still adds tests inline inlower.rswill conflict, or push the file back over the limit.Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T19:17:45Z.
Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with vkd3d-proton. This fixes a crash I was chasing: pipeline worker threads dying of stack overflow inside
CreateComputePipelineState.Setup:
mainplus #439, #233, #320, #1129 (64 MiB pipeline worker stacks), my #2977 and a few others, with this PR's headec845d6merged on top.Without this PR, every run had 6 Wine
stack overflowerrors, on 6 of the 8victory-pipelines-Nthreads. Each died insideCreateComputePipelineState, after our own translation had finished with ~3.7 KiB of its 64 MiB stack used, so the depth was in dxil-spirv's conversion. The other 2 workers built everything else, and these 6 compute pipelines never existed:32ed072b9f845048CS_LaserLightShadowRaytracing559d9f0184e15fe3CS_TraceShadowRays_Checkerboard17829ac71aab4e8d,a1b20bc47e3c9597,afeea48bbb9913ad,e8c962358d862e3fCS_RTDistantShadowTrace*_TiledWith this PR:
slow host submissioncount drops (578 → 538, max 1471 → 527 ms).My #2977 was also in this build, but on its own it changes 9 other programs and none of these six, so the fix comes from this PR. #2309 covers the same back-edge case more generally, so I'll fold #2977 into it or close it. Also, the 64 MiB stack from #1129 was enough here, so #1885's 256 MiB commit wasn't needed.
AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-27T08:24:40Z.
@neonbyte1 thanks, this is the in-title confirmation the PR needed, and on a different card and Wine build from mine. Six stack overflows down to none, all eight workers alive, and the six RT shadow pipelines built and dispatched every frame. These are the same pipelines I saw hang or crash pipeline creation here (
32ed072b9f845048,17829ac71aab4e8d,afeea48bbb9913ad). Your census, with no count changes and nothing newly refused, is useful too. On #2977, folding it in or closing it is your call. If its 9 other programs need their own change, it could stay separate.Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T08:48:35Z.
@desplmfao thanks. Then I'll keep #2977 separate: it's the standalone one-back-edge-per-block fix for
mainwithout #439, and its 9 programs don't include these six. If #2309 lands first, I'll rebase #2977 onto it and drop whatever becomes redundant; if #2977 turns out fully covered at that point, I'll close it with a note here.For what it's worth, #2309 has stayed in every stack I've measured since (now at ~205 ms/frame in the prison yard on the RTX 5090, details in #3425), with all eight pipeline workers alive in every run.
AI-assisted (Claude); no game data shared.
Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-27T08:50:02Z.
Verified the exact Prop BatchNoCull failure/fix on Linux / Wine11 / RTX4060 Laptop8GiB / NVIDIA590.48.1 / 16GiB RAM.
Provenance: newer #439
e2d3cfd50715954fb89ff462edb37a0c4395ecd0plus only this PR's bitcode writer changes fromec845d633b47e4f98789a8f0353c172f3070d942, and the requiredShader::finish → single_latches()call. Two dirty files, not an exact #2309-head result. This preserves #439's newer root-title-memory safety guard. Diagnostic-relaxed vkd3d-proton2576c0b4adfae4a+, not stock-stack certification.Before: the original locally extracted
InstanceCulling/CS_Prop_BatchNoCullcontainer (fdd56d97a806bcca) translates and SDK-validates, but--pipelinesstack-overflows/stalls. Default-stack batch stopped at300s. A separate bounded16MiBRUST_MIN_STACKdiagnostic still overflows/stalls at90s. No dispatch and no resource-limit increase.After the writer fix, normal stack: same six scene containers,
translate ... --pipelines --validate --list --jobs 1, fresh intended-worktree release41.29s: 5 emitted / 5 validated / 5 native PSOs created, includingfdd56...and all four requested prop/tree InstanceCulling programs. The sixth (02384a60fda6f2d0, VFX heap ComputeRelocations) remains deliberately refused for a group larger than64. Full command finished66.15s including build, with no overflow. These are original-container native-creation checks, not title-shader GPU execution.Synthetic correctness: writer tests15pass/0fail (one benchmark intentionally ignored), including all three latch/phi/fold regressions;
split_tests36/36,0ignored,46.74s, 81 exact readback lines explicitly on NVIDIA withsplit true. Includes cross-half LDS order, lane reads, whole-wave sums/prefixes and multi-dimensional groups. No skipped-adapter messages, no WARP reference claim.Evidence:
verify-pr439-loop-writer-20261127T084248Z/,verify-pr439-loop-split-20261127T084423Z/,verify-pr439-loop-scene-native-20261127T084551Z/. Native leg peakGPU221MiB/min availableRAM11008MiB; unchanged9GiB/512MiB scope and external guards. Original assets/DXIL remain local and unmodified at source.This clears the exact compiler boundary on another NVIDIA model. No rendered-title-frame claim yet; integrating into our paging/file-backed-memory runtime next, retaining the all-or-none BVH gate and the remaining unsupported-program refusals.
Mixed-runtime follow-through (2026-11-27 09:15 UTC): integrated this writer and #439 into our existing paging/file-backed-memory runtime (dirty base
3ed7d725, not an exact PR head). Fresh release44.08s; all five repaired prop/tree-culling and VFX RelocateStartIndex keys now have both native-built and title-used records. The 180s guarded run reaches the prologue card, then remains black. The colour texture entering native FFX is exactly zero RGB on two sampled dispatches, with zero nonfinite values; therefore this native-compiler fix is real but is not sufficient scene-rendering proof. Trace1529used/658built,611used with built records,916still pending at last status: incomplete compilation remains a confounder. GPUpeak4012MiB, availableRAMminimum4920.7MiB; wall stop, not a resource/crash stop. Evidenceculling-depth-trial-20261127T091527Z/summary.jsonand matching guard logs. Depth observation was unavailable because the local probe rejected actual R32G8X24_TYPELESS; no geometry conclusion from its missing image. No images or original program assets uploaded.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.