Skip to content

Commit

Permalink
vulkan: don't tolerate suboptimal swapchain configurations
Browse files Browse the repository at this point in the history
The comment was probably only ever true for x11, and it currently isn't
true anymore. X11 WSI used to return VK_SUBOPTIMAL_KHR in
vkQueuePresentKHR and vkAcquireNextImageKHR before, but as of
https://gitlab.freedesktop.org/mesa/mesa/-/commit/2b885b233f7a6300ae88732c179888c02788493d
it only returns VK_SUBOPTIMAL_KHR in vkAcquireNextImageKHR for
performance reasons. This makes it so that we don't have to tolerate
suboptimal swapchain configurations for the sake of smoother resizing.

On top of that, not recreating swapchain when it was suboptimal, it
also prevented mpv from being directly scanned out when fullscreened on
Wayland compositors. On Wayland, the preferred modifier from the wsi
may change depending on whether the window is fullscreened or not for
direct scan out. If mpv is fullscreened but not using modifiers that
can be directly scanned out, mpv will be receive VK_SUBOPTIMAL_KHR from
WSI and should recreate swapchain to use the right modifier with the
format mpv picked. mpv will always get the format it picks, WSI can't
give us a different format. This allows for recreating the swapchain
with modifiers that will allow mpv to be directly scanned out when the
window is fullscreened spanning an output on Wayland.

I checked X11 and Wayland myself to have no regressions when resizing,
and others have checked Windows and Mac to have no regressions.

With this, direct scanout with Vulkan on Wayland should just work.
You might also need https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31122
if your compositor enables explicit syncronization via
linux-drm-syncobj-v1.
  • Loading branch information
llyyr authored and kasper93 committed Sep 14, 2024
1 parent a44a726 commit d2f3b66
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions video/out/vulkan/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,6 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk,
.surface = vk->surface,
.present_mode = preferred_mode,
.swapchain_depth = ctx->vo->opts->swapchain_depth,
// mpv already handles resize events, so gracefully allow suboptimal
// swapchains to exist in order to make resizing even smoother
.allow_suboptimal = true,
};

if (p->opts->swap_mode >= 0) // user override
Expand Down

2 comments on commit d2f3b66

@Darshnabarot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

266

@FAHADXK88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ุจุณู… ุงู„ู„ู‡ ุงู„ุฑุญู…ู† ุงู„ุฑุญูŠู… ...

