GPU: textures picked by index: looked-at and fresh slots in turns; slots without memory looked at again after up to 20 s #1246

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

@⁠Exopus-0x65f7ad0 on GitHub · 2026-11-26 01:53 UTC · original
Exopus-0x65f7ad0:pr/fair-due → main · +81 −14 · 2 files · 1 commits · open

Problem

Faces whose textures are picked by index (the diner waitress, Lucia's close-ups, the extras) come out black, red or noisy in the opening cutscene, differently from run to run. cafeoh traced this in #821 to the texture queue: until a slot's turn comes, the shader reads an empty slot or an older view.

I added a counter line to the pass (passes, slots handed, slots looked at, why each pass stopped) and ran the cutscene on an 8 GB card with 16 GB of RAM:

  • 8,000 to 30,000 slots stayed due through the cutscene. The oldest had waited 300 to 1,500 frames.
  • About one pass a frame, and nearly every pass was cut by its time (750 ms with the catch-up), with 4,096 slots handed and 2,000 to 4,000 looked at.

TextureQueue::due hands out every slot looked at before ahead of every fresh one. In the cutscene, thousands of slots stream in a part at a time, or wait for memory that is not mapped yet. They are looked at again every 1, 2, 4… frames, at most (4000 / ms per frame).clamp(16, 256) frames, which at 4 fps means every 16 frames. So they filled each pass, and fresh slots (the shot on screen) rarely got a turn.

Change

  • TextureQueue::due serves the two kinds in turns, a slot looked at before first. The head of the order is unchanged (the existing test still holds), and a pass that takes only part of the backlog now reaches fresh slots. VICTORY_FAIR_DUE=0 restores the old order.
  • Re-look interval: a slot whose memory is not mapped is looked at again after at most VICTORY_RELOOK_MS (default 20,000 ms, was 4,000 ms), clamped to 16–1,024 frames. The runtime's mappings already make such a slot due (texture_slots_remapped), so these looks only catch what that path does not tell.

Tested

  • New test: descriptor::host::tests::the_texture_queue_serves_looked_at_and_fresh_slots_in_turns. With 10 looked-at slots, 3 fresh ones and a pass of 6, a looked-at slot comes first and all 3 fresh slots are reached.
  • the_texture_queue_serves_the_newest_writes_first and slots_read_through_tables_leave_the_texture_queue still pass (MSVC 1.98.1).
  • In game (Series S profile, RTX 5060 Ti 8 GB, 16 GB RAM, Windows 11), on a local tree with more open PRs. Same scenes in several runs before and after, opening cutscene:
    • before: the diner waitress was black or red, and the bar close-up of Lucia was black in 3 runs out of 3;
    • with this change, plus the heap worker chaining its passes (comment on #1007): the close-up is textured, the wall frames and the extras are textured, and the queue drains mid-scene instead of staying at 20,000–30,000;
    • still left: the first seconds after a change of place (the queue peaks at about 24,000 slots there), so the waitress's first shot can still be dark.
    • Frame rate unchanged within noise (3.9–4.2 fps average over the cutscene).

The real limit after this is the cost of each look: reading the texture's bytes when its pages are out of memory, and creating the host texture. That is not changed here.

No game data in this PR (no captures, hashes, addresses or logs).

🤖 Generated with Claude Code

**@⁠Exopus-0x65f7ad0** on GitHub · 2026-11-26 01:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/1246) `Exopus-0x65f7ad0:pr/fair-due` → `main` · +81 −14 · 2 files · 1 commits · open ## Problem Faces whose textures are picked by index (the diner waitress, Lucia's close-ups, the extras) come out black, red or noisy in the opening cutscene, differently from run to run. cafeoh traced this in #821 to the texture queue: until a slot's turn comes, the shader reads an empty slot or an older view. I added a counter line to the pass (passes, slots handed, slots looked at, why each pass stopped) and ran the cutscene on an 8 GB card with 16 GB of RAM: - 8,000 to 30,000 slots stayed due through the cutscene. The oldest had waited 300 to 1,500 frames. - About one pass a frame, and nearly every pass was cut by its time (750 ms with the catch-up), with 4,096 slots handed and 2,000 to 4,000 looked at. `TextureQueue::due` hands out **every** slot looked at before ahead of **every** fresh one. In the cutscene, thousands of slots stream in a part at a time, or wait for memory that is not mapped yet. They are looked at again every 1, 2, 4… frames, at most `(4000 / ms per frame).clamp(16, 256)` frames, which at 4 fps means every 16 frames. So they filled each pass, and fresh slots (the shot on screen) rarely got a turn. ## Change - **`TextureQueue::due`** serves the two kinds **in turns**, a slot looked at before first. The head of the order is unchanged (the existing test still holds), and a pass that takes only part of the backlog now reaches fresh slots. `VICTORY_FAIR_DUE=0` restores the old order. - **Re-look interval:** a slot whose memory is not mapped is looked at again after at most `VICTORY_RELOOK_MS` (default 20,000 ms, was 4,000 ms), clamped to 16–1,024 frames. The runtime's mappings already make such a slot due (`texture_slots_remapped`), so these looks only catch what that path does not tell. ## Tested - New test: `descriptor::host::tests::the_texture_queue_serves_looked_at_and_fresh_slots_in_turns`. With 10 looked-at slots, 3 fresh ones and a pass of 6, a looked-at slot comes first and all 3 fresh slots are reached. - `the_texture_queue_serves_the_newest_writes_first` and `slots_read_through_tables_leave_the_texture_queue` still pass (MSVC 1.98.1). - In game (Series S profile, RTX 5060 Ti 8 GB, 16 GB RAM, Windows 11), on a local tree with more open PRs. Same scenes in several runs before and after, opening cutscene: - before: the diner waitress was black or red, and the bar close-up of Lucia was black in 3 runs out of 3; - with this change, plus the heap worker chaining its passes (comment on #1007): the close-up is textured, the wall frames and the extras are textured, and the queue drains mid-scene instead of staying at 20,000–30,000; - still left: the first seconds after a change of place (the queue peaks at about 24,000 slots there), so the waitress's first shot can still be dark. - Frame rate unchanged within noise (3.9–4.2 fps average over the cutscene). The real limit after this is the cost of each look: reading the texture's bytes when its pages are out of memory, and creating the host texture. That is not changed here. No game data in this PR (no captures, hashes, addresses or logs). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The queue handed every slot looked at before ahead of every fresh one.
In the opening cutscene thousands of slots stream in a part at a time,
so they filled each pass, which its time then cut, and fresh slots
waited 300 to 1,500 frames. Faces whose textures are picked by index
read an empty slot or an older view meanwhile.

- TextureQueue::due serves the two kinds in turns, a slot looked at
  before first (VICTORY_FAIR_DUE=0: as before), with a test.
- A slot whose memory is not mapped is looked at again after at most
  VICTORY_RELOOK_MS (20,000; 4,000 before): the runtime's mappings
  already make such a slot due.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:00:17 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-26 02:29 UTC · original · edited 2026-11-26 02:46 UTC

I tried the queue change on an RX 7900 XT with RADV 26.3.1, Wine and vkd3d-proton. The interleaved-queue test passed. In the diner the server's face was still nearly black at both the first exchange and the later shot with her hand on her hip. Hair, forearms and the pink shirt drew in the same frames. The seated character had visible skin in both shots.

On the preceding build I saw the same missing face with VICTORY_RELAY=0 and =2. With VICTORY_PAGE_WRITES=1 on its own, the runtime counted 2,985 early uploads made due again by the end of the run. With this PR, the background heap worker and page writes enabled together, the defect was still visible. This worker waits for the next kick between passes. The combined run also had the ordered-pixel and face-buffer changes. This is a visual reproduction on another card, not an isolated measurement of queue throughput.

Tested integration

I replayed the water order at fixed texture-copy budgets of 4 GiB and 8 GiB on the same build, once per budget. The server's forearms looked normal and her face was blotchy red on the same reply in both runs. At 4 GiB the queue had 24,862 slots due during the exchange, including 5,646 fully mapped entries whose textures had never received a host copy. I haven't traced those entries to the face draw. Matched dialogue results

**@⁠UwUCammie** on GitHub · 2026-11-26 02:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/1246#issuecomment-7180852203) · edited 2026-11-26 02:46 UTC I tried the queue change on an RX 7900 XT with RADV 26.3.1, Wine and vkd3d-proton. The interleaved-queue test passed. In the diner the server's face was still nearly black at both the first exchange and the later shot with her hand on her hip. Hair, forearms and the pink shirt drew in the same frames. The seated character had visible skin in both shots. On the preceding build I saw the same missing face with `VICTORY_RELAY=0` and `=2`. With `VICTORY_PAGE_WRITES=1` on its own, the runtime counted 2,985 early uploads made due again by the end of the run. With this PR, the background heap worker and page writes enabled together, the defect was still visible. This worker waits for the next kick between passes. The combined run also had the ordered-pixel and face-buffer changes. This is a visual reproduction on another card, not an isolated measurement of queue throughput. [Tested integration](https://github.com/UwUCammie/victory-amd/tree/e3617c8) I replayed the water order at fixed texture-copy budgets of 4 GiB and 8 GiB on the same build, once per budget. The server's forearms looked normal and her face was blotchy red on the same reply in both runs. At 4 GiB the queue had 24,862 slots due during the exchange, including 5,646 fully mapped entries whose textures had never received a host copy. I haven't traced those entries to the face draw. [Matched dialogue results](https://github.com/UwUCammie/victory-amd/blob/f587604/benchmarks/README.md#opening-dialogue-visual-check)
Author
Owner

@⁠ArturoWolff on GitHub · 2026-11-26 02:52 UTC · original · edited 2026-11-26 03:27 UTC

I isolated the ordering part of Exopus-0x65f7ad0’s faf709b5 on the private #854-based receiving build described in the deferred-material trace. This is not a build of this PR head: I kept #1031’s bounded selection, the receiver’s original 4,000 ms re-look calculation and its 16–256 frame clamp. No worker chaining. A full-sort reference test for the alternating order and the receiver’s original ordering regression both passed (2 passed, 0 failed; the benchmark was ignored).

The age of a null descriptor matters here. Each retail capture contained three recorded commands for the same deferred character pixel shader, with seven in-bounds material fields per command:

Queue order Null field observations / total Distinct null slots Capture frame minus recorded slot-write frame
Original, retries first 4/21 4 537 frames for all four
Alternating 6/21 5 0 frames for all five

Every null in this table was due, had zero recorded looks, and had no host resource. The original-order capture reproduces old writes with an empty host slot, but not necessarily writes that were never inspected. In this receiver looks counts consecutive memory retries, not all inspections: the no-room path can hold a slot without incrementing it. Neither capture recorded the history of a specific write generation. In the alternating capture the outstanding writes were from that very frame. Counting nulls alone would miss this difference. Write age is not time continuously due. These are CPU observations at command recording, not measurements of the first service event, GPU consumption or skin pixels. The observations are not independent: two commands reference the same set of slots in each capture. Neither frame dump finished its image set.

RTX 4060 8 GB, Linux, GE-Proton11-14 / vkd3d-proton 71cae09, Series X, 1920×1080. Same executable, separate byte-matched starting prefix/saves/title cache/driver cache, runs serialized with the host-memory guard enabled. Both reached the dark opening exterior and ended at the scheduled bound (~333 s), without a host OOM or logged device loss. The original-order run received A at the account picker; no qualifying prompt was captured in the alternating run, so no input was sent there. Different poses and material records: not a matched visual or performance result, and no claim about the full PR or AMD/Windows. A useful next measurement is whether each same-frame write is inspected and gets a usable view before the next draw that references that write generation.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).

**@⁠ArturoWolff** on GitHub · 2026-11-26 02:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/1246#issuecomment-7181188995) · edited 2026-11-26 03:27 UTC I isolated the **ordering** part of Exopus-0x65f7ad0’s `faf709b5` on the private #854-based receiving build described in [the deferred-material trace](https://git.gtahub.st/github/fxceless--victory-fork/issues/279). This is not a build of this PR head: I kept #1031’s bounded selection, the receiver’s original 4,000 ms re-look calculation and its 16–256 frame clamp. No worker chaining. A full-sort reference test for the alternating order and the receiver’s original ordering regression both passed (2 passed, 0 failed; the benchmark was ignored). **The age of a null descriptor matters here.** Each retail capture contained three recorded commands for the same deferred character pixel shader, with seven in-bounds material fields per command: | Queue order | Null field observations / total | Distinct null slots | Capture frame minus recorded slot-write frame | |---|---:|---:|---| | Original, retries first | 4/21 | 4 | 537 frames for all four | | Alternating | 6/21 | 5 | 0 frames for all five | Every null in this table was due, had zero recorded looks, and had no host resource. The original-order capture reproduces old writes with an empty host slot, but not necessarily writes that were never inspected. In this receiver `looks` counts consecutive memory retries, not all inspections: the no-room path can hold a slot without incrementing it. Neither capture recorded the history of a specific write generation. In the alternating capture the outstanding writes were from **that very frame**. Counting nulls alone would miss this difference. Write age is not time continuously due. These are CPU observations at command recording, not measurements of the first service event, GPU consumption or skin pixels. The observations are not independent: two commands reference the same set of slots in each capture. Neither frame dump finished its image set. RTX 4060 8 GB, Linux, GE-Proton11-14 / vkd3d-proton `71cae09`, Series X, 1920×1080. Same executable, separate byte-matched starting prefix/saves/title cache/driver cache, runs serialized with the host-memory guard enabled. Both reached the dark opening exterior and ended at the scheduled bound (~333 s), without a host OOM or logged device loss. The original-order run received A at the account picker; no qualifying prompt was captured in the alternating run, so no input was sent there. Different poses and material records: **not a matched visual or performance result**, and no claim about the full PR or AMD/Windows. A useful next measurement is whether each same-frame write is inspected and gets a usable view before the next draw that references that *write generation*. AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/draw.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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