A performance panel on screen: FPS, frame times, GPU/CPU load, VRAM and RAM #57

Merged
TaynanGT merged 6 commits from upstream-pr/57 into main 2026-11-26 19:58:23 +00:00
TaynanGT commented 2026-11-26 19:52:35 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-26T19:52:35Z.


A performance panel in the top-left corner, on by default, so clips and screenshots show what the build runs at, at what resolution and on what PC: FPS (coloured against the target), frame time with a graph, 1% low and worst frame, draws per frame, GPU name and load, VRAM (with what the layer itself holds), CPU name with per-core bars, the game's RAM and the PC's. F3 hides it; scripts\play.ps1 -NoPanel starts without it.

  • The HUD is Belo's, from Belobug/VIctory-Belobug-AMD (commit authored by beloooo).
  • GPU load comes from Windows' "GPU Engine" counters for this process on the game's adapter, the busiest engine, as Task Manager shows it. The panel labels it APP; when Windows has no sample it falls back to an estimate from the queue's idle time, labelled EST.
  • The panel's upload buffers are not reused while the GPU still reads them.
  • The panel exists in diagnostics builds, the default of play.ps1 and of every measurement in the README.

Checked: ci-local.ps1 (clippy both ways, tests, xtask) green together with #55; a Series S run with the panel on screen on the RTX 4090: 22 fps, GPU APP 87%, readings matching the log.

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5516306416 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/57). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-26T19:52:35Z. --- A performance panel in the top-left corner, on by default, so clips and screenshots show what the build runs at, at what resolution and on what PC: FPS (coloured against the target), frame time with a graph, 1% low and worst frame, draws per frame, GPU name and load, VRAM (with what the layer itself holds), CPU name with per-core bars, the game's RAM and the PC's. F3 hides it; `scripts\play.ps1 -NoPanel` starts without it. - The HUD is Belo's, from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD) (commit authored by beloooo). - GPU load comes from Windows' "GPU Engine" counters for this process on the game's adapter, the busiest engine, as Task Manager shows it. The panel labels it `APP`; when Windows has no sample it falls back to an estimate from the queue's idle time, labelled `EST`. - The panel's upload buffers are not reused while the GPU still reads them. - The panel exists in diagnostics builds, the default of `play.ps1` and of every measurement in the README. Checked: `ci-local.ps1` (clippy both ways, tests, xtask) green together with #55; a Series S run with the panel on screen on the RTX 4090: 22 fps, GPU `APP 87%`, readings matching the log. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chatgpt-codex-connector[bot] commented 2026-11-26 19:52:43 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T19:52:43Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T19:54:40.364101Z 5963f41 PR opened
🔒 Security Review ✅ Completed 2026-11-26T19:55:58.528168Z 5963f41 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7202054909 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/57#issuecomment-7202054909). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T19:52:43Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5963f41556a228d06e67149242c4e34a1a6a9c37","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":"5963f41556a228d06e67149242c4e34a1a6a9c37","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} --> <!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"5963f41556a228d06e67149242c4e34a1a6a9c37","mergeGateEnabled":false,"pullRequestNumber":57,"repository":"TaynanGT/Vice-Tay","status":"completed"} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T19:54:40.364101Z">2026-11-26T19:54:40.364101Z</relative-time> | `5963f41` | PR opened | | 🔒 **Security Review** | ✅ **Completed** <relative-time datetime="2026-11-26T19:55:58.528168Z">2026-11-26T19:55:58.528168Z</relative-time> | `5963f41` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-26 19:54:38 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T19:54:38Z.

Code review location: crates/victory-gpu/src/host/panel.rs; line 914

