mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
panfrost: Switch resources from an array to a set
This will help us reduce shared state and simplify multithreading, at the expense of additional CPU overhead. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12528>
This commit is contained in:
parent
8e2159a57f
commit
2f63ccd080
2 changed files with 16 additions and 15 deletions
|
|
@ -78,7 +78,8 @@ panfrost_batch_init(struct panfrost_context *ctx,
|
||||||
batch->maxx = batch->maxy = 0;
|
batch->maxx = batch->maxy = 0;
|
||||||
|
|
||||||
util_copy_framebuffer_state(&batch->key, key);
|
util_copy_framebuffer_state(&batch->key, key);
|
||||||
util_dynarray_init(&batch->resources, NULL);
|
batch->resources =_mesa_set_create(NULL, _mesa_hash_pointer,
|
||||||
|
_mesa_key_pointer_equal);
|
||||||
|
|
||||||
/* Preallocate the main pool, since every batch has at least one job
|
/* Preallocate the main pool, since every batch has at least one job
|
||||||
* structure so it will be used */
|
* structure so it will be used */
|
||||||
|
|
@ -121,16 +122,17 @@ panfrost_batch_cleanup(struct panfrost_batch *batch)
|
||||||
panfrost_bo_unreference(bo);
|
panfrost_bo_unreference(bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
util_dynarray_foreach(&batch->resources, struct panfrost_resource *, rsrc) {
|
set_foreach_remove(batch->resources, entry) {
|
||||||
BITSET_CLEAR((*rsrc)->track.users, batch_idx);
|
struct panfrost_resource *rsrc = (void *) entry->key;
|
||||||
|
BITSET_CLEAR(rsrc->track.users, batch_idx);
|
||||||
|
|
||||||
if ((*rsrc)->track.writer == batch)
|
if (rsrc->track.writer == batch)
|
||||||
(*rsrc)->track.writer = NULL;
|
rsrc->track.writer = NULL;
|
||||||
|
|
||||||
pipe_resource_reference((struct pipe_resource **) rsrc, NULL);
|
pipe_resource_reference((struct pipe_resource **) &rsrc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
util_dynarray_fini(&batch->resources);
|
_mesa_set_destroy(batch->resources, NULL);
|
||||||
panfrost_pool_cleanup(&batch->pool);
|
panfrost_pool_cleanup(&batch->pool);
|
||||||
panfrost_pool_cleanup(&batch->invisible_pool);
|
panfrost_pool_cleanup(&batch->invisible_pool);
|
||||||
|
|
||||||
|
|
@ -229,16 +231,15 @@ panfrost_batch_update_access(struct panfrost_batch *batch,
|
||||||
struct panfrost_context *ctx = batch->ctx;
|
struct panfrost_context *ctx = batch->ctx;
|
||||||
uint32_t batch_idx = panfrost_batch_idx(batch);
|
uint32_t batch_idx = panfrost_batch_idx(batch);
|
||||||
struct panfrost_batch *writer = rsrc->track.writer;
|
struct panfrost_batch *writer = rsrc->track.writer;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
if (unlikely(!BITSET_TEST(rsrc->track.users, batch_idx))) {
|
_mesa_set_search_or_add(batch->resources, rsrc, &found);
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
BITSET_SET(rsrc->track.users, batch_idx);
|
BITSET_SET(rsrc->track.users, batch_idx);
|
||||||
|
|
||||||
/* Reference the resource on the batch */
|
/* Reference the resource on the batch */
|
||||||
struct pipe_resource **dst = util_dynarray_grow(&batch->resources,
|
pipe_reference(NULL, &rsrc->base.reference);
|
||||||
struct pipe_resource *, 1);
|
|
||||||
|
|
||||||
*dst = NULL;
|
|
||||||
pipe_resource_reference(dst, &rsrc->base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush users if required */
|
/* Flush users if required */
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,8 @@ struct panfrost_batch {
|
||||||
mali_ptr uniform_buffers[PIPE_SHADER_TYPES];
|
mali_ptr uniform_buffers[PIPE_SHADER_TYPES];
|
||||||
mali_ptr push_uniforms[PIPE_SHADER_TYPES];
|
mali_ptr push_uniforms[PIPE_SHADER_TYPES];
|
||||||
|
|
||||||
/* Referenced resources for cleanup */
|
/* Referenced resources */
|
||||||
struct util_dynarray resources;
|
struct set *resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Functions for managing the above */
|
/* Functions for managing the above */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue