GPU: a run with no presentable desktop asks DXGI for a swap chain once per frame (1,654 warnings in 60 s) #1591

Closed
opened 2026-11-26 04:37:22 +00:00 by github-bot · 1 comment
Owner

@⁠fiestorra on GitHub · 2026-11-24 19:33 UTC · original

What's wrong

Host::present (crates/victory-gpu/src/host.rs) retries the whole presenter path on every presented frame while the presenter is absent, and logs a WARN for each attempt:

if presenter.is_none() {
    *presenter = match self.presenter(width, height, format) {
        Ok(p) => Some(p),
        Err(e) => {
            tracing::warn!(error = %e, "no swap chain");
            return None;
        }
    };
}

A run whose desktop cannot be presented on (locked screen, sleeping display, a session with no visible desktop) therefore does CreateDXGIFactory2 + CreateSwapChainForHwnd once per frame and writes one line per frame. The same shape exists in the resize path (swap chain not resized).

Measured today on my machine (RTX 4090, driver 621.24, Windows 11 26100, package 1.0.2.1, diagnostics build, empty cache), while the desktop happened to be un-presentable:

run presented frames no swap chain lines
unmodified main ffe310e, 60 s 1,024 1,654
unmodified main ffe310e, 60 s (second probe) 128 131

That is roughly one and a half attempts per presented frame; the first run's log was 311 KB after 60 seconds, about four fifths of it these lines, and nothing else in it can be read. Two different errors appear, so the failure is not even stable:

  • 0x887A0022 "a resource is not available at the time of the call, but may become available later" — the transient case retrying is for;
  • 0x8007000E "not enough memory resources are available to process this command".

Neither line says which step failed. presenter() funnels the window, the factory, the swap chain and the copy list into one error, so the log cannot tell a missing window from a refused swap chain.

This is not a hang and not the cause of the device removals people report; it is a state that a tester behind a locked screen hits immediately, and it costs work and log every frame in it.

The fix

One failure state on Host, a backoff that grows and caps, and log lines that say what failed:

  • Retry { attempts: u32, next: Option<Instant> } with due(now) / failed(now) / reset(); the wait is retry_delay(attempts) = 100 ms doubling to a 1 s cap, so a state that clears recovers within a second.
  • present() returns early (no DXGI call, no log) until the retry is due; the resize path uses the same gate.
  • The first failure is a WARN naming the step and the frame size; later ones are DEBUG with the attempt count. When a presenter finally appears, one INFO reports how many attempts failed.
  • presenter() returns Result<Presenter, (PresentStep, windows::core::Error)>, naming window, DXGI factory, swap chain or copy list.

Five unit tests cover the schedule (100/200/400/800/1,000/1,000 ms), the gate, the reset, the step names, and a simulated minute at 20 fps with no desktop — bounded to 63 attempts where the old code made 1,200.

Measured effect

Same machine state, same command, patches applied to ffe310e only:

presented frames no swap chain lines
main unmodified (target\main-check, release) 128 131
patched (diag build) 128 1

Both runs ended at frame 128 with the same host GPU device removed after a submission of 1 lists (0x887A0004 / 0x887A0007), so the two windows are directly comparable — and that removal reproduces identically on the unmodified binary, so it is not from this change.

Verification run: cargo test -p victory-gpu present_retry → 5 passed; cargo clippy -p victory-gpu --all-targets --locked -- -D warnings → clean; rustfmt --check on the file reports only hunks in pre-existing code, none in the added lines.

The patch

External PRs are collaborators-only here, so the diff is below; apply it on ffe310e and it builds clean.

