From 7158950a6f039de697b8227f83d0173923763c79 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 18 Jul 2024 10:49:27 +0200 Subject: [PATCH] v3d: use operations to specify what to save in blitter So far, in order to know what we need to save before using the blitter utility, we use a boolean to know if we are going to do a blit or not, and if we need to take in account conditional rendering or not. In other to allow to specify more operations than blit or not, use an enum to define what operation we would like to do, and based on that what information we need to store. This also merge the conditional rendering as part of these operations. Reviewed-by: Iago Toral Quiroga Signed-off-by: Juan A. Suarez Romero Part-of: --- src/gallium/drivers/v3d/v3d_blit.c | 18 +++++++++++------- src/gallium/drivers/v3d/v3d_context.h | 13 ++++++++++++- src/gallium/drivers/v3d/v3dx_draw.c | 8 +++++--- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index 0c60f19e729..b72878464df 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -38,7 +38,7 @@ */ void -v3d_blitter_save(struct v3d_context *v3d, bool op_blit, bool render_cond) +v3d_blitter_save(struct v3d_context *v3d, enum v3d_blitter_op op) { util_blitter_save_fragment_constant_buffer_slot(v3d->blitter, v3d->constbuf[PIPE_SHADER_FRAGMENT].cb); @@ -59,7 +59,7 @@ v3d_blitter_save(struct v3d_context *v3d, bool op_blit, bool render_cond) v3d->streamout.targets); util_blitter_save_framebuffer(v3d->blitter, &v3d->framebuffer); - if (op_blit) { + if (op & V3D_SAVE_TEXTURES) { util_blitter_save_scissor(v3d->blitter, &v3d->scissor); util_blitter_save_fragment_sampler_states(v3d->blitter, v3d->tex[PIPE_SHADER_FRAGMENT].num_samplers, @@ -69,7 +69,7 @@ v3d_blitter_save(struct v3d_context *v3d, bool op_blit, bool render_cond) v3d->tex[PIPE_SHADER_FRAGMENT].textures); } - if (!render_cond) { + if (!(op & V3D_DISABLE_RENDER_COND)) { util_blitter_save_render_condition(v3d->blitter, v3d->cond_query, v3d->cond_cond, v3d->cond_mode); } @@ -126,7 +126,8 @@ v3d_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info) return; } - v3d_blitter_save(v3d, true, info->render_condition_enable); + v3d_blitter_save(v3d, info->render_condition_enable ? + V3D_BLIT_COND : V3D_BLIT); util_blitter_blit(v3d->blitter, info, NULL); pipe_resource_reference(&tiled, NULL); @@ -196,7 +197,8 @@ v3d_stencil_blit(struct pipe_context *ctx, struct pipe_blit_info *info) struct pipe_sampler_view *src_view = ctx->create_sampler_view(ctx, &src->base, &src_tmpl); - v3d_blitter_save(v3d, true, info->render_condition_enable); + v3d_blitter_save(v3d, info->render_condition_enable ? + V3D_BLIT_COND : V3D_BLIT); util_blitter_blit_generic(v3d->blitter, dst_surf, &info->dst.box, src_view, &info->src.box, src->base.width0, src->base.height0, @@ -654,7 +656,8 @@ v3d_sand8_blit(struct pipe_context *pctx, struct pipe_blit_info *info) assert(info->src.box.width == info->dst.box.width); assert(info->src.box.height == info->dst.box.height); - v3d_blitter_save(v3d, true, info->render_condition_enable); + v3d_blitter_save(v3d, info->render_condition_enable ? + V3D_BLIT_COND : V3D_BLIT); struct pipe_surface dst_tmpl; util_blitter_default_dst_texture(&dst_tmpl, info->dst.resource, @@ -971,7 +974,8 @@ v3d_sand30_blit(struct pipe_context *pctx, struct pipe_blit_info *info) assert(info->src.box.width == info->dst.box.width); assert(info->src.box.height == info->dst.box.height); - v3d_blitter_save(v3d, true, info->render_condition_enable); + v3d_blitter_save(v3d, info->render_condition_enable ? + V3D_BLIT_COND : V3D_BLIT); struct pipe_surface dst_tmpl; util_blitter_default_dst_texture(&dst_tmpl, info->dst.resource, diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 3a822d19eb8..93446b305d0 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -151,6 +151,17 @@ enum v3d_flush_cond { V3D_FLUSH_NOT_CURRENT_JOB, }; +/* bitmask */ +enum v3d_blitter_op { + V3D_SAVE_TEXTURES = (1u << 1), + V3D_DISABLE_RENDER_COND = (1u << 2), + + V3D_BLIT = V3D_SAVE_TEXTURES, + V3D_BLIT_COND = V3D_BLIT | V3D_DISABLE_RENDER_COND, + V3D_CLEAR = 0, + V3D_CLEAR_COND = V3D_CLEAR | V3D_DISABLE_RENDER_COND, +}; + struct v3d_sampler_view { struct pipe_sampler_view base; uint32_t p0; @@ -790,7 +801,7 @@ bool v3d_format_supports_tlb_msaa_resolve(const struct v3d_device_info *devinfo, void v3d_init_query_functions(struct v3d_context *v3d); void v3d_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info); -void v3d_blitter_save(struct v3d_context *v3d, bool op_blit, bool render_cond); +void v3d_blitter_save(struct v3d_context *v3d, enum v3d_blitter_op op); bool v3d_generate_mipmap(struct pipe_context *pctx, struct pipe_resource *prsc, enum pipe_format format, diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index c274a30c685..d31e3ac22a1 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -1631,7 +1631,7 @@ v3d_draw_clear(struct v3d_context *v3d, */ job->clear_draw |= buffers; - v3d_blitter_save(v3d, false, true); + v3d_blitter_save(v3d, V3D_CLEAR_COND); util_blitter_clear(v3d->blitter, v3d->framebuffer.width, v3d->framebuffer.height, @@ -1792,7 +1792,8 @@ v3d_clear_render_target(struct pipe_context *pctx, struct pipe_surface *ps, if (render_condition_enabled && !v3d_render_condition_check(v3d)) return; - v3d_blitter_save(v3d, false, render_condition_enabled); + v3d_blitter_save(v3d, render_condition_enabled ? + V3D_CLEAR_COND : V3D_CLEAR); util_blitter_clear_render_target(v3d->blitter, ps, color, x, y, w, h); } @@ -1807,7 +1808,8 @@ v3d_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps, if (render_condition_enabled && !v3d_render_condition_check(v3d)) return; - v3d_blitter_save(v3d, false, render_condition_enabled); + v3d_blitter_save(v3d, render_condition_enabled ? + V3D_CLEAR_COND : V3D_CLEAR); util_blitter_clear_depth_stencil(v3d->blitter, ps, buffers, depth, stencil, x, y, w, h); }