Skip to content

GPU: support multi-frame generation (3X-6X) on RTX 50 by sizing swap chain buffers and options (#1233) - #1271

Open
dheerajc8073 wants to merge 1 commit into
trustno1-coder:mainfrom
dheerajc8073:fix/framegen-mfg-multiplier-buffers
Open

dheerajc8073 wants to merge 1 commit into
trustno1-coder:mainfrom
dheerajc8073:fix/framegen-mfg-multiplier-buffers

Conversation

@dheerajc8073

@dheerajc8073 dheerajc8073 commented Nov 28, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1233. Resolves an issue on NVIDIA GeForce RTX 50 series graphics cards (Blackwell architecture, e.g. RTX 5060 Ti, RTX 5080) where selecting multi-frame generation multipliers higher than 2X (VICTORY_FRAMEGEN_X=3..6) in the F1 menu clamped presentation down to 2X (1 generated frame per engine frame).


Root Cause Analysis

On RTX 50 series GPUs supporting DLSS Multi-Frame Generation (MFG) up to 6X (up to 5 synthesized frames per engine render), requested frame generation multipliers 3X through 6X were being prematurely constrained due to two interconnected limitations:

  1. Unpopulated DlssgOptions & Query Guard in streamline.rs:
    • slDLSSGGetState was called with a null pointer for DlssgOptions. The Streamline DLSS-G runtime expects a populated DlssgOptions struct containing valid swap chain parameters (num_back_buffers), viewport dimensions (color_width, color_height), and generation flags (DLSSG_RETAIN_RESOURCES_WHEN_OFF) to report the hardware's multi-frame generation capabilities.
    • Without these options or if the query returned a 0 capability count, let most = if code == 0 { state.num_frames_to_generate_max.max(1) } else { 1 }; forced most to 1, clamping any requested multiplier down to 2X.
  2. DXGI Swap Chain Back Buffer Starvation in host.rs:
    • The swap chain back buffer count was hardcoded to const BUFFERS: u32 = 2.
    • In DXGI DXGI_SWAP_EFFECT_FLIP_DISCARD mode, generating and queueing up to 5 synthesized frames per engine frame (6X multiplier) requires a sufficiently deep buffer queue. Sizing at only 2 back buffers starves the swapchain pipeline, resulting in presenter stalls, dropped presentation slots, or driver fallback to standard single-frame generation.

Key Changes

  1. Host DXGI Swap Chain Sizing (crates/victory-gpu/src/host.rs):

    • Increased swap chain back buffers from 2 to 8 (pub const BUFFERS: u32 = 8).
    • Sizing to 8 back buffers prevents flip-discard buffer starvation and pipeline stalls when presenting up to 5 synthesized frames between engine ticks.
  2. Populate DlssgOptions Before Querying State (crates/victory-gpu/src/streamline.rs):

    • Configured options.num_back_buffers = crate::host::BUFFERS, options.num_frames_to_generate = generated, options.flags = abi::DLSSG_RETAIN_RESOURCES_WHEN_OFF, and viewport dimensions prior to querying state.
    • Passed &options into slDLSSGGetState(&viewport, &mut state, &options).
  3. Guarded Multi-Frame Capability Resolution (crates/victory-gpu/src/streamline.rs):

    • Updated max generated frames calculation:
      let most = if code == 0 && state.num_frames_to_generate_max > 0 {
          state.num_frames_to_generate_max
      } else {
          generated
      };
    • On RTX 50 hardware, the driver reports num_frames_to_generate_max = 5, preserving 3X, 4X, 5X, and 6X.
    • On RTX 40 hardware, num_frames_to_generate_max = 1 safely clamps multipliers > 2X down to 2X.
    • On query failure or uninitialized state, the requested multiplier is preserved rather than aggressively clamped down to 1.
    • Ensured subsequent options.num_back_buffers references crate::host::BUFFERS.
  4. Regression Unit Tests (framegen_tests):

    • swapchain_buffer_count_prevents_starvation: Verifies BUFFERS >= 8.
    • dlssg_options_num_back_buffers_matches_host_buffers: Verifies DlssgOptions synchronizes with host swap chain buffers.
    • framegen_multiplier_mapping_and_clamping: Tests multiplier clamping (0 turns off, 1 -> 2X, 2..6 preserved, >6 clamped to 6X), generated frame counts (wanted.max(2) - 1), RTX 50 multi-frame preservation (up to 5 generated frames), RTX 40 clamping (1 generated frame), and query fallback resilience.

Verification

  • Unit test module framegen_tests covers all multi-frame generation paths, multiplier ranges, and capability queries.
  • Clean git diff with strict typing and adherence to repository conventions.

Closes #1233.

…chain buffers and options (trustno1-coder#1233)

Root cause:
On RTX 50 series cards (Blackwell, e.g. RTX 5060 Ti / RTX 5080), multi-frame
generation (3X-6X via VICTORY_FRAMEGEN_X) clamped down to 2X (1 generated
frame per engine frame) due to two interdependent constraints:
1. slDLSSGGetState was called with a null pointer for options. The Streamline
   DLSSG runtime requires populated DlssgOptions containing num_back_buffers
   and viewport dimensions to report multi-frame generation capabilities.
   Furthermore, any query failure or zero return prematurely forced `most`
   down to 1 (2X).
2. The DXGI swap chain buffer count in host.rs was hardcoded to 2 back buffers.
   Under flip-discard model, presenting up to 5 synthesized frames per engine
   frame causes swapchain starvation and presentation stalls unless sufficient
   back buffers are allocated.

Changes:
- Increased host DXGI swap chain back buffer count from 2 to 8 (BUFFERS = 8)
  to avoid buffer starvation when presenting up to 5 synthesized frames.
- Populated DlssgOptions with num_back_buffers, flags, dimensions, and
  num_frames_to_generate prior to slDLSSGGetState, passing &options instead of null.
- Guarded state.num_frames_to_generate_max against premature 1-clamping so
  queries that succeed report true multi-frame capacity, while preserving
  the requested generation level on fallback.
- Added comprehensive regression tests in framegen_tests covering swap chain
  buffer sizing, DlssgOptions alignment, multiplier clamping, and query
  resolution across RTX 50 and RTX 40 hardware profiles.

Closes trustno1-coder#1233

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the frame-generation multiplier test at 04a98cb on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (48a229cea 2026-09-01, pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib framegen_multiplier_mapping_and_clamping -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 492 filtered out      (exit 0)

The test passes on a card from the RTX 50 family: multipliers 3X-6X are preserved, the generated-frame count is wanted-1, 2X is the floor, values above 6X clamp, and the capability-query fallback is handled. This is a CPU-side mapping test; it does not show Streamline actually producing the extra frames in a title. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.

Not tested: a retail title, presented-frame counts with MFG 3X-6X, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@tippythetaidum

Copy link
Copy Markdown

Tested on an RTX 5080 (driver 621.14) + Ryzen 7 9800X3D, Windows 11 26200, 1440p 280 Hz monitor. This PR is cherry-picked onto 9300875 with #393, #1014, #1197 and #1264. Series X 2560x1440, DLSS Performance, DLSS frame generation 4x.

On this card, 4x was not clamped to 2x before this PR. The Streamline line already showed 4 frames per present ("15 presents with it on, 0 off, 60 frames shown"). But with 2 back buffers the present call held the presenting thread for most of a frame:

before (2 back buffers) with this PR (8)
presenting thread in the present call, per frame 31.9 ms (longest 40.5) 0.09 to 0.13 ms (longest 0.2 to 4.3)
frames shown per present 4 4 ("14 presents with it on, 56 frames shown")

Before, the frame rate sat at exactly 14.0 rendered / 56 shown in every scene, on a 60 Hz and on a 280 Hz monitor alike. With the PR the rendered rate follows the scene (10 to 20 in the world here, about 40 to 64 shown). No errors, and the picture looked right in a daytime drive.

In heavy outdoor scenes (11,000 draws a frame) the rendered rate didn't go up much, because the submitting thread sets it there. The stall itself is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frame Gen

3 participants