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 <derek.foreman@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13039>
This commit is contained in:
Derek Foreman 2021-10-25 15:58:13 -05:00 committed by Marge Bot
parent f96ad5d71c
commit 1c4f1c2290
1 changed files with 12 additions and 0 deletions

View File

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