Shaders: retain empty-EXEC guards around a reachable loop #888
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/888"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-28T08:37:38Z.
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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-28T10:50:46Z.
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
ec53bf5de618973750ef4064e558a1aab654acf4).The GPU compiled different DXIL for
926c46bab3b86bd6. The input container had the same SHA-256 prefix3f81993d6defin both runs. The DXIL prefixes were64c2c8ad9824on the control and3c1d390965f2on the candidate. I matched the first sampled dispatch, DLSS evaluation and presented frame by their guest frame number.In the control, 883 groups exited at guest offset
0x101a8and one at0x11f80. The locations of the exit codes and the retained companion texture values agreed at every pixel. With the patch, both outputs replaced every injected marker in the five fully submerged captures (14,400 groups per capture).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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by MrEjecutor on 2026-11-28T14:14:54Z.
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,
victory.exe run.8fc2254plus local commits (a port ofVICTORY_THIN_BAKE, fxceless's tile-slot rewrite ofGenerateTiles, cache-key names, scripted keys), with and without this commit cherry-picked on top; nothing else differs. Shader cache and pipelines made again for each build.Offline (
translate --list,VICTORY_HOST_WAVE=32):5dc3b25986622949and6f225b641c5b0708change their emitted hash, as expected. The 13 that stop translating:1f1fbd86759b3da239998898c90889b24e9b58cc637d927267353810417f6c197842e2ce8ccd9280a1bf269d5b19f025b8f3f7979d6bbc50c042a10ed3428758d24ad002f5250958d89ff746914b8cf7e5d3e62bd4dfc1fbeae3498e6553afa8fcd8b294ee41c57fBy 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):
6b82bc7d22016cb5)The 9 are
6b82bc7d22016cb5,a10179ab7eda0dc3, four of the list above (eae3498e6553afa8,b8f3f7979d6bbc50,a1bf269d5b19f025,1f1fbd86759b3da2), and three that fail with "a lane mask exchanged where not every lane runs" at 0x218 (17af85f170e66f30,477b52e73ddeb6f2,8b437ab61d8008fe), which did not show in runs without the commit.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
926c46bab3b86bd6got.Not tested: with #348 or the other open PRs;
63b902fitself (its one commit over8fc2254touches no translator file); the buoy and marker close up; more than one run per build, so the fps and the darker cutscene are single observations. The opening run with the commit ended at the title's watchdog during a load after 288 s; that happens now and then without it too, so I do not count it.AI-assisted (Claude Code): the builds, the runs and this text; the captures were judged by eye on my PC. No game files attached.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by d0dev on 2026-11-28T14:26:29Z.
Confirming on an RTX 4070 Ti SUPER 16 GB (Ryzen 7 5800X3D, Series X 1440p DLSS Quality):
63b902fe+ this PR fixes the dark tile blocks on the water around the floating bales in the chapter 1 plane drop (same as the crates in #955), and under boats.Before: blocks around the bale, even with #45 and #822 on top. Leaving shaders out while playing pinned it to
5dc3b25986622949(CS_TransmissionVolumetrics_Tiled): with only it left out, the blocks went away (dark water); with only6f225b641c5b0708left out, they stayed. With #888 both run and the water around the bale is clean, with its light.(Build:
63b902fe+ #45, #822, #1019, #1018, #1066 with its switches off, #703, and this PR.)Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by oz-stanislav-zhukov on 2026-11-28T14:31:54Z.
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
63b902feplus #814, #923, #933, #934, #919, #973, #1014, #1019, #1005, #1066 and a few others. Series S 720p → 1080p, DLSS Quality, FG 2x,VICTORY_WATER_LIGHT=1. Release build.1f1fbd86759b3da27842e2ce8ccd9280a1bf269d5b19f025b8f3f7979d6bbc50eae3498e6553afa8, all "no wave32 lowering for this wave64 program".victory translate --listwithVICTORY_HOST_WAVE=32andVICTORY_TRANSLATE_ONLYset to those five plus407eca669212d400emits 0 of 6 with #888 and 5 of 6 with only #888 reverted.407eca669212d400fails either way. Reverting #1019 instead changes nothing.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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by MrEjecutor on 2026-11-28T15:30:40Z.
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
emit()already uses for the loop step (LOOPS_OFF).What I changed locally (on
8fc2254+ this PR):ir.rs: the oldstallswalk kept beside the new one, chosen by a thread-local thatemitsets (with_loose_guards).emit/mod.rs:emit()runs as now; onErr(Unsupported)it runs once more insidewith_loose_guardsand returns that result.Results, same PC and settings as my comment above (RTX 5060 Ti 16 GB, Series S, no DLSS,
victory.exe run; shader cache and pipelines made again for each build):6b82bc7d22016cb5,a10179ab7eda0dc3; the second is not bound in every run, hence "1 or 2").5dc3b25986622949and6f225b641c5b0708get the same emitted hashes as with #888 alone; 47 programs change their translation against the base.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:
63b902fand the open PRs; the Series X profile; more than a few runs; under water.AI-assisted (Claude Code): the change, the runs and this text; the captures were judged by eye on my PC. No game files attached.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by d0dev on 2026-11-28T16:48:15Z.
Tried the retry from the comment above on an RTX 4070 Ti SUPER (Series X 1440p, DLSS Quality), on
63b902f+ #888 + the retry: the dark squares in the water around the dropped bale in chapter 1 are gone, the water is lit, and shadows and the boat cutscene's light look normal. Boat: 26-28 fps idle, 18-25 accelerating/turning, no frame over 100 ms.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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by oz-stanislav-zhukov on 2026-11-28T22:45:05Z.
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
63b902feplus #348 (paired Wave64), #1019, #814, #923, #933, #934 and others. Series S 720p → 1080p, DLSS Quality, FG 2x,VICTORY_WATER_LIGHT=1, release build.The change, as described above:
ir.rs: the oldstallswalk is kept beside the #888 one and chosen by a thread-local (with_loose_guards).emit/mod.rs:emit()tries with the kept guards first, and onErr(Unsupported)runs once more insidewith_loose_guards.VICTORY_KEPT_GUARDS=0andVICTORY_GUARD_RETRY=0switch it off. Both names are in the shader cache key.Census (
victory translate --listovershaders.rpf,VICTORY_HOST_WAVE=32):shadowmask:CS_TraceShadowRays_*"a descriptor read only as data"1f1fbd86759b3da27842e2ce8ccd9280a1bf269d5b19f025b8f3f7979d6bbc50eae3498e6553afa8407eca669212d400(5 of 6 without it)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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by reefbluesky on 2026-11-28T23:32:47Z.
Another confirmation of @MrEjecutor's retry, on an RTX 3060.
Setup: RTX 3060 12 GB, Xeon E5-2678 v3, Windows 10 19045. main
923e38c+ #888 (90eb835a) + the retry as described above, plus a local controller input commit. Series S, DLSS Quality, FSR frame generation, water light on,VICTORY_LDS_WRITE_ONLY_OK=1(#1435).Census (
victory translate --list,VICTORY_HOST_WAVE=32,VICTORY_HOST_MAX_WAVE=32,VICTORY_LDS_WRITE_ONLY_OK=1,VICTORY_EARLY_DEPTH=1), without and with #888 + retry:no wave32 loweringrefusals: 18 and 185dc3b25986622949and6f225b641c5b0708Tests:
victory-shaderlib, 348 passed and 1 failed (split_lds_wave32_read_after_read_barrier_coalescing_and_parity, which also fails here without these changes, on Windows 10 WARP). #530 was applied for the test run only.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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-29T02:27:00Z.
Thanks @MrEjecutor for testing the fallback, and @d0dev, @oz-stanislav-zhukov and @reefbluesky for checking it on other builds. On MrEjecutor’s 5060 Ti, retrying with the old guard walk only after
Unsupportedbrought the Wave32 refusal count from 35 back to the original 22. Both water shaders kept their #888 hashes. On the 4070 Ti SUPER, the dropped bale had lit water around it again, and on the 3060 the retry matched the baseline count of 25,700 emitted shaders.For a follow-up on main, grosterr’s logs give us three small regression cases.
477b52e73ddeb6f2,8b437ab61d8008feand17af85f170e66f30all translated on63b902fand failed at0x218with #888. I’d check that all three translate again and that5dc3b25986622949and6f225b641c5b0708keep their #888 hashes. At568c5e5, the retry inemitstill switches onlyLOOPS_OFF. FidelityFX logs in #739 · main at 568c5e5Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by d0dev on 2026-11-29T03:24:30Z.
I tried the follow-up on main (
d1486134): MrEjecutor's retry (with_loose_skipsafterUnsupported), applied after main's whole chain (the loops-wave retry and the wave-wide/LDS last resorts), so it only touches programs main can't translate any other way. Programs on the wave-wide skip list (the reflections) are left alone.VICTORY_GUARD_RETRY=0switches it off (it's in the cache key).Offline (
victory translate --list,VICTORY_HOST_WAVE=32), without and with the retry:amd_fidelityfx_upscaler_xbox.dll):477b52e73ddeb6f2,8b437ab61d8008feand17af85f170e66f30fail at0x218without the retry ("a lane mask exchanged where not every lane runs"). All three emit with it, 29 of 29.shaders.rpf: identical with and without the retry, program by program. Same 2 refusals, and5dc3b25986622949and6f225b641c5b0708keep their #888 hashes.A first attempt that held main's last resorts back until after the retry was wrong: it moved 45 programs (TAA resolves, cascade-shadow classify, particles, water sim…) from the wave-wide form to the loose-guard form, and in game that showed garbage. The version above doesn't do that.
In game (RTX 4070 Ti SUPER, Series X 1440p, DLSS Quality): on current main I see red dots on the police officers' clothes in the chapter 1 intro, broken or blocky lighting and reflections, and a water-like reflection over the boat. It shows with the retry switched off (
VICTORY_GUARD_RETRY=0) and withVICTORY_WAVE_WIDE_FALLBACK=0too (worse there, as more programs are dropped). It isn't stale caches. My older build on63b902f+ #888 + the retry, at the same spots, looks right. So it's something else that came into main between those two, not #888 or the retry. I won't be able to test more for a couple of days. If it helps, recent translator changes that have a switch and are on by default includeVICTORY_QUAD_DIVERGENT,VICTORY_HDR_CLAMP,VICTORY_MEMORY_NEAR,VICTORY_LDS_INIT_HOIST,VICTORY_LDS_LOOP_ATOMICSandVICTORY_THREAD_TICKET.I haven't had the FidelityFX programs run in game: with DLSS off the log never names them. If someone knows how to get the title's FSR path running, I can check the picture too.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by MrEjecutor on 2026-11-29T03:41:01Z.
Ran that check on
568c5e5: offline,translate --listwithVICTORY_HOST_WAVE=32andVICTORY_EARLY_DEPTH=1, main alone and main plus the retry commit from my comment above. The commit cherry-picks clean onto568c5e5(ir.rsandemit/mod.rs, +192/−1).568c5e5477b52e73ddeb6f2,8b437ab61d8008feand17af85f170e66f30: from the error at0x218to emitted.5dc3b25986622949and6f225b641c5b0708are emitted in both builds. They translate at the first try, so the retry does not run for them. I did not compare their emitted bytes.8fc2254are all back on568c5e5without the retry, so on main these three are all the retry still buys.On the tree I play on (
923e38c+ #888 + the retry) the three are emitted as well.The commit is two files. I can open a PR with it if you want it on main.
Not tested: in play on
568c5e5(this is the offline list only); whether the three are bound with the title's own upscaler; other cards.AI-assisted (Claude Code): the builds, the runs and this text. No game files attached.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-29T07:34:37Z.
@MrEjecutor, thanks for checking all 25,787 programs on
568c5e5. Before opening a separate retry PR, could you runtranslate --liston #1952 (7347259) for477b52e73ddeb6f2,8b437ab61d8008feand17af85f170e66f30, and post the three emit results there? The review on that PR checked which guards it removes. If any of the three still fails at0x218on that branch, yes, please open the retry PR with that case. Swimming and boat buoyancy from #1914 still need an in-game check on #1952. Guard review on #1952@d0dev, thanks for verifying the emitted hashes of both water shaders. For your Series X run, turn off DLSS and frame generation, then add
--set VICTORY_FSR_PATH=1to your usualvictory playcommand. Ond1486134, look forthe title's own FidelityFX at the … scale (VICTORY_FSR_PATH=1)in the startup log. That confirms the upscaler selection. A runtime dispatch naming one of the three hashes would confirm which shader actually ran. Launcher code and log lineImported from trustno1-coder/VIctory-NVIDIA. Originally posted by domx4q on 2026-11-29T13:32:45Z.
A picture regression bisects to this merge (
5cfe1b61).Symptom. A large white blown-out area covers the lower middle of the picture. In play this looks like strong glare from any reflection outdoors, and like very bright windows and harsh contrast indoors. It shows from the apartment save onward, with no switch involved.
Setup. RTX 4090, Linux, Proton Experimental 11 with vkd3d-proton master. Series X, DLSS quality, 1440p, frame generation 2x. Every run used the same save and the same scripted input, with screenshots at 150 s and 210 s. As a number for "white blob or not", I took the mean brightness of the bottom-middle quarter (480×150 at 240,340 of a 960×540 shot).
Bisect.
git bisect --first-parent 9ce3cf9..f9dfb76, one game run per step:9ce3cf96178da10(#978)5cfe1b61(#888)f9dfb76f9dfb76+ revert of5cfe1b61, run 1f9dfb76+ revert of5cfe1b61, run 2Two steps (
f2217874,6da8e376) did not build and were skipped.Before this, I checked whether a switch causes it, on
f9dfb76. None of these removed the blob:VICTORY_AMBIENT_SPECULAR=0,VICTORY_AMBIENT_SPECULAR_BOUND=1,VICTORY_AMBIENT=0,VICTORY_AMBIENT_AIR=0,VICTORY_NAN_SCRUB=0,VICTORY_BVH_MISS=0. It is the translation itself.Guess, not verified. Some program in the post or lighting chain now keeps the empty-EXEC guard around a loop that was removed before. Or the new
v_cmp(not onlyv_cmpx) rule decides a branch differently, and a value meant to be written is not written, for example an exposure or luminance reduction. I have not yet found which program. If it helps, I can capture the shader hashes whose translation changes between6178da10and5cfe1b61in this scene.Current main still has this code, so main probably shows the same. #2418 ("frosty white floor indoors") might be the same thing.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by domx4q on 2026-11-29T15:53:46Z.
Update: on current main (
829188e9), with #888 in, the white patch is gone. Same save, same measurement: brightness 77 and 90, where the bad builds gave 218–237. The bisect on the older range still holds:f9dfb76fixed it in 2 of 2 runs.So something merged after
f9dfb76seems to cover it. I'm leaving this here in case the same pattern comes back. There's nothing to do on main as it stands.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-30T01:09:43Z.
@domx4q Thanks for following the bisect with the same-save retest. The two successful reverts on the older build and the 77/90 readings with #888 still present on
829188e9are both worth keeping in the thread. I agree with leaving main as it stands on this evidence. If the glare returns on a later build, those two frames give us a concrete comparison point.