Trees and palms no longer drop out: raw twins of buffer views not on 16 bytes begin at the view's own dword (VICTORY_TWIN_EXACT, on) #437

Open
github-bot wants to merge 1 commit from github-bot/gh-437 into main AGit
Owner

@⁠LloydNicholson on GitHub · 2026-11-27 07:00 UTC · original
LloydNicholson:fix/raw-twin-exact → main · +42 −4 · 2 files · 1 commits · open

Fixes the outdoor tree and palm flicker tracked in #122: whole trees appearing and disappearing for single frames while the camera moves, with the title asking for the same draws every frame.

Cause

descriptor/host.rs gives every table buffer view a raw twin that translated shaders read for byte-addressed loads. A raw view has to begin on 16 bytes, so twin_window begins the twin up to 12 bytes early (by). When by > 0 the twin is only kept if move_raw can move a staged slot; otherwise it is made a null view (buffer_srv and buffer_uav). The frame line already counts these: in play, 200 to 1,000 twins a frame are null ("raw twins of buffer views made per frame … N that do not begin on 16 bytes (N null)").

InstanceCulling:CS_Tree_BatchCull (55679a0547649d0b) runs in two dispatches a frame. The CPU splits the frame's tree batches between them differently every frame, and the second dispatch's batch list (4-byte entries, a table SRV) begins right after the first one's. Whenever the first dispatch's batch count is not a multiple of 4, the second list begins off 16 bytes, its twin is null, the second dispatch reads a batch list of zeros, and none of its trees are drawn that frame. Which trees drop out depends on that frame's split, so they flicker.

The change

When by > 0, the twin begins at the view's own dword (FirstElement + by / 4, NumElements - by / 4) instead of being nulled. AMD's hardware and RADV read raw buffers from any dword. On by default; VICTORY_TWIN_EXACT=0 restores the null views. The frame line gains a count of twins made this way. Two files, +42/−4.

Proof

All runs: RX 9060 XT 16 GB (RDNA 4), Linux, Proton (vkd3d-proton), Series X, the "Just Like Paradise" title shot in the boat mission (repeatable: about 2.5 minutes into a new game, holding A through the cutscenes).

1. On this repository's own code. Upstream 014d52de plus only the Linux page-mapping patch needed to run under Wine at all, scripts/play.ps1 default switches, stock RADV. Same binary, one switch apart:

upstream A/B

Left (VICTORY_TWIN_EXACT=0): the mangroves and palms drop out to a bare dead tree in some frames. Right (this PR): full in every title frame. The frame line with =0: 782 twins a frame not on 16 bytes, all 782 null. With the fix: 399 a frame, 0 null.

2. On a full build (≈8 fps), 10 consecutive game frames each. Before: 42% of the shot's frames flicker (an A-B-A detector on de-duplicated frames). After: 0 of 20 distinct frames, every one full:

before/after

3. How it was traced (frame recorder, 3 consecutive frames of the shot; frames 0 and 1 full, frame 2 sparse).

  • A captured sparse frame replays sparse 24 of 24 times: deterministic, decided by the frame's inputs.
  • Frames 1 and 2 issue the same draws, and the CPU's batch records are the same set in both (same instance counts, only reordered). On the card the trunk draws (903776ba469c8bac) get, draw by draw:
    frame 1: 16 4 7 14 88 22 24 12 5 2 8 2 8 7 12 2 0 0 43 7 58 2 15 1 0 0 156 5 4 2 1 1
    frame 2:  0 0 0  0  0  0  0  0 0 2 8 2 8 7  0 0 0 0 43 7 58 2  0 0 0 0 156 5 0 0 0 0
    
  • Mapping each draw to its batch (word 22 of a batch record points at its draw arguments): every draw whose batch went through the first tree dispatch is right in both frames; every draw whose batch went through the second dispatch is right in frame 1 and zero in frame 2. The meshlet passes, allocation (0 refused, counter ~9,000 of 0x40000) and our argument clamp are all fine; the second dispatch's batches never get through.
  • The second dispatch's batch list begins at byte 94,876,256 in frame 1 (on 16 bytes) and 113,754,916 in frame 2 (4 bytes off). The first dispatch's batch counts: frame 1 88 (multiple of 4), frame 2 105.
  • Things ruled out on the same shot first: the relay, all the speed switches at once, VICTORY_INDIRECT_BATCH=1 + INDIRECT_WINDOW=0, renderer ports (port 1 and 2 off here), the CPU occlusion pyramid (copied back, and forced to constants), GPU timestamps, lodScale, a fixed simulation step.

