Fix startup flicker by snapshotting SRV descriptor tables #20

Closed
github-bot wants to merge 1 commit from gh-pr/20/head into gh-pr/20/base
Owner

@⁠Ryx69 on GitHub · 2026-11-23 23:14 UTC · original
Ryx69:codex/fix-srv-descriptor-flicker → main · +16 −12 · 1 files · 1 commits · closed without merging

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.

**@⁠Ryx69** on GitHub · 2026-11-23 23:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/20) `Ryx69:codex/fix-srv-descriptor-flicker` → `main` · +16 −12 · 1 files · 1 commits · closed without merging ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:46:48 +00:00
github-bot closed this pull request 2026-11-26 03:46:48 +00:00
Author
Owner

@⁠DaniloMaglia on GitHub · 2026-11-23 23:33 UTC · original

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
    #16
    (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.

**@⁠DaniloMaglia** on GitHub · 2026-11-23 23:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117098839) 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://git.gtahub.st/github/Marvisak--VIctory/issues/16 (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._
Author
Owner

@⁠Sunkiller-qc on GitHub · 2026-11-23 23:46 UTC · original

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.

**@⁠Sunkiller-qc** on GitHub · 2026-11-23 23:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117353169) 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.
Author
Owner

@⁠DaniloMaglia on GitHub · 2026-11-23 23:51 UTC · original

@⁠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.

**@⁠DaniloMaglia** on GitHub · 2026-11-23 23:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/20#issuecomment-7117432400) @⁠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._

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!20
No description provided.