From b538519bbcfdfadab443c045a09a130e07e17602 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Fri, 10 Jun 2022 22:51:07 +1200 Subject: [PATCH] panfrost: Use a macro for checking for a shared bind type PAN_BIND_SHARED_MASK is all binding flags that mean that a resource might be shared and accessible by other contexts. Don't replace the usage of this pattern in panfrost_should_afbc and panfrost_should_tile in case a new binding is introduced that not all layouts can support. Part-of: --- src/gallium/drivers/panfrost/pan_job.c | 4 +--- src/gallium/drivers/panfrost/pan_resource.c | 5 ++--- src/gallium/drivers/panfrost/pan_resource.h | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index ba07c6cfc65..3ba8948387a 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -762,9 +762,7 @@ panfrost_batch_submit(struct panfrost_context *ctx, /* Shared depth/stencil resources are not supported, and would * break this optimisation. */ - assert(!(z_rsrc->base.bind & (PIPE_BIND_SHARED | - PIPE_BIND_SCANOUT | - PIPE_BIND_DISPLAY_TARGET))); + assert(!(z_rsrc->base.bind & PAN_BIND_SHARED_MASK)); if (batch->clear & PIPE_CLEAR_STENCIL) { z_rsrc->stencil_value = batch->clear_stencil; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index fcf5114eb11..65d8be8127b 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -619,8 +619,7 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen, util_range_init(&so->valid_buffer_range); - if (template->bind & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { + if (template->bind & PAN_BIND_SHARED_MASK) { /* For compatibility with older consumers that may not be * modifiers aware, treat INVALID as LINEAR for shared * resources. @@ -814,7 +813,7 @@ pan_alloc_staging(struct panfrost_context *ctx, struct panfrost_resource *rsc, } tmpl.last_level = 0; tmpl.bind |= PIPE_BIND_LINEAR; - tmpl.bind &= ~(PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); + tmpl.bind &= ~PAN_BIND_SHARED_MASK; struct pipe_resource *pstaging = pctx->screen->resource_create(pctx->screen, &tmpl); diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index 06ced7bd5af..beeb233fccc 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -35,6 +35,9 @@ #define LAYOUT_CONVERT_THRESHOLD 8 #define PAN_MAX_BATCHES 32 +#define PAN_BIND_SHARED_MASK (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | \ + PIPE_BIND_SHARED) + struct panfrost_resource { struct pipe_resource base; struct {