Repository navigation
Shaders: retain empty-EXEC guards around a reachable loop - #888
Conversation
|
I reran the underwater test on the RTX 4070 Ti SUPER with separate, initially empty shader and pipeline caches. Both builds used copies of the same v100 save, Series X, 2560×1440 input to 3840×2160 DLSS Quality M, frame generation off and the same diagnostic instrumentation. The actual game log confirmed all 53 BVH-builder pipelines in both runs. The candidate differs from the control by the patch in this PR (stable patch ID The GPU compiled different DXIL for
In the control, 883 groups exited at guest offset I also kept a sixth candidate capture with the camera crossing the waterline. The companion texture kept its marker in the top 28 tile rows and part of row 28. It had zero watchdog codes and no diagnostic colour in the DLSS input. A dark horizontal band is still visible in some underwater views. The captures support the fix for these two exits. Surface colour, the buoy rectangle and gameplay 1% lows need their own measurements. |
|
Tried this on a tree without #348 (no paired form), since #739 says it removes the dark rectangle at the buoy. It does seem to help the water here, but 13 programs lose their wave32 lowering with it, and some of them are used in play. Setup: RTX 5060 Ti 16 GB, Core Ultra 5 225F, 32 GB, Windows 11. Series S, 1920x1080, no DLSS, no frame generation, diagnostics profile, Offline (
By their names they are the four cascade-shadow classification programs, the ray-tile sort of the scattering system, a river-simulation one, a particle-emit count, a decal classification and five decal/triangle heap relocations. In the game (boat mission after the prologue, 470 s; and the opening, one run each):
The 9 are Picture, one run: the water is lit and I saw no dark rectangle beside a moored boat on the route. The boat cutscene is clearly darker than without the commit: people and mangroves stand in shade, which would fit the cascade-shadow classification being dropped. So on this tree the extra kept guards seem to push these programs out of every wave32 form. Perhaps the guard should be kept only where the lowering that bounds the loop is the one taken, or these programs need the same retry that Not tested: with #348 or the other open PRs; AI-assisted (Claude Code): the builds, the runs and this text; the captures were judged by eye on my PC. No game files attached. |
|
Confirming on an RTX 4070 Ti SUPER 16 GB (Ryzen 7 5800X3D, Series X 1440p DLSS Quality): Before: blocks around the bale, even with #45 and #822 on top. Leaving shaders out while playing pinned it to (Build: |
|
I saw the same on another tree: @MrEjecutor's list holds up here, and the picture shows it. Setup: RTX 5060 Ti 16 GB, i7-14700KF, Windows 10. trustno1 main
I reverted it locally for now. I'm happy to test a version that keeps the guards only where the wave32 lowering still succeeds. AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
|
A small change on top of this PR gave me the water fix without the lost lowerings: when a program does not translate with the guards kept, try it once more with the walk as it was before. It is the same pattern What I changed locally (on
// sketch: arguments as emit() has them
pub fn emit(c, native, p, st, io, res) -> Result<HostShader, ShaderError> {
let kept = emit_loops(c, native, p, st, io, res); // the body emit() has today
if !matches!(kept, Err(ShaderError::Unsupported { .. })) {
return kept;
}
ir::with_loose_guards(|| emit_loops(c, native, p, st, io, res))
}Results, same PC and settings as my comment above (RTX 5060 Ti 16 GB, Series S, no DLSS,
It costs a second translation of every program that fails with the guards kept (once per program, cached). It does not say why those 13 stop translating; it only puts them back where they were, so the real fix may be narrower than this. Not tested: AI-assisted (Claude Code): the change, the runs and this text; the captures were judged by eye on my PC. No game files attached. |
|
Tried the retry from the comment above on an RTX 4070 Ti SUPER (Series X 1440p, DLSS Quality), on I also tried #742 instead of #888: the squares around the bale are gone too, but in that run part of the boat was missing its texture. I can't say yet whether that comes from #742 or was a one-off. |
|
One more confirmation of @MrEjecutor's retry, on a different tree and with an offline census. Setup: RTX 5060 Ti 16 GB, i7-14700KF, Windows 10. trustno1 main The change, as described above:
Census (
In game, two runs: the grey, flat outdoor picture I posted above (shaders dropped) is gone. From the hill, the open water at sunset is lit and shows no dark squares. I have not been near the buoy or the bale with this build, so that part rests on d0dev's run. AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
|
Another confirmation of @MrEjecutor's retry, on an RTX 3060. Setup: RTX 3060 12 GB, Xeon E5-2678 v3, Windows 10 19045. main Census (
Tests: In game: the dark squares around items in the water, which I had before, are gone, and the water stays lit. Water foam, vegetation and scene lighting look normal. AI-assisted (Claude Code); no game data. |
…oder#888, and the LDS last resort on Upstream 90eb835 (trustno1-coder#888) keeps more empty-EXEC guards around loops in without_skips; with it four wave64 compute programs of the prologue that translated before the merge were refused on 32-lane hosts (1f1fbd86759b3da2, a1bf269d5b19f025, b8f3f7979d6bbc50, eae3498e6553afa8), 13 in trustno1-coder#888's thread. emit now tries a refused program once more with the walk from before trustno1-coder#888 (ir::with_loose_guards, VICTORY_GUARD_RETRY=0: not); programs that translate with the stricter guards keep them, so trustno1-coder#888's water fix stays. As trustno1-coder#888's thread suggested. Upstream 9f628a0 turned the LDS write-only last resort off by default; here 15 more compute programs were then dropped, and the picture was banded, washed out in white haze and tinted. It is on again (VICTORY_LDS_LAST_RESORT=0: off).
…0eb835); -PreloadOnly 90eb835 (upstream trustno1-coder#888) leaves 22 more 64-lane compute programs without a 32-lane form on an RTX 4090: the translator keeps skips it used to prove away ("a loop behind it does not end with no lane left"). Counted with `translate --warm` over the 37 programs this build's preload refused among the pipelines earlier runs made (VICTORY_HOST_WAVE=32), found by git bisect over victory-shader in two passes: upstream up to 6178da1 15 refused (9 with LDS_LAST_RESORT=1) from 5cfe1b6, the merge of trustno1-coder#888 37 (14) f9dfb76 with 90eb835 reverted 15 (9) The 22 are the particle updates (CS_UpdateParticles and three more), the scene colour temporal resolves (four variants), CS_TemporalResolve1_Alpha, CS_TemporalResolve2_Opaque_FrameStatistics, CS_TAA2_PrepareFrameStats, CS_Disocclusion, CS_RayPrePass_Opaque_SSR, three CS_MinMax programs, CS_DrawBatch, CS_Tree_BatchNoCull and CS_Tree_BatchCullReflect. What trustno1-coder#888 mends is not known (it has no description); that is unprotected again here. cargo test -p victory-shader: 386 passed (the revert takes the commit's own test with it). Not run in the game. play-foxhound.ps1 and play-rtx4090.ps1 take -PreloadOnly: the preload, and the game is not started. docs: section 3.6 has the table and the names. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…, off again emit's loose-guard retry (cf125f3) ran outside the LDS last resort, so a program trustno1-coder#888 had refused got the last resort's write-only shortcut, an approximation, before the exact retry was tried. Now the strict and the loose-guard tries come first, both without the last resort, and the last resort only after them. With it off altogether, all 15 compute programs the merge had dropped translate exactly, and only those refused before the merge are (6b82bc7d22016cb5, 21f7ad7863620328, 7c9a6a83826cdfac): trustno1-coder#888 was the cause for all of them, not the last resort's default. It is off by default again, as upstream has it (VICTORY_LDS_LAST_RESORT=1: on).


In
ir::without_skips, an empty wave can enter a loop the guest would have branched around. The old walk recognises cycles composed of fully decided branches. If a scalar test is unresolved, revisiting its state is treated as already explored. The outer guard can then disappear and a lowering that bounds loop iterations can return before later stores.This change tracks states on the current path separately from fully explored states. A reachable cycle, or exhausting the existing analysis budget, keeps the guard. An ordinary vector compare under empty EXEC produces an empty predicate mask; following VCCZ/VCCNZ lets the analysis still remove the guard around a provably single-pass loop.
Reproduction on current main (
63b902f)The new unit test uses synthetic instructions. It covers a VCCZ backedge, a scalar loop whose initial value comes from an inactive vector lane, and the VCCNZ control that can still be simplified. On the unmodified base the test fails on the VCCZ case. With the patch,
cargo test --locked -p victory-shader --libpassed all 208 enabled tests (2 ignored).Runtime evidence and review scope
On an RTX 4070 Ti SUPER, the diagnostic captures in #739 identify two watchdog exits and 1,039 affected workgroups. A separate replay of a 56-program selection yielded 52 validated DXIL outputs on both builds, with four hashes changed and no outputs lost or gained. One timed run took 19.12 s before and 27.08 s after for the replay including validation. This is a single pair, and compile cost is worth reviewing.
#326 also protects scalar-test loops as part of its Wave32 water changes. This PR is limited to the current skip analysis and explicitly tests VCC-controlled backedges. I am leaving it in draft: the earlier in-game candidate/control shared shader and pipeline caches, so that comparison cannot establish a visual fix. I have not measured a gameplay FPS improvement from this change.