From cf501a7f348c9a1f7d29beca86acecf6ac056373 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 25 Nov 2022 20:21:21 +0100 Subject: [PATCH] etnaviv: split adding resource to context flush set into own function It is needed in a few more places, so split it into a separate function to make it reusable. Signed-off-by: Lucas Stach Reviewed-by: Philipp Zabel Part-of: --- src/gallium/drivers/etnaviv/etnaviv_context.c | 13 +++++++++++++ src/gallium/drivers/etnaviv/etnaviv_context.h | 4 ++++ src/gallium/drivers/etnaviv/etnaviv_state.c | 10 ++-------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index cabb0c75fe0..3d1b827167a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -52,6 +52,7 @@ #include "util/u_blitter.h" #include "util/u_draw.h" #include "util/u_helpers.h" +#include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_prim.h" #include "util/u_upload_mgr.h" @@ -546,6 +547,18 @@ etna_context_force_flush(struct etna_cmd_stream *stream, void *priv) } +void +etna_context_add_flush_resource(struct etna_context *ctx, + struct pipe_resource *rsc) +{ + bool found; + + _mesa_set_search_or_add(ctx->flush_resources, rsc, &found); + + if (!found) + pipe_reference(NULL, &rsc->reference); +} + static void etna_set_debug_callback(struct pipe_context *pctx, const struct util_debug_callback *cb) diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h index c674e74a1b1..e10f9f35296 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.h +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h @@ -216,4 +216,8 @@ etna_transfer(struct pipe_transfer *p) struct pipe_context * etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags); +void +etna_context_add_flush_resource(struct etna_context *ctx, + struct pipe_resource *rsc); + #endif diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index 550eac6c8f3..0b49afd6c42 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -803,14 +803,8 @@ etna_record_flush_resources(struct etna_context *ctx) if (fb->nr_cbufs > 0) { struct etna_surface *surf = etna_surface(fb->cbufs[0]); - if (!etna_resource(surf->prsc)->explicit_flush) { - bool found; - - _mesa_set_search_or_add(ctx->flush_resources, surf->prsc, &found); - - if (!found) - pipe_reference(NULL, &surf->prsc->reference); - } + if (!etna_resource(surf->prsc)->explicit_flush) + etna_context_add_flush_resource(ctx, surf->prsc); } return true;