From 13946b8a6a2ead49b9617056cfdcc04ebd593d16 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 29 Oct 2022 12:17:07 -0700 Subject: [PATCH] freedreno/a6xx: Use box to pass 2d clear params Simplifies the interface slightly and makes it possible to re-use the path for pctx->clear_texture() in the next commit. The z dimensions still come from the surface. Signed-off-by: Rob Clark Part-of: --- src/gallium/drivers/freedreno/a6xx/fd6_blitter.c | 9 +++++---- src/gallium/drivers/freedreno/a6xx/fd6_blitter.h | 3 +-- src/gallium/drivers/freedreno/a6xx/fd6_gmem.c | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index bc9c75849bc..a113d90f160 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -784,7 +784,7 @@ convert_color(enum pipe_format format, union pipe_color_union *pcolor) void fd6_clear_surface(struct fd_context *ctx, struct fd_ringbuffer *ring, - struct pipe_surface *psurf, uint32_t width, uint32_t height, + struct pipe_surface *psurf, const struct pipe_box *box2d, union pipe_color_union *color, uint32_t unknown_8c01) { if (DEBUG_BLIT) { @@ -795,9 +795,10 @@ fd6_clear_surface(struct fd_context *ctx, struct fd_ringbuffer *ring, uint32_t nr_samples = fd_resource_nr_samples(psurf->texture); OUT_PKT4(ring, REG_A6XX_GRAS_2D_DST_TL, 2); - OUT_RING(ring, A6XX_GRAS_2D_DST_TL_X(0) | A6XX_GRAS_2D_DST_TL_Y(0)); - OUT_RING(ring, A6XX_GRAS_2D_DST_BR_X(width * nr_samples - 1) | - A6XX_GRAS_2D_DST_BR_Y(height - 1)); + OUT_RING(ring, A6XX_GRAS_2D_DST_TL_X(box2d->x * nr_samples) | + A6XX_GRAS_2D_DST_TL_Y(box2d->y)); + OUT_RING(ring, A6XX_GRAS_2D_DST_BR_X((box2d->x + box2d->width) * nr_samples - 1) | + A6XX_GRAS_2D_DST_BR_Y(box2d->y + box2d->height - 1)); union pipe_color_union clear_color = convert_color(psurf->format, color); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.h b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.h index a354dd6a6a6..69d1c61f607 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.h @@ -41,8 +41,7 @@ unsigned fd6_tile_mode(const struct pipe_resource *tmpl); */ void fd6_clear_surface(struct fd_context *ctx, struct fd_ringbuffer *ring, - struct pipe_surface *psurf, uint32_t width, - uint32_t height, + struct pipe_surface *psurf, const struct pipe_box *box2d, union pipe_color_union *color, uint32_t unknown_8c01) assert_dt; void fd6_resolve_tile(struct fd_batch *batch, struct fd_ringbuffer *ring, uint32_t base, struct pipe_surface *psurf, uint32_t unknown_8c01) assert_dt; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index 33ddaeab71d..17fbb2d5c54 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -1505,6 +1505,9 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_ringbuffer *ring) assert_dt if (!buffers) return; + struct pipe_box box2d; + u_box_2d(0, 0, pfb->width, pfb->height, &box2d); + trace_start_clear_restore(&batch->trace, ring, buffers); if (buffers & PIPE_CLEAR_COLOR) { @@ -1517,8 +1520,7 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_ringbuffer *ring) assert_dt if (!(buffers & (PIPE_CLEAR_COLOR0 << i))) continue; - fd6_clear_surface(ctx, ring, pfb->cbufs[i], pfb->width, pfb->height, - &color, 0); + fd6_clear_surface(ctx, ring, pfb->cbufs[i], &box2d, &color, 0); } } if (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) { @@ -1533,7 +1535,7 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_ringbuffer *ring) assert_dt if ((buffers & PIPE_CLEAR_DEPTH) || (!separate_stencil && (buffers & PIPE_CLEAR_STENCIL))) { value.f[0] = batch->clear_depth; value.ui[1] = batch->clear_stencil; - fd6_clear_surface(ctx, ring, pfb->zsbuf, pfb->width, pfb->height, + fd6_clear_surface(ctx, ring, pfb->zsbuf, &box2d, &value, fd6_unknown_8c01(pfb->zsbuf->format, buffers)); } @@ -1544,8 +1546,7 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_ringbuffer *ring) assert_dt stencil_surf.format = PIPE_FORMAT_S8_UINT; stencil_surf.texture = separate_stencil; - fd6_clear_surface(ctx, ring, &stencil_surf, pfb->width, pfb->height, - &value, 0); + fd6_clear_surface(ctx, ring, &stencil_surf, &box2d, &value, 0); } }