Fix most tree and prop flicker on AMD: move off-16-byte raw twins on every driver #36

Manually merged
github merged 1 commit from github-bot/gh-36 into gh-pr/36/base 2026-12-04 00:32:13 +00:00 AGit
Owner

@⁠staticman256 on GitHub · 2026-12-04 00:21 UTC · original
staticman256:raw-twin-move → main · +469 −8 · 2 files · 1 commits · merged 2026-12-04 00:29 UTC

Fix most tree and prop flicker on AMD: move off-16-byte raw twins on every driver

On an RX 9070 XT, trees, bushes, fences and poles were seen blinking constantly: single
objects missing for one frame, all the time, standing still or moving. Most of that is
removed by this PR. The cause is not specific to one card, so other GPUs and drivers
that show the same flicker are expected to be helped as well.

What was wrong

The game's lists of objects to draw are kept in buffers, and many of those lists do not
start on a 16-byte boundary. A raw buffer view in D3D12 has to. That is already handled
in ReVIctory (6c0bbb3, VICTORY_MOVE_CACHED_TWINS): the raw twin is made from the 16
bytes below and the descriptor is then edited to shift it to the real start
(move_raw).

Only a descriptor that is recognised is edited by move_raw: address, then byte count,
in the first 12 bytes. That is what is written by RX 7000 drivers. Something else is
written by the RX 9070 XT's driver, so every one of those moves was refused and the twin
was left null. A null twin is read as zeros, which is an empty list to the game, so
whatever that list held was not drawn that frame.

It had been reported in the log all along:

raw twins of buffer views made per frame: ~44,000, of them 1,000-1,400 that do not begin on 16 bytes (same number null)

What is changed

One descriptor layout is no longer assumed. The layout of the running driver is found
once at start (raw_layout, called from probe_view_limit):

  • Three raw views of a small buffer are made that differ only in start and length, and
    their descriptors are compared to find the address field and the length field
    (raw_layout_of). Every other byte has to be equal, or the layout is not used.
  • If no address is held in the descriptor at all, each pointer in it is followed and
    what lies behind it is examined. This is the RX 9070 XT case: the handle points at a
    32-byte record (pointer, stamp, resource, offset), and the address and byte count are
    found behind the first pointer.
  • Before the layout is trusted, a view is moved by 8 bytes in private heaps and eight
    things are checked: the move shows, it is carried by copies (also into a
    shader-visible heap), and the neighbouring slots and the same view in another slot
    are left untouched.

The known layout is still tried first by move_raw, exactly as before, and the probed
one is only fallen back to (move_raw_probed). On a driver whose layout is the known
one, nothing is changed. On a driver where the probe fails, nothing is changed either:
the twins stay null as they do today, and that is said in the log.

Two files are touched: crates/victory-gpu/src/descriptor/host.rs and its tests
(+469 -8).

Switches

Switch Default Meaning
VICTORY_RAW_MOVE_PROBE 1 0: only the known layout is used, as before this PR. 2: a probed layout is used even if it could not be proven by the read-back from a shader-visible heap.
VICTORY_OFF16_COPIES off 1: shader views that start off 16 bytes are given their own copy that starts on 16 bytes, so no move is needed. Memory is spent on it and views written by shaders are not covered. Meant as a fallback for a driver the probe cannot read; it is also the diagnostic by which the cause was confirmed.

How the cause was found

  1. A fix for instance lists disappearing on an RX 7900 XTX was published by
    Ancient Souzou: lists that
    start off 16 bytes were being read as zeros. The right place was pointed at by that.
    The same repair was already present in ReVIctory, so the question became why it did
    not help on this card.
  2. That was answered by the "(same number null)" counter above: the repair was run and
    was refused every time on this driver.
  3. The flicker was cut sharply by a test with VICTORY_OFF16_COPIES=1 (aligned copies,
    no move needed). Null off-16 twins were thereby confirmed as the cause before any
    descriptor was touched.
  4. The driver's descriptors were logged in hex by the first probe. A pointer and no
    address were found in them, which is why the pointer is followed in the second step
    and the move is proven with a trial.

