compositor/drm: Move failure reason stringification into compositor

While this is generally drm specific stuff, it's leaked into paint nodes
a little bit already.

Pushing it into the core gives us the ability to print failure reasons
in the scene graph debug text (in a future commit), which can be very
informative.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-08-26 14:15:24 -05:00
parent b4529320ff
commit 6e7b4d63c2
4 changed files with 59 additions and 54 deletions

View file

@ -153,31 +153,6 @@ struct drm_property_info {
uint64_t range_values[2];
};
/**
* Reasons why placing a view on a plane failed. Needed by the dma-buf feedback.
*/
enum try_view_on_plane_failure_reasons {
FAILURE_REASONS_NONE = 0,
FAILURE_REASONS_FORCE_RENDERER = 1 << 0,
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,
FAILURE_REASONS_INADEQUATE_CONTENT_PROTECTION = 1 << 6,
FAILURE_REASONS_INCOMPATIBLE_TRANSFORM = 1 << 7,
FAILURE_REASONS_NO_BUFFER = 1 << 8,
FAILURE_REASONS_BUFFER_TOO_BIG = 1 << 9,
FAILURE_REASONS_BUFFER_TYPE = 1 << 10,
FAILURE_REASONS_GLOBAL_ALPHA = 1 << 11,
FAILURE_REASONS_NO_GBM = 1 << 12,
FAILURE_REASONS_GBM_BO_IMPORT_FAILED = 1 << 13,
FAILURE_REASONS_GBM_BO_GET_HANDLE_FAILED = 1 << 14,
FAILURE_REASONS_NO_COLOR_TRANSFORM = 1 << 15,
FAILURE_REASONS_SOLID_SURFACE = 1 << 16,
FAILURE_REASONS_OCCLUDED_BY_RENDERER = 1 << 17,
};
/**
* We use this to keep track of actions we need to do with the dma-buf feedback
* in order to keep it up-to-date with the info we get from the DRM-backend.

View file

@ -444,33 +444,6 @@ dmabuf_feedback_maybe_update(struct drm_device *device, struct weston_view *ev,
dmabuf_feedback->action_needed = ACTION_NEEDED_NONE;
}
static const char *
failure_reasons_to_str(enum try_view_on_plane_failure_reasons failure_reasons)
{
switch(failure_reasons) {
case FAILURE_REASONS_NONE: return "none";
case FAILURE_REASONS_FORCE_RENDERER: return "force renderer";
case FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE: return "fb format incompatible";
case FAILURE_REASONS_DMABUF_MODIFIER_INVALID: return "dmabuf modifier invalid";
case FAILURE_REASONS_ADD_FB_FAILED: return "add fb failed";
case FAILURE_REASONS_NO_PLANES_AVAILABLE: return "no planes available";
case FAILURE_REASONS_PLANES_REJECTED: return "planes rejected";
case FAILURE_REASONS_INADEQUATE_CONTENT_PROTECTION: return "inadequate content protection";
case FAILURE_REASONS_INCOMPATIBLE_TRANSFORM: return "incompatible transform";
case FAILURE_REASONS_NO_BUFFER: return "no buffer";
case FAILURE_REASONS_BUFFER_TOO_BIG: return "buffer too big";
case FAILURE_REASONS_BUFFER_TYPE: return "buffer type";
case FAILURE_REASONS_GLOBAL_ALPHA: return "global alpha";
case FAILURE_REASONS_NO_GBM: return "no gbm";
case FAILURE_REASONS_GBM_BO_IMPORT_FAILED: return "gbm bo import failed";
case FAILURE_REASONS_GBM_BO_GET_HANDLE_FAILED: return "gbm bo get handle failed";
case FAILURE_REASONS_NO_COLOR_TRANSFORM: return "no color transform";
case FAILURE_REASONS_SOLID_SURFACE: return "solid surface";
case FAILURE_REASONS_OCCLUDED_BY_RENDERER: return "occluded by renderer";
}
return "???";
}
static struct drm_plane_state *
drm_output_find_plane_for_view(struct drm_output_state *state,
struct weston_paint_node *pnode,
@ -578,7 +551,8 @@ drm_output_find_plane_for_view(struct drm_output_state *state,
if (fb) {
possible_plane_mask &= fb->plane_mask;
} else {
char *fr_str = bits_to_str(fb_failure_reasons, failure_reasons_to_str);
char *fr_str = bits_to_str(fb_failure_reasons,
weston_plane_failure_reasons_to_str);
weston_assert_ptr_not_null(b->compositor, fr_str);
drm_debug(b, "\t\t\t[view] couldn't get FB for view: %s\n", fr_str);
free(fr_str);
@ -988,7 +962,7 @@ drm_output_propose_state(struct weston_output *output_base,
goto err_region;
} else if (!ps) {
char *fr_str = bits_to_str(pnode->try_view_on_plane_failure_reasons,
failure_reasons_to_str);
weston_plane_failure_reasons_to_str);
weston_assert_ptr_not_null(b->compositor, fr_str);
drm_debug(b, "\t\t\t\t[view] view %p will be placed "
"on the renderer: %s\n", ev, fr_str);

View file

@ -8888,6 +8888,33 @@ debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
fprintf(fp, "\t\t\tdirect-display buffer (no renderer access)\n");
}
WL_EXPORT const char *
weston_plane_failure_reasons_to_str(enum try_view_on_plane_failure_reasons failure_reasons)
{
switch(failure_reasons) {
case FAILURE_REASONS_NONE: return "none";
case FAILURE_REASONS_FORCE_RENDERER: return "force renderer";
case FAILURE_REASONS_FB_FORMAT_INCOMPATIBLE: return "fb format incompatible";
case FAILURE_REASONS_DMABUF_MODIFIER_INVALID: return "dmabuf modifier invalid";
case FAILURE_REASONS_ADD_FB_FAILED: return "add fb failed";
case FAILURE_REASONS_NO_PLANES_AVAILABLE: return "no planes available";
case FAILURE_REASONS_PLANES_REJECTED: return "planes rejected";
case FAILURE_REASONS_INADEQUATE_CONTENT_PROTECTION: return "inadequate content protection";
case FAILURE_REASONS_INCOMPATIBLE_TRANSFORM: return "incompatible transform";
case FAILURE_REASONS_NO_BUFFER: return "no buffer";
case FAILURE_REASONS_BUFFER_TOO_BIG: return "buffer too big";
case FAILURE_REASONS_BUFFER_TYPE: return "buffer type";
case FAILURE_REASONS_GLOBAL_ALPHA: return "global alpha";
case FAILURE_REASONS_NO_GBM: return "no gbm";
case FAILURE_REASONS_GBM_BO_IMPORT_FAILED: return "gbm bo import failed";
case FAILURE_REASONS_GBM_BO_GET_HANDLE_FAILED: return "gbm bo get handle failed";
case FAILURE_REASONS_NO_COLOR_TRANSFORM: return "no color transform";
case FAILURE_REASONS_SOLID_SURFACE: return "solid surface";
case FAILURE_REASONS_OCCLUDED_BY_RENDERER: return "occluded by renderer";
}
return "???";
}
static void
debug_scene_view_print(FILE *fp, struct weston_view *view, int view_idx)
{

View file

@ -651,6 +651,32 @@ enum paint_node_status {
PAINT_NODE_ALL_DIRTY = (1 << 5) - 1,
};
/**
* Reasons why placing a view on a plane failed. Needed by the dma-buf feedback.
*/
enum try_view_on_plane_failure_reasons {
FAILURE_REASONS_NONE = 0,
FAILURE_REASONS_FORCE_RENDERER = 1 << 0,
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,
FAILURE_REASONS_INADEQUATE_CONTENT_PROTECTION = 1 << 6,
FAILURE_REASONS_INCOMPATIBLE_TRANSFORM = 1 << 7,
FAILURE_REASONS_NO_BUFFER = 1 << 8,
FAILURE_REASONS_BUFFER_TOO_BIG = 1 << 9,
FAILURE_REASONS_BUFFER_TYPE = 1 << 10,
FAILURE_REASONS_GLOBAL_ALPHA = 1 << 11,
FAILURE_REASONS_NO_GBM = 1 << 12,
FAILURE_REASONS_GBM_BO_IMPORT_FAILED = 1 << 13,
FAILURE_REASONS_GBM_BO_GET_HANDLE_FAILED = 1 << 14,
FAILURE_REASONS_NO_COLOR_TRANSFORM = 1 << 15,
FAILURE_REASONS_SOLID_SURFACE = 1 << 16,
FAILURE_REASONS_OCCLUDED_BY_RENDERER = 1 << 17,
};
/**
* paint node
*
@ -768,4 +794,7 @@ weston_surface_state_init(struct weston_surface *surface,
void
weston_surface_state_fini(struct weston_surface_state *state);
const char *
weston_plane_failure_reasons_to_str(enum try_view_on_plane_failure_reasons failure_reasons);
#endif