crates/victory-gpu/src/host.rs (+212 −13)
diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs
index 6672c1e..cfae08f 100644
--- a/crates/victory-gpu/src/host.rs
+++ b/crates/victory-gpu/src/host.rs
@@ -53,6 +53,78 @@ pub(crate) struct Host {
     messages: Option<ID3D12InfoQueue>,
     next_rtv: AtomicU32,
     presenter: Mutex<Option<Presenter>>,
+    /// Why no presenter was made, and when to try again: a run with no
+    /// desktop to present on would otherwise ask DXGI at the frame rate.
+    present_retry: Mutex<Retry>,
+}
+
+/// A presenter that could not be made, and when to try again. Without this,
+/// a run behind a locked screen or a sleeping display retried every frame:
+/// 1,654 `no swap chain` lines in 60 seconds, and one DXGI call per frame,
+/// which buries the log and costs a submission's worth of work each time.
+struct Retry {
+    attempts: u32,
+    /// The next attempt is due at (or after) this instant; `None` with
+    /// `attempts == 0` means nothing has failed.
+    next: Option<std::time::Instant>,
+}
+
+impl Retry {
+    const fn new() -> Self {
+        Retry {
+            attempts: 0,
+            next: None,
+        }
+    }
+
+    /// Whether an attempt is due at `now`.
+    fn due(&self, now: std::time::Instant) -> bool {
+        self.next.is_none_or(|at| now >= at)
+    }
+
+    /// Records a failed attempt at `now` and when the next one may run.
+    fn failed(&mut self, now: std::time::Instant) {
+        self.attempts = self.attempts.saturating_add(1);
+        self.next = Some(now + retry_delay(self.attempts));
+    }
+
+    /// Clears the failure state after an attempt worked, returning how many
+    /// attempts had failed before it.
+    fn reset(&mut self) -> u32 {
+        let attempts = self.attempts;
+        *self = Retry::new();
+        attempts
+    }
+}
+
+/// How long to wait before retry number `attempts`: 100 ms, doubling, up to
+/// one second, so a state that clears still recovers within a second.
+fn retry_delay(attempts: u32) -> std::time::Duration {
+    const FIRST_MS: u64 = 100;
+    const MOST_MS: u64 = 1_000;
+    let doubling = FIRST_MS << attempts.saturating_sub(1).min(4);
+    std::time::Duration::from_millis(doubling.min(MOST_MS))
+}
+
+/// Which step of making a presenter failed, so the log says whether the
+/// window, the swap chain or its command list was refused.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum PresentStep {
+    Window,
+    Factory,
+    SwapChain,
+    List,
+}
+
+impl PresentStep {
+    fn name(self) -> &'static str {
+        match self {
+            PresentStep::Window => "window",
+            PresentStep::Factory => "DXGI factory",
+            PresentStep::SwapChain => "swap chain",
+            PresentStep::List => "copy list",
+        }
+    }
 }
 
 // SAFETY: D3D12 devices, queues, fences and descriptor heaps are
@@ -222,6 +294,7 @@ fn create() -> windows::core::Result<Host> {
             messages,
             next_rtv: AtomicU32::new(0),
             presenter: Mutex::new(None),
+            present_retry: Mutex::new(Retry::new()),
         })
     }
 }
@@ -1596,14 +1669,44 @@ impl Host {
         };
         let (width, height) = (desc.Width as u32, desc.Height);
         let mut presenter = self.presenter.lock().unwrap_or_else(|e| e.into_inner());
