freedreno/a6xx: invalidate tex state cache entries on rebind
When a resource's backing bo changes, its seqno will be incremented. Which would result in a new tex state cache key, and nothing to clean up the old tex state until the sampler view/state is destroyed. But in some games, that may never happen, or at least not happen before we run out of memory. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2830 Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4744>
This commit is contained in:
parent
ca05e6b04d
commit
6de01faac5
|
@ -441,10 +441,31 @@ fd6_texture_state_destroy(struct fd6_texture_state *state)
|
||||||
free(state);
|
free(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fd6_rebind_resource(struct fd_context *ctx, struct fd_resource *rsc)
|
||||||
|
{
|
||||||
|
if (!(rsc->dirty & FD_DIRTY_TEX))
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct fd6_context *fd6_ctx = fd6_context(ctx);
|
||||||
|
|
||||||
|
hash_table_foreach (fd6_ctx->tex_cache, entry) {
|
||||||
|
struct fd6_texture_state *state = entry->data;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < ARRAY_SIZE(state->key.view); i++) {
|
||||||
|
if (rsc->seqno == state->key.view[i].rsc_seqno) {
|
||||||
|
fd6_texture_state_destroy(entry->data);
|
||||||
|
_mesa_hash_table_remove(fd6_ctx->tex_cache, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fd6_texture_init(struct pipe_context *pctx)
|
fd6_texture_init(struct pipe_context *pctx)
|
||||||
{
|
{
|
||||||
struct fd6_context *fd6_ctx = fd6_context(fd_context(pctx));
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
|
struct fd6_context *fd6_ctx = fd6_context(ctx);
|
||||||
|
|
||||||
pctx->create_sampler_state = fd6_sampler_state_create;
|
pctx->create_sampler_state = fd6_sampler_state_create;
|
||||||
pctx->delete_sampler_state = fd6_sampler_state_delete;
|
pctx->delete_sampler_state = fd6_sampler_state_delete;
|
||||||
|
@ -454,6 +475,8 @@ fd6_texture_init(struct pipe_context *pctx)
|
||||||
pctx->sampler_view_destroy = fd6_sampler_view_destroy;
|
pctx->sampler_view_destroy = fd6_sampler_view_destroy;
|
||||||
pctx->set_sampler_views = fd_set_sampler_views;
|
pctx->set_sampler_views = fd_set_sampler_views;
|
||||||
|
|
||||||
|
ctx->rebind_resource = fd6_rebind_resource;
|
||||||
|
|
||||||
fd6_ctx->tex_cache = _mesa_hash_table_create(NULL, key_hash, key_equals);
|
fd6_ctx->tex_cache = _mesa_hash_table_create(NULL, key_hash, key_equals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,9 @@ struct fd_context {
|
||||||
|
|
||||||
struct pipe_debug_callback debug;
|
struct pipe_debug_callback debug;
|
||||||
|
|
||||||
|
/* Called on rebind_resource() for any per-gen cleanup required: */
|
||||||
|
void (*rebind_resource)(struct fd_context *ctx, struct fd_resource *rsc);
|
||||||
|
|
||||||
/* GMEM/tile handling fxns: */
|
/* GMEM/tile handling fxns: */
|
||||||
void (*emit_tile_init)(struct fd_batch *batch);
|
void (*emit_tile_init)(struct fd_batch *batch);
|
||||||
void (*emit_tile_prep)(struct fd_batch *batch, const struct fd_tile *tile);
|
void (*emit_tile_prep)(struct fd_batch *batch, const struct fd_tile *tile);
|
||||||
|
|
|
@ -69,6 +69,9 @@ rebind_resource_in_ctx(struct fd_context *ctx, struct fd_resource *rsc)
|
||||||
{
|
{
|
||||||
struct pipe_resource *prsc = &rsc->base;
|
struct pipe_resource *prsc = &rsc->base;
|
||||||
|
|
||||||
|
if (ctx->rebind_resource)
|
||||||
|
ctx->rebind_resource(ctx, rsc);
|
||||||
|
|
||||||
/* VBOs */
|
/* VBOs */
|
||||||
if (rsc->dirty & FD_DIRTY_VTXBUF) {
|
if (rsc->dirty & FD_DIRTY_VTXBUF) {
|
||||||
struct fd_vertexbuf_stateobj *vb = &ctx->vtx.vertexbuf;
|
struct fd_vertexbuf_stateobj *vb = &ctx->vtx.vertexbuf;
|
||||||
|
|
Loading…
Reference in New Issue