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
LloydNicholson wants to merge 1 commit from upstream-pr/437 into main
LloydNicholson commented 2026-11-27 07:00:30 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by LloydNicholson on 2026-11-27T07:00:30Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5522607022 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/437). Originally posted by [LloydNicholson](https://github.com/LloydNicholson) on 2026-11-27T07:00:30Z. --- 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)
UwUCammie commented 2026-11-27 07:19:53 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by UwUCammie on 2026-11-27T07:19:53Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7212367616 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/437#issuecomment-7212367616). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-27T07:19:53Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/437:upstream-pr/437'
git switch 'upstream-pr/437'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/437'
git switch 'upstream-pr/437'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/437'
git switch 'upstream-pr/437'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/437'
git switch 'main'
git merge --squash 'upstream-pr/437'
git switch 'main'
git merge --ff-only 'upstream-pr/437'
git switch 'main'
git merge 'upstream-pr/437'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
avatarmanz/VIctory-7900XTX!437
No description provided.