Light stand-in: an opt-in hold of the traced reflections to the light around (VICTORY_AMBIENT_REFLECT) #99
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/TaynanGT--Vice-Tay!99
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-99"
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?
@CowboyBingus on GitHub · 2026-11-27 00:46 UTC · original
CowboyBingus:fix/ambient-reflect-hold→main· +332 −10 · 2 files · 2 commits · closed without mergingWhat it fixes
In our runs with the ray-tracing structure builder off, eyes in many close-ups showed a flat blue-white glow or a pale lavender where the irises should be. With this hold on, the irises were dark in the close-ups we captured.
avatarmanz/VIctory-7900XTX#231 reports the same symptom on AMD cards: flat, bright, bluish-white patches over the eyes, with no iris or pupil. A comment there reports the eyes correct with
VICTORY_BVH_BUILDER=1.What it does
This only acts while the builder is off and the light stand-in is on.
Right after each program that resolves the traced reflections, one pass runs over the reflection image. The image is found the same way as in #314. Any texel brighter than a set multiple of the stand-in's light around it is scaled down to that limit, keeping its hue.
How to switch it on
It is off by default. Two switches are needed:
VICTORY_AMBIENT_REFLECT=<multiple>: a positive number. Unset,0oroffleaves the title's own reflections. We used1.VICTORY_AMBIENT_REFLECT_IN=<text>[,<text>]: text in the names of the programs that resolve the reflections.It also needs the stand-in on:
VICTORY_AMBIENT(whichplay.ps1sets), orVICTORY_AMBIENT_RT, which also switches the stand-in on. It does nothing while the builder runs, including withVICTORY_AMBIENT_RT.Log lines:
reflections held to a multiple of the light around (VICTORY_AMBIENT_REFLECT) held=… count=….the reflections are held after their resolve size=[…].With either switch unset, behaviour is unchanged. (With only
VICTORY_AMBIENT_REFLECTset, a warning says that no reflections are held.)If the hold's pass fails to compile, a warning is logged and the rest of the stand-in still runs.
Measured
Setup:
play.ps1settings without-Safeor-RayTracing: its 4090 machine settings, picked automatically, except the last three runs below, which used-Machine 4070.Results:
0b5b906): a flat blue-white glow over the eyes in one close-up (run V3, s0120). Pale lavender in a close-up of another run (run P1, s0129).0b5b906plus this change, switches as above): dark irises in close-ups at s0118 and s0123 (run E2b). In another run (H1) they were dark brown at s0125 and s0130. Both log lines were present once in each of the three runs with the hold and absent from the five without it.VICTORY_BVH_BUILDER=1, no hold): the eyes looked normal, but the run had other picture defects and ran at about 2 fps (median 428 ms).4e3e366plus this change,-Machine 4070, one run): both log lines present, the eye close-ups dark, and a median of 48.4 ms. Two plain4e3e366runs on the same preset had medians of 49.5 and 47.05 ms.All runs with the hold except the last one used the change on
0b5b906. The runs without it used plain0b5b906, except the two plain4e3e366runs. This branch is the same change rebased onto4e3e366.ambient.rsafter(), where this change'smostmeets the newerbounds(). For the hold,mostis its own multiple andleastis 0; the hold's pass does not readleast.VICTORY_AMBIENT_RTlets the stand-in run with the builder.Credit
Ported from Serph91P's avatarmanz/VIctory-7900XTX#314 (commit 6c7e3a8, GPL-3.0-or-later): the hold's HLSL pass, the reflection role, the image lookup and the hook after indirect dispatches. The idea of holding the reflections to the ambient light, and the switch's name, are beloooo's (VIctory-Belobug-AMD 44dcd437).
Differences from #314:
--reflectand the docs are left out.Tests
ambient::tests::settings: parsing of both switches.ambient::tests::roles_by_name: the role is given only by the texts passed in, and never without them.ambient::tests::the_hold_compiles: the hold's pass compiles with the system's compiler.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: both pass (exit 0).cargo test --workspace --locked --no-fail-faston4e3e366+ this change: 1105 passed, 0 failed, 53 ignored (29 test result lines; RTX 5070 Ti, Windows 11).No game data in the commit.
🤖 Generated with Claude Code
@TaynanGT on GitHub · 2026-11-27 01:28 UTC · original · reviewed
Thanks for the alternating runs and the comparison with the builder enabled. I started CI on
fc9ef8a7. Could you confirm whether the reflection resolves you measured use a count buffer? I left a question on the indirect path.@ -4625,0 +4641,4 @@if p.stages.first().and_then(|s| s.shader.ambient)== Some(crate::ambient::Role::Reflect){self.after_dispatch(list, p);@TaynanGT on GitHub · 2026-11-27 01:28 UTC · original
This hook records a write to the reflection UAV after
ExecuteIndirect. With a count buffer of zero, the resolve records no dispatch at playback and this still rewrites the previous contents. Do the targeted resolves always run at least one dispatch? Please document or guard that requirement if the counted path can reach the hook.After an ExecuteIndirect with a count buffer the record count is read on the card and may be 0, and a Dispatch may ask for no groups. The resolve then writes nothing, and a hold recorded after it would rewrite what the image held before. In both cases the hold is no longer recorded. The first time each happens while `ambient::after` would record a hold (the image's view is not checked), an INFO line says so: "reflections not held after a counted indirect dispatch" and "reflections not held after a dispatch of no groups". To show which ways the title dispatches the resolves, they are counted by how they were dispatched: holds after a Dispatch and after an ExecuteIndirect without a count buffer; counted and empty resolves left alone (counted only while `ambient::after` would record a hold; the image's view is not checked). The counts are logged at INFO at the first noted resolve 100 or more frames after the first noted one, then at most once every 1000 frames ("reflections' resolves: held after a direct dispatch, held after an indirect one without a count, not held after a counted one or a direct one of no groups", with frames, direct, indirect, counted and empty). Nothing changes while the hold is off (VICTORY_AMBIENT_REFLECT or VICTORY_AMBIENT_REFLECT_IN unset): no program has the reflections' role (Role::Reflect), so neither the new branches nor the counts are reached. Not covered: an ExecuteIndirect without a count buffer whose records ask for no groups; the hold still follows it. Test: ambient::tests::counts_by_dispatch_are_due_after_the_first_note_then_every_so_often. Co-Authored-By: Claude Opus 5.5 <[email protected]>@CowboyBingus on GitHub · 2026-11-27 02:12 UTC · original
Thanks. Our earlier logs could not answer the count-buffer question, so I added counts by dispatch path and measured one run.
Earlier runs. These were four runs with the hold, all on an RTX 5070 Ti: three on
0b5b906with a port of this PR's first commit, and one on4e3e366with its first commit, before these guards. Their logs have only these hold lines:role=Reflect).None of these lines says whether the resolve came from
Dispatch, fromExecuteIndirectwithout a count buffer, or fromExecuteIndirectwith one.In
fa90adf:ExecuteIndirectwith a count buffer, the hold is no longer recorded.Dispatchof no groups, the hold is no longer recorded either.ambient::afterwould record a hold, an INFO line says so:reflections not held after a counted indirect dispatchreflections not held after a dispatch of no groupsDispatch, holds afterExecuteIndirectwithout a count, and counted and empty resolves left alone (noted only whileambient::afterwould record a hold). The counts are logged at the first noted resolve 100 or more frames after the first noted one, then at most once every 1000 frames:reflections' resolves: held after a direct dispatch, held after an indirect one without a count, not held after a counted one or a direct one of no groups frames=… direct=… indirect=… counted=… empty=…ambient::tests::counts_by_dispatch_are_due_after_the_first_note_then_every_so_oftenchecks the schedule of the count lines (counts_due).Measured. One run (its log spans 230 s) with a diagnostics build (
--profile diag --features diagnostics) of b8fda70, whose tree is the same as fa90adf's (exe md5 b6405e23…): RTX 5070 Ti, Series S,-Machine 4070,VICTORY_AMBIENT_REFLECT=1andVICTORY_AMBIENT_REFLECT_INset. The count lines, verbatim:frames=100 direct=0 indirect=201 counted=0 empty=0frames=1100 direct=0 indirect=2201 counted=0 empty=0frames=2100 direct=0 indirect=4201 counted=0 empty=0frames=3100 direct=0 indirect=6201 counted=0 empty=0(the last one)In this run, up to the last count line (frames=3100), every hold that was recorded followed an
ExecuteIndirectwithout a count buffer (direct=0). The log goes on for 10.6 s after that line, and holds in those seconds are in no count.Neither "reflections not held after …" line appears anywhere in the log. So while
ambient::afterwould have recorded a hold (by its own checks; the image's view is not checked), no resolve with a count buffer and no emptyDispatchreached the hook.These counts cover only the scenes this one run reached.
Not covered: an
ExecuteIndirectwithout a count buffer whose records ask for no groups. The hook still follows it, and these counts do not show such records.Checks.
cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: both exit 0.cargo test --workspace --locked --no-fail-fast: exit 0, 1106 passed, 0 failed, 53 ignored. Both ran on this tree (b8fda70) on Windows 11, on the same machine as the run above.@CowboyBingus on GitHub · 2026-11-27 02:12 UTC · original
On
crates/victory-gpu/src/draw.rsline 4644 (outdated):Guarded in
fa90adf: after anExecuteIndirectwith a count buffer (and after aDispatchof no groups) the hold is not recorded, with a one-time INFO line and counts by dispatch path. Measured counts and the case not covered are in the PR conversation.@TaynanGT on GitHub · 2026-11-27 02:19 UTC · original
On
crates/victory-gpu/src/draw.rsline 4644 (outdated):Thanks for adding the counted and direct zero-group guards and measuring the dispatch paths. I approved CI for
fa90adf. Since all 6,201 holds in the reported window followed uncounted indirect resolves, the zero-group record you called out is the remaining case to cover. Could you check whether the targeted resolves can reach that path with a zero group dimension, or guard the hold so it only runs when the resolve actually wrote the image?@TaynanGT on GitHub · 2026-11-27 03:14 UTC · original
@CowboyBingus Thanks for calling out the uncounted zero-group case. I tested a guard that reads the actual group counts after the clamp. The WARP test preserved the reflection texel for a zero in each dimension and for an oversized dispatch that the clamp zeroed. A valid dispatch changed the texel. I kept your commits in draft #127.
Could you repeat your RTX 5070 Ti scene on #127 with the same settings? The new counters distinguish
indirect_gatedfrommultiple. The original 6,201 uncounted calls did not distinguish those paths. A short excerpt with those counts, the GPU time and how the eyes look would cover the remaining check.@TaynanGT on GitHub · 2026-11-27 04:11 UTC · original
Thanks for the reflection work and the follow-up RTX 5070 Ti run, @CowboyBingus. The opt-in hold is now on
mainthrough #127 with your commits preserved. The guard passed the empty-dispatch WARP regression, and I reran the ambient, indirect and texture readback checks together with #141. The gameplay numbers remain useful context for measuring the pass separately.Pull request closed