Display output: bars around the picture in a window of other proportions, instead of stretching it #3755

Open
stasadance wants to merge 1 commit from upstream-pr/3755 into main
stasadance commented 2026-11-30 06:03:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by stasadance on 2026-11-30T06:03:16Z.


Related: #3366

What it changes

When the window's client area isn't at the picture's proportions, the swap chain scales the back buffer to the window, and vkd3d-proton only stretches. Under Wine's X11 driver on GNOME the window manager resizes the window freely (no WM_SIZING, no aspect hints), so the picture came out stretched, e.g. a 1920x1080 window resized to 1328x1080.

Now, when the proportions differ, the back buffer takes the window's size, the composer draws the picture whole in its middle and the rest is black, so the picture is never stretched. DLSS Frame Generation is told the picture's part of the back buffer (kBufferTypeBackbuffer, 53, with its extent alone), so the bars are copied as they are. VICTORY_LETTERBOX=0 stretches, as before.

How it was tested

  • GPU and profile: RTX 4090 on Linux, GNOME Wayland with XWayland (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X
  • Before: the window resized to 1328x1080 and the picture was stretched to it.
  • After (run 20261129-225559): "display output: the window's proportions differ from the picture's: bars around it" logged 36 times as the window was resized (back buffers 2560x1443 to 2560x1459 around a 2560x1440 picture), the picture at its own proportions with black bars, and frame generation switched on 7 times in the same run.
  • cargo test passed for the crates it touches: native cargo test cannot build victory-gpu on a Linux host (same on main), so no; cargo xwin clippy for the Windows target adds no warning over current main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3366 (stretched in a bordered window), #1615 (FSR 3 FG rectangle for bars, closed), #132.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5559963728 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3755). Originally posted by [stasadance](https://github.com/stasadance) on 2026-11-30T06:03:16Z. --- Related: #3366 ## What it changes When the window's client area isn't at the picture's proportions, the swap chain scales the back buffer to the window, and vkd3d-proton only stretches. Under Wine's X11 driver on GNOME the window manager resizes the window freely (no WM_SIZING, no aspect hints), so the picture came out stretched, e.g. a 1920x1080 window resized to 1328x1080. Now, when the proportions differ, the back buffer takes the window's size, the composer draws the picture whole in its middle and the rest is black, so the picture is never stretched. DLSS Frame Generation is told the picture's part of the back buffer (`kBufferTypeBackbuffer`, 53, with its extent alone), so the bars are copied as they are. `VICTORY_LETTERBOX=0` stretches, as before. ## How it was tested - GPU and profile: RTX 4090 on Linux, GNOME Wayland with XWayland (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X - Before: the window resized to 1328x1080 and the picture was stretched to it. - After (run 20261129-225559): "display output: the window's proportions differ from the picture's: bars around it" logged 36 times as the window was resized (back buffers 2560x1443 to 2560x1459 around a 2560x1440 picture), the picture at its own proportions with black bars, and frame generation switched on 7 times in the same run. - `cargo test` passed for the crates it touches: native `cargo test` cannot build `victory-gpu` on a Linux host (same on main), so no; `cargo xwin clippy` for the Windows target adds no warning over current main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3366 (stretched in a bordered window), #1615 (FSR 3 FG rectangle for bars, closed), #132.
andrewpozdnakov7-jpg commented 2026-11-30 07:11:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T07:11:57Z.

Code review location: crates/victory-gpu/src/streamline.rs; line 2533

@@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt
         } else if hudless_wanted() {
             HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed);
         }
-        let tags: Vec<abi::ResourceTag> = resources
+        let mut tags: Vec<abi::ResourceTag> = resources
             .iter_mut()
             .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size)))
             .collect();
+        // Bars around the picture (a window of other proportions,
+        // `crate::host` letterbox): generation runs on the picture's part of
+        // the back buffer alone, the bars are copied as they are. (Streamline
+        // knows the back buffer: the tag carries the extent only.)
+        let picture = crate::host::letterboxed();
+        if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) {

|| skips its right-hand operand when picture.is_some() is true. That leaves LETTERBOX_TAGGED false during frames with bars, so the first full-size frame never emits the intended reset extent.

I ran the exact condition extracted from a2439f2 and from the one-line fix in a native Rust harness. With two transitions from bars to full size, the PR omitted both reset extents. With the swap evaluated first, both transitions emitted the full extent once. Consecutive full-size frames emitted nothing. This checks the tag decisions before the Streamline call. NVIDIA DLSS-G guide, backbuffer subrect

        if LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) || picture.is_some() {

Local fix bd7ab26 is based on the exact PR head. If incorporating it manually, please retain the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review-comment:4735970466 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3755#discussion_r4735970466). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T07:11:57Z. **Code review location:** `crates/victory-gpu/src/streamline.rs`; line 2533 ~~~~diff @@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt } else if hudless_wanted() { HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed); } - let tags: Vec<abi::ResourceTag> = resources + let mut tags: Vec<abi::ResourceTag> = resources .iter_mut() .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size))) .collect(); + // Bars around the picture (a window of other proportions, + // `crate::host` letterbox): generation runs on the picture's part of + // the back buffer alone, the bars are copied as they are. (Streamline + // knows the back buffer: the tag carries the extent only.) + let picture = crate::host::letterboxed(); + if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) { ~~~~ --- `||` skips its right-hand operand when `picture.is_some()` is true. That leaves `LETTERBOX_TAGGED` false during frames with bars, so the first full-size frame never emits the intended reset extent. I ran the exact condition extracted from `a2439f2` and from the one-line fix in a native Rust harness. With two transitions from bars to full size, the PR omitted both reset extents. With the swap evaluated first, both transitions emitted the full extent once. Consecutive full-size frames emitted nothing. This checks the tag decisions before the Streamline call. [NVIDIA DLSS-G guide, backbuffer subrect](https://github.com/NVIDIA-RTX/Streamline/blob/main/docs/ProgrammingGuideDLSS_G.md#52-tagging-recommendations) ```suggestion if LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) || picture.is_some() { ``` Local fix `bd7ab26` is based on the exact PR head. If incorporating it manually, please retain the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with OpenAI Codex.
stasadance commented 2026-11-30 08:22:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by stasadance on 2026-11-30T08:22:57Z.

Code review location: crates/victory-gpu/src/streamline.rs; line 2533

@@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt
         } else if hudless_wanted() {
             HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed);
         }