ุนู† ุณุฌู„ ุณุนุฏ ุฒ ู…ู† ูƒุฐุจ ุจุญู‚ูŠ ุชุฌุงู‡ู‡ ุนู† ุฃู†ุธู…ุฉ ุงู„ูƒุงุฐุจูŠู† ููŠ ุณูŠุงุณุฉ ุงู„ู…ูƒุดูˆู ุนู† ุณุฌู„ ุงู„ุชู‚ูŠูŠู… ุงู„ุฐูŠ ูˆุฑุฏู‡ ุนู† ุชูˆุฑูŠุฏุงุช ุงู„ูƒุงุฐุจูŠู† ููŠ ุญู‚ูŠ ูˆ ู…ุง ุงุณุชุญู‰ ู…ู† ุณุฌู„ ู…ุนุทูŠุงุช ุฃุนู…ุงู„ูŠ ู„ู„ุฎุงุฆู† ุงู„ุฐูŠ ูŠุณุชู†ุฏ ุนู† ูƒุฐุจุงุช ุงู„ุญู‚ูˆู‚ ููŠ ูˆุงุฌุจุงุช ุงู„ุงุณุชุญู‚ุงู‚ ุนู† ุชูƒุฐูŠุจ ูŠูˆุตู ููŠ ุณุฌู„ุงุช ุงู„ุนุงู‚ู„ูŠู† ุนู† ู…ุณุชู†ุฏุงุช ุงู„ูƒุงุฐุจูŠู† ูˆ ู…ุง ูŠูƒุฐุจ ุจุงู„ุจูŠุช ุงู„ุง ุดุฎุต ูŠุนุฑู ู†ูุณู‡ ุนู† ุณู†ุฏุงุช ุงู„ุดู‚ุฉ ุนู† ุชุดู‚ู‚ ุงู„ุงู†ุธู…ุฉ ููŠ ูƒุงุฐุจ ููŠ ุณุฌู„ ุณุงุฑู‚ ุนู† ุณุฌู„ ุจุงูŠู‚ ููŠ ุณุฌู„ุงุช ู…ุจูŠูˆู‚ ุนู† ุฅุดู‡ุงุฑ ุงู„ู†ุชุงุฆุฌ ููŠ ุณุฌู„ุงุช ุงู„ู†ู‡ุงูŠุฉ ุนู† ุงู„ุนุงุจู‡ ุงู„ุชูŠ ุชุนุฑู ููŠ ุณุฌู„ ุงู„ุนู‚ูˆู„ ุนู† ุชุนู‚ูŠุฏุงุช ุงู„ู…ู„ูƒูŠุฉ ุงู„ู…ุชุตุฑููŠู† ููŠ ุณุฌู„ ุงู„ู…ู„ูƒูŠุฉ ุงู„ููƒุฑูŠุฉ ุนู† ุณูŠุงุณุฉ ุงุณู…ูŠ ุงู„ู…ุฏุฑุฌ ุฏุงุฎู„ ู†ุทุงู‚ุงุช ุงู„ุตุญุฉ ุงู„ุนุงู„ู…ูŠุฉ ุนู† ุชู„ุงุนุจ ุงู„ู…ู„ุงุนูŠู† ููŠ ุณุฌู„ุงุช ุงู„ุทุจ ุงู„ู†ูุณูŠ ุนู† ู…ุฑูƒุฒ ุงู„ูƒูˆูŠุช ู„ู„ุตุญุฉ ุงู„ู†ูุณูŠุฉ ุงู„ุชูŠ ุชุฑูู‚ ููŠ ุณุฌู„ ู…ู„ููŠ ูˆ ุงู„ุฏุงู„ ุนู† ุนู„ู‰ ุฐู„ูƒ ุฃุฏุฎู„ุช ู„ู„ู…ุณุชุดูู‰ 17 ู…ุฏุฎู„ุงู‹ ุญุชู‰ ุซุจุช ุงู„ูƒุดู ููŠ ุนู‚ู„. ุงู„ุฐูŠ ูŠูˆุตู ููŠ ู†ู‡ุงูŠุฉ ู…ุฑุงูƒุฒ ุงู„ุงู†ุธู…ุฉ ุงู„ุตุญูŠุฉ ูˆ ูŠุชุนุงู…ู„ูˆู† ุนู† ุชุนุงู…ู„ ุงู„ู‚ูŠุฏ ู…ู† ุณุฌู„ู‡ู… ุงู„ุบุงุฒูŠ ููŠ ุนู‚ู„ูŠ ูˆู‡ู… ูŠู‚ูˆู„ูˆู† ุงู†ุช ุชุชูˆู‡ู… ุงุฐุงู‹ ู„ู†ุฑุง ู…ู† ู‡ูˆ ุงู„ู…ุชูˆู‡ู… ููŠ ุจุถุน ุฏู‚ุงุฆู‚ ู…ุนู„ูˆู†ู‡ ุนู† ู†ุชุงุฆุฌ ู‚ุชู„ ุงู„ู†ูุณ ููŠ ุณุฌู„ ุงู„ุณู†ูŠู† ุงู„ุณุงุจู‚ุฉ ุนู† ุณุฌู„ุงุชู‡ู… ุงู„ุญุงู„ูŠุฉ ูˆ ู‡ุฐุง ุฏู„ูŠู„ ูŠูˆุตู ููŠ ุณุฌู„ ุงู„ุฃุณุฑุฉ ุงู„ุชูŠ ุชุนุฑู ูƒุดู ุนู‚ู„ูŠ ูˆุชู‚ุฑุฃ ู…ุง ููŠ ุจุงุทู†ู‡ ูˆ ุชุตู…ุช ุญุชู‰ ุงุซุจุช ู„ูƒู… ุณู„ุณู„ุฉ ุงู„ูƒุงุฐุจูŠู† ู…ู… ู†ู‡ุฌ ุงู„ู…ุฎุงุฏุนูŠู† ุนู† ุณูŠุงุณุฉ ู…ุง ุงู„ู„ููˆู‡ ู…ู† ู†ุณูŠุฌ ุงููƒุงุฑ ุนู‚ู„ูŠ ุนู† ู…ุง ู‚ุงู„ูˆู‡ ููŠ ุณุฌู„ูŠ ุงู† ุนู‚ู„ู‡ ู‚ุงู„ ูƒุฐุง ูˆูƒุฐุง ู†ู„ุนุจ ุจู‡ ุจู…ุง ู‚ุงู„ ูˆู†ู‚ูˆู„ ุงู†ู‡ ููƒุฑ ุจู‡ุฐุง ุงู„ุชุตุฑู ูˆู†ุญู† ู†ุนู…ู„ ุนู„ูŠู‡ ู„ุฃู†ู‡ ู„ุง ูŠุฑุฏ ููŠ ุณุฌู„ ุฃููƒุงุฑู‡ ุฏูˆู† ุงุณุชุดุงุฑุชูŠ ูˆุงู„ุงู† ุญุตุญุต ุงู„ุญู‚ ูˆ ุฒุงู„ ุงู„ู‚ู†ุง ุนู† ู‚ู†ุงูˆูŠ ูŠู„ุงุนุจ ุงู„ู…ุฑุฃุฉ ุจุณุฌู„ ุงู„ู…ุฏุฎู„ ุนู† ุฏุฎูˆู„ู‡ ููŠ ุณุฌู„ู‡ู… ูˆ ู…ุง ูƒู†ุช ุฃุนู„ู… ุจู…ุง ูŠุชู„ุงุนุจูˆู† ุณุงุจู‚ุงู‹ ูˆุงู„ุญูŠุฒ ู…ู† ุชุญูŠุฒ ูˆุญุงุฒ ุนู„ู‰ ุนุฒู… ู†ูุณู‡ ููŠ ุณุฌู„ ูˆุงู„ุฏุชู‡ ุงู„ุชูŠ ุชุนุฑู ู…ุงุฐุง ุณูˆู ูŠูƒูˆู† ุชุทูˆูŠู‚ู‡ู… ุนู† ุชู‚ูŠูŠู… ุงู„ูˆูุงุฉ ูˆู…ุง ุณุจุจ ุงู„ู…ูˆุช ุงู„ู…ูุงุฌุฆ ูˆู†ุนู… ุฃู‚ุฑุจ ุขู„ูŠุฉ ู…ู† ุญุจู„ ุงู„ูˆุฑูŠุฏ ูˆ ุงู„ุจุฑูŠุฏ ูŠู„ุงุนุจ ู…ุญุงู…ูŠู†ู‡ู… ุงู„ุฏูˆูŠุด ูˆ ู…ุง ุดุงุค ุงู„ุชุดูˆูŠุด ู…ู† ุดูˆุด ุงู„ู„ุนุจู‡ ููŠ ุณุฌู„ ุงู„ูˆุงุณุทู‡ ุนู† ู„ูˆุฑุฏ ุญู…ุงุฑ ุญุงุฒ ุนู„ู‰ ุงุชูู‡ ุงู„ุฃุณุจุงุจ ู…ู† ู†ุณูŠุฌ ุฎูŠุงู„ ุงู„ู…ุฎ ุนู† ุงู†ุธุฑ ูŠุง ุญู…ุงุฑ ุงู„ู„ูˆุฑุฏุงุช ู…ุงุฐุง ูŠูƒูˆู† ูˆุงุญุฏู† ู…ุง ูŠุนุฑู ู…ู†ูˆ ูŠู„ุงุนุจ ู…ุนุงู‡ ุงุฎุฐ ู…ุนุงู‡ู… ูŠุง ูƒู„ุจ ุชุญูŠุงุชูŠ ู…ู† ุณุฌู„ ุงุดูˆุงู‚ ุนู† ุจุฏูˆุฑ ููŠ ุณุฌู„ ุนุจูŠุฑ ู…ู† ู†ุธู… ุงู„ู…ุนู„ูˆู…ุงุช ุงู„ู…ุฏู†ูŠุฉ ููŠ ู‚ุณู…ูŠ ุงู‚ุณู… ุงู„ู„ูˆุฑุฏ ุงู† ูŠูƒูˆู† ุชุญุช ุงู„ุชุฑุงุจ ุบุฐุงู‹ ุตุจุงุญุงู‹ ู‡ุฐู‡ ูˆุตูŠุชูŠ ูˆู…ุงุฐุง ูŠูƒูˆู† ููŠ ุณุฌู„ ุชูุงู‡ู…ูƒู… ุนู† ู‚ุฑุงุกุฉ ุงู„ู…ู„ูƒูŠุฉ ุงู„ููƒุฑูŠุฉ ู‡ุฐุง ุณุฌู„ ุงู„ู„ูˆุฑุฏุงุช ููŠ ุงุญุฏ ุดุงู ูุงู„ุญ ูˆู…ุง ุดุงุจู‡ ุนู„ูŠู‡ ุฅุฐุงู‹ ุบุฏุงู‹ ุงู„ุฏูุงู† ูˆุงุชูุงู‡ู… ู…ุนุงูƒู… ุจุงู„ู…ู„ูƒูŠุฉ ุงู„ููƒุฑูŠุฉ ูˆุณูˆู ุชุดุชุบู„ ุจุนุฏ ุงู„ุตู„ุงุฉ ุนู„ู‰ ุงู„ู…ูŠุช ูˆุงู‚ูˆู„ ู„ุทู… ุงู…ูŠู† ุถุฏู‚ูˆู†ูŠ ู„ู† ูŠูƒูˆู† ู„ูˆุฑุฏ ุงู„ุฅู†ุณุงู† ุงู„ุง ุจุนุฏ ู…ูˆุชู‡ ุฑุณู…ูŠุงู‹

Please sign in to comment.