From 9a88064162ad0a8815a40eb21e03090beddd22ec Mon Sep 17 00:00:00 2001 From: Italo Nicola Date: Wed, 28 Jun 2023 14:23:02 +0000 Subject: [PATCH] freedreno: implement clear_render_target and clear_depth_stencil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Italo Nicola Reviewed-by: Alyssa Rosenzweig Reviewed-by: Marek Olšák Part-of: --- .../drivers/freedreno/freedreno_blitter.c | 29 +++++++++++++++++++ .../drivers/freedreno/freedreno_blitter.h | 10 +++++++ .../drivers/freedreno/freedreno_draw.c | 18 ++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.c b/src/gallium/drivers/freedreno/freedreno_blitter.c index 781d0a584cb..b947b9f1e97 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.c +++ b/src/gallium/drivers/freedreno/freedreno_blitter.c @@ -279,6 +279,35 @@ fd_blitter_clear(struct pipe_context *pctx, unsigned buffers, fd_blitter_pipe_end(ctx); } +/* Partially generic clear_render_target implementation using u_blitter */ +void +fd_blitter_clear_render_target(struct pipe_context *pctx, struct pipe_surface *ps, + const union pipe_color_union *color, unsigned x, + unsigned y, unsigned w, unsigned h, + bool render_condition_enabled) +{ + struct fd_context *ctx = fd_context(pctx); + + fd_blitter_pipe_begin(ctx, render_condition_enabled); + util_blitter_clear_render_target(ctx->blitter, ps, color, x, y, w, h); + fd_blitter_pipe_end(ctx); +} + +/* Partially generic clear_depth_stencil implementation using u_blitter */ +void +fd_blitter_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps, + unsigned buffers, double depth, unsigned stencil, + unsigned x, unsigned y, unsigned w, unsigned h, + bool render_condition_enabled) +{ + struct fd_context *ctx = fd_context(pctx); + + fd_blitter_pipe_begin(ctx, render_condition_enabled); + util_blitter_clear_depth_stencil(ctx->blitter, ps, buffers, depth, + stencil, x, y, w, h); + fd_blitter_pipe_end(ctx); +} + /** * Optimal hardware path for blitting pixels. * Scaling, format conversion, up- and downsampling (resolve) are allowed. diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.h b/src/gallium/drivers/freedreno/freedreno_blitter.h index d90c03d915e..1d88d420254 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.h +++ b/src/gallium/drivers/freedreno/freedreno_blitter.h @@ -41,6 +41,16 @@ void fd_blitter_clear(struct pipe_context *pctx, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) assert_dt; +void fd_blitter_clear_render_target(struct pipe_context *pctx, struct pipe_surface *ps, + const union pipe_color_union *color, unsigned x, + unsigned y, unsigned w, unsigned h, + bool render_condition_enabled) assert_dt; + +void fd_blitter_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps, + unsigned buffers, double depth, unsigned stencil, + unsigned x, unsigned y, unsigned w, unsigned h, + bool render_condition_enabled) assert_dt; + void fd_resource_copy_region(struct pipe_context *pctx, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index be469715127..1324e1f0685 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -540,19 +540,27 @@ static void fd_clear_render_target(struct pipe_context *pctx, struct pipe_surface *ps, const union pipe_color_union *color, unsigned x, unsigned y, unsigned w, unsigned h, - bool render_condition_enabled) + bool render_condition_enabled) in_dt { - DBG("TODO: x=%u, y=%u, w=%u, h=%u", x, y, w, h); + if (render_condition_enabled && !fd_render_condition_check(pctx)) + return; + + fd_blitter_clear_render_target(pctx, ps, color, x, y, w, h, + render_condition_enabled); } static void fd_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps, unsigned buffers, double depth, unsigned stencil, unsigned x, unsigned y, unsigned w, unsigned h, - bool render_condition_enabled) + bool render_condition_enabled) in_dt { - DBG("TODO: buffers=%u, depth=%f, stencil=%u, x=%u, y=%u, w=%u, h=%u", - buffers, depth, stencil, x, y, w, h); + if (render_condition_enabled && !fd_render_condition_check(pctx)) + return; + + fd_blitter_clear_depth_stencil(pctx, ps, buffers, + depth, stencil, x, y, w, h, + render_condition_enabled); } static void