From 1c4f1c229011f62b43fde1327fd0bd8762883993 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Mon, 25 Oct 2021 15:58:13 -0500 Subject: [PATCH] panfrost: support PIPE_RESOURCE_PARAM_NPLANES query While panfrost doesn't support multi-planar formats directly, we might still import multi-planar BOs through GBM (for example, when doing direct scanout in weston). We can support PIPE_RESOURCE_PARAM_NPLANES by simply counting the planes we have. Signed-off-by: Derek Foreman Reviewed-by: Daniel Stone Reviewed-by: Simon Ser Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 84120be64a0..b6a6d811387 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -204,6 +204,8 @@ panfrost_resource_get_param(struct pipe_screen *pscreen, unsigned usage, uint64_t *value) { struct panfrost_resource *rsrc = (struct panfrost_resource *) prsc; + struct pipe_resource *cur; + unsigned count; switch (param) { case PIPE_RESOURCE_PARAM_STRIDE: @@ -215,6 +217,16 @@ panfrost_resource_get_param(struct pipe_screen *pscreen, case PIPE_RESOURCE_PARAM_MODIFIER: *value = rsrc->image.layout.modifier; return true; + case PIPE_RESOURCE_PARAM_NPLANES: + /* Panfrost doesn't directly support multi-planar formats, + * but we should still handle this case for gbm users + * that might want to use resources shared with panfrost + * on video processing hardware that does. + */ + for (count = 0, cur = prsc; cur; cur = cur->next) + count++; + *value = count; + return true; default: return false; }