-        let tags: Vec<abi::ResourceTag> = resources
+        let mut tags: Vec<abi::ResourceTag> = resources
             .iter_mut()
             .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size)))
             .collect();
+        // Bars around the picture (a window of other proportions,
+        // `crate::host` letterbox): generation runs on the picture's part of
+        // the back buffer alone, the bars are copied as they are. (Streamline
+        // knows the back buffer: the tag carries the extent only.)
+        let picture = crate::host::letterboxed();
+        if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) {

Thanks @andrewpozdnakov7-jpg, you're right: with || short-circuiting, the swap never ran on frames with bars, so the first full-size frame after them never re-tagged the whole back buffer. Fixed in f9feb31 by evaluating the swap first, as you suggested, with you as co-author.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review-comment:4736526269 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3755#discussion_r4736526269). Originally posted by [stasadance](https://github.com/stasadance) on 2026-11-30T08:22:57Z. **Code review location:** `crates/victory-gpu/src/streamline.rs`; line 2533 ~~~~diff @@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt } else if hudless_wanted() { HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed); } - let tags: Vec<abi::ResourceTag> = resources + let mut tags: Vec<abi::ResourceTag> = resources .iter_mut() .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size))) .collect(); + // Bars around the picture (a window of other proportions, + // `crate::host` letterbox): generation runs on the picture's part of + // the back buffer alone, the bars are copied as they are. (Streamline + // knows the back buffer: the tag carries the extent only.) + let picture = crate::host::letterboxed(); + if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) { ~~~~ --- Thanks @andrewpozdnakov7-jpg, you're right: with `||` short-circuiting, the swap never ran on frames with bars, so the first full-size frame after them never re-tagged the whole back buffer. Fixed in f9feb31 by evaluating the swap first, as you suggested, with you as co-author.
andrewpozdnakov7-jpg commented 2026-11-30 08:48:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T08:48:04Z.

Code review location: crates/victory-gpu/src/streamline.rs; line 2533

@@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt
         } else if hudless_wanted() {
             HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed);
         }
-        let tags: Vec<abi::ResourceTag> = resources
+        let mut tags: Vec<abi::ResourceTag> = resources
             .iter_mut()
             .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size)))
             .collect();
+        // Bars around the picture (a window of other proportions,
+        // `crate::host` letterbox): generation runs on the picture's part of
+        // the back buffer alone, the bars are copied as they are. (Streamline
+        // knows the back buffer: the tag carries the extent only.)
+        let picture = crate::host::letterboxed();
+        if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) {

Retested the exact updated head f9feb31d on Windows. In the eight-frame fixture, both returns from bars to full size emitted the full extent once and the following full-size frames emitted no additional tag. This resolves the tag-decision issue I raised. The fixture stops before the Streamline call.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review-comment:4736747846 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3755#discussion_r4736747846). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T08:48:04Z. **Code review location:** `crates/victory-gpu/src/streamline.rs`; line 2533 ~~~~diff @@ -2519,10 +2521,19 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>, video: bool) -> Opt } else if hudless_wanted() { HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed); } - let tags: Vec<abi::ResourceTag> = resources + let mut tags: Vec<abi::ResourceTag> = resources .iter_mut() .map(|(r, kind, size)| abi::ResourceTag::new(r, *kind, abi::VALID_UNTIL_PRESENT, abi::Extent::sized(*size))) .collect(); + // Bars around the picture (a window of other proportions, + // `crate::host` letterbox): generation runs on the picture's part of + // the back buffer alone, the bars are copied as they are. (Streamline + // knows the back buffer: the tag carries the extent only.) + let picture = crate::host::letterboxed(); + if picture.is_some() || LETTERBOX_TAGGED.swap(picture.is_some(), Relaxed) { ~~~~ --- Retested the exact updated head `f9feb31d` on Windows. In the eight-frame fixture, both returns from bars to full size emitted the full extent once and the following full-size frames emitted no additional tag. This resolves the tag-decision issue I raised. The fixture stops before the Streamline call.
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/3755:upstream-pr/3755'
git switch 'upstream-pr/3755'

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/3755'
git switch 'upstream-pr/3755'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3755'
git switch 'upstream-pr/3755'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3755'
git switch 'main'
git merge --squash 'upstream-pr/3755'
git switch 'main'
git merge --ff-only 'upstream-pr/3755'
git switch 'main'
git merge 'upstream-pr/3755'
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
trustno1-coder/VIctory-NVIDIA!3755
No description provided.