@@ -357,36 +867,59 @@ impl Panel {
         back: &ID3D12Resource,
         (width, height): (u32, u32),
         format: DXGI_FORMAT,
-    ) {
-        if !shown().load(Ordering::Relaxed) || self.lines.is_empty() || self.failed {
-            return;
+    ) -> Option<PanelCopy> {
+        self.last_size = (width, height);
+        if !shown().load(Ordering::Relaxed) || self.failed {
+            return None;
         }
+        let snap = self.snap.as_ref()?;
         let began = Instant::now();
         // Not the title's: the frame recorder leaves it out.
+        #[cfg(feature = "diagnostics")]
         let _ours = crate::replay::record::unrecorded();
         let scale = scale(height);
-        if self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)) {
-            // (What the card may still read stays: a picture's size changes once or twice in a run.)
-            std::mem::forget(self.buffers.take());
+        let replace = self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale));
+        // SAFETY: a nonblocking query on the same queue fence used by Host::submit.
+        let completed = if replace || self.changed { unsafe { host.fence.GetCompletedValue() } } else { 0 };
+        if completed == u64::MAX {
+            // Device removal signals every fence. Stop using this device's resources.
+            self.buffers = None;
+            self.failed = true;
+            return None;
+        }
+        if replace {
+            // Resize normally settled the queue already. Keep the old buffer
+            // if the wait failed; the next present can try the replacement.
+            if self.buffers.as_ref().is_some_and(|b| b.card_fence > completed) {
+                return None;
+            }
+            drop(self.buffers.take());
             self.buffers = Buffers::new(host, format, scale);
             self.failed = self.buffers.is_none();
             self.changed = true;
         }
