output: fix back buffer checks

The back buffer is no longer set at commit time since 0556aa0c59
("output: rejigger attach/clear for back buffer").

Instead, check whether the buffer belongs to the output swapchain.
This is more robust.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3496
This commit is contained in:
Simon Ser 2022-09-21 16:16:53 +02:00
parent 800ea7d52d
commit 8e8b9a7217
4 changed files with 21 additions and 2 deletions

View File

@ -8,6 +8,8 @@ void output_pending_resolution(struct wlr_output *output,
const struct wlr_output_state *state, int *width, int *height);
void output_state_attach_buffer(struct wlr_output_state *state,
struct wlr_buffer *buffer);
bool output_is_direct_scanout(struct wlr_output *output,
struct wlr_buffer *buffer);
struct wlr_drm_format *output_pick_format(struct wlr_output *output,
const struct wlr_drm_format_set *display_formats, uint32_t format);

View File

@ -575,7 +575,7 @@ static bool output_basic_test(struct wlr_output *output,
return false;
}
if (output->back_buffer == NULL) {
if (output_is_direct_scanout(output, state->buffer)) {
if (output->attach_render_locks > 0) {
wlr_log(WLR_DEBUG, "Direct scan-out disabled by lock");
return false;

View File

@ -329,3 +329,18 @@ uint32_t wlr_output_preferred_read_format(struct wlr_output *output) {
return fmt;
}
bool output_is_direct_scanout(struct wlr_output *output,
struct wlr_buffer *buffer) {
if (output->swapchain == NULL) {
return true;
}
for (size_t i = 0; i < WLR_SWAPCHAIN_CAP; i++) {
if (output->swapchain->slots[i].buffer == buffer) {
return false;
}
}
return true;
}

View File

@ -5,6 +5,7 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
#include "types/wlr_output.h"
static void output_handle_destroy(struct wl_listener *listener, void *data) {
struct wlr_output_damage *output_damage =
@ -53,7 +54,8 @@ static void output_handle_precommit(struct wl_listener *listener, void *data) {
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
// TODO: find a better way to access this info without a precommit
// handler
output_damage->pending_attach_render = output->back_buffer != NULL;
output_damage->pending_attach_render =
output_is_direct_scanout(output, state->buffer);
}
}