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

Open
Xvania7 wants to merge 1 commit from upstream-pr/2441 into main
Xvania7 commented 2026-11-25 13:34:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T13:34:29Z.


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]

<!-- greyfinch-sync:Marvisak/VIctory:issue:6605683585 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T13:34:29Z. --- 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]>
DenRakEiw commented 2026-11-25 14:07:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:58:26Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6058953407 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#pullrequestreview-6058953407). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T13:58:26Z. **Review:** APPROVED --- 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).
Xvania7 commented 2026-11-25 14:07:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T14:00:51Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164625093 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7164625093). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T14:00:51Z. --- 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.
catminou4 commented 2026-11-25 15:03:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:18Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059177562 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#pullrequestreview-6059177562). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:18Z. **Review:** COMMENTED --- 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.
kotekompotek commented 2026-11-25 15:04:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:27:44Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165314156 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7165314156). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:27:44Z. --- 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.
Xvania7 commented 2026-11-25 15:04:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T14:28:47Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165341678 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7165341678). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T14:28:47Z. --- 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.
Marvisak commented 2026-11-25 17:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:10:16Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167655481 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7167655481). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:10:16Z. --- <!-- 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)_
Xvania7 commented 2026-11-25 18:02:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T17:49:27Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170050254 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7170050254). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-25T17:49:27Z. --- 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.
upstream-sync changed title from [PR #2441] GPU: live 1440p present fallback when 4K primaries stay unwritten (fixes #841) to [PR #2441] GPU: live 1440p present fallback when 4K primaries stay unwritten (#841) 2026-11-26 08:02:23 +00:00
upstream-sync changed title from [PR #2441] GPU: live 1440p present fallback when 4K primaries stay unwritten (#841) to [PR #2441] GPU: diagnostic 1440p present fallback for 4K primaries (#841) 2026-11-26 09:05:17 +00:00
Xvania7 commented 2026-11-26 09:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-26T08:49:20Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7187061865 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2441#issuecomment-7187061865). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-26T08:49:20Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2441:upstream-pr/2441'
git switch 'upstream-pr/2441'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2441'
git switch 'upstream-pr/2441'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2441'
git switch 'upstream-pr/2441'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2441'
git switch 'main'
git merge --squash 'upstream-pr/2441'
git switch 'main'
git merge --ff-only 'upstream-pr/2441'
git switch 'main'
git merge 'upstream-pr/2441'
git push origin 'main'
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!2439
No description provided.