From 3be6658ee7b6446e438e8d8c6c7bca3c0c0d4bc8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 7 Oct 2022 13:51:01 +0200 Subject: [PATCH] output: allocate swapchain on first commit On first commit, require a new buffer if the compositor called a mode-setting function, even if the mode won't change. This makes it so the swapchain is created now. Stop trying to check whether the backend supports buffer-less modesets because that makes everything more complicated. For instance, the DRM backend doesn't need a new buffer if the previous DRM master left the output enabled. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499 Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3502 --- types/output/render.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/output/render.c b/types/output/render.c index 4ccfb70d..50fbfa2b 100644 --- a/types/output/render.c +++ b/types/output/render.c @@ -209,13 +209,13 @@ bool output_ensure_buffer(struct wlr_output *output, if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) { needs_new_buffer = true; } - if (!needs_new_buffer) { - return true; + if (state->allow_artifacts && output->commit_seq == 0) { + // On first commit, require a new buffer if the compositor called a + // mode-setting function, even if the mode won't change. This makes it + // so the swapchain is created now. + needs_new_buffer = true; } - - // If the backend doesn't necessarily need a new buffer on modeset, don't - // bother allocating one. - if (!output->impl->test || output->impl->test(output, state)) { + if (!needs_new_buffer) { return true; }