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: 6c46890325 ("v3d: avoid load/store of tile buffer on invalidated framebuffer")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12456
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33148>
This commit is contained in:
Jose Maria Casanova Crespo 2025-01-21 18:08:29 +01:00 committed by Marge Bot
parent 09aa19fb64
commit bfd29a55e5
2 changed files with 15 additions and 20 deletions

View file

@ -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,

View file

@ -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)