What to look for in a log

raw buffer view descriptors of this host, for moving raw twins that do not begin on 16 bytes ...: behind a pointer, understood and tried: such twins are moved by it
the first raw twin that does not begin on 16 bytes moved by this host's layout

The first line is ended by one of four verdicts: the known layout, another layout
understood, behind a pointer, or not understood. The descriptors are also printed in
hex, so a log from a card where it fails is enough for the probe to be extended. With
VICTORY_STATS_LOG=1 the "(N null)" counter is expected to read 0.

Tested

RX 9070 XT, Windows 11, diag build, play.ps1 defaults with FSR 4 performance, ray
tracing and frame generation, tested before the rebase onto current main:

  • "behind a pointer, understood and tried" is reported by the probe with all eight
    trial checks true, and the first move is logged about 30 seconds in.
  • The constant flicker of single trees and props is gone.

Not tested

  • Any other card. The known path is expected to be taken unchanged on RX 7000. NVIDIA
    and Intel were not run; the probe is only acted on where upstream's move_raw
    refuses.
  • VICTORY_RAW_MOVE_PROBE=2 and the "another layout, understood" path (address and
    length directly in the descriptor but at other offsets): written, never met.

Not fixed by this

A whole row of trees can still be seen to vanish for one frame every few seconds. That
is a separate fault: it is removed by VICTORY_THIN=0 (or VICTORY_THIN_THREADS=1), so
it is a timing problem between the threads by which thin lists are translated, not a
null view. It is not addressed here.


Claude Fable 5.2/High