+        let mut retry = self.present_retry.lock().unwrap_or_else(|e| e.into_inner());
+        let now = std::time::Instant::now();
+        // After a failure, wait for the backoff: one attempt per state, not
+        // one per frame.
+        if !retry.due(now) {
+            return None;
+        }
         if presenter.is_none() {
-            *presenter = match self.presenter(width, height, format) {
-                Ok(p) => Some(p),
-                Err(e) => {
-                    tracing::warn!(error = %e, "no swap chain");
+            match self.presenter(width, height, format) {
+                Ok(p) => {
+                    let attempts = retry.reset();
+                    if attempts > 0 {
+                        tracing::info!(attempts, "swap chain created after the failed attempts");
+                    }
+                    *presenter = Some(p);
+                }
+                Err((step, e)) => {
+                    retry.failed(now);
+                    if retry.attempts == 1 {
+                        tracing::warn!(
+                            error = %e,
+                            step = step.name(),
+                            width,
+                            height,
+                            format = format.0,
+                            "no swap chain; the next attempt waits for the backoff"
+                        );
+                    } else {
+                        tracing::debug!(
+                            error = %e,
+                            step = step.name(),
+                            attempts = retry.attempts,
+                            "no swap chain"
+                        );
+                    }
                     return None;
                 }
-            };
+            }
         }
         let p = presenter.as_mut()?;
         if (p.width, p.height, p.format) != (width, height, format) {
@@ -1613,9 +1716,22 @@ impl Host {
                     .ResizeBuffers(BUFFERS, width, height, format, DXGI_SWAP_CHAIN_FLAG(0))
             };
             match resized {
-                Ok(()) => (p.width, p.height, p.format) = (width, height, format),
+                Ok(()) => {
+                    retry.reset();
+                    (p.width, p.height, p.format) = (width, height, format);
+                }
                 Err(e) => {
-                    tracing::warn!(error = %e, width, height, "swap chain not resized");
+                    retry.failed(now);
+                    if retry.attempts == 1 {
+                        tracing::warn!(
+                            error = %e,
+                            width,
+                            height,
+                            "swap chain not resized; the next attempt waits for the backoff"
+                        );
+                    } else {
+                        tracing::debug!(error = %e, attempts = retry.attempts, "swap chain not resized");
+                    }
                     return None;
                 }
             }
@@ -1674,14 +1790,15 @@ impl Host {
         width: u32,
         height: u32,
         format: DXGI_FORMAT,
-    ) -> windows::core::Result<Presenter> {
+    ) -> Result<Presenter, (PresentStep, windows::core::Error)> {
         let hwnd = match title_window() {
             Some(hwnd) => hwnd,
-            None => window(width, height)?,
+            None => window(width, height).map_err(|e| (PresentStep::Window, e))?,
         };
         // SAFETY: plain object creation for our window.
         unsafe {
-            let factory: IDXGIFactory2 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0))?;
+            let factory: IDXGIFactory2 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0))
+                .map_err(|e| (PresentStep::Factory, e))?;
             let desc = DXGI_SWAP_CHAIN_DESC1 {
                 Width: width,
                 Height: height,
@@ -1696,9 +1813,11 @@ impl Host {
                 ..Default::default()
             };
             let swap_chain = factory
-                .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?
-                .cast::<IDXGISwapChain3>()?;
-            let copy = self.new_list()?;
+                .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)
+                .map_err(|e| (PresentStep::SwapChain, e))?
+                .cast::<IDXGISwapChain3>()
+                .map_err(|e| (PresentStep::SwapChain, e))?;
+            let copy = self.new_list().map_err(|e| (PresentStep::List, e))?;
             copy.close();
             tracing::info!(width, height, format = format.0, "presenting to a window");
             Ok(Presenter {
@@ -2053,3 +2172,83 @@ mod batch {   // Batch::texture_due lives here; `mod tests` is already taken at
         );
     }
 }
