Skip to content

vulkan: preserve the game aspect when presenting - #205

Draft
monsterlag wants to merge 7 commits into
NotRexed:mainfrom
monsterlag:fix/preserve-game-aspect
Draft

monsterlag wants to merge 7 commits into
NotRexed:mainfrom
monsterlag:fix/preserve-game-aspect

Conversation

@monsterlag

@monsterlag monsterlag commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #119. Refs #297.

Fit the game's source crop into a centered presentation rectangle and clear uncovered areas to black, including frame-generated presents. Preserve the existing camera-aspect override when Ultrawide or HOS_ASPECT is enabled.

The branch includes upstream main 4c236f3 and retains its controller callbacks. The aspect callback is appended after them, requiring renderer API v4. The executable and DLL must be deployed together. The actual DLL rejects a null/API3 host before loading Vulkan.

Current validation at 552e0f1:

  • Eleven rectangle/crop/odd-size/override cases pass with MSVC C++17 /W4 /WX. The matching game/renderer build passes: 339 seconds, zero failed files.
  • RTX 5090, isolated frozen save, 100% game resolution: actual 3840x1080 and 5120x1440 windows each display the Kokiri scene, HUD and centered sidebars with configured Catmull-Rom/2x frame generation and Lanczos/2x. No persistent black or obvious corruption appeared. Logs confirm both window dimensions and 2x initialization.
  • With frame generation off, plain presentation at 3840x1080 and the 5120x2160 fullscreen round trip display correctly. This does not validate the upscaler: current upstream bypasses its view/initialization paths when interpolation is off. Independent upscaling is being addressed in vulkan: initialize presentation upscaling independently of frame generation #417.
  • Older integration checks also covered 16:10 letterboxing, explicit camera-aspect overrides and fullscreen restoration. Current Windows/Linux source checks and the AppImage renderer build pass.

This remains draft pending active FG-off filter validation. The machine's panel is 5120x2160, so physical 32:9 fullscreen and the reported RTX 4070 FG-off black-screen case remain unverified. These are display-compatibility checks, not a native-FPS benchmark. No speculative black-screen workaround is included. AMD/Intel, wider progression and arbitrary drag/minimize transitions remain untested.

@turpcorp

turpcorp commented Nov 7, 2026

Copy link
Copy Markdown

Tested the same approach on another setup, and found one case where it goes black.

Setup: RTX 4070, 5120x1440 (32:9), Windows 11, fullscreen, the movie-sync build (44abdcd). Frame generation Off, Ultrawide 16:9, Resolution 100%.

I patched only hookshot_vk.dll with essentially the same change as this PR: a centered fit rectangle, a black clear, then the blit into the rectangle.

Upscaling Upscale target Result
Off n/a (blit into the rect) ✅ Correct: 2560x1440 centered, bars both sides
Catmull-Rom framegen_scale(..., rect.w, rect.h), as in this PR ❌ Title screen fine; gameplay all black (sound plays, the save icon shows, ~878 draws/frame in the log)
Catmull-Rom framegen_scale(..., swap_extent.w, swap_extent.h), then blit that into the rect ✅ Correct

Switching Upscaling to Off live in the Insert menu brought the picture back right away, so the black screen comes from upscaling straight to the rectangle's size. I didn't find the root cause. Your 5090 test had frame generation at 2x, and mine had it off, so that may be the difference.

The workaround I'm running upscales at the window's size (as before this PR) and then blits that into the rectangle:

if (const VkImage scaled = src && view ? framegen_scale(f.cmd, view, src, sw, sh, crop, dev.swap_extent.width, dev.swap_extent.height) : VK_NULL_HANDLE) {
    blit_crop_to_rect(f.cmd, scaled, dev.swap_extent.width, dev.swap_extent.height, nullptr, dst,
                      VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, rect);
}

It does extra upscaling work on wide screens, so it's a workaround, not a fix. Happy to test a build or send logs.

Also relevant to #119 (16:10 laptop, stretched in fullscreen).

@NotRexed

NotRexed commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks, this is a good fix for #119/#297. Before merging: a 32:9 user reported a black picture with upscaling on (see #297). Could you check that case (3840x1080 or 5120x1440 fullscreen with Upscaling Catmull-Rom/Lanczos) and the frame generation path at those sizes? Also, it bumps the renderer API to v2, which #324 also did; that one is closing, so v2 is yours.

@monsterlag
monsterlag marked this pull request as draft November 8, 2026 00:08
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.

lssues encountered during operation on a laptop

3 participants