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

@ -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;
}