+
+#[cfg(test)]
+mod present_retry {
+    use super::{PresentStep, Retry, retry_delay};
+    use std::time::{Duration, Instant};
+
+    #[test]
+    fn the_backoff_starts_short_and_stops_at_a_second() {
+        let schedule: Vec<u64> = (1..=7).map(|n| retry_delay(n).as_millis() as u64).collect();
+        assert_eq!(schedule, [100, 200, 400, 800, 1_000, 1_000, 1_000]);
+    }
+
+    #[test]
+    fn a_failed_attempt_waits_before_the_next_one() {
+        let start = Instant::now();
+        let mut retry = Retry::new();
+        // Nothing has failed, so an attempt is due.
+        assert!(retry.due(start));
+        retry.failed(start);
+        assert_eq!(retry.attempts, 1);
+        assert!(!retry.due(start));
+        assert!(!retry.due(start + Duration::from_millis(99)));
+        assert!(retry.due(start + Duration::from_millis(100)));
+        // A second failure doubles the wait and counts.
+        let second = start + Duration::from_millis(100);
+        retry.failed(second);
+        assert_eq!(retry.attempts, 2);
+        assert!(!retry.due(second + Duration::from_millis(199)));
+        assert!(retry.due(second + Duration::from_millis(200)));
+    }
+
+    #[test]
+    fn a_working_attempt_clears_the_state_and_reports_the_failures() {
+        let start = Instant::now();
+        let mut retry = Retry::new();
+        for _ in 0..3 {
+            retry.failed(start);
+        }
+        assert_eq!(retry.attempts, 3);
+        assert_eq!(retry.reset(), 3);
+        assert_eq!(retry.attempts, 0);
+        assert!(retry.due(start));
+        // A later failure starts the schedule over.
+        retry.failed(start);
+        assert!(!retry.due(start + Duration::from_millis(99)));
+    }
+
+    /// A minute behind a desktop that never appears: one attempt per backoff
+    /// instead of one per presented frame.
+    #[test]
+    fn a_minute_without_a_desktop_asks_a_bounded_number_of_times() {
+        let mut retry = Retry::new();
+        let mut now = Instant::now();
+        let mut attempts = 0u32;
+        for _ in 0..1_200 {
+            // 60 s at 20 fps.
+            if retry.due(now) {
+                attempts += 1;
+                retry.failed(now);
+            }
+            now += Duration::from_millis(50);
+        }
+        assert!(
+            (59..=64).contains(&attempts),
+            "{attempts} attempts in a minute, one per backoff expected"
+        );
+    }
+
+    #[test]
+    fn every_step_of_a_presenter_has_a_name() {
+        for step in [
+            PresentStep::Window,
+            PresentStep::Factory,
+            PresentStep::SwapChain,
+            PresentStep::List,
+        ] {
+            assert!(!step.name().is_empty());
+        }
+    }
+}

