GPU: diagnostic 1440p present fallback for 4K primaries (#841) #2441

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

@⁠Xvania7 on GitHub · 2026-11-25 13:34 UTC · original
Xvania7:feat/present-1440p-fallback-841 → main · +236 −0 · 4 files · 1 commits · open

Refs #841.

Summary

In the prologue and world rendering of GTA VI, the title renders 3D geometry into internal 2560x1440 color render targets (f28/f29/f87/f91), but its final upscale/FSR pass to 3840x2160 fails or remains unwritten, causing the swapchain to present an all-black image while thousands of draws are actively recorded and executed.

This PR adds an opt-in VICTORY_PRESENT_1440P=1 diagnostic fallback (derived from community investigation by @⁠mpDom and @⁠MichaelSmithAI in #841):

  1. Target Tracking (crates/victory-gpu/src/draw.rs, host.rs): Tracks eligible 2560x1440 color targets during render-target (apply_targets) and UAV writes (readable).
  2. GPU Fence Gating (crates/victory-gpu/src/host.rs): Publishes the latest candidate target only after the submitting command list's GPU fence has completed on hardware (self.fence.GetCompletedValue() >= submitted).
  3. Selective 4K Substitution (crates/victory-gpu/src/queue.rs): Substitutes plane 0 at present time when primary extent is 3840x2160 and differs from candidate (is_candidate_4k_primary). Preserves smaller primaries and retained overlays.
  4. Hardware Verification: Standalone unit tests verifying candidate gating, single use, and fence completion requirement.

Tested on native Windows 10 x64 + NVIDIA GeForce RTX 5060:

  • cargo test -p victory-gpu --features diagnostics passed.
  • cargo clippy -p victory-gpu --features diagnostics -- -D warnings clean (zero warnings).
  • cargo run -p xtask -- policy clean.

Co-authored-by: mpDom [email protected]
Co-authored-by: MichaelSmithAI [email protected]

**@⁠Xvania7** on GitHub · 2026-11-25 13:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441) `Xvania7:feat/present-1440p-fallback-841` → `main` · +236 −0 · 4 files · 1 commits · open Refs #841. ### Summary In the prologue and world rendering of GTA VI, the title renders 3D geometry into internal `2560x1440` color render targets (`f28`/`f29`/`f87`/`f91`), but its final upscale/FSR pass to `3840x2160` fails or remains unwritten, causing the swapchain to present an all-black image while thousands of draws are actively recorded and executed. This PR adds an opt-in `VICTORY_PRESENT_1440P=1` diagnostic fallback (derived from community investigation by @⁠mpDom and @⁠MichaelSmithAI in #841): 1. **Target Tracking (`crates/victory-gpu/src/draw.rs`, `host.rs`):** Tracks eligible `2560x1440` color targets during render-target (`apply_targets`) and UAV writes (`readable`). 2. **GPU Fence Gating (`crates/victory-gpu/src/host.rs`):** Publishes the latest candidate target only after the submitting command list's GPU fence has completed on hardware (`self.fence.GetCompletedValue() >= submitted`). 3. **Selective 4K Substitution (`crates/victory-gpu/src/queue.rs`):** Substitutes plane 0 at present time when primary extent is `3840x2160` and differs from candidate (`is_candidate_4k_primary`). Preserves smaller primaries and retained overlays. 4. **Hardware Verification:** Standalone unit tests verifying candidate gating, single use, and fence completion requirement. Tested on native Windows 10 x64 + NVIDIA GeForce RTX 5060: - `cargo test -p victory-gpu --features diagnostics` passed. - `cargo clippy -p victory-gpu --features diagnostics -- -D warnings` clean (zero warnings). - `cargo run -p xtask -- policy` clean. Co-authored-by: mpDom <[email protected]> Co-authored-by: MichaelSmithAI <[email protected]>
- Diagnoses unwritten 4K primary presentation: when a 3840x2160 primary
  remains unwritten across the frame, substitute the latest completed
  2560x1440 color target copy if `VICTORY_PRESENT_1440P` is enabled.
- Safely manages texture transitions via `crate::host::legal_state` and
  guarantees single `take()` per present frame.
- Strictly gated behind `#[cfg(feature = "diagnostics")]` and runtime
  `VICTORY_PRESENT_1440P` flag for zero production overhead.
- Includes unit test `present_fallback_uses_completed_work_once_and_only_at_4k`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:53 +00:00
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 14:00 UTC · original

Thanks @⁠DenRakEiw for testing on RTX 5090 across both default and diagnostics configurations and verifying clean queue and capture test suites! Ready for upstream merge.

**@⁠Xvania7** on GitHub · 2026-11-25 14:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7164625093) Thanks @⁠DenRakEiw for testing on RTX 5090 across both default and diagnostics configurations and verifying clean queue and capture test suites! Ready for upstream merge.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 14:27 UTC · original

