Add opt-in GPU memory synchronization tracing #1514

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

@⁠draggygaggy-maker on GitHub · 2026-11-24 18:40 UTC · original
draggygaggy-maker:diagnostics/memory-wait-trace → main · +274 −4 · 4 files · 1 commits · open

Motivation

Related to #1323.

The current wait_value implementation ignores GPU memory waits. Without visibility into their addresses, comparison codes, reference values and associated writes, investigating potential synchronization dependencies is difficult.

This PR introduces opt-in diagnostics without implementing or altering the existing wait semantics.

Changes

  • Adds VICTORY_SYNC_TRACE=1, available in diagnostics builds and disabled by default.
  • Records ignored memory waits with their address, raw comparison code and reference value.
  • Traces memory-write recording and deferred execution.
  • Correlates title queues, title command lists and host command lists.
  • Records command-list reset requests and final releases.
  • Adds two synthetic regression tests and documents the diagnostic switch.

Runtime findings

Tested on Windows with an NVIDIA RTX 4060 Ti against upstream commit ffe310e.

During a story intro session:

  • 6,145 ignored memory waits.
  • 55 unique wait addresses.
  • 28,414 memory writes recorded.
  • 28,358 deferred writes executed.
  • 30,342 command-list submission requests.
  • 27,311 command-list reset requests.
  • 5,925 write events matching wait addresses.

All observed waits used raw comparison code 7.

One address accounted for 3,177 waits (51.7% of all observed waits), with no captured write starting at that exact address. Nearby writes exhibited a repeating three-slot counter pattern with 72-byte spacing.

These observations provide potential investigation targets, not proof of missing synchronization or incorrect counter values. Matching write events include both recording and execution.

Validation

  • GPU regression suite: 55 passed, 0 failed, 1 ignored.
  • Dedicated memory-wait tracing test passed with tracing enabled and disabled.
  • GPU-backed deferred-write and queue-correlation tests passed.
  • Compilation succeeded with and without diagnostics.
  • Release build succeeded.
  • Runtime trace collection verified.
  • Repository asset policy passed.

Limitations

This PR does not implement GPU memory waits, interpret comparison code 7, or intentionally change synchronization behavior.

The black-world rendering issue persisted during testing. Neither the reported CrossQueueBarrier message nor DEVICE_HUNG appeared in the captured session log.

Pointer identities may be reused, uninstrumented memory writers are not captured, and verbose logging may affect timing.

AI assistance

Developed with assistance from ChatGPT through iterative source inspection, implementation, code review and regression testing. All reported test and runtime results were obtained locally on physical hardware.

**@⁠draggygaggy-maker** on GitHub · 2026-11-24 18:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1514) `draggygaggy-maker:diagnostics/memory-wait-trace` → `main` · +274 −4 · 4 files · 1 commits · open ## Motivation Related to #1323. The current `wait_value` implementation ignores GPU memory waits. Without visibility into their addresses, comparison codes, reference values and associated writes, investigating potential synchronization dependencies is difficult. This PR introduces opt-in diagnostics without implementing or altering the existing wait semantics. ## Changes - Adds `VICTORY_SYNC_TRACE=1`, available in diagnostics builds and disabled by default. - Records ignored memory waits with their address, raw comparison code and reference value. - Traces memory-write recording and deferred execution. - Correlates title queues, title command lists and host command lists. - Records command-list reset requests and final releases. - Adds two synthetic regression tests and documents the diagnostic switch. ## Runtime findings Tested on Windows with an NVIDIA RTX 4060 Ti against upstream commit `ffe310e`. During a story intro session: - **6,145** ignored memory waits. - **55** unique wait addresses. - **28,414** memory writes recorded. - **28,358** deferred writes executed. - **30,342** command-list submission requests. - **27,311** command-list reset requests. - **5,925** write events matching wait addresses. All observed waits used raw comparison code `7`. One address accounted for 3,177 waits (51.7% of all observed waits), with no captured write starting at that exact address. Nearby writes exhibited a repeating three-slot counter pattern with 72-byte spacing. These observations provide potential investigation targets, not proof of missing synchronization or incorrect counter values. Matching write events include both recording and execution. ## Validation - GPU regression suite: **55 passed, 0 failed, 1 ignored**. - Dedicated memory-wait tracing test passed with tracing enabled and disabled. - GPU-backed deferred-write and queue-correlation tests passed. - Compilation succeeded with and without diagnostics. - Release build succeeded. - Runtime trace collection verified. - Repository asset policy passed. ## Limitations This PR does not implement GPU memory waits, interpret comparison code `7`, or intentionally change synchronization behavior. The black-world rendering issue persisted during testing. Neither the reported `CrossQueueBarrier` message nor `DEVICE_HUNG` appeared in the captured session log. Pointer identities may be reused, uninstrumented memory writers are not captured, and verbose logging may affect timing. ## AI assistance Developed with assistance from ChatGPT through iterative source inspection, implementation, code review and regression testing. All reported test and runtime results were obtained locally on physical hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:38 +00:00
Author
Owner