-        let Some(buffers) = &mut self.buffers else { return };
-        if std::mem::take(&mut self.changed) {
-            buffers.write(&self.lines);
-        }
+        let buffers = self.buffers.as_mut()?;
+        let upload = if self.changed { buffers.write(snap, completed) } else { None };
+        if upload.is_some() { self.changed = false; }
         let (w, h) = size(scale);
         let list = &list.list;
         // SAFETY: an open list and live resources; the box lies within both.
         unsafe {
-            if std::mem::take(&mut buffers.fresh) {
-                list.CopyResource(&buffers.card, &buffers.uploads[buffers.turn].0);
+            if let Some(slot) = upload {
+                if buffers.uploaded {
+                    list.ResourceBarrier(&[transition(
+                        &buffers.card,
+                        D3D12_RESOURCE_STATE_COPY_SOURCE,
+                        D3D12_RESOURCE_STATE_COPY_DEST,
+                    )]);

P2 Badge Account for buffer decay before refreshing the panel

On every HUD refresh after the first upload, this barrier assumes the card buffer remains in COPY_SOURCE from the previous presentation. D3D12 buffers decay to COMMON when their ExecuteCommandLists operation completes, even after explicit transitions, so buffers.uploaded does not establish the resource's current state. Consequently, the next refresh records a mismatched StateBefore, producing resource-state validation errors when the D3D12 debug layer is enabled. Remove this inter-submission barrier and allow promotion from COMMON to COPY_DEST, while retaining the transition between the upload and texture copy within the current submission.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4712860532 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/57#discussion_r4712860532). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T19:54:38Z. **Code review location:** `crates/victory-gpu/src/host/panel.rs`; line 914 ~~~~diff @@ -357,36 +867,59 @@ impl Panel { back: &ID3D12Resource, (width, height): (u32, u32), format: DXGI_FORMAT, - ) { - if !shown().load(Ordering::Relaxed) || self.lines.is_empty() || self.failed { - return; + ) -> Option<PanelCopy> { + self.last_size = (width, height); + if !shown().load(Ordering::Relaxed) || self.failed { + return None; } + let snap = self.snap.as_ref()?; let began = Instant::now(); // Not the title's: the frame recorder leaves it out. + #[cfg(feature = "diagnostics")] let _ours = crate::replay::record::unrecorded(); let scale = scale(height); - if self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)) { - // (What the card may still read stays: a picture's size changes once or twice in a run.) - std::mem::forget(self.buffers.take()); + let replace = self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)); + // SAFETY: a nonblocking query on the same queue fence used by Host::submit. + let completed = if replace || self.changed { unsafe { host.fence.GetCompletedValue() } } else { 0 }; + if completed == u64::MAX { + // Device removal signals every fence. Stop using this device's resources. + self.buffers = None; + self.failed = true; + return None; + } + if replace { + // Resize normally settled the queue already. Keep the old buffer + // if the wait failed; the next present can try the replacement. + if self.buffers.as_ref().is_some_and(|b| b.card_fence > completed) { + return None; + } + drop(self.buffers.take()); self.buffers = Buffers::new(host, format, scale); self.failed = self.buffers.is_none(); self.changed = true; } - let Some(buffers) = &mut self.buffers else { return }; - if std::mem::take(&mut self.changed) { - buffers.write(&self.lines); - } + let buffers = self.buffers.as_mut()?; + let upload = if self.changed { buffers.write(snap, completed) } else { None }; + if upload.is_some() { self.changed = false; } let (w, h) = size(scale); let list = &list.list; // SAFETY: an open list and live resources; the box lies within both. unsafe { - if std::mem::take(&mut buffers.fresh) { - list.CopyResource(&buffers.card, &buffers.uploads[buffers.turn].0); + if let Some(slot) = upload { + if buffers.uploaded { + list.ResourceBarrier(&[transition( + &buffers.card, + D3D12_RESOURCE_STATE_COPY_SOURCE, + D3D12_RESOURCE_STATE_COPY_DEST, + )]); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Account for buffer decay before refreshing the panel** On every HUD refresh after the first upload, this barrier assumes the card buffer remains in `COPY_SOURCE` from the previous presentation. D3D12 buffers decay to `COMMON` when their `ExecuteCommandLists` operation completes, even after explicit transitions, so `buffers.uploaded` does not establish the resource's current state. Consequently, the next refresh records a mismatched `StateBefore`, producing resource-state validation errors when the D3D12 debug layer is enabled. Remove this inter-submission barrier and allow promotion from `COMMON` to `COPY_DEST`, while retaining the transition between the upload and texture copy within the current submission. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 19:54:38 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T19:54:38Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5963f41556

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6079827934 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/57#pullrequestreview-6079827934). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T19:54:38Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5963f41556` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
TaynanGT commented 2026-11-26 20:03:28 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-26T20:03:28Z.

Code review location: crates/victory-gpu/src/host/panel.rs; line 914

@@ -357,36 +867,59 @@ impl Panel {
         back: &ID3D12Resource,
         (width, height): (u32, u32),
         format: DXGI_FORMAT,
-    ) {
-        if !shown().load(Ordering::Relaxed) || self.lines.is_empty() || self.failed {
-            return;
+    ) -> Option<PanelCopy> {
+        self.last_size = (width, height);
+        if !shown().load(Ordering::Relaxed) || self.failed {
+            return None;
         }
+        let snap = self.snap.as_ref()?;
         let began = Instant::now();
         // Not the title's: the frame recorder leaves it out.
+        #[cfg(feature = "diagnostics")]
         let _ours = crate::replay::record::unrecorded();
         let scale = scale(height);
-        if self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)) {
-            // (What the card may still read stays: a picture's size changes once or twice in a run.)
-            std::mem::forget(self.buffers.take());
+        let replace = self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale));
+        // SAFETY: a nonblocking query on the same queue fence used by Host::submit.
+        let completed = if replace || self.changed { unsafe { host.fence.GetCompletedValue() } } else { 0 };
+        if completed == u64::MAX {
+            // Device removal signals every fence. Stop using this device's resources.
+            self.buffers = None;
+            self.failed = true;
+            return None;
+        }
+        if replace {
+            // Resize normally settled the queue already. Keep the old buffer
+            // if the wait failed; the next present can try the replacement.
+            if self.buffers.as_ref().is_some_and(|b| b.card_fence > completed) {
+                return None;
+            }
+            drop(self.buffers.take());
             self.buffers = Buffers::new(host, format, scale);
             self.failed = self.buffers.is_none();
             self.changed = true;
         }
-        let Some(buffers) = &mut self.buffers else { return };
-        if std::mem::take(&mut self.changed) {
-            buffers.write(&self.lines);
-        }
+        let buffers = self.buffers.as_mut()?;
+        let upload = if self.changed { buffers.write(snap, completed) } else { None };
+        if upload.is_some() { self.changed = false; }
         let (w, h) = size(scale);
         let list = &list.list;
         // SAFETY: an open list and live resources; the box lies within both.
         unsafe {
-            if std::mem::take(&mut buffers.fresh) {
-                list.CopyResource(&buffers.card, &buffers.uploads[buffers.turn].0);
+            if let Some(slot) = upload {
+                if buffers.uploaded {
+                    list.ResourceBarrier(&[transition(
+                        &buffers.card,
+                        D3D12_RESOURCE_STATE_COPY_SOURCE,
+                        D3D12_RESOURCE_STATE_COPY_DEST,
+                    )]);

I checked five separate upload and copy submissions with GPU-based validation enabled. On both the RTX 4090 and the Radeon iGPU, the submitted bytes matched on every iteration and there were zero D3D12 errors, both with the existing barrier and with implicit promotion.

Buffers do decay to COMMON between submissions. The D3D12 documentation also allows a promotable state such as COPY_SOURCE as StateBefore on a resource in COMMON. Removing the barrier would save work, but the existing transition is valid for this buffer.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4712921484 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/57#discussion_r4712921484). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-26T20:03:28Z. **Code review location:** `crates/victory-gpu/src/host/panel.rs`; line 914 ~~~~diff @@ -357,36 +867,59 @@ impl Panel { back: &ID3D12Resource, (width, height): (u32, u32), format: DXGI_FORMAT, - ) { - if !shown().load(Ordering::Relaxed) || self.lines.is_empty() || self.failed { - return; + ) -> Option<PanelCopy> { + self.last_size = (width, height); + if !shown().load(Ordering::Relaxed) || self.failed { + return None; } + let snap = self.snap.as_ref()?; let began = Instant::now(); // Not the title's: the frame recorder leaves it out. + #[cfg(feature = "diagnostics")] let _ours = crate::replay::record::unrecorded(); let scale = scale(height); - if self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)) { - // (What the card may still read stays: a picture's size changes once or twice in a run.) - std::mem::forget(self.buffers.take()); + let replace = self.buffers.as_ref().is_none_or(|b| (b.format, b.scale) != (format, scale)); + // SAFETY: a nonblocking query on the same queue fence used by Host::submit. + let completed = if replace || self.changed { unsafe { host.fence.GetCompletedValue() } } else { 0 }; + if completed == u64::MAX { + // Device removal signals every fence. Stop using this device's resources. + self.buffers = None; + self.failed = true; + return None; + } + if replace { + // Resize normally settled the queue already. Keep the old buffer + // if the wait failed; the next present can try the replacement. + if self.buffers.as_ref().is_some_and(|b| b.card_fence > completed) { + return None; + } + drop(self.buffers.take()); self.buffers = Buffers::new(host, format, scale); self.failed = self.buffers.is_none(); self.changed = true; } - let Some(buffers) = &mut self.buffers else { return }; - if std::mem::take(&mut self.changed) { - buffers.write(&self.lines); - } + let buffers = self.buffers.as_mut()?; + let upload = if self.changed { buffers.write(snap, completed) } else { None }; + if upload.is_some() { self.changed = false; } let (w, h) = size(scale); let list = &list.list; // SAFETY: an open list and live resources; the box lies within both. unsafe { - if std::mem::take(&mut buffers.fresh) { - list.CopyResource(&buffers.card, &buffers.uploads[buffers.turn].0); + if let Some(slot) = upload { + if buffers.uploaded { + list.ResourceBarrier(&[transition( + &buffers.card, + D3D12_RESOURCE_STATE_COPY_SOURCE, + D3D12_RESOURCE_STATE_COPY_DEST, + )]); ~~~~ --- I checked five separate upload and copy submissions with GPU-based validation enabled. On both the RTX 4090 and the Radeon iGPU, the submitted bytes matched on every iteration and there were zero D3D12 errors, both with the existing barrier and with implicit promotion. Buffers do decay to `COMMON` between submissions. [The D3D12 documentation](https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-resource-barriers-to-synchronize-resource-states-in-direct3d-12#performance-implications) also allows a promotable state such as `COPY_SOURCE` as `StateBefore` on a resource in `COMMON`. Removing the barrier would save work, but the existing transition is valid for this buffer.
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
TaynanGT/Vice-Tay!57
No description provided.