No game data is involved: no shaders, textures, keys or package bytes, only counts and error codes.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-24 19:33 UTC · [original](https://github.com/Marvisak/VIctory/issues/1591) ### What's wrong `Host::present` (`crates/victory-gpu/src/host.rs`) retries the whole presenter path on **every presented frame** while the presenter is absent, and logs a `WARN` for each attempt: ```rust if presenter.is_none() { *presenter = match self.presenter(width, height, format) { Ok(p) => Some(p), Err(e) => { tracing::warn!(error = %e, "no swap chain"); return None; } }; } ``` A run whose desktop cannot be presented on (locked screen, sleeping display, a session with no visible desktop) therefore does `CreateDXGIFactory2` + `CreateSwapChainForHwnd` once per frame and writes one line per frame. The same shape exists in the resize path (`swap chain not resized`). Measured today on my machine (RTX 4090, driver 621.24, Windows 11 26100, package 1.0.2.1, diagnostics build, empty cache), while the desktop happened to be un-presentable: | run | presented frames | `no swap chain` lines | | --- | --- | --- | | unmodified `main` `ffe310e`, 60 s | 1,024 | **1,654** | | unmodified `main` `ffe310e`, 60 s (second probe) | 128 | **131** | That is roughly one and a half attempts per presented frame; the first run's log was 311 KB after 60 seconds, about four fifths of it these lines, and nothing else in it can be read. Two different errors appear, so the failure is not even stable: - `0x887A0022` "a resource is not available at the time of the call, but may become available later" — the transient case retrying is for; - `0x8007000E` "not enough memory resources are available to process this command". Neither line says **which** step failed. `presenter()` funnels the window, the factory, the swap chain and the copy list into one error, so the log cannot tell a missing window from a refused swap chain. This is not a hang and not the cause of the device removals people report; it is a state that a tester behind a locked screen hits immediately, and it costs work and log every frame in it. ### The fix One failure state on `Host`, a backoff that grows and caps, and log lines that say what failed: - `Retry { attempts: u32, next: Option<Instant> }` with `due(now)` / `failed(now)` / `reset()`; the wait is `retry_delay(attempts)` = 100 ms doubling to a 1 s cap, so a state that clears recovers within a second. - `present()` returns early (no DXGI call, no log) until the retry is due; the resize path uses the same gate. - The **first** failure is a `WARN` naming the step and the frame size; later ones are `DEBUG` with the attempt count. When a presenter finally appears, one `INFO` reports how many attempts failed. - `presenter()` returns `Result<Presenter, (PresentStep, windows::core::Error)>`, naming `window`, `DXGI factory`, `swap chain` or `copy list`. Five unit tests cover the schedule (100/200/400/800/1,000/1,000 ms), the gate, the reset, the step names, and a simulated minute at 20 fps with no desktop — bounded to 63 attempts where the old code made 1,200. ### Measured effect Same machine state, same command, patches applied to `ffe310e` only: | | presented frames | `no swap chain` lines | | --- | --- | --- | | `main` unmodified (`target\main-check`, release) | 128 | 131 | | patched (diag build) | 128 | **1** | Both runs ended at frame 128 with the same `host GPU device removed after a submission of 1 lists` (`0x887A0004` / `0x887A0007`), so the two windows are directly comparable — and that removal reproduces identically on the unmodified binary, so it is not from this change. Verification run: `cargo test -p victory-gpu present_retry` → 5 passed; `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` → clean; `rustfmt --check` on the file reports only hunks in pre-existing code, none in the added lines. ### The patch External PRs are collaborators-only here, so the diff is below; apply it on `ffe310e` and it builds clean. <details> <summary>crates/victory-gpu/src/host.rs (+212 −13)</summary> ```diff diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 6672c1e..cfae08f 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -53,6 +53,78 @@ pub(crate) struct Host { messages: Option<ID3D12InfoQueue>, next_rtv: AtomicU32, presenter: Mutex<Option<Presenter>>, + /// Why no presenter was made, and when to try again: a run with no + /// desktop to present on would otherwise ask DXGI at the frame rate. + present_retry: Mutex<Retry>, +} + +/// A presenter that could not be made, and when to try again. Without this, +/// a run behind a locked screen or a sleeping display retried every frame: +/// 1,654 `no swap chain` lines in 60 seconds, and one DXGI call per frame, +/// which buries the log and costs a submission's worth of work each time. +struct Retry { + attempts: u32, + /// The next attempt is due at (or after) this instant; `None` with + /// `attempts == 0` means nothing has failed. + next: Option<std::time::Instant>, +} + +impl Retry { + const fn new() -> Self { + Retry { + attempts: 0, + next: None, + } + } + + /// Whether an attempt is due at `now`. + fn due(&self, now: std::time::Instant) -> bool { + self.next.is_none_or(|at| now >= at) + } + + /// Records a failed attempt at `now` and when the next one may run. + fn failed(&mut self, now: std::time::Instant) { + self.attempts = self.attempts.saturating_add(1); + self.next = Some(now + retry_delay(self.attempts)); + } + + /// Clears the failure state after an attempt worked, returning how many + /// attempts had failed before it. + fn reset(&mut self) -> u32 { + let attempts = self.attempts; + *self = Retry::new(); + attempts + } +} + +/// How long to wait before retry number `attempts`: 100 ms, doubling, up to +/// one second, so a state that clears still recovers within a second. +fn retry_delay(attempts: u32) -> std::time::Duration { + const FIRST_MS: u64 = 100; + const MOST_MS: u64 = 1_000; + let doubling = FIRST_MS << attempts.saturating_sub(1).min(4); + std::time::Duration::from_millis(doubling.min(MOST_MS)) +} + +/// Which step of making a presenter failed, so the log says whether the +/// window, the swap chain or its command list was refused. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum PresentStep { + Window, + Factory, + SwapChain, + List, +} + +impl PresentStep { + fn name(self) -> &'static str { + match self { + PresentStep::Window => "window", + PresentStep::Factory => "DXGI factory", + PresentStep::SwapChain => "swap chain", + PresentStep::List => "copy list", + } + } } // SAFETY: D3D12 devices, queues, fences and descriptor heaps are @@ -222,6 +294,7 @@ fn create() -> windows::core::Result<Host> { messages, next_rtv: AtomicU32::new(0), presenter: Mutex::new(None), + present_retry: Mutex::new(Retry::new()), }) } } @@ -1596,14 +1669,44 @@ impl Host { }; let (width, height) = (desc.Width as u32, desc.Height); let mut presenter = self.presenter.lock().unwrap_or_else(|e| e.into_inner()); + let mut retry = self.present_retry.lock().unwrap_or_else(|e| e.into_inner()); + let now = std::time::Instant::now(); + // After a failure, wait for the backoff: one attempt per state, not + // one per frame. + if !retry.due(now) { + return None; + } if presenter.is_none() { - *presenter = match self.presenter(width, height, format) { - Ok(p) => Some(p), - Err(e) => { - tracing::warn!(error = %e, "no swap chain"); + match self.presenter(width, height, format) { + Ok(p) => { + let attempts = retry.reset(); + if attempts > 0 { + tracing::info!(attempts, "swap chain created after the failed attempts"); + } + *presenter = Some(p); + } + Err((step, e)) => { + retry.failed(now); + if retry.attempts == 1 { + tracing::warn!( + error = %e, + step = step.name(), + width, + height, + format = format.0, + "no swap chain; the next attempt waits for the backoff" + ); + } else { + tracing::debug!( + error = %e, + step = step.name(), + attempts = retry.attempts, + "no swap chain" + ); + } return None; } - }; + } } let p = presenter.as_mut()?; if (p.width, p.height, p.format) != (width, height, format) { @@ -1613,9 +1716,22 @@ impl Host { .ResizeBuffers(BUFFERS, width, height, format, DXGI_SWAP_CHAIN_FLAG(0)) }; match resized { - Ok(()) => (p.width, p.height, p.format) = (width, height, format), + Ok(()) => { + retry.reset(); + (p.width, p.height, p.format) = (width, height, format); + } Err(e) => { - tracing::warn!(error = %e, width, height, "swap chain not resized"); + retry.failed(now); + if retry.attempts == 1 { + tracing::warn!( + error = %e, + width, + height, + "swap chain not resized; the next attempt waits for the backoff" + ); + } else { + tracing::debug!(error = %e, attempts = retry.attempts, "swap chain not resized"); + } return None; } } @@ -1674,14 +1790,15 @@ impl Host { width: u32, height: u32, format: DXGI_FORMAT, - ) -> windows::core::Result<Presenter> { + ) -> Result<Presenter, (PresentStep, windows::core::Error)> { let hwnd = match title_window() { Some(hwnd) => hwnd, - None => window(width, height)?, + None => window(width, height).map_err(|e| (PresentStep::Window, e))?, }; // SAFETY: plain object creation for our window. unsafe { - let factory: IDXGIFactory2 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0))?; + let factory: IDXGIFactory2 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)) + .map_err(|e| (PresentStep::Factory, e))?; let desc = DXGI_SWAP_CHAIN_DESC1 { Width: width, Height: height, @@ -1696,9 +1813,11 @@ impl Host { ..Default::default() }; let swap_chain = factory - .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)? - .cast::<IDXGISwapChain3>()?; - let copy = self.new_list()?; + .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None) + .map_err(|e| (PresentStep::SwapChain, e))? + .cast::<IDXGISwapChain3>() + .map_err(|e| (PresentStep::SwapChain, e))?; + let copy = self.new_list().map_err(|e| (PresentStep::List, e))?; copy.close(); tracing::info!(width, height, format = format.0, "presenting to a window"); Ok(Presenter { @@ -2053,3 +2172,83 @@ mod batch { // Batch::texture_due lives here; `mod tests` is already taken at ); } } + +#[cfg(test)] +mod present_retry { + use super::{PresentStep, Retry, retry_delay}; + use std::time::{Duration, Instant}; + + #[test] + fn the_backoff_starts_short_and_stops_at_a_second() { + let schedule: Vec<u64> = (1..=7).map(|n| retry_delay(n).as_millis() as u64).collect(); + assert_eq!(schedule, [100, 200, 400, 800, 1_000, 1_000, 1_000]); + } + + #[test] + fn a_failed_attempt_waits_before_the_next_one() { + let start = Instant::now(); + let mut retry = Retry::new(); + // Nothing has failed, so an attempt is due. + assert!(retry.due(start)); + retry.failed(start); + assert_eq!(retry.attempts, 1); + assert!(!retry.due(start)); + assert!(!retry.due(start + Duration::from_millis(99))); + assert!(retry.due(start + Duration::from_millis(100))); + // A second failure doubles the wait and counts. + let second = start + Duration::from_millis(100); + retry.failed(second); + assert_eq!(retry.attempts, 2); + assert!(!retry.due(second + Duration::from_millis(199))); + assert!(retry.due(second + Duration::from_millis(200))); + } + + #[test] + fn a_working_attempt_clears_the_state_and_reports_the_failures() { + let start = Instant::now(); + let mut retry = Retry::new(); + for _ in 0..3 { + retry.failed(start); + } + assert_eq!(retry.attempts, 3); + assert_eq!(retry.reset(), 3); + assert_eq!(retry.attempts, 0); + assert!(retry.due(start)); + // A later failure starts the schedule over. + retry.failed(start); + assert!(!retry.due(start + Duration::from_millis(99))); + } + + /// A minute behind a desktop that never appears: one attempt per backoff + /// instead of one per presented frame. + #[test] + fn a_minute_without_a_desktop_asks_a_bounded_number_of_times() { + let mut retry = Retry::new(); + let mut now = Instant::now(); + let mut attempts = 0u32; + for _ in 0..1_200 { + // 60 s at 20 fps. + if retry.due(now) { + attempts += 1; + retry.failed(now); + } + now += Duration::from_millis(50); + } + assert!( + (59..=64).contains(&attempts), + "{attempts} attempts in a minute, one per backoff expected" + ); + } + + #[test] + fn every_step_of_a_presenter_has_a_name() { + for step in [ + PresentStep::Window, + PresentStep::Factory, + PresentStep::SwapChain, + PresentStep::List, + ] { + assert!(!step.name().is_empty()); + } + } +} ``` </details> No game data is involved: no shaders, textures, keys or package bytes, only counts and error codes. Written with an AI assistant.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:37:22 +00:00
Author
Owner

@⁠fiestorra on GitHub · 2026-11-24 20:19 UTC · original

Correction: this measurement ran on the integrated GPU, not on the RTX 4090

The runs behind this report took adapter 0, which on this machine is AMD Radeon(TM) Graphics, the Ryzen's integrated GPU (driver 32.0.21045.29003). The RTX 4090 is adapter 1 (32.0.16.2124, the 621.24 marketing version), and D3D12CreateDevice(None, …) — what crates/victory-gpu/src/host.rs calls — takes DXGI's default adapter, the first one enumerated. The numbers stand, because they are what that adapter did; the hardware I named in the report does not.

The defect itself does not depend on it: the retry storm and the backoff live in the present path, which every adapter shares, and the 131-against-1 count is per presented frame either way.

The adapter selection, the log line that now names the adapter, and what each one answers (mesh tier not supported on adapter 0, tier 1 on adapter 1) are in #1630, together with the three fixes in this report.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-24 20:19 UTC · [original](https://github.com/Marvisak/VIctory/issues/1591#issuecomment-7143379570) **Correction: this measurement ran on the integrated GPU, not on the RTX 4090** The runs behind this report took **adapter 0**, which on this machine is `AMD Radeon(TM) Graphics`, the Ryzen's integrated GPU (driver `32.0.21045.29003`). The RTX 4090 is adapter 1 (`32.0.16.2124`, the 621.24 marketing version), and `D3D12CreateDevice(None, …)` — what `crates/victory-gpu/src/host.rs` calls — takes DXGI's default adapter, the first one enumerated. The numbers stand, because they are what that adapter did; the hardware I named in the report does not. The defect itself does not depend on it: the retry storm and the backoff live in the present path, which every adapter shares, and the 131-against-1 count is per presented frame either way. The adapter selection, the log line that now names the adapter, and what each one answers (mesh tier not supported on adapter 0, tier 1 on adapter 1) are in https://git.gtahub.st/github/Marvisak--VIctory/pulls/1630, together with the three fixes in this report. Written with an AI assistant.
This discussion has been locked. Commenting is limited to contributors.
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#1591
No description provided.