From e30d95309f45b892a724c31b3369fe1deb994708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Wed, 25 Mar 2026 16:19:14 +0100 Subject: [PATCH] panfrost: Move blit funcs to pan_blitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a dedicated header and prefix blit funcs accordingly. Signed-off-by: Loïc Molinari Reviewed-by: Ashley Smith Acked-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/meson.build | 2 +- .../panfrost/{pan_blit.c => pan_blitter.c} | 10 +++-- src/gallium/drivers/panfrost/pan_blitter.h | 45 +++++++++++++++++++ src/gallium/drivers/panfrost/pan_context.c | 1 + src/gallium/drivers/panfrost/pan_resource.c | 11 ++--- src/gallium/drivers/panfrost/pan_resource.h | 36 --------------- 6 files changed, 59 insertions(+), 46 deletions(-) rename src/gallium/drivers/panfrost/{pan_blit.c => pan_blitter.c} (94%) create mode 100644 src/gallium/drivers/panfrost/pan_blitter.h diff --git a/src/gallium/drivers/panfrost/meson.build b/src/gallium/drivers/panfrost/meson.build index 5b3e5e41d97..68aa5b3c845 100644 --- a/src/gallium/drivers/panfrost/meson.build +++ b/src/gallium/drivers/panfrost/meson.build @@ -17,7 +17,7 @@ files_panfrost = files( 'pan_resource.h', 'pan_context.c', 'pan_blend_cso.c', - 'pan_blit.c', + 'pan_blitter.c', 'pan_job.c', 'pan_shader.c', 'pan_mempool.c', diff --git a/src/gallium/drivers/panfrost/pan_blit.c b/src/gallium/drivers/panfrost/pan_blitter.c similarity index 94% rename from src/gallium/drivers/panfrost/pan_blit.c rename to src/gallium/drivers/panfrost/pan_blitter.c index f49504be582..e03ad8fadfd 100644 --- a/src/gallium/drivers/panfrost/pan_blit.c +++ b/src/gallium/drivers/panfrost/pan_blitter.c @@ -5,6 +5,7 @@ */ #include "util/format/u_format.h" +#include "pan_blitter.h" #include "pan_context.h" #include "pan_resource.h" #include "pan_trace.h" @@ -131,8 +132,8 @@ panfrost_blitter_save(struct panfrost_context *ctx, } void -panfrost_blit_no_afbc_legalization(struct pipe_context *pipe, - const struct pipe_blit_info *info) +panfrost_blitter_blit_no_afbc_legalization(struct pipe_context *pipe, + const struct pipe_blit_info *info) { PAN_TRACE_FUNC(PAN_TRACE_GL_BLIT); @@ -145,7 +146,8 @@ panfrost_blit_no_afbc_legalization(struct pipe_context *pipe, } void -panfrost_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) +panfrost_blitter_blit(struct pipe_context *pipe, + const struct pipe_blit_info *info) { PAN_TRACE_FUNC(PAN_TRACE_GL_BLIT); @@ -167,6 +169,6 @@ panfrost_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) pan_legalize_format(ctx, dst, dst_view_format, true, false); panfrost_flush_all_batches(ctx, "Blit"); - panfrost_blit_no_afbc_legalization(pipe, info); + panfrost_blitter_blit_no_afbc_legalization(pipe, info); panfrost_flush_all_batches(ctx, "Blit"); } diff --git a/src/gallium/drivers/panfrost/pan_blitter.h b/src/gallium/drivers/panfrost/pan_blitter.h new file mode 100644 index 00000000000..64f381cbe21 --- /dev/null +++ b/src/gallium/drivers/panfrost/pan_blitter.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2026 Amazon.com, Inc. or its affiliates + * SPDX-License-Identifier: MIT + */ + +#ifndef __PAN_BLITTER_H__ +#define __PAN_BLITTER_H__ + +#include "pan_context.h" + +enum panfrost_blitter_op /* bitmask */ +{ + PAN_SAVE_TEXTURES = 1, + PAN_SAVE_FRAMEBUFFER = 2, + PAN_SAVE_FRAGMENT_STATE = 4, + PAN_SAVE_FRAGMENT_CONSTANT = 8, + PAN_DISABLE_RENDER_COND = 16, +}; + +enum { + PAN_RENDER_BLIT = + PAN_SAVE_TEXTURES | PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE, + PAN_RENDER_BLIT_COND = PAN_SAVE_TEXTURES | PAN_SAVE_FRAMEBUFFER | + PAN_SAVE_FRAGMENT_STATE | PAN_DISABLE_RENDER_COND, + PAN_RENDER_BASE = PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE, + PAN_RENDER_COND = + PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE | PAN_DISABLE_RENDER_COND, + PAN_RENDER_CLEAR = PAN_SAVE_FRAGMENT_STATE | PAN_SAVE_FRAGMENT_CONSTANT, +}; + +struct blitter_context *panfrost_blitter_create(struct pipe_context *pipe); + +void panfrost_blitter_save(struct panfrost_context *ctx, + const enum panfrost_blitter_op blitter_op); + +/* Callers should ensure that all AFBC/AFRC resources that will be used in the + * blit operation are legalized before calling blitter operations, otherwise + * we may trigger a recursive blit */ +void panfrost_blitter_blit_no_afbc_legalization(struct pipe_context *pipe, + const struct pipe_blit_info *info); + +void panfrost_blitter_blit(struct pipe_context *pipe, + const struct pipe_blit_info *info); + +#endif diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 94303193d55..2def7f7fca6 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -32,6 +32,7 @@ #include "compiler/pan_compiler.h" #include "compiler/nir/nir_serialize.h" #include "decode.h" +#include "pan_blitter.h" #include "pan_device.h" #include "pan_fence.h" #include "pan_screen.h" diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 5ac43cdeeae..212fc84ba94 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -27,6 +27,7 @@ #include "decode.h" #include "pan_afbc.h" #include "pan_afrc.h" +#include "pan_blitter.h" #include "pan_bo.h" #include "pan_context.h" #include "pan_resource.h" @@ -1355,7 +1356,7 @@ pan_blit_from_staging(struct pipe_context *pctx, blit.mask = util_format_get_mask(blit.src.format); blit.filter = PIPE_TEX_FILTER_NEAREST; - panfrost_blit_no_afbc_legalization(pctx, &blit); + panfrost_blitter_blit_no_afbc_legalization(pctx, &blit); } static void @@ -1375,7 +1376,7 @@ pan_blit_to_staging(struct pipe_context *pctx, struct panfrost_transfer *trans) blit.mask = util_format_get_mask(blit.dst.format); blit.filter = PIPE_TEX_FILTER_NEAREST; - panfrost_blit_no_afbc_legalization(pctx, &blit); + panfrost_blitter_blit_no_afbc_legalization(pctx, &blit); } static void @@ -1473,7 +1474,7 @@ pan_dump_resource(struct panfrost_context *ctx, struct panfrost_resource *rsc) blit.mask = util_format_get_mask(blit.dst.format); blit.filter = PIPE_TEX_FILTER_NEAREST; - panfrost_blit(pctx, &blit); + panfrost_blitter_blit(pctx, &blit); linear = pan_resource(plinear); } @@ -1863,7 +1864,7 @@ pan_resource_modifier_convert(struct panfrost_context *ctx, if (drm_is_mtk_tiled(rsrc->modifier)) screen->vtbl.mtk_detile(ctx, &blit); else - panfrost_blit_no_afbc_legalization(&ctx->base, &blit); + panfrost_blitter_blit_no_afbc_legalization(&ctx->base, &blit); } } @@ -2578,7 +2579,7 @@ panfrost_resource_context_init(struct pipe_context *pctx) pctx->texture_map = u_transfer_helper_transfer_map; pctx->texture_unmap = u_transfer_helper_transfer_unmap; pctx->resource_copy_region = util_resource_copy_region; - pctx->blit = panfrost_blit; + pctx->blit = panfrost_blitter_blit; pctx->generate_mipmap = panfrost_generate_mipmap; pctx->flush_resource = panfrost_flush_resource; pctx->invalidate_resource = panfrost_invalidate_resource; diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index 95bf4075c24..392463d105b 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -145,39 +145,6 @@ void panfrost_resource_screen_destroy(struct pipe_screen *screen); void panfrost_resource_context_init(struct pipe_context *pctx); -/* Blitting */ - -enum panfrost_blitter_op /* bitmask */ -{ - PAN_SAVE_TEXTURES = 1, - PAN_SAVE_FRAMEBUFFER = 2, - PAN_SAVE_FRAGMENT_STATE = 4, - PAN_SAVE_FRAGMENT_CONSTANT = 8, - PAN_DISABLE_RENDER_COND = 16, -}; - -enum { - PAN_RENDER_BLIT = - PAN_SAVE_TEXTURES | PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE, - PAN_RENDER_BLIT_COND = PAN_SAVE_TEXTURES | PAN_SAVE_FRAMEBUFFER | - PAN_SAVE_FRAGMENT_STATE | PAN_DISABLE_RENDER_COND, - PAN_RENDER_BASE = PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE, - PAN_RENDER_COND = - PAN_SAVE_FRAMEBUFFER | PAN_SAVE_FRAGMENT_STATE | PAN_DISABLE_RENDER_COND, - PAN_RENDER_CLEAR = PAN_SAVE_FRAGMENT_STATE | PAN_SAVE_FRAGMENT_CONSTANT, -}; - -struct blitter_context *panfrost_blitter_create(struct pipe_context *pipe); - -/* Callers should ensure that all AFBC/AFRC resources that will be used in the - * blit operation are legalized before calling blitter operations, otherwise - * we may trigger a recursive blit */ -void panfrost_blitter_save(struct panfrost_context *ctx, - const enum panfrost_blitter_op blitter_op); - -void panfrost_blit(struct pipe_context *pipe, - const struct pipe_blit_info *info); - void panfrost_resource_set_damage_region(struct pipe_screen *screen, struct pipe_resource *res, unsigned int nrects, @@ -251,7 +218,4 @@ void pan_legalize_format(struct panfrost_context *ctx, void pan_dump_resource(struct panfrost_context *ctx, struct panfrost_resource *rsc); -void panfrost_blit_no_afbc_legalization(struct pipe_context *pipe, - const struct pipe_blit_info *info); - #endif /* PAN_RESOURCE_H */