draw: clamp only the ray-traced shadow dispatches alone (fixes 3–4 frame shadow flicker) #445
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!445
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-445"
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?
@Spel0 on GitHub · 2026-12-04 06:03 UTC · original
Spel0:fix/vegetation-flicker→main· +176 −18 · 5 files · 3 commits · draftWhat this fixes
Tree and vegetation shadows could flicker for a single frame every 3–4 frames, most visibly in the background; looking directly at them made fewer of them flicker. The same symptom is tracked in #287 as background areas behind foreground objects dropping to near-black for one frame every 3–4 frames.
The existing workaround,
VICTORY_IN_PLACE_ALONE=dispatch, stops it, but it clamps every in-place indirect dispatch alone and costs about 30% of the frame rate on this GPU. This PR keeps that fix only for the ray-traced shadow and trace dispatches that actually show the flicker, so the cost is effectively gone.What was wrong
A batched indirect clamp is recorded where the batch opens, before the commands between it and the execution that reads the record. That is fine for a host copy, whose bytes are the title's at submission, but an in-place argument buffer is read from title memory. A culling or shadow pass recorded after the batch then writes the records the execution should read, and the execution gets an earlier frame's record or none. With the title's triple-buffered argument buffers this repeats every third or fourth frame.
That is the mechanism described in upstream #121 and #204. Clamping every in-place dispatch alone fixes it, but the title issues thousands of in-place indirect executions a frame.
VICTORY_IN_PLACE_ALONE=changedwas also tried: it reopens the clamp when a shader is declared to write the argument copy. It did not fix the shadow flicker, because the records of the ray-traced shadow/trace dispatches are not the copies whose writes that path tracks.Change
VICTORY_IN_PLACE_ALONE=shadow, now the default. It clamps only the title's ray-traced shadow and trace dispatches alone, by shader hash:0873f80dd84a3c5ce8c962358d862e3fafeea48bbb9913ada1b20bc47e3c959717829ac71aab4e8dchanged,dispatch,all, and0(batch everything).VICTORY_IN_PLACE_ALONE=dispatchremains the full fallback.Files
crates/victory-gpu/src/draw.rs— mode selection, the RT trace hash set, and the batch/write tracking used bychangedcrates/victory-gpu/src/indirect.rs— pass the write count and wait through the batch opencrates/victory-gpu/src/shadow.rs— shader-write counter on copiesrun.conf.default,docs/SETTINGS.md— the setting and its modesBenchmark
RX 6800 XT, Ryzen 5 7600, 32 GB RAM, CachyOS, patched RADV / vkd3d-proton, Series X profile. Built-in
VICTORY_BENCH=rtpreset: 3840×2160 output, FSR 4 Quality, ray tracing on, frame generation off. 3-minute runs, first 60 s excluded, 120 s measured per run.VICTORY_IN_PLACE_ALONE0changeddispatchallshadowshadowis within run-to-run variance of the batched baseline, so the narrowed clamp costs effectively nothing.Tested
VICTORY_IN_PLACE_ALONE=shadow: the 3–4 frame shadow flicker is gone.VICTORY_IN_PLACE_ALONE=dispatchstill fixes it and remains the fallback for other title builds.in_place_dispatches_are_clamped_alone_unless_asked_otherwise.cargo check -p victory-gpu --libon the Windows target.Not tested here: other GPUs, other saves, a long session, or a title build other than 1.0.2.1.
Credits
The in-place indirect batching bug and the “clamp every dispatch alone” fix are from HeroOfOlympus: upstream PR #121 and PR #204, neither merged upstream. The downstream fork by t-jonesy carried #121 and exposed it as
VICTORY_IN_PLACE_ALONE(6c1efe6), with the first A/B measurements. The five ray-traced shadow/trace hashes were identified from the hash list in LooperSalty's comment on Marvisak/VIctory PR #1198 and cross-checked against the in-place dispatch profile of title 1.0.2.1. #287, by avishai0258, is the report that described this exact 3–4 frame symptom.Written with AI assistance (DeepSeek V4.1 Flash via OpenCode).
741f768081tod64aa6bcbf@Kal0s-design on GitHub · 2026-12-04 06:36 UTC · original
Tested
d64aa6bnatively on Windows 11 (MSVC) with real D3D12, one NVIDIA desktop card plus WARP. No game run, only the crate tests and one local device test.The new
in_place_dispatches_are_clamped_alone_unless_asked_otherwisepasses 10/10. Fullcargo test -p victory-gpu --libgives the same result as current main, which is also the PR's base (340 passed, the same failures on both sides). Those failures are the twoindirect::tests::host_list_*tests, twopipeline::hostlibrary loads and a flaky watch test, all failing on main here too. The PR only edits theopen_batchcall inhost_list_batches, which passes. clippy shows no new warnings.I also ran a local device test (not pushed, diagnostics build with
VICTORY_D3D12_DEBUG=1). It drivesboundandopen_batchdirectly, notexecute_indirectwith the mode switch. One dispatch record holds 5 groups, a compute shader rewrites it to 9, and the test counts the groups that actually run. 10 runs per adapter, same result every time.bound(the alone path the five hashes now take)wait(thechangedpath)So the batched clamp reads the record as it was where the batch opened, and the alone clamp reads the new one, which is the mechanism in the description. With no barrier after the write,
open_batchgave 9 with or withoutwaiton both adapters, so the extra wait made no visible difference in this small case. The debug layer reported nothing.Some notes from reading it
batched(.., false, false)andopen_batch(.., false), which is main's path. An alone dispatch also drops the open batch, so the next batched execution opens a new one, which looks harmless.pipeline.rs:123), so translator changes or host recompiles won't affect it, only a title update. If the shaders change the fix just stops with no sign. Aonce!or a count in the in-place line when one of the five is hit would make that visible. I couldn't check that the five values are in this repo's hash form beyond the PR's own test, since nothing else in the tree mentions them.alone_modesends any unknown value toshadow. The startup log saysdispatchesfor mode 1 while the accepted value isdispatch, so copying the word from the log silently givesshadow. Accepting both or warning on unknown values would help.VICTORY_IN_PLACE_ALONEyet, all modes arrive with this PR. The description reads as ifdispatchalready existed here.execute_indirect,); unsafe {on one line.Fine by me for the default path, I'd just add some log when the hashes are hit.
AI-assisted: yes
@fsrajner on GitHub · 2026-12-04 08:14 UTC · original
Tested on top of main together with the other PRs listed below. The new default (
VICTORY_IN_PLACE_ALONE=shadow) cost nothing measurable for us: 46 vs 47 ms/frame. That is good news compared with the ~30%dispatchcost. I did not check the flicker itself, since these runs are headless.Setup: RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, RADV from this repo's
setup.sh. Series X, 3840x2160 output, FSR 4 Quality (4.1.2), RT at defaults, headless gamescope. Same save (the intro); the game stops 120 s after the first press. The figures come from the 5 sstats: framewindows after loading. 2 runs per variant; main =0fd7614. The PR build is main + #382 + #392 + #393 + #408 + #445 + #369 together. #398 was left out because it conflicts with #369 in the residency planning. The #369 merge conflicted only with local counters.VICTORY_TEXTURE_BARRIERS=1VICTORY_CARD_KEPT_MB=9216The first run of main and of the PR build each began by re-preparing shaders after a translator change. That is likely where the 48 ms run and the 82.9 ms worst window come from. Otherwise the spread between runs is about ±1 ms/frame, so all of these are within noise. In this scene the card is the limit (about 21-24 ms of GPU wait per frame).
@Spel0 on GitHub · 2026-12-04 09:13 UTC · original
The five-hash
shadowset did not fully fix it: the same 3–4 frame flicker is still visible in game, whileVICTORY_IN_PLACE_ALONE=dispatchstill removes it.The five hashes covered only the distant ray-traced shadow traces and one SR raytracing program. Mapping
shaders.rpfwithshader-info --verboseand intersecting it with the in-place dispatch profile shows that title 1.0.2.1 has 28 shadow/denoise compute programs running as in-place indirect dispatches. The missing ones include the normal tree-shadow path:CS_ShadowRenderTiledCascades*andCS_ShadowRenderTiledMisc*CS_DenoiseShadowMaskLDSPackedCS_TraceShadowRays_CheckerboardCS_IrradianceCache_ShadowTrace_WithFarThose are about 4% of the in-place dispatches, so clamping all of them alone should stay far closer to the batched baseline than
dispatch.I have expanded the set to all 28 locally and it passes the Windows-target check and the unit test, but it is not pushed to this PR yet. I will update the branch and the benchmark once it has been rebuilt and tested in game. Marking the PR draft again until then.
@Luxuride on GitHub · 2026-12-04 10:58 UTC · original
The diagnosis is convincing and the A/B table is exactly the kind of evidence a reviewer needs —
shadowat 17.5 fps vsdispatchat 11.7 is a clear win, and the mechanism (a clamp recorded at batch open reading records a later pass has rewritten) is explained well enough to check against the code.One organisational suggestion, because the three commits here are really three different decisions and only one of them is a mechanism:
shadow.rs,indirect.rs, and thechangedreopen path indraw.rs). It is neutral for everyone who does not set the variable, and it is the part that needs the most careful reading.shadowas a new mode, opt-in. New behaviour behind a new value; a reviewer can accept the mechanism and still want to see this land separately.VICTORY_IN_PLACE_ALONE=shadowinrun.conf.defaultplus the docs row). This changes behaviour for every user who never set the variable, and it rests on five shader hashes that only hold for title build 1.0.2.1. That is a policy decision, not a mechanism, and it deserves its own line in the history — and its own revert if 1.0.2.2 shifts the hashes.Two questions that would make the result hold up on other builds:
On this project specifically: it merged roughly twenty PRs in a day last week, with ~85 open, and most of them touch
draw.rs/indirect.rs. A PR that mixes mechanism, a new mode and a default is where rebase churn and review fatigue come from — three small PRs would each be mergeable in hours and each would keep its own rationale. The idea is good; splitting it is what makes it land.@joaowtrdev on GitHub · 2026-12-04 18:27 UTC · original
Tried
d64aa6bon a Ryzen 7 5700X3D with an RX 9070 XT. The build was main0fd7614with #354, #364, #376, #382 and #385 merged in, run at 4K output with FSR 4 Performance, RT on, ML frame generation (mode 4) andVICTORY_PARTS_ONE_CALL=1. I did one run of each mode back to back from the same save: 1 min standing, then 5 to 6 min driving through the city. The log confirms the mode in each run (kinds="none"withVICTORY_IN_PLACE_ALONE=0,kinds="shadow"by default).There was no cost here:
0shadowlong frame≥ 100 ms, per minlong frame≥ 250 ms, per mingpu_wait_ms, meanThese differences are within my usual run-to-run noise. Neither run lost the device.
That said, I didn't see the tree shadows flicker in either run,
0included. So on this route and at that time of day I couldn't reproduce #287, and this doesn't confirm the fix. It only shows that the default costs nothing here. I'm keepingshadowon and will report if the flicker shows up with it.@MikeSouza1 on GitHub · 2026-12-04 18:57 UTC · original
Tested
pr-445on Linux (Fedora, Ryzen 5 5600G, 16 GB RAM, RX 6750 XT 12 GB RADV NAVI22),CONSOLE=series-s,VICTORY_OUTPUT=1920x1080,VICTORY_FSR_HOST=1,VICTORY_BVH_BUILDER=1,VICTORY_PARTS_ONE_CALL=1(tested in a local build combiningmain+ #384/#385/#481):VICTORY_IN_PLACE_ALONE=shadow(default): completely stopped the tree/vegetation shadow flicker both standing and driving (Ammu-Nation ↔ Jason's house), even withVICTORY_LATE_MOST=384and512(where tree shadows flickered continuously before). No noticeable frame-time regression (19.0 fpsmedian /52.6 msframe time at384).VICTORY_IN_PLACE_ALONE=changed: tree shadow flicker immediately came back while driving, confirmingshadowas the right default.Great fix!
@Xough on GitHub · 2026-12-04 21:02 UTC · original
Tested this PR on an RX 6700 XT (12 GB, RDNA 2), Ryzen 9 7900X, CachyOS, ray tracing off, preset high, FSR 4.1 performance, no frame generation, 1920x1080 output. Built-in benchmark (
VICTORY_BENCH=nort, 3 min each, first 60 s excluded), merged on top of main at2382b4c.shadow), two runsVICTORY_IN_PLACE_ALONE=dispatchSo on this card the default mode costs nothing against main, and the full
dispatchfallback costs about 5 fps (-16%), which matches the cost described above.Not verified: I only measured frame rates, not whether the 3-4 frame shadow flicker is gone on this setup. The shader hashes are for the 1.0.2.1 build.
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.