Reflections: VICTORY_RAYMISS_ZERO clears the image a left-out miss program would have written #2872

Open
github-bot wants to merge 2 commits from github-bot/gh-2872 into main AGit
Owner

@⁠Kam471 on GitHub · 2026-11-29 18:25 UTC · original
Kam471:reflections-raymiss-zero → main · +301 −42 · 2 files · 2 commits · open

What this changes

VICTORY_RAYMISS_ZERO=1 clears the reflections' image at the place in the
list where a left-out miss program would have written it.

Why

Since e2d7854e the reflections' miss program is left out for opaque and
transparent surfaces, so its sky light does not grain indoor floors seen at a
grazing angle (draw.rs, sky_miss_left_out). Left out, its image keeps what
an earlier frame left there. For the rays the screen-space resolve does not
cover, that is the flickering red/green/purple blocks #2440 reports on windows
and glass, and what #2643, #2661 and #2275 report on other reflective surfaces.

Zero is neither the sky's light nor an earlier frame: the resolve still writes
what its march found over it, and what it does not cover is unlit — the same
every frame, so nothing flickers. The parquet floors the skip was for keep the
skip.

This is the direction #2534 was closed with: the layer constants do not split
glass from the floors (one dispatch fills the whole half-size target), so the
fix has to be at the dispatch rather than per layer. #2464's section 1 asks for
exactly this: give the dispatch's output zero instead of leaving the dispatch
out.

How

  • ambient::zero records a small compute pass (cs_5_1,
    DescriptorTable(UAV(u0))) over the image between the title's own UAV
    barrier and one after it, at the place of the skipped dispatch. It replaces
    the list's compute root signature and pipeline, as ambient::after already
    does.
  • State::miss_image finds the image the program would have written: its usual
    place (ambient::MISS_LIGHT), else the first 2D R11G11B10 UAV in its tables
    (a variant binds it elsewhere), with the size of the host texture.
  • State::host_heaps is lifted out of bind so the clear can bind the heap the
    title last set before its table is addressed; bind calls the same function.
  • The image size is logged once:
    the reflections' image is cleared where the miss program is left out (VICTORY_RAYMISS_ZERO).

VICTORY_RAYMISS_KEEP=1 still runs the program instead. The two are exclusive,
KEEP first: with the program running the image is filled as before and
nothing is cleared.

Default

Off, read with asked_for!: a run that does not set VICTORY_RAYMISS_ZERO=1
records nothing new. Turning it on by default should follow a play session on
#2440's spot (the stilt house's windows) and on the parquet floors the skip is
for; the switch is there so that can be done one machine at a time.

Tests

  • cargo test -p victory-gpu --lib ambient — the_clear_zeroes_every_texel
    (WARP: an 8x1 R11G11B10 image filled with 0xDEADBEEF, the clear's calls
    recorded on a list, every texel reads back zero) and the_passes_build,
    which now compiles ZERO_SOURCE with the estimate kernels.
  • cargo test -p victory-gpu --lib for the whole crate.

Refs #2440, #2464.

