diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 26ca139ec6b..c612db03a92 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -70,6 +70,11 @@ panfrost_clear_depth_stencil(struct pipe_context *pipe, if (render_condition_enabled && !panfrost_render_condition_check(ctx)) return; + /* Legalize here because it could trigger a recursive blit otherwise */ + struct panfrost_resource *rdst = pan_resource(dst->texture); + enum pipe_format dst_view_format = util_format_linear(dst->format); + pan_legalize_format(ctx, rdst, dst_view_format, true, false); + panfrost_blitter_save( ctx, render_condition_enabled ? PAN_RENDER_COND : PAN_RENDER_BASE); util_blitter_clear_depth_stencil(ctx->blitter, dst, clear_flags, depth, @@ -88,6 +93,11 @@ panfrost_clear_render_target(struct pipe_context *pipe, if (render_condition_enabled && !panfrost_render_condition_check(ctx)) return; + /* Legalize here because it could trigger a recursive blit otherwise */ + struct panfrost_resource *rdst = pan_resource(dst->texture); + enum pipe_format dst_view_format = util_format_linear(dst->format); + pan_legalize_format(ctx, rdst, dst_view_format, true, false); + panfrost_blitter_save( ctx, (render_condition_enabled ? PAN_RENDER_COND : PAN_RENDER_BASE) | PAN_SAVE_FRAGMENT_CONSTANT); util_blitter_clear_render_target(ctx->blitter, dst, color, dstx, dsty, width, diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index f6e5f54e6cd..82973a945f3 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -137,6 +137,9 @@ enum { PAN_RENDER_CLEAR = PAN_SAVE_FRAGMENT_STATE | PAN_SAVE_FRAGMENT_CONSTANT, }; +/* 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);