Skip to content

Commit

Permalink
etnaviv: implicitly update shared texture resources
Browse files Browse the repository at this point in the history
Implicitly update shared texture resources whenever they are first
used after the context has been flushed. This implements the
necessary behavior to get updated content for resources shared
outside of the screen without relying on any other API level
trigger, discussed to be necessary in [1].

[1] KhronosGroup/OpenGL-Registry#566

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6220
Signed-off-by: Lucas Stach <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25756>
  • Loading branch information
lynxeye-dev authored and Marge Bot committed Jan 15, 2024
1 parent 27ac558 commit 2f229a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gallium/drivers/etnaviv/etnaviv_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ etna_context_destroy(struct pipe_context *pctx)
if (ctx->pending_resources)
_mesa_hash_table_destroy(ctx->pending_resources, NULL);

if (ctx->updated_resources)
_mesa_set_destroy(ctx->updated_resources, NULL);

if (ctx->flush_resources)
_mesa_set_destroy(ctx->flush_resources, NULL);

Expand Down Expand Up @@ -534,6 +537,13 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
pipe_resource_reference(&prsc, NULL);
}
_mesa_set_clear(ctx->flush_resources, NULL);

/* reset shared resources update tracking */
set_foreach(ctx->updated_resources, entry) {
struct pipe_resource *prsc = (struct pipe_resource *)entry->key;
pipe_resource_reference(&prsc, NULL);
}
_mesa_set_clear(ctx->updated_resources, NULL);
}

etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd,
Expand Down Expand Up @@ -625,6 +635,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
if (!ctx->flush_resources)
goto fail;

ctx->updated_resources = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
if (!ctx->updated_resources)
goto fail;

/* context ctxate setup */
ctx->screen = screen;
/* need some sane default in case gallium frontends don't set some state: */
Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/etnaviv/etnaviv_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ struct etna_context {

/* resources that must be flushed implicitly at the context flush time */
struct set *flush_resources;
/* resources that need to be updated after a context flush */
struct set *updated_resources;

bool is_noop;

Expand Down
8 changes: 8 additions & 0 deletions src/gallium/drivers/etnaviv/etnaviv_texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ etna_update_sampler_source(struct pipe_sampler_view *view, int num)
struct etna_context *ctx = etna_context(view->context);
bool enable_sampler_ts = false;

if (base->shared && !_mesa_set_search(ctx->updated_resources, view->texture)) {
for (int i = view->u.tex.first_level; i <= view->u.tex.last_level; i++)
etna_resource_level_mark_changed(&base->levels[i]);

pipe_reference(NULL, &view->texture->reference);
_mesa_set_add(ctx->updated_resources, view->texture);
}

if (base->render && etna_resource_newer(etna_resource(base->render), base))
from = etna_resource(base->render);

Expand Down

0 comments on commit 2f229a8

Please sign in to comment.