**@⁠staticman256** on GitHub · 2026-12-04 00:21 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/36) `staticman256:raw-twin-move` → `main` · +469 −8 · 2 files · 1 commits · merged 2026-12-04 00:29 UTC ## Fix most tree and prop flicker on AMD: move off-16-byte raw twins on every driver On an RX 9070 XT, trees, bushes, fences and poles were seen blinking constantly: single objects missing for one frame, all the time, standing still or moving. Most of that is removed by this PR. The cause is not specific to one card, so other GPUs and drivers that show the same flicker are expected to be helped as well. ### What was wrong The game's lists of objects to draw are kept in buffers, and many of those lists do not start on a 16-byte boundary. A raw buffer view in D3D12 has to. That is already handled in ReVIctory (6c0bbb3, `VICTORY_MOVE_CACHED_TWINS`): the raw twin is made from the 16 bytes below and the descriptor is then edited to shift it to the real start (`move_raw`). Only a descriptor that is recognised is edited by `move_raw`: address, then byte count, in the first 12 bytes. That is what is written by RX 7000 drivers. Something else is written by the RX 9070 XT's driver, so every one of those moves was refused and the twin was left null. A null twin is read as zeros, which is an empty list to the game, so whatever that list held was not drawn that frame. It had been reported in the log all along: ``` raw twins of buffer views made per frame: ~44,000, of them 1,000-1,400 that do not begin on 16 bytes (same number null) ``` ### What is changed One descriptor layout is no longer assumed. The layout of the running driver is found once at start (`raw_layout`, called from `probe_view_limit`): - Three raw views of a small buffer are made that differ only in start and length, and their descriptors are compared to find the address field and the length field (`raw_layout_of`). Every other byte has to be equal, or the layout is not used. - If no address is held in the descriptor at all, each pointer in it is followed and what lies behind it is examined. This is the RX 9070 XT case: the handle points at a 32-byte record (pointer, stamp, resource, offset), and the address and byte count are found behind the first pointer. - Before the layout is trusted, a view is moved by 8 bytes in private heaps and eight things are checked: the move shows, it is carried by copies (also into a shader-visible heap), and the neighbouring slots and the same view in another slot are left untouched. The known layout is still tried first by `move_raw`, exactly as before, and the probed one is only fallen back to (`move_raw_probed`). On a driver whose layout is the known one, nothing is changed. On a driver where the probe fails, nothing is changed either: the twins stay null as they do today, and that is said in the log. Two files are touched: `crates/victory-gpu/src/descriptor/host.rs` and its tests (+469 -8). ### Switches | Switch | Default | Meaning | |---|---|---| | `VICTORY_RAW_MOVE_PROBE` | `1` | `0`: only the known layout is used, as before this PR. `2`: a probed layout is used even if it could not be proven by the read-back from a shader-visible heap. | | `VICTORY_OFF16_COPIES` | off | `1`: shader views that start off 16 bytes are given their own copy that starts on 16 bytes, so no move is needed. Memory is spent on it and views written by shaders are not covered. Meant as a fallback for a driver the probe cannot read; it is also the diagnostic by which the cause was confirmed. | ### How the cause was found 1. A fix for instance lists disappearing on an RX 7900 XTX was published by [Ancient Souzou](https://github.com/Ancient-Souzou/Whiplash-Contribution): lists that start off 16 bytes were being read as zeros. The right place was pointed at by that. The same repair was already present in ReVIctory, so the question became why it did not help on this card. 2. That was answered by the "(same number null)" counter above: the repair was run and was refused every time on this driver. 3. The flicker was cut sharply by a test with `VICTORY_OFF16_COPIES=1` (aligned copies, no move needed). Null off-16 twins were thereby confirmed as the cause before any descriptor was touched. 4. The driver's descriptors were logged in hex by the first probe. A pointer and no address were found in them, which is why the pointer is followed in the second step and the move is proven with a trial. ### What to look for in a log ``` raw buffer view descriptors of this host, for moving raw twins that do not begin on 16 bytes ...: behind a pointer, understood and tried: such twins are moved by it the first raw twin that does not begin on 16 bytes moved by this host's layout ``` The first line is ended by one of four verdicts: the known layout, another layout understood, behind a pointer, or not understood. The descriptors are also printed in hex, so a log from a card where it fails is enough for the probe to be extended. With `VICTORY_STATS_LOG=1` the "(N null)" counter is expected to read 0. ### Tested RX 9070 XT, Windows 11, diag build, `play.ps1` defaults with FSR 4 performance, ray tracing and frame generation, tested before the rebase onto current `main`: - "behind a pointer, understood and tried" is reported by the probe with all eight trial checks true, and the first move is logged about 30 seconds in. - The constant flicker of single trees and props is gone. ### Not tested - Any other card. The known path is expected to be taken unchanged on RX 7000. NVIDIA and Intel were not run; the probe is only acted on where upstream's `move_raw` refuses. - `VICTORY_RAW_MOVE_PROBE=2` and the "another layout, understood" path (address and length directly in the descriptor but at other offsets): written, never met. ### Not fixed by this A whole row of trees can still be seen to vanish for one frame every few seconds. That is a separate fault: it is removed by `VICTORY_THIN=0` (or `VICTORY_THIN_THREADS=1`), so it is a timing problem between the threads by which thin lists are translated, not a null view. It is not addressed here. --- Claude Fable 5.2/High
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 00:26:45 +00:00
github-bot changed target branch from main to gh-pr/36/base 2026-12-04 00:32:09 +00:00
github manually merged commit ac47027380 into gh-pr/36/base 2026-12-04 00:32:13 +00:00
Author
Owner

@⁠staticman256 on GitHub · 2026-12-04 00:27 UTC · original

cc: @⁠SovietBearz0r strongly suggest bringing this in. This fixes both tree/prop flash and the LOD fade in/out.

cc: @⁠ReTerryDavis same. Also please see the note about VICTORY_THIN at the bottom.

**@⁠staticman256** on GitHub · 2026-12-04 00:27 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/36#issuecomment-7396808179) cc: @⁠SovietBearz0r strongly suggest bringing this in. This fixes both tree/prop flash and the LOD fade in/out. cc: @⁠ReTerryDavis same. Also please see the note about VICTORY_THIN at the bottom.
This discussion has been locked. Commenting is limited to contributors.
No description provided.