From 4215d503848864fca2e07927cde010ca76317237 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 18 Jul 2024 11:04:15 +0200 Subject: [PATCH] v3d: add new clear blitter op A specific clear_surface blitter operation is required, because in this case we need to save framebuffer information, but not in standard clear, as we are currently doing. This fixes a leak in depthstencil surface, which happens because we were storing saving it as part for the framebuffer information, but the blitter clear wasn't restoring it because it wasn't required (only it is required in clearing a surface). Reviewed-by: Iago Toral Quiroga Signed-off-by: Juan A. Suarez Romero Part-of: --- src/gallium/drivers/v3d/v3d_blit.c | 4 +++- src/gallium/drivers/v3d/v3d_context.h | 7 +++++-- src/gallium/drivers/v3d/v3dx_draw.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index b72878464df..cc7d589958e 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -57,7 +57,9 @@ v3d_blitter_save(struct v3d_context *v3d, enum v3d_blitter_op op) util_blitter_save_sample_mask(v3d->blitter, v3d->sample_mask, 0); util_blitter_save_so_targets(v3d->blitter, v3d->streamout.num_targets, v3d->streamout.targets); - util_blitter_save_framebuffer(v3d->blitter, &v3d->framebuffer); + + if (op & V3D_SAVE_FRAMEBUFFER) + util_blitter_save_framebuffer(v3d->blitter, &v3d->framebuffer); if (op & V3D_SAVE_TEXTURES) { util_blitter_save_scissor(v3d->blitter, &v3d->scissor); diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 93446b305d0..16f782f1a75 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -154,12 +154,15 @@ enum v3d_flush_cond { /* bitmask */ enum v3d_blitter_op { V3D_SAVE_TEXTURES = (1u << 1), - V3D_DISABLE_RENDER_COND = (1u << 2), + V3D_SAVE_FRAMEBUFFER = (1u << 2), + V3D_DISABLE_RENDER_COND = (1u << 3), - V3D_BLIT = V3D_SAVE_TEXTURES, + V3D_BLIT = V3D_SAVE_FRAMEBUFFER | V3D_SAVE_TEXTURES, V3D_BLIT_COND = V3D_BLIT | V3D_DISABLE_RENDER_COND, V3D_CLEAR = 0, V3D_CLEAR_COND = V3D_CLEAR | V3D_DISABLE_RENDER_COND, + V3D_CLEAR_SURFACE = V3D_SAVE_FRAMEBUFFER, + V3D_CLEAR_SURFACE_COND = V3D_CLEAR_SURFACE | V3D_DISABLE_RENDER_COND }; struct v3d_sampler_view { diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index d31e3ac22a1..0dfeac0bf6b 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -1793,7 +1793,7 @@ v3d_clear_render_target(struct pipe_context *pctx, struct pipe_surface *ps, return; v3d_blitter_save(v3d, render_condition_enabled ? - V3D_CLEAR_COND : V3D_CLEAR); + V3D_CLEAR_SURFACE_COND : V3D_CLEAR_SURFACE); util_blitter_clear_render_target(v3d->blitter, ps, color, x, y, w, h); } @@ -1809,7 +1809,7 @@ v3d_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps, return; v3d_blitter_save(v3d, render_condition_enabled ? - V3D_CLEAR_COND : V3D_CLEAR); + V3D_CLEAR_SURFACE_COND : V3D_CLEAR_SURFACE); util_blitter_clear_depth_stencil(v3d->blitter, ps, buffers, depth, stencil, x, y, w, h); }