freedreno: Fix resource tracking vs rebind/invalidate

We can now no longer rely on certain dirty bits to re-trigger draw time
resource tracking.  We need to use the new fd_dirty*_resource() APIs.

Fixes `org.skia.skqp.SkQPRunner#gles_recordopts` on android 9.

Fixes: 0a62a874fc ("freedreno: Re-work dirty-resource tracking")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22683>
This commit is contained in:
Rob Clark 2023-04-24 15:11:09 -07:00 committed by Marge Bot
parent 7cad28571b
commit d437e389e0
2 changed files with 18 additions and 8 deletions

View file

@ -82,7 +82,7 @@ rebind_resource_in_ctx(struct fd_context *ctx,
for (unsigned i = 0; i < vb->count && !(ctx->dirty & FD_DIRTY_VTXBUF);
i++) {
if (vb->vb[i].buffer.resource == prsc)
fd_context_dirty(ctx, FD_DIRTY_VTXBUF);
fd_dirty_resource(ctx, prsc, FD_DIRTY_VTXBUF, false);
}
}
@ -94,7 +94,7 @@ rebind_resource_in_ctx(struct fd_context *ctx,
i < so->num_targets && !(ctx->dirty & FD_DIRTY_STREAMOUT);
i++) {
if (so->targets[i]->buffer == prsc)
fd_context_dirty(ctx, FD_DIRTY_STREAMOUT);
fd_dirty_resource(ctx, prsc, FD_DIRTY_STREAMOUT, true);
}
}
@ -115,7 +115,8 @@ rebind_resource_in_ctx(struct fd_context *ctx,
const unsigned num_ubos = util_last_bit(cb->enabled_mask);
for (unsigned i = 1; i < num_ubos; i++) {
if (cb->cb[i].buffer == prsc) {
fd_context_dirty_shader(ctx, stage, FD_DIRTY_SHADER_CONST);
fd_dirty_shader_resource(ctx, prsc, stage,
FD_DIRTY_SHADER_CONST, false);
break;
}
}
@ -127,7 +128,8 @@ rebind_resource_in_ctx(struct fd_context *ctx,
struct fd_texture_stateobj *tex = &ctx->tex[stage];
for (unsigned i = 0; i < tex->num_textures; i++) {
if (tex->textures[i] && (tex->textures[i]->texture == prsc)) {
fd_context_dirty_shader(ctx, stage, FD_DIRTY_SHADER_TEX);
fd_dirty_shader_resource(ctx, prsc, stage,
FD_DIRTY_SHADER_TEX, false);
break;
}
}
@ -140,7 +142,9 @@ rebind_resource_in_ctx(struct fd_context *ctx,
const unsigned num_images = util_last_bit(si->enabled_mask);
for (unsigned i = 0; i < num_images; i++) {
if (si->si[i].resource == prsc) {
fd_context_dirty_shader(ctx, stage, FD_DIRTY_SHADER_IMAGE);
bool write = si->si[i].access & PIPE_IMAGE_ACCESS_WRITE;
fd_dirty_shader_resource(ctx, prsc, stage,
FD_DIRTY_SHADER_IMAGE, write);
break;
}
}
@ -153,7 +157,9 @@ rebind_resource_in_ctx(struct fd_context *ctx,
const unsigned num_ssbos = util_last_bit(sb->enabled_mask);
for (unsigned i = 0; i < num_ssbos; i++) {
if (sb->sb[i].buffer == prsc) {
fd_context_dirty_shader(ctx, stage, FD_DIRTY_SHADER_SSBO);
bool write = sb->writable_mask & BIT(i);
fd_dirty_shader_resource(ctx, prsc, stage,
FD_DIRTY_SHADER_SSBO, write);
break;
}
}
@ -1560,13 +1566,13 @@ fd_invalidate_resource(struct pipe_context *pctx,
if (pfb->zsbuf && pfb->zsbuf->texture == prsc) {
batch->resolve &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
fd_context_dirty(ctx, FD_DIRTY_ZSA);
fd_dirty_resource(ctx, prsc, FD_DIRTY_ZSA, true);
}
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i] && pfb->cbufs[i]->texture == prsc) {
batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i);
fd_context_dirty(ctx, FD_DIRTY_FRAMEBUFFER);
fd_dirty_resource(ctx, prsc, FD_DIRTY_FRAMEBUFFER, true);
}
}
}

View file

@ -410,6 +410,8 @@ fd_dirty_resource(struct fd_context *ctx, struct pipe_resource *prsc,
BITMASK_ENUM(fd_dirty_3d_state) dirty, bool write)
assert_dt
{
fd_context_dirty(ctx, dirty);
if (ctx->dirty_resource & dirty)
return;
@ -426,6 +428,8 @@ fd_dirty_shader_resource(struct fd_context *ctx, struct pipe_resource *prsc,
bool write)
assert_dt
{
fd_context_dirty_shader(ctx, shader, dirty);
if (ctx->dirty_shader_resource[shader] & dirty)
return;