Skip to content

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

Open
Kam471 wants to merge 2 commits into
trustno1-coder:mainfrom
Kam471:reflections-raymiss-zero
Open

Kam471 wants to merge 2 commits into
trustno1-coder:mainfrom
Kam471:reflections-raymiss-zero

Conversation

@Kam471

@Kam471 Kam471 commented Nov 29, 2026

Copy link
Copy Markdown

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.

…ogram would have written

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
(trustno1-coder#2440). The switch clears that image where the dispatch would have run, so
the screen-space resolve writes over a known unlit value.
…e once

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.
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants