Fix startup flicker by snapshotting SRV descriptor tables #20

Closed
Ryx69 wants to merge 1 commit from upstream-pr/20 into main
Ryx69 commented 2026-11-23 23:14:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ryx69 on 2026-11-23T23:14:54Z.


Why the startup flickered

SRV-only tables used shared mirrored heap slots. Reusing a slot after command recording could make an earlier draw sample a different resource when the GPU executed it. The recorded frame tokens matched, and the black pixels were already in the source texture before DXGI presentation. The A/B result points to descriptor reuse in the startup render path.

The runtime already puts tables with constant-buffer views in command-list-owned slots. Apply the same policy to tables with shader-resource views so later descriptor writes cannot change what a recorded draw samples. Keep the existing mirrored path when the snapshot would exceed its heap range or the dynamic slots are exhausted.

Test system and results

  • CPU: AMD Ryzen 5 9600X (6 cores).
  • GPU: NVIDIA GeForce RTX 5060 Ti, Windows driver 32.0.16.2124.
  • OS: Windows 11 Pro, build 26300.
  • In the local diagnostics A/B run, the SRV snapshot change reduced black startup frames from 226 to 0 over the same 581-frame window.
  • On the upstream PR branch, 35 GPU tests passed. The host root-signature serialization test failed with E_INVALIDARG, which was also reproduced on a baseline without the descriptor fix.

This AI-assisted PR covers the startup descriptor change. The post-terms black screen and packed-format allocation failures remain open.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6570811709 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/20). Originally posted by [Ryx69](https://github.com/Ryx69) on 2026-11-23T23:14:54Z. --- ## Why the startup flickered SRV-only tables used shared mirrored heap slots. Reusing a slot after command recording could make an earlier draw sample a different resource when the GPU executed it. The recorded frame tokens matched, and the black pixels were already in the source texture before DXGI presentation. The A/B result points to descriptor reuse in the startup render path. The runtime already puts tables with constant-buffer views in command-list-owned slots. Apply the same policy to tables with shader-resource views so later descriptor writes cannot change what a recorded draw samples. Keep the existing mirrored path when the snapshot would exceed its heap range or the dynamic slots are exhausted. ## Test system and results - CPU: AMD Ryzen 5 9600X (6 cores). - GPU: NVIDIA GeForce RTX 5060 Ti, Windows driver `32.0.16.2124`. - OS: Windows 11 Pro, build `26300`. - In the local diagnostics A/B run, the SRV snapshot change reduced black startup frames from 226 to 0 over the same 581-frame window. - On the upstream PR branch, 35 GPU tests passed. The host root-signature serialization test failed with `E_INVALIDARG`, which was also reproduced on a baseline without the descriptor fix. This AI-assisted PR covers the startup descriptor change. The post-terms black screen and packed-format allocation failures remain open.
DaniloMaglia commented 2026-11-24 06:54:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaniloMaglia on 2026-11-23T23:33:33Z.


Tested on an RTX 4060 and it fixes the menu flicker here too.

Setup

  • NVIDIA GeForce RTX 4060, driver 621.24 (32.0.16.2124), Windows 11 Pro 26200
  • main at 8c26061, plus the refused-formats patch from
    https://github.com/Marvisak/VIctory/issues/16#issuecomment-7116625315
    (without it, this GPU loses the device in the menus before the flicker
    matters), plus this PR
  • diag build; black frames counted from the "a black frame after a frame
    that was not" lines

Before: single black frames about every 216 frames during the setup
screens (357, 573, 789, ...), plus bursts at screen changes. 18 in about
2 min 20 s. The logged brightness drops to 0 for exactly one frame between
normal frames, so this is flicker, not a fade.

With this PR: the only black frames left are frame 1 and frame 759.
Frame 759 is four frames at 0 between normal ones (44 → 0, 0, 0, 0 → 45),
which looks like an intended cut. Nothing flickered while playing through the
setup screens and menus.

The PR applies to current main with line offsets only (after 8c26061).
cargo test -p victory-gpu passes (36) and clippy is clean.

For the record, what I saw before applying it: in one capture the copy
of the sRGB video target into the UNORM target (pixel shader
f9bf13c6c099ccec, same pipeline in every frame) came out flat gray or
red-only, even though the sRGB source had the right picture when saved at
present. That's what you'd expect from the draw sampling whatever a shared
mirrored slot held when the GPU ran it, rather than what it held when the
draw was recorded.

AI-assisted (Claude Code); tested on my machine. No game data in this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7117098839 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117098839). Originally posted by [DaniloMaglia](https://github.com/DaniloMaglia) on 2026-11-23T23:33:33Z. --- Tested on an RTX 4060 and it fixes the menu flicker here too. **Setup** - NVIDIA GeForce RTX 4060, driver 621.24 (32.0.16.2124), Windows 11 Pro 26200 - `main` at 8c26061, plus the refused-formats patch from https://github.com/Marvisak/VIctory/issues/16#issuecomment-7116625315 (without it, this GPU loses the device in the menus before the flicker matters), plus this PR - `diag` build; black frames counted from the "a black frame after a frame that was not" lines **Before:** single black frames about every 216 frames during the setup screens (357, 573, 789, ...), plus bursts at screen changes. 18 in about 2 min 20 s. The logged brightness drops to 0 for exactly one frame between normal frames, so this is flicker, not a fade. **With this PR:** the only black frames left are frame 1 and frame 759. Frame 759 is four frames at 0 between normal ones (44 → 0, 0, 0, 0 → 45), which looks like an intended cut. Nothing flickered while playing through the setup screens and menus. The PR applies to current `main` with line offsets only (after 8c26061). `cargo test -p victory-gpu` passes (36) and clippy is clean. **For the record, what I saw before applying it:** in one capture the copy of the sRGB video target into the UNORM target (pixel shader `f9bf13c6c099ccec`, same pipeline in every frame) came out flat gray or red-only, even though the sRGB source had the right picture when saved at present. That's what you'd expect from the draw sampling whatever a shared mirrored slot held when the GPU ran it, rather than what it held when the draw was recorded. _AI-assisted (Claude Code); tested on my machine. No game data in this comment._
Sunkiller-qc commented 2026-11-24 06:54:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Sunkiller-qc on 2026-11-23T23:46:44Z.


Nice A/B data. One interaction to check now that #21 is on main: tables past a capped host heap (NVIDIA) also rely on the 65,536 dynamic slots, and with this change every SRV table draws from the same pool (draw.rs:592). When host.dynamic(n) fails, the new fallback (draw.rs:652) sends the table back to the mirrored path. For a table past the cap that means the shader reads past the host heap again, which is the #21 hang. Startup screens are probably fine, but the world binds large SRV tables (see the comment you removed above tables). Could you give tables past host.count() priority over plain SRV snapshots, or test in-world on NVIDIA and count the "did not fit" fallbacks? Also, this now conflicts with #33. Static review, not built or run.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7117353169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117353169). Originally posted by [Sunkiller-qc](https://github.com/Sunkiller-qc) on 2026-11-23T23:46:44Z. --- Nice A/B data. One interaction to check now that #21 is on main: tables past a capped host heap (NVIDIA) also rely on the 65,536 dynamic slots, and with this change every SRV table draws from the same pool (`draw.rs:592`). When `host.dynamic(n)` fails, the new fallback (`draw.rs:652`) sends the table back to the mirrored path. For a table past the cap that means the shader reads past the host heap again, which is the #21 hang. Startup screens are probably fine, but the world binds large SRV tables (see the comment you removed above `tables`). Could you give tables past `host.count()` priority over plain SRV snapshots, or test in-world on NVIDIA and count the "did not fit" fallbacks? Also, this now conflicts with #33. Static review, not built or run.
DaniloMaglia commented 2026-11-24 06:54:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaniloMaglia on 2026-11-23T23:51:08Z.


@Sunkiller-qc I ran this in-world on NVIDIA with #21, so here are the counts.

Setup: RTX 4060 (32-lane waves only, view heap capped at 1,000,000),
driver 621.24. main at 97c78d1 (includes #21) + this PR + the
refused-formats patch from #16. diag build, about 3 minutes from boot
into the world.

Fallbacks: none. Neither descriptor table did not fit in command-list slots (this PR's fallback) nor no free dynamic descriptor slots appears in
the log. Both are logged on their first occurrence, so the pool never ran out
in the menus or in the world.

Black frames: five, all multi-frame cuts or fades
(e.g. 44 → 0 for 6+ frames), no single-frame flicker.

The world still loses the device on this GPU, but for a reason that looks
unrelated to this PR.
An Aftermath dump shows a mesh shader page-faulting
on an address no resource owns. No fallback had fired before it, and in the
same run the host refused 78 compute pipelines that require WaveSize(64)
(this GPU only runs 32-lane waves). My current guess is wave64 assumptions
in mesh shaders on 32-lane hardware. Upstream reports the world staying up
on AMD.

That's one run on one GPU, and the world part only lasted until that device
loss, so it doesn't rule out exhaustion with heavier world scenes. I agree
that giving tables past host.count() priority over plain SRV snapshots
would be the safer design. I haven't looked at how this PR and #33 conflict.

AI-assisted (Claude Code); tested on my machine. No game data in this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7117432400 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117432400). Originally posted by [DaniloMaglia](https://github.com/DaniloMaglia) on 2026-11-23T23:51:08Z. --- @Sunkiller-qc I ran this in-world on NVIDIA with #21, so here are the counts. **Setup:** RTX 4060 (32-lane waves only, view heap capped at 1,000,000), driver 621.24. `main` at 97c78d1 (includes #21) + this PR + the refused-formats patch from #16. `diag` build, about 3 minutes from boot into the world. **Fallbacks:** none. Neither `descriptor table did not fit in command-list slots` (this PR's fallback) nor `no free dynamic descriptor slots` appears in the log. Both are logged on their first occurrence, so the pool never ran out in the menus or in the world. **Black frames:** five, all multi-frame cuts or fades (e.g. 44 → 0 for 6+ frames), no single-frame flicker. **The world still loses the device on this GPU, but for a reason that looks unrelated to this PR.** An Aftermath dump shows a mesh shader page-faulting on an address no resource owns. No fallback had fired before it, and in the same run the host refused 78 compute pipelines that require `WaveSize(64)` (this GPU only runs 32-lane waves). My current guess is wave64 assumptions in mesh shaders on 32-lane hardware. Upstream reports the world staying up on AMD. That's one run on one GPU, and the world part only lasted until that device loss, so it doesn't rule out exhaustion with heavier world scenes. I agree that giving tables past `host.count()` priority over plain SRV snapshots would be the safer design. I haven't looked at how this PR and #33 conflict. _AI-assisted (Claude Code); tested on my machine. No game data in this comment._
mercuryVM commented 2026-11-24 08:13:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:13:14Z.

Review: APPROVED


Tested a68ac08 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (221 passed, 0 failed; the branch is based on an old main). I can't reproduce the startup flicker without a game package.

  • The reasoning holds. A table that points into the mirrored heap reads whatever is in those slots when the GPU executes, not when the draw was recorded, so a later title descriptor write races the draw. Giving SRV tables list-owned slots, as CBV tables already have, freezes them at record time.
  • Both fallbacks keep the old path rather than failing: a table whose last entry lies outside the heap, and running out of dynamic slots (with a one-time warning).
  • Cost to keep an eye on: the old doc comment explains that the world's big tables would take "hundreds of slots per draw". Including SRV tables makes that more likely. The per-list (table, contents) dedup still applies, but if the dynamic ring wraps onto lists not yet submitted, that is the same corruption in another form. A diagnostics counter for how often the "did not fit" fallback fires in the world would show whether the ring needs to grow.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035736365 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/20#pullrequestreview-6035736365). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:13:14Z. **Review:** APPROVED --- Tested a68ac08 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (221 passed, 0 failed; the branch is based on an old main). I can't reproduce the startup flicker without a game package. - The reasoning holds. A table that points into the mirrored heap reads whatever is in those slots when the GPU executes, not when the draw was recorded, so a later title descriptor write races the draw. Giving SRV tables list-owned slots, as CBV tables already have, freezes them at record time. - Both fallbacks keep the old path rather than failing: a table whose last entry lies outside the heap, and running out of dynamic slots (with a one-time warning). - Cost to keep an eye on: the old doc comment explains that the world's big tables would take "hundreds of slots per draw". Including SRV tables makes that more likely. The per-list `(table, contents)` dedup still applies, but if the dynamic ring wraps onto lists not yet submitted, that is the same corruption in another form. A diagnostics counter for how often the "did not fit" fallback fires in the world would show whether the ring needs to grow. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 09:04:53 +00:00

Pull request closed

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
Marvisak/VIctory!20
No description provided.