@⁠pfhandler on GitHub · 2026-11-24 20:50 UTC · original

Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB):

  • VICTORY_NO_HOST_PAD=1 — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets VICTORY_KEYS drive the title again.
  • VICTORY_MODE=1920x1080 — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here).

Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above.

diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs
index c7f7c45..2535b68 100644
--- a/crates/victory-gpu/src/dxgi.rs
+++ b/crates/victory-gpu/src/dxgi.rs
@@ -219,6 +219,19 @@ struct Mode {
 }
 const _: () = assert!(size_of::<Mode>() == 32);
 
+/// The console's fixed output mode, overridable for hosts smaller than the
+/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead.
+fn mode_size() -> (u32, u32) {
+    const DEFAULT: (u32, u32) = (3840, 2160);
+    let Some(text) = std::env::var_os("VICTORY_MODE") else {
+        return DEFAULT;
+    };
+    let text = text.to_string_lossy();
+    text.split_once('x')
+        .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?)))
+        .unwrap_or(DEFAULT)
+}
+
 /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks
 /// for a 120 Hz one to allow 120 Hz frame intervals).
 /// shortcut: fixed mode, not the host display's; report the host's rates if
@@ -242,9 +255,10 @@ extern "system" fn modes(
         return MORE_DATA;
     }
     *count = 1;
+    let (width, height) = mode_size();
     let mode = Mode {
-        width: 3840,
-        height: 2160,
+        width,
+        height,
         refresh: [60, 1],
         format: 0,
         scanlines: 1, // progressive
diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs
index a411bd0..da8d66c 100644
--- a/crates/victory-hle/src/modules/gameinput.rs
+++ b/crates/victory-hle/src/modules/gameinput.rs
@@ -1134,6 +1134,11 @@ mod host {
 
     impl Source for Host {
         fn pad(&mut self, slot: usize) -> Option<PadState> {
+            // The keyboard stand-in pad only exists while no host pad is
+            // connected; this hides a host pad the title mis-handles.
+            if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() {
+                return None;
+            }
             if self.empty_until[slot].is_some_and(|until| Instant::now() < until) {
                 return None;
             }
**@⁠pfhandler** on GitHub · 2026-11-24 20:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1514#issuecomment-7144124229) Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB): - `VICTORY_NO_HOST_PAD=1` — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets `VICTORY_KEYS` drive the title again. - `VICTORY_MODE=1920x1080` — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here). Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above. ```diff diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs index c7f7c45..2535b68 100644 --- a/crates/victory-gpu/src/dxgi.rs +++ b/crates/victory-gpu/src/dxgi.rs @@ -219,6 +219,19 @@ struct Mode { } const _: () = assert!(size_of::<Mode>() == 32); +/// The console's fixed output mode, overridable for hosts smaller than the +/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead. +fn mode_size() -> (u32, u32) { + const DEFAULT: (u32, u32) = (3840, 2160); + let Some(text) = std::env::var_os("VICTORY_MODE") else { + return DEFAULT; + }; + let text = text.to_string_lossy(); + text.split_once('x') + .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?))) + .unwrap_or(DEFAULT) +} + /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks /// for a 120 Hz one to allow 120 Hz frame intervals). /// shortcut: fixed mode, not the host display's; report the host's rates if @@ -242,9 +255,10 @@ extern "system" fn modes( return MORE_DATA; } *count = 1; + let (width, height) = mode_size(); let mode = Mode { - width: 3840, - height: 2160, + width, + height, refresh: [60, 1], format: 0, scanlines: 1, // progressive diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs index a411bd0..da8d66c 100644 --- a/crates/victory-hle/src/modules/gameinput.rs +++ b/crates/victory-hle/src/modules/gameinput.rs @@ -1134,6 +1134,11 @@ mod host { impl Source for Host { fn pad(&mut self, slot: usize) -> Option<PadState> { + // The keyboard stand-in pad only exists while no host pad is + // connected; this hides a host pad the title mis-handles. + if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() { + return None; + } if self.empty_until[slot].is_some_and(|until| Instant::now() < until) { return None; } ```
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:29 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: README.md). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1514#issuecomment-7149614680) <!-- victory-triage v1 head=1288c632bb8f238f0554d0f7ca826f11b298c3d0 verdict=needs-rebase at=2026-11-25T01:29:58Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `README.md`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • README.md
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/queue.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/1514/head:github-bot/gh-1514'
git switch 'github-bot/gh-1514'

Merge

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