GPU: an opt-in constant stands in for one view a named program writes (VICTORY_AMBIENT) #2619
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!2619
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2619"
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?
@r4tedx on GitHub · 2026-11-25 16:58 UTC · original
r4tedx:gpu/ambient-stand-in-main→main· +1323 −12 · 5 files · 4 commits · openSome outputs depend on inputs the host never fills. Light gathered by rays walks structures that are not built yet, so the program that resolves it leaves black (or whatever its memory held), and every shaded surface that reads it goes dark. This adds a run-time switch that clears one unordered view to a constant after every dispatch of one program the user names.
Opt-in, off by default. Nothing runs while
VICTORY_AMBIENTis unset. No title program names or hashes appear in the code: the user names the program by the shader hash the log already prints.Syntax
VICTORY_AMBIENT=<program>:<view>:<value>, rules separated by;<program>: the 16-hex-digit shader hash the log prints for the compute program (compute 0123456789abcdef).<view>: the unordered view as the console shader addresses it: root parameter and table offset in dwords,s1+176or1+176(the notation of the diagnostics' table listings). The address comes from the console code, so it holds across translator versions. An n-th-view index would shift as the translator finds more views.<value>: a colourr,g,b[,a](alpha 1 if left out). A float or normalized view takes it as it is (ClearUnorderedAccessViewFloat). An integer view takes it packed by the texture's format, or as named:rgb9e5=,r11g11b10=(into a 32-bit word) orrgba16f=(intoR16G16B16A16_UINT/R32G32_UINT). A raw word is0x...,mask(all ones) orzero, for an integer view of any width (zeroclears float views too).Example:
VICTORY_AMBIENT=0123456789abcdef:s1+176:rgb9e5=0.3,0.294,0.282(Level 0.3 per @tippythetaidum's measurement against Series X footage in three prison shots, where 0.6 came out 12-16 display-luma steps too bright: #2619. The right level depends on the scene; it is a stand-in, not the title's lighting.)
What it does
dispatch) or indirect (execute_indirectof kind dispatch), the named view is cleared through the existing UAV clear path, between UAV barriers on the resource.Tests
The title was not used in these tests.
the_ambient_stand_in_fills_the_named_views_after_the_named_program(WARP): a program writes three views of a title table. After it runs, the two views its rules name hold the R9G9B9E5 word and the RGBA16F colour, the third keeps what the program wrote, and a program no rule names changes nothing.clears_of_one_view_in_a_list_share_a_dynamic_slot, anda_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held) are #2871's.ambient.rs: R9G9B9E5 against a reference encoder (smallest shared exponent whose mantissas fit), small floats against a nearest-code search, rule parsing, and the packing chosen per format.a83bdc1d(on #2871d3f9b11e,mainf3578e38, WARP):cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand the same with--all-features, both clean;VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked: 251 passed, 0 failed, 1 ignored (an existing benchmark). The stacked VICTORY_STAND_IN branch (#2620,33df0691): 253 passed, 0 failed, 1 ignored.In game
In our play build (RTX 5070, local title data used for the in-game measurement; only log lines and a description of the picture are reported), with #2311 holding back the BVH walks:
(
VICTORY_STAND_INis the follow-up PR, stacked on this one.)Credits
runtime/victory/crates/victory-shader/src/emit/stand_in.rs, GPL-3.0-or-later).🤖 Generated with Claude Code
@DrDarkDK on GitHub · 2026-11-25 17:04 UTC · original
An indirect dispatch can have a valid pipeline and a zero count-buffer value. In that case
ExecuteIndirectruns zero commands, but the success path still callsstand_insand clears the named UAV. That can overwrite an output the title expected to keep. D3D12 command-count semanticsShould the clear run even when the indirect call executes zero commands? If it should only run after shader work, a focused regression test could seed the UAV with a sentinel, issue the indirect call with
max = 1and a zero count buffer, and verify that the sentinel survives.Static review only.
AI-assisted with Codex.
@kotekompotek on GitHub · 2026-11-25 17:52 UTC · original
Reviewed together with #2620: this is the same new
ambient.rs; #2620 is the superset (addsVICTORY_STAND_INfor programs that never run, ~250 more lines of docs + logic). If #2620 lands, this one is subsumed — the docs here are accurate on the spec (per-dispatch UAV clear between barriers, view addressed by console root-param + dword offset so it survives translator changes). Opt-in, off by default. CI green.@r4tedx on GitHub · 2026-11-25 18:23 UTC · original
@DrDarkDK, thanks, good catch. An indirect dispatch with a zero count ran nothing, but the stand-in still cleared the view. Fixed in the new commit on this branch (head
67320f31):D3D12_PREDICATION_OP_EQUAL_ZERO), so a zero count skips it on the GPU. A predicate is a 64-bit value at an 8-byte-aligned offset, while the count is a 32-bit word anywhere, so the count is first copied into the low half of a zeroed 8-byte word the list owns. The copy is recorded just beforeExecuteIndirect, at the point where the execution reads the count: after the count's host copy is refreshed and after the argument clamp's UAV barrier. Only the Clear call itself is predicated.Regression test on WARP, as you suggested:
the_ambient_stand_in_follows_only_indirect_dispatches_that_ran_records. It seeds the view with a sentinel and runs a hostExecuteIndirectwith at most one record and a zero count, placed at an unaligned offset with a non-zero word after it. The sentinel survives. A count of one clears it, at most zero records keeps it, and no count clears it.The same commit fixes a test flake:
ambient::filled()now counts per calling thread under test, so stand-in tests running side by side no longer change each other's counts. The run-wide count in the log is unchanged.victory-gpu --lib, WARP,--test-threads=1--test-threads=4, 5 rounds67320f31af1973b2#2620 (
VICTORY_STAND_IN) is rebased on this head and has the same fix for dispatches that don't run.@kotekompotek, thanks for reviewing both. Yes, #2620 is stacked on this one by design: this PR is the smaller, self-contained
VICTORY_AMBIENTpart, and #2620 adds only its last commit on top. If the maintainers prefer one PR, merging #2620 takes both.The title was not used in these tests.
AI-assisted
@Venom2054 on GitHub · 2026-11-25 18:25 UTC · original · edited 2026-11-25 18:27 UTC
I tested the two switches separately on an RTX 5070 Ti in the prison-window shot. I used the same local integration of #2619 (
11012ead) and #2620 (9d73ed65), executable, initial save, starting caches, input sequence and SDR settings for all three runs. Character textures were present in the material buffer in every run.Values are displayed SDR luma on a 0–255 scale, averaged within each region and then summarized by the median of three camera-matched frames per run. With ambient alone, the shirt lettering and seams became readable. Before lighting, the shirt's median RGB stayed within two code values per channel across all runs.
The captured screen-probe dispatch was direct (320×360×1). The ambient rule filled the 2560×1440 packed screen-probe output. In the shadow-only run, all four held-back passes reported a successful fill on their 1280×720 R16_UINT masks. The last counters were 197 ambient fills and 693 shadow fills respectively, with zero skipped in both runs.
This isolates a visible contribution from ambient in this shot. Filling the four distant-shadow masks with all ones on its own produced no appreciable change on the character here. Mask polarity and interaction with ambient remain open. The ambient result still looks flat, especially around the hair.
@r4tedx on GitHub · 2026-11-25 18:28 UTC · original
@Venom2054, thanks. The three runs on matched frames make this easy to read: ambient alone takes the back of the head from 1.33 to 32.77 and the shirt from 0.36 to 40.02, while the four distant-shadow masks alone change nothing measurable.
Two notes on the heads you tested:
11012ead/9d73ed65predate the zero-count fix (DrDarkDK's report above). The current heads are67320f31(this PR) andaf1973b2(#2620). The fix only matters for indirect dispatches whose count is zero, so your runs should come out the same; your screen-probe dispatch was direct anyway.On polarity:
maskfills all ones. If those R16_UINT masks mean "1 = in shadow" in this title, all ones would keep the character shadowed, which looks the same as before. Two cheap checks on the same shot:zeroin place ofmask;maskand once withzero.If
zerobrightens the character, the masks are "1 = shadowed". If neither moves it, those four distant passes aren't what darkens a close-up. The near cascades (cascadeshadows_renderingCS_ShadowRenderTiledCascades*) don't translate on a 32-lane host onmain940d32f(see my note on #1962), so a stand-in for one of them would need its own rule.AI-assisted
@Venom2054 on GitHub · 2026-11-25 18:56 UTC · original
I ran the three follow-ups from your reply on the same RTX 5070 Ti using the same executable, initial state and camera-matching method as the earlier report. One run per setting, three matched window frames per run. The values are median displayed luma on the same 0–255 scale.
For reference, ambient alone was 32.77 / 40.02 / 238.64. Each of the four 1280×720 R16_UINT outputs accepted the requested fill in each run. The last combined counters showed 928 fills for ambient + ones and 1,002 for ambient + zeros, with zero skipped in either run.
Changing the masks to zero without ambient left the character a silhouette. With ambient on, the lettering and collar stayed visible with either mask value. I could see individual strands at the right edge of the head in both the ambient-only and ambient-plus-ones frames, but no additional rim lighting or ponytail detail from the distant masks. This closes the interaction check for this close-up on these revisions. The small differences do not establish mask polarity elsewhere.
@tippythetaidum on GitHub · 2026-11-25 21:53 UTC · original
Calibration data for the example value, measured against Series X footage instead of by eye.
On victory-fork (its own version of this switch,
VICTORY_AMBIENT=<level>, written aslevel × (1.0, 0.98, 0.94)into the same screen-probe resolve output), level 0.6 is exactly this PR's examplergb9e5=0.6,0.588,0.564. I compared two 600 s runs on an RTX 5080 (Series X profile, ray-tracing structure builder off, otherwise the same build and settings) shot by shot with console footage of the same scenes. The numbers are the mean display luma of the whole frame (0-255, Rec. 709 weights, 240×135 downscale); the footage is a YouTube capture of the console:So 0.6 sits 12-16 above the console in these shots and 0.3 within 2-4. The rooms also lost their flat look at 0.3: ceilings and corners darker, closer to the footage. It's still one constant everywhere, so it can't give the console's falloff. The common room, about 52 in the footage, measured 86 at 0.6; I don't have a 0.3 shot of it yet. Most of the console's light there comes from the windows, which a constant can't follow.
Caveats: one machine, one capture of the footage (YouTube's encode and levels sit between the console and these numbers), and the shots are matched by camera, not frame-exact. If the example is meant as a sensible default,
0.3,0.294,0.282measured closer here.AI-assisted (Claude Code, Claude Opus 5.5): runs, captures, the measurement and this text. Numbers only; no frames attached.
@r4tedx on GitHub · 2026-11-25 21:55 UTC · original
@tippythetaidum, thanks for measuring it against console footage. Three matched shots, with 0.6 at 12-16 over and 0.3 within 2-4, is enough to change the example. The PR description now suggests
rgb9e5=0.3,0.294,0.282and links your comment. The values in the tests stay as they are, because they check the parser, not a level.Your caveat on the common room (about 52 on the console, 86 at 0.6) fits what the switch is: one constant for every pixel in place of probe lighting, so it can't match both a lit cell and a dim room. The real fix is getting the probe passes themselves to run, and the stand-in only bridges that gap.
AI-assisted
@Marvisak on GitHub · 2026-11-25 22:18 UTC · original · edited 2026-11-26 00:24 UTC
Automated triage for the maintainers.
Needs the maintainer's decision. The switch is opt-in, names no title program in code, and handles the zero-count indirect case raised in review (predicated clear).
On your reply: thanks for splitting the slot sharing out into #2871. That resolves the second point of the earlier triage. This branch still carries #2871's two commits (
e7169ee,d3f9b11) under the stand-in's own (8d9a25b,a83bdc1), so it can only land after #2871. The scope question is still open and isn't something triage can settle.VICTORY_AMBIENT(crates/victory-gpu/src/ambient.rs, plus the dispatch hooks indraw.rs) overwrites a program's output with a hand-tuned constant in place of lighting the host doesn't produce. Whether VIctory wants user-configured per-program stand-ins of this kind is up to the maintainer. CIcheckis passing.Generated by Claude Code
@r4tedx on GitHub · 2026-11-25 23:28 UTC · original
Following triage: the slot sharing (the old second commit, 11012ead) is now its own PR, #2871. It was adapted to
mainthere, and a cut test was added in review. This PR is rebased on top of it, so its heada83bdc1dis #2871's two commits plus the stand-in's two (8d9a25b3,a83bdc1d). Please merge #2871 first. The stand-in code itself is unchanged; the only difference from the previous head is the rebase and #2871's added test.WARP at
a83bdc1d(onmainf3578e38): clippy-D warningsclean with and without--all-features; victory-gpu lib 251 passed, 0 failed, 1 ignored. The description is updated to match. The title was not used in these tests.AI-assisted
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.