GPU: small unordered-access textures get their host copies with their views (one tile repeated over the shore after #996) #1183

Merged
seabed-dev merged 1 commit from upstream-pr/1183 into main 2026-11-28 19:39:38 +00:00
seabed-dev commented 2026-11-28 15:05:45 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by seabed-dev on 2026-11-28T15:05:45Z.


Follows #996. With #996 the tessellated terrain next to water is drawn; this makes its ground look right.

What it fixes

With #996 applied, the ground that it brings back (the sand at a beach, the seabed) shows one tile of the terrain's virtual texture repeated everywhere, in strips about a texel of the terrain's material map wide, and the tile changes while you move. It looks like a texture set to repeat.

Cause

That terrain's pixel shader (PS_TexturedDeferred) looks its pages up in a page table: a 256x256 R16_UINT texture of six levels. It takes the table from the view heap by an index it reads from a constant buffer (slot 8716 here). The programs that write the table (terrain_indirection_texture:CS_UpdateIndirection and its siblings) take it the same way: an index from a buffer, the descriptor from the resource heap, image_store.

A host copy is made when a list names its texture, and a slot written with a view of a texture that has none waits for it (descriptor.rs wait_for / make_waiting). No list ever names this texture, so:

  • its slot waited for the whole run (logged for 3,900 frames: "host copy made: false, waits: true", while the writers were first bound at frames 1145 to 2108),
  • the slot read as a null view, every lookup gave 0, and 0 is "page 0, valid".

The textures the title fills itself are covered by the pass over textures picked by index. A texture the host writes has nobody: with VICTORY_QUEUE_HOST_TEXTURES=0 it leaves that queue, and with it on the pass has nothing to bring up to date for it.

Fix

A texture with the unordered-access flag and neither the target nor the depth flag, of at most 1 MiB of texels, gets its host copy when a view of it is written into a view heap (wait_for), instead of on a first use that may never come.

  • Targets and depth textures are left as they are: the list that binds them names them, always.
  • VICTORY_UNORDERED_NOW_KB sets the size: 1024 by default, 0 turns the rule off (as before).
  • The size limit is a cut-off, not a principle. Without it the rule is complete (every texture that can have this problem); it then costs about 110 MiB, see below. An index-picked texture over the limit stays as it was before this PR.

Measured

RTX 5080 16 GB, Ryzen 9 9950X3D, 32 GB, Windows 11, Series X profile, 2560x1440.

What the rule adds to the card. Counted in a build that only counts (on Vice-Tay 57deba5c4, which has the same wait_for): every host-written texture seen in a view heap without a host copy, and whether anything made it later. One session over water, a beach, the inside of a bar and a street, 6,000 frames:

Rule Textures nothing else made Texel bytes
this PR (unordered access only, up to 1 MiB) 32 to 34 1.9 MiB
the same without the size limit 41 to 43 112 MiB
every host-written texture (targets and depth too) about 470 about 1.1 GiB

About 400 unordered-access textures are seen by frame 2,400 and the number does not grow with the places visited. Among those still waiting, nothing lies between 682 KiB and 2.7 MiB, so the default is not on an edge. (Sizes are texel bytes with levels counted as 4/3, not allocations.)

Frame time, this fork, #996 plus this PR, rule on against VICTORY_UNORDERED_NOW_KB=0, four unattended runs of 180 s alternating, the 40 s where the picture stands still at the start of play:

Run Rule ms/frame, mean Range
1 on 33.1 31.9 to 33.8
2 off 32.6 32.2 to 32.9
3 on 32.9 31.6 to 33.7
4 off 33.8 31.9 to 36.4

On 33.0 ms, off 33.2 ms; two runs of one setting differ by more than the settings do. No difference these runs can show.

Tested

  • This fork, 216bca9 (#996) plus this commit, release build: played at a beach and in the water next to it; the ground is continuous, no strips, nothing else looked different. The rule's log line counts the host copies it makes.
  • Vice-Tay: the same rule in three play sessions; the slot's record logged before (never made) and after (made at frame 88); a recorded frame replayed with and without the mesh-record fix to find the cause.
  • cargo test -p victory-gpu: 454 passed, 0 failed, 36 ignored. One new test, small_unordered_textures_are_made_with_their_views.
  • cargo test --workspace: all pass except three in victory-shader (emit::rect::tests::the_rectangle_stage_is_a_geometry_shader, rectangles_are_drawn_whole, emit::barycentric_tests::first_half_values_render_on_hardware_and_warp: "Container part 'Pipeline State Validation' does not match"). They fail the same way on this PC without this commit, and this commit does not touch that crate.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings: three errors, none in lines this commit touches (victory-shader/src/emit/mod.rs:2768, victory-gpu/src/descriptor.rs:1234, victory-gpu/src/shadow.rs:1708); the same without this commit.

Not tested

  • Series S, cards with less than 16 GB, AMD and Intel cards, Linux.
  • Long sessions: the counting is from one session of about five minutes.
  • Whether any of the larger unordered-access textures that still wait is picked by index somewhere; nothing was seen to render wrong for it.
  • The tessellated terrain's shadow draws (MST_DS_CascadeShadows) were not looked at.

Notes

  • The commit is independent of #996 in code (other files) and applies to main as it is; its effect shows only with #996, because without it that ground is not drawn.
  • Found and written with Claude (Anthropic); every number above is from runs on the PC named.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5541495198 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1183). Originally posted by [seabed-dev](https://github.com/seabed-dev) on 2026-11-28T15:05:45Z. --- Follows #996. With #996 the tessellated terrain next to water is drawn; this makes its ground look right. ## What it fixes With #996 applied, the ground that it brings back (the sand at a beach, the seabed) shows one tile of the terrain's virtual texture repeated everywhere, in strips about a texel of the terrain's material map wide, and the tile changes while you move. It looks like a texture set to repeat. ## Cause That terrain's pixel shader (`PS_TexturedDeferred`) looks its pages up in a page table: a 256x256 R16_UINT texture of six levels. It takes the table from the view heap by an index it reads from a constant buffer (slot 8716 here). The programs that write the table (`terrain_indirection_texture:CS_UpdateIndirection` and its siblings) take it the same way: an index from a buffer, the descriptor from the resource heap, `image_store`. A host copy is made when a list names its texture, and a slot written with a view of a texture that has none waits for it (`descriptor.rs` `wait_for` / `make_waiting`). No list ever names this texture, so: - its slot waited for the whole run (logged for 3,900 frames: "host copy made: false, waits: true", while the writers were first bound at frames 1145 to 2108), - the slot read as a null view, every lookup gave 0, and 0 is "page 0, valid". The textures the title fills itself are covered by the pass over textures picked by index. A texture the host writes has nobody: with `VICTORY_QUEUE_HOST_TEXTURES=0` it leaves that queue, and with it on the pass has nothing to bring up to date for it. ## Fix A texture with the unordered-access flag and neither the target nor the depth flag, of at most 1 MiB of texels, gets its host copy when a view of it is written into a view heap (`wait_for`), instead of on a first use that may never come. - Targets and depth textures are left as they are: the list that binds them names them, always. - `VICTORY_UNORDERED_NOW_KB` sets the size: 1024 by default, 0 turns the rule off (as before). - The size limit is a cut-off, not a principle. Without it the rule is complete (every texture that can have this problem); it then costs about 110 MiB, see below. An index-picked texture over the limit stays as it was before this PR. ## Measured RTX 5080 16 GB, Ryzen 9 9950X3D, 32 GB, Windows 11, Series X profile, 2560x1440. **What the rule adds to the card.** Counted in a build that only counts (on Vice-Tay 57deba5c4, which has the same `wait_for`): every host-written texture seen in a view heap without a host copy, and whether anything made it later. One session over water, a beach, the inside of a bar and a street, 6,000 frames: | Rule | Textures nothing else made | Texel bytes | |---|---|---| | this PR (unordered access only, up to 1 MiB) | 32 to 34 | 1.9 MiB | | the same without the size limit | 41 to 43 | 112 MiB | | every host-written texture (targets and depth too) | about 470 | about 1.1 GiB | About 400 unordered-access textures are seen by frame 2,400 and the number does not grow with the places visited. Among those still waiting, nothing lies between 682 KiB and 2.7 MiB, so the default is not on an edge. (Sizes are texel bytes with levels counted as 4/3, not allocations.) **Frame time**, this fork, #996 plus this PR, rule on against `VICTORY_UNORDERED_NOW_KB=0`, four unattended runs of 180 s alternating, the 40 s where the picture stands still at the start of play: | Run | Rule | ms/frame, mean | Range | |---|---|---|---| | 1 | on | 33.1 | 31.9 to 33.8 | | 2 | off | 32.6 | 32.2 to 32.9 | | 3 | on | 32.9 | 31.6 to 33.7 | | 4 | off | 33.8 | 31.9 to 36.4 | On 33.0 ms, off 33.2 ms; two runs of one setting differ by more than the settings do. No difference these runs can show. ## Tested - This fork, 216bca9 (#996) plus this commit, release build: played at a beach and in the water next to it; the ground is continuous, no strips, nothing else looked different. The rule's log line counts the host copies it makes. - Vice-Tay: the same rule in three play sessions; the slot's record logged before (never made) and after (made at frame 88); a recorded frame replayed with and without the mesh-record fix to find the cause. - `cargo test -p victory-gpu`: 454 passed, 0 failed, 36 ignored. One new test, `small_unordered_textures_are_made_with_their_views`. - `cargo test --workspace`: all pass except three in `victory-shader` (`emit::rect::tests::the_rectangle_stage_is_a_geometry_shader`, `rectangles_are_drawn_whole`, `emit::barycentric_tests::first_half_values_render_on_hardware_and_warp`: "Container part 'Pipeline State Validation' does not match"). They fail the same way on this PC without this commit, and this commit does not touch that crate. - `cargo clippy --workspace --all-targets --all-features -- -D warnings`: three errors, none in lines this commit touches (`victory-shader/src/emit/mod.rs:2768`, `victory-gpu/src/descriptor.rs:1234`, `victory-gpu/src/shadow.rs:1708`); the same without this commit. ## Not tested - Series S, cards with less than 16 GB, AMD and Intel cards, Linux. - Long sessions: the counting is from one session of about five minutes. - Whether any of the larger unordered-access textures that still wait is picked by index somewhere; nothing was seen to render wrong for it. - The tessellated terrain's shadow draws (`MST_DS_CascadeShadows`) were not looked at. ## Notes - The commit is independent of #996 in code (other files) and applies to main as it is; its effect shows only with #996, because without it that ground is not drawn. - Found and written with Claude (Anthropic); every number above is from runs on the PC named.
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
trustno1-coder/VIctory-NVIDIA!1183
No description provided.