From 30de9386242b5f7f5c8d9d4d6959783c5cf5aa6a Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 9 Dec 2021 16:55:37 +0000 Subject: [PATCH] backend-drm: Add more view-to-plane failure states Specifically log if there were no suitable planes for us to use, or if we tried to place it on a plane but were told no by the kernel. Signed-off-by: Daniel Stone --- libweston/backend-drm/drm-internal.h | 2 ++ libweston/backend-drm/state-propose.c | 33 ++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index bbc86a17..0331e1de 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -236,6 +236,8 @@ enum try_view_on_plane_failure_reasons { FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE = (1 << 1), FAILURE_REASONS_DMABUF_MODIFIER_INVALID = (1 << 2), FAILURE_REASONS_ADD_FB_FAILED = (1 << 3), + FAILURE_REASONS_NO_PLANES_AVAILABLE = (1 << 4), + FAILURE_REASONS_PLANES_REJECTED = (1 << 5), }; /** diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 6feeade0..b998268c 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -438,20 +438,30 @@ drm_output_find_plane_for_view(struct drm_output_state *state, bool view_matches_entire_output, scanout_has_view_assigned; uint32_t possible_plane_mask = 0; + pnode->try_view_on_plane_failure_reasons = FAILURE_REASONS_NONE; + /* check view for valid buffer, doesn't make sense to even try */ - if (!weston_view_has_valid_buffer(ev)) - return ps; + if (!weston_view_has_valid_buffer(ev)) { + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE; + return NULL; + } buffer = ev->surface->buffer_ref.buffer; shmbuf = wl_shm_buffer_get(buffer->resource); if (shmbuf) { - if (!output->cursor_plane || b->cursors_are_broken) + if (!output->cursor_plane || b->cursors_are_broken) { + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE; return NULL; + } if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888) { drm_debug(b, "\t\t\t\t[view] not placing view %p on " "plane; SHM buffers must be ARGB8888 for " "cursor view", ev); + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE; return NULL; } @@ -460,6 +470,8 @@ drm_output_find_plane_for_view(struct drm_output_state *state, drm_debug(b, "\t\t\t\t[view] not assigning view %p to plane " "(buffer (%dx%d) too large for cursor plane)", ev, buffer->width, buffer->height); + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE; return NULL; } @@ -581,12 +593,22 @@ drm_output_find_plane_for_view(struct drm_output_state *state, ps = drm_output_try_view_on_plane(plane, state, ev, mode, fb, zpos); } + if (ps) { drm_debug(b, "\t\t\t\t[view] view %p has been placed to " "%s plane with computed zpos %"PRIu64"\n", ev, p_name, zpos); break; } + + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_PLANES_REJECTED; + } + + if (!ps && + pnode->try_view_on_plane_failure_reasons == FAILURE_REASONS_NONE) { + pnode->try_view_on_plane_failure_reasons |= + FAILURE_REASONS_NO_PLANES_AVAILABLE; } /* if we have a plane state, it has its own ref to the fb; if not then @@ -784,11 +806,6 @@ drm_output_propose_state(struct weston_output *output_base, ps = drm_output_find_plane_for_view(state, pnode, mode, scanout_state, current_lowest_zpos); - /* If we were able to place the view in a plane, set - * failure reasons to none. */ - if (ps) - pnode->try_view_on_plane_failure_reasons = - FAILURE_REASONS_NONE; } else { /* We are forced to place the view in the renderer, set * the failure reason accordingly. */