Not tested: Windows, and NVIDIA. If a host refuses raw views that are not on 16 bytes, VICTORY_TWIN_EXACT=0 is the old behaviour; move_raw stays as it was for staged slots.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠LloydNicholson** on GitHub · 2026-11-27 07:00 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/437) `LloydNicholson:fix/raw-twin-exact` → `main` · +42 −4 · 2 files · 1 commits · open Fixes the outdoor tree and palm flicker tracked in #122: whole trees appearing and disappearing for single frames while the camera moves, with the title asking for the same draws every frame. ## Cause `descriptor/host.rs` gives every table buffer view a raw twin that translated shaders read for byte-addressed loads. A raw view has to begin on 16 bytes, so `twin_window` begins the twin up to 12 bytes early (`by`). When `by > 0` the twin is only kept if `move_raw` can move a staged slot; otherwise it is made a **null view** (`buffer_srv` and `buffer_uav`). The frame line already counts these: in play, 200 to 1,000 twins a frame are null ("raw twins of buffer views made per frame … N that do not begin on 16 bytes (N null)"). `InstanceCulling:CS_Tree_BatchCull` (55679a0547649d0b) runs in two dispatches a frame. The CPU splits the frame's tree batches between them differently every frame, and the second dispatch's batch list (4-byte entries, a table SRV) begins right after the first one's. Whenever the first dispatch's batch count is not a multiple of 4, the second list begins off 16 bytes, its twin is null, the second dispatch reads a batch list of zeros, and none of its trees are drawn that frame. Which trees drop out depends on that frame's split, so they flicker. ## The change When `by > 0`, the twin begins at the view's own dword (`FirstElement + by / 4`, `NumElements - by / 4`) instead of being nulled. AMD's hardware and RADV read raw buffers from any dword. On by default; `VICTORY_TWIN_EXACT=0` restores the null views. The frame line gains a count of twins made this way. Two files, +42/−4. ## Proof All runs: RX 9060 XT 16 GB (RDNA 4), Linux, Proton (vkd3d-proton), Series X, the "Just Like Paradise" title shot in the boat mission (repeatable: about 2.5 minutes into a new game, holding A through the cutscenes). **1. On this repository's own code.** Upstream `014d52de` plus only the Linux page-mapping patch needed to run under Wine at all, `scripts/play.ps1` default switches, stock RADV. Same binary, one switch apart: ![upstream A/B](https://github.com/LloydNicholson/VIctory-Linux/raw/evidence/tree-flicker/upstream-ab.png) Left (`VICTORY_TWIN_EXACT=0`): the mangroves and palms drop out to a bare dead tree in some frames. Right (this PR): full in every title frame. The frame line with `=0`: 782 twins a frame not on 16 bytes, all 782 null. With the fix: 399 a frame, 0 null. **2. On a full build (≈8 fps), 10 consecutive game frames each.** Before: 42% of the shot's frames flicker (an A-B-A detector on de-duplicated frames). After: 0 of 20 distinct frames, every one full: ![before/after](https://github.com/LloydNicholson/VIctory-Linux/raw/evidence/tree-flicker/before-after.png) **3. How it was traced (frame recorder, 3 consecutive frames of the shot; frames 0 and 1 full, frame 2 sparse).** - A captured sparse frame replays sparse 24 of 24 times: deterministic, decided by the frame's inputs. - Frames 1 and 2 issue the same draws, and the CPU's batch records are the same set in both (same instance counts, only reordered). On the card the trunk draws (903776ba469c8bac) get, draw by draw: ``` frame 1: 16 4 7 14 88 22 24 12 5 2 8 2 8 7 12 2 0 0 43 7 58 2 15 1 0 0 156 5 4 2 1 1 frame 2: 0 0 0 0 0 0 0 0 0 2 8 2 8 7 0 0 0 0 43 7 58 2 0 0 0 0 156 5 0 0 0 0 ``` - Mapping each draw to its batch (word 22 of a batch record points at its draw arguments): every draw whose batch went through the first tree dispatch is right in both frames; every draw whose batch went through the second dispatch is right in frame 1 and zero in frame 2. The meshlet passes, allocation (0 refused, counter ~9,000 of 0x40000) and our argument clamp are all fine; the second dispatch's batches never get through. - The second dispatch's batch list begins at byte 94,876,256 in frame 1 (on 16 bytes) and 113,754,916 in frame 2 (4 bytes off). The first dispatch's batch counts: frame 1 88 (multiple of 4), frame 2 105. - Things ruled out on the same shot first: the relay, all the speed switches at once, `VICTORY_INDIRECT_BATCH=1` + `INDIRECT_WINDOW=0`, renderer ports (port 1 and 2 off here), the CPU occlusion pyramid (copied back, and forced to constants), GPU timestamps, `lodScale`, a fixed simulation step. Not tested: Windows, and NVIDIA. If a host refuses raw views that are not on 16 bytes, `VICTORY_TWIN_EXACT=0` is the old behaviour; `move_raw` stays as it was for staged slots. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The tree culling (InstanceCulling:CS_Tree_BatchCull) runs in two dispatches a
frame; the second one's batch list begins right after the first one's 4-byte
entries. In every frame whose split left it off 16 bytes its raw twin was a
null view, the second dispatch read a batch list of zeros, and its trees were
not drawn: whole trees and palms dropped out for single frames while the
camera moved (the 'Just Like Paradise' title shot: 42% of frames). Up to
1,000 such twins a frame were null in play. With exact twins: 0 flicker frames
(run titleTX). Also on upstream main without this fork's changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7a03d84de21847d2fbbd71c43e89b484b4b070ba)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:07:56 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 07:19 UTC · original

The exact offsets work on my RX 7900 XT too. With RADV 26.3.1, Wine 11.22 and vkd3d-proton cae8353ed7959c4, a compute shader read and wrote the expected words through the runtime's raw SRV/UAV twins at 4, 8 and 12 bytes. The surrounding words stayed intact.

I opened the Linux AMD backport with the exact path opt-in and the existing byte relocation for sub-dword views. Foliage still needs a matched in-game run on this card.

**@⁠UwUCammie** on GitHub · 2026-11-27 07:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/437#issuecomment-7212367616) The exact offsets work on my RX 7900 XT too. With RADV 26.3.1, Wine 11.22 and vkd3d-proton `cae8353ed7959c4`, a compute shader read and wrote the expected words through the runtime's raw SRV/UAV twins at 4, 8 and 12 bytes. The surrounding words stayed intact. I opened [the Linux AMD backport](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/59) with the exact path opt-in and the existing byte relocation for sub-dword views. Foliage still needs a matched in-game run on this card.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-437'
git switch 'github-bot/gh-437'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-437'
git switch 'github-bot/gh-437'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-437'
git switch 'main'
git merge --squash 'github-bot/gh-437'
git switch 'main'
git merge --ff-only 'github-bot/gh-437'
git switch 'main'
git merge 'github-bot/gh-437'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.