diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index dc855408f62..60a717b1024 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -432,6 +432,11 @@ struct v3d_job { * first rendering. */ uint32_t clear; + /* Bitmask of PIPE_CLEAR_* of buffers that were cleared using a draw + * call (not necessarily before the first rendering) instead of a TLB + * clear. + */ + uint32_t clear_draw; /* Bitmask of PIPE_CLEAR_* of buffers that have been read by a draw * call without having been cleared first. */ diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index ca378096e46..a84cb3135d0 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -1357,11 +1357,11 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, u_stream_outputs_for_vertices(info->mode, draws[0].count); } + uint32_t clear_mask = job->clear | job->clear_draw; if (v3d->zsa && job->zsbuf && v3d->zsa->base.depth_enabled) { struct v3d_resource *rsc = v3d_resource(job->zsbuf->texture); v3d_job_add_bo(job, rsc->bo); - - job->load |= PIPE_CLEAR_DEPTH & ~job->clear; + job->load |= PIPE_CLEAR_DEPTH & ~clear_mask; if (v3d->zsa->base.depth_writemask) job->store |= PIPE_CLEAR_DEPTH; rsc->initialized_buffers = PIPE_CLEAR_DEPTH; @@ -1374,7 +1374,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, v3d_job_add_bo(job, rsc->bo); - job->load |= PIPE_CLEAR_STENCIL & ~job->clear; + job->load |= PIPE_CLEAR_STENCIL & ~clear_mask; if (v3d->zsa->base.stencil[0].writemask || v3d->zsa->base.stencil[1].writemask) { job->store |= PIPE_CLEAR_STENCIL; @@ -1390,7 +1390,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, continue; struct v3d_resource *rsc = v3d_resource(job->cbufs[i]->texture); - job->load |= bit & ~job->clear; + job->load |= bit & ~clear_mask; if (v3d->blend->base.rt[blend_rt].colormask) job->store |= bit; v3d_job_add_bo(job, rsc->bo); @@ -1619,10 +1619,18 @@ v3d_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) */ static void v3d_draw_clear(struct v3d_context *v3d, + struct v3d_job *job, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) { + /* Flag we are clearing these buffers with a draw call so we can + * skip loads for them. Notice that if we had emitted any draw calls + * before this clear the loads will still happen, since those previous + * draw calls would have flagged them. + */ + job->clear_draw |= buffers; + v3d_blitter_save(v3d, false, true); util_blitter_clear(v3d->blitter, v3d->framebuffer.width, @@ -1770,7 +1778,7 @@ v3d_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor if (!buffers || !v3d_render_condition_check(v3d)) return; - v3d_draw_clear(v3d, buffers, color, depth, stencil); + v3d_draw_clear(v3d, job, buffers, color, depth, stencil); } static void