**@⁠Kam471** on GitHub · 2026-11-29 18:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2872) `Kam471:reflections-raymiss-zero` → `main` · +301 −42 · 2 files · 2 commits · open ## What this changes `VICTORY_RAYMISS_ZERO=1` clears the reflections' image at the place in the list where a left-out miss program would have written it. ## Why Since `e2d7854e` the reflections' miss program is left out for opaque and transparent surfaces, so its sky light does not grain indoor floors seen at a grazing angle (`draw.rs`, `sky_miss_left_out`). Left out, its image keeps what an earlier frame left there. For the rays the screen-space resolve does not cover, that is the flickering red/green/purple blocks #2440 reports on windows and glass, and what #2643, #2661 and #2275 report on other reflective surfaces. Zero is neither the sky's light nor an earlier frame: the resolve still writes what its march found over it, and what it does not cover is unlit — the same every frame, so nothing flickers. The parquet floors the skip was for keep the skip. This is the direction #2534 was closed with: the layer constants do not split glass from the floors (one dispatch fills the whole half-size target), so the fix has to be at the dispatch rather than per layer. #2464's section 1 asks for exactly this: give the dispatch's output zero instead of leaving the dispatch out. ## How - `ambient::zero` records a small compute pass (`cs_5_1`, `DescriptorTable(UAV(u0))`) over the image between the title's own UAV barrier and one after it, at the place of the skipped dispatch. It replaces the list's compute root signature and pipeline, as `ambient::after` already does. - `State::miss_image` finds the image the program would have written: its usual place (`ambient::MISS_LIGHT`), else the first 2D R11G11B10 UAV in its tables (a variant binds it elsewhere), with the size of the host texture. - `State::host_heaps` is lifted out of `bind` so the clear can bind the heap the title last set before its table is addressed; `bind` calls the same function. - The image size is logged once: `the reflections' image is cleared where the miss program is left out (VICTORY_RAYMISS_ZERO)`. `VICTORY_RAYMISS_KEEP=1` still runs the program instead. The two are exclusive, `KEEP` first: with the program running the image is filled as before and nothing is cleared. ## Default Off, read with `asked_for!`: a run that does not set `VICTORY_RAYMISS_ZERO=1` records nothing new. Turning it on by default should follow a play session on #2440's spot (the stilt house's windows) and on the parquet floors the skip is for; the switch is there so that can be done one machine at a time. ## Tests - `cargo test -p victory-gpu --lib ambient` — `the_clear_zeroes_every_texel` (WARP: an 8x1 R11G11B10 image filled with `0xDEADBEEF`, the clear's calls recorded on a list, every texel reads back zero) and `the_passes_build`, which now compiles `ZERO_SOURCE` with the estimate kernels. - `cargo test -p victory-gpu --lib` for the whole crate. Refs #2440, #2464.
With no ray-tracing structures the miss program is left out so its sky light
does not grain floors, but then its image keeps earlier frames' bytes: on
glass and windows that is coloured blocks that flicker as the view moves
(#2440). The switch clears that image where the dispatch would have run, so
the screen-space resolve writes over a known unlit value.
The reflections' image is a view in the heap the title last set, and a
draw of another pipeline may have bound another heap since. The clear now
binds the host's for the title's before it dispatches: `State::host_heaps`,
lifted out of `bind` so the same check serves both. The image size is said
once, at the image `miss_image` finds.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:28:53 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 11:17 UTC · original

I applied both commits of 99270e2 on top of release/main 41adb551 (aab77d8) and ran the ambient suite on Windows. All 16 tests passed, including a WARP readback with a generated 17Г—11 R11G11B10_FLOAT image. Each texel started with the same nonzero value.

Commands on the test list Zero texels on readback
Omit the miss dispatch and any clear 0 / 187
This PR's compute clear 187 / 187
Native ClearUnorderedAccessViewFloat, as used by #2764 187 / 187

The native row exercises the D3D12 clear in isolation. Both #2764 commits also apply cleanly to 41adb551 as e409dff, and cargo check --locked -p victory --features diagnostics --target x86_64-pc-windows-msvc completed.

One coverage gap remains here. The direct branch records the clear when opted in. The indirect dispatch branch still returns without a clear. #2764 calls its clear in both places. Do indirect miss dispatches need the same treatment here, or is the scope direct dispatches only? I have no gameplay capture identifying an indirect miss dispatch.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 11:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2872#issuecomment-7276809107) I applied both commits of `99270e2` on top of release/main `41adb551` (`aab77d8`) and ran the ambient suite on Windows. All 16 tests passed, including a WARP readback with a generated 17Г—11 `R11G11B10_FLOAT` image. Each texel started with the same nonzero value. | Commands on the test list | Zero texels on readback | | --- | ---: | | Omit the miss dispatch and any clear | 0 / 187 | | This PR's compute clear | 187 / 187 | | Native `ClearUnorderedAccessViewFloat`, as used by #2764 | 187 / 187 | The native row exercises the D3D12 clear in isolation. Both #2764 commits also apply cleanly to `41adb551` as `e409dff`, and `cargo check --locked -p victory --features diagnostics --target x86_64-pc-windows-msvc` completed. One coverage gap remains here. The [direct branch](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/99270e2b679ad804cfbe011c4fd9e43a147947e1/crates/victory-gpu/src/draw.rs#L4735) records the clear when opted in. The [indirect dispatch branch](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/99270e2b679ad804cfbe011c4fd9e43a147947e1/crates/victory-gpu/src/draw.rs#L6636) still returns without a clear. #2764 calls its clear in both places. Do indirect miss dispatches need the same treatment here, or is the scope direct dispatches only? I have no gameplay capture identifying an indirect miss dispatch. AI-assisted with OpenAI Codex.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2872/head:github-bot/gh-2872'
git switch 'github-bot/gh-2872'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2872'
git switch 'github-bot/gh-2872'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2872'
git switch 'github-bot/gh-2872'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2872'
git switch 'main'
git merge --squash 'github-bot/gh-2872'
git switch 'main'
git merge --ff-only 'github-bot/gh-2872'
git switch 'main'
git merge 'github-bot/gh-2872'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2872
No description provided.