From bfd29a55e5ac45879750515106f9e4f930bfaaaa Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Tue, 21 Jan 2025 18:08:29 +0100 Subject: [PATCH] v3d: Apply FBO resources invalidations on job creation We can handle invalidation of the FBO attachments at job creation. It solves that we were skipping invalidations in jobs that had been created by a clear call, as before this change invalidations were only taken into account the first draw calls of the job. In these cases where there is a clear after FB invalidation the resource attachment was tracked as invalidated for more time than expected. So the stores of the job with the clear were not being loaded by the next job attaching it because of the not correct application of the invalidation. Fixes: 6c46890325e ("v3d: avoid load/store of tile buffer on invalidated framebuffer") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12456 Reviewed-by: Iago Toral Quiroga Part-of: --- src/gallium/drivers/v3d/v3d_job.c | 14 ++++++++++++++ src/gallium/drivers/v3d/v3dx_draw.c | 21 +-------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_job.c b/src/gallium/drivers/v3d/v3d_job.c index c03fa8c7ea3..ae827d9091b 100644 --- a/src/gallium/drivers/v3d/v3d_job.c +++ b/src/gallium/drivers/v3d/v3d_job.c @@ -426,6 +426,10 @@ v3d_get_job_for_fbo(struct v3d_context *v3d) struct v3d_resource *rsc = v3d_resource(cbufs[i]->texture); if (!rsc->writes) job->clear_tlb |= PIPE_CLEAR_COLOR0 << i; + if (rsc->invalidated) { + job->invalidated_load |= PIPE_CLEAR_COLOR0 << i; + rsc->invalidated = false; + } } } @@ -439,6 +443,16 @@ v3d_get_job_for_fbo(struct v3d_context *v3d) if (!rsc->writes) job->clear_tlb |= PIPE_CLEAR_STENCIL; + if (rsc->invalidated) { + /* Currently gallium only applies invalidates if it + * affects both depth and stencil together. + */ + job->invalidated_load |= + PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL; + rsc->invalidated = false; + if (rsc->separate_stencil) + rsc->separate_stencil->invalidated = false; + } } job->tile_desc.draw_x = DIV_ROUND_UP(v3d->framebuffer.width, diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 3853f2ef722..506284dae98 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -1094,13 +1094,8 @@ v3d_update_job_tlb_load_store(struct v3d_job *job) { if (job->store & bit || !job->cbufs[i]) continue; struct v3d_resource *rsc = v3d_resource(job->cbufs[i]->texture); + job->load |= bit & ~no_load_mask; - if (rsc->invalidated) { - job->invalidated_load |= bit; - rsc->invalidated = false; - } else { - job->load |= bit & ~no_load_mask; - } if (v3d->blend->base.rt[blend_rt].colormask) job->store |= bit; v3d_job_add_bo(job, rsc->bo); @@ -1401,20 +1396,6 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, u_stream_outputs_for_vertices(info->mode, draws[0].count); } - if (v3d->zsa && job->zsbuf) { - struct v3d_resource *rsc = v3d_resource(job->zsbuf->texture); - if (rsc->invalidated) { - /* Currently gallium only applies invalidates if it - * affects both depth and stencil together. - */ - job->invalidated_load |= - PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL; - rsc->invalidated = false; - if (rsc->separate_stencil) - rsc->separate_stencil->invalidated = false; - } - } - v3d_update_job_tlb_load_store(job); if (indirect && indirect->buffer)