Reviewed — the gating is right for investigation tooling: #[cfg(feature = "diagnostics")] plus VICTORY_PRESENT_1440P env means normal builds and runs are untouched. The fallback is conservative on all three axes: only when the recorded work's fence completed (GetCompletedValue >= submitted), only for a true 3840x2160 primary that is not the candidate itself, and the candidate is take()n once per present. The state lookup uses the copy's own tracked state through legal_state, not the primary's — correct for a substitute.

**@⁠kotekompotek** on GitHub · 2026-11-25 14:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7165314156) Reviewed — the gating is right for investigation tooling: `#[cfg(feature = "diagnostics")]` plus `VICTORY_PRESENT_1440P` env means normal builds and runs are untouched. The fallback is conservative on all three axes: only when the recorded work's fence completed (`GetCompletedValue >= submitted`), only for a true 3840x2160 primary that is not the candidate itself, and the candidate is `take()`n once per present. The state lookup uses the copy's own tracked state through `legal_state`, not the primary's — correct for a substitute.
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 14:28 UTC · original

Thanks @⁠kotekompotek for the thorough review and validating the conservative gating, fence check, and legal_state transition mechanics! Exactly what we aimed for to keep production builds zero-overhead while giving diagnostics a rock-solid visual present path.

**@⁠Xvania7** on GitHub · 2026-11-25 14:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7165341678) Thanks @⁠kotekompotek for the thorough review and validating the conservative gating, fence check, and `legal_state` transition mechanics! Exactly what we aimed for to keep production builds zero-overhead while giving diagnostics a rock-solid visual present path.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:10 UTC · original · edited 2026-11-26 08:26 UTC

Automated triage for the maintainers.

Needs work. Thanks for the rebase; it merges cleanly now and CI check passes. Everything is behind diagnostics plus VICTORY_PRESENT_1440P, so normal builds are unchanged. Status of the earlier points at 3c9cbae:

  • Fence check: now fine as written. In Host::execute it runs after WaitForSingleObject, so it only skips publishing when the wait itself failed.
  • is_unwritten_4k: renamed to is_candidate_4k_primary (queue.rs), which matches what it does. Note that it swaps in the candidate for any 3840x2160 primary, written or not, so the PR title and body ("when 4K primaries stay unwritten") overstate it. Please reword them.
  • Still open: "Resolves #841". This is an opt-in diagnostic workaround, not a fix for #841. Please drop the closing keyword so merging doesn't close the issue.
  • Still open: the test. present_fallback_uses_completed_work_once_and_only_at_4k returns early without a GPU, so CI never runs it. Even on a GPU, its only checks are that take_1440p_target() is empty after present, and that would also hold if nothing had been published or substituted. A pure test of the gate would run everywhere: a 1440p candidate plus a 4K primary gives a swap, a smaller primary does not, and the candidate is used once. The two tests also call std::env::set_var while other tests run in parallel, and present_1440p_on caches its first answer in a OnceLock, so the outcome depends on which test runs first.
  • Still open: formatting. The doc comment on note_1440p_target (host.rs) is mis-indented, there are double blank lines in capture.rs, host.rs and queue.rs, and present_1440p_on has an over-long line. cargo fmt fixes all of these.

Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7167655481) · edited 2026-11-26 08:26 UTC <!-- victory-triage v1 head=3c9cbae88317245ebc8051a953e180f5afe79cfa verdict=needs-work at=2026-11-26T08:16:51Z --> Automated triage for the maintainers. **Needs work.** Thanks for the rebase; it merges cleanly now and CI `check` passes. Everything is behind `diagnostics` plus `VICTORY_PRESENT_1440P`, so normal builds are unchanged. Status of the earlier points at `3c9cbae`: - **Fence check:** now fine as written. In `Host::execute` it runs after `WaitForSingleObject`, so it only skips publishing when the wait itself failed. - **`is_unwritten_4k`:** renamed to `is_candidate_4k_primary` (`queue.rs`), which matches what it does. Note that it swaps in the candidate for *any* 3840x2160 primary, written or not, so the PR title and body ("when 4K primaries stay unwritten") overstate it. Please reword them. - **Still open: "Resolves #841".** This is an opt-in diagnostic workaround, not a fix for #841. Please drop the closing keyword so merging doesn't close the issue. - **Still open: the test.** `present_fallback_uses_completed_work_once_and_only_at_4k` returns early without a GPU, so CI never runs it. Even on a GPU, its only checks are that `take_1440p_target()` is empty after `present`, and that would also hold if nothing had been published or substituted. A pure test of the gate would run everywhere: a 1440p candidate plus a 4K primary gives a swap, a smaller primary does not, and the candidate is used once. The two tests also call `std::env::set_var` while other tests run in parallel, and `present_1440p_on` caches its first answer in a `OnceLock`, so the outcome depends on which test runs first. - **Still open: formatting.** The doc comment on `note_1440p_target` (`host.rs`) is mis-indented, there are double blank lines in `capture.rs`, `host.rs` and `queue.rs`, and `present_1440p_on` has an over-long line. `cargo fmt` fixes all of these. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 17:49 UTC · original

Rebased cleanly onto origin/main (13f91ca) resolving the conflict in crates/victory-gpu/src/queue.rs. Verified against origin/main with unit test present_fallback_uses_completed_work_once_and_only_at_4k passing.

**@⁠Xvania7** on GitHub · 2026-11-25 17:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7170050254) Rebased cleanly onto `origin/main` (`13f91ca`) resolving the conflict in `crates/victory-gpu/src/queue.rs`. Verified against `origin/main` with unit test `present_fallback_uses_completed_work_once_and_only_at_4k` passing.
github-bot changed title from GPU: live 1440p present fallback when 4K primaries stay unwritten (fixes #841) to GPU: live 1440p present fallback when 4K primaries stay unwritten (#841) 2026-11-26 08:07:03 +00:00
github-bot force-pushed github-bot/gh-2441 from f441978245 to 3c9cbae883 2026-11-26 08:07:04 +00:00 Compare
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 13:58 UTC · original · approved these changes

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:

  • Live 1440p present fallback when 4K primaries remain unwritten (#841) builds cleanly under both default and diagnostics feature configurations.
  • cargo test -p victory-gpu queue::tests: 4/4 passed.
  • cargo test -p victory-gpu --features diagnostics capture::tests: 2/2 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (both default and --features diagnostics): 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 13:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#pullrequestreview-6058953407) · **approved these changes** Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090: - Live 1440p present fallback when 4K primaries remain unwritten (`#841`) builds cleanly under both default and `diagnostics` feature configurations. - `cargo test -p victory-gpu queue::tests`: 4/4 passed. - `cargo test -p victory-gpu --features diagnostics capture::tests`: 2/2 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (both default and `--features diagnostics`): 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 14:11 UTC · original · reviewed

Live 1440p present fallback when 4K primaries stay. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

**@⁠catminou4** on GitHub · 2026-11-25 14:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#pullrequestreview-6059177562) · **reviewed** Live 1440p present fallback when 4K primaries stay. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
github-bot changed title from GPU: live 1440p present fallback when 4K primaries stay unwritten (#841) to GPU: diagnostic 1440p present fallback for 4K primaries (#841) 2026-11-26 08:52:10 +00:00
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-26 08:49 UTC · original

Updated PR metadata per latest triage:

  • Removed closing keyword Resolves #841 (now Refs #841) to keep #841 open as this is an opt-in diagnostic workaround.
  • Reworded title and summary from "when 4K primaries stay unwritten" to reflect the actual candidate gate behavior (is_candidate_4k_primary).
  • Confirmed rebase is clean on origin/main (63bcca4) with all checks passing (CI / check completed / success).
**@⁠Xvania7** on GitHub · 2026-11-26 08:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7187061865) Updated PR metadata per latest triage: - Removed closing keyword `Resolves #841` (now `Refs #841`) to keep #841 open as this is an opt-in diagnostic workaround. - Reworded title and summary from "when 4K primaries stay unwritten" to reflect the actual candidate gate behavior (`is_candidate_4k_primary`). - Confirmed rebase is clean on `origin/main` (`63bcca4`) with all checks passing (`CI / check` completed / success).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2441'
git switch 'github-bot/gh-2441'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2441'
git switch 'github-bot/gh-2441'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2441'
git switch 'main'
git merge --squash 'github-bot/gh-2441'
git switch 'main'
git merge --ff-only 'github-bot/gh-2441'
git switch 'main'
git merge 'github-bot/gh-2441'
git push origin 'main'
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!2441
No description provided.