freedreno: Precompute resource pointer hash values.

It was around half a percent of the CPU in the fd-bc-ctx branch, and adds
4b to our 472b struct.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11511>
This commit is contained in:
Emma Anholt 2021-06-16 20:34:37 -07:00 committed by Marge Bot
parent f24f62f4ad
commit cbbe3e7641
4 changed files with 7 additions and 5 deletions

View file

@ -444,13 +444,13 @@ fd_batch_add_resource(struct fd_batch *batch, struct fd_resource *rsc)
{
if (likely(fd_batch_references_resource(batch, rsc))) {
debug_assert(_mesa_set_search(batch->resources, rsc));
debug_assert(_mesa_set_search_pre_hashed(batch->resources, rsc->hash, rsc));
return;
}
debug_assert(!_mesa_set_search(batch->resources, rsc));
_mesa_set_add(batch->resources, rsc);
_mesa_set_add_pre_hashed(batch->resources, rsc->hash, rsc);
rsc->track->batch_mask |= (1 << batch->idx);
}

View file

@ -315,7 +315,7 @@ fd_bc_invalidate_resource(struct fd_resource *rsc, bool destroy)
if (destroy) {
foreach_batch (batch, &screen->batch_cache, rsc->track->batch_mask) {
struct set_entry *entry = _mesa_set_search(batch->resources, rsc);
struct set_entry *entry = _mesa_set_search_pre_hashed(batch->resources, rsc->hash, rsc);
_mesa_set_remove(batch->resources, entry);
}
rsc->track->batch_mask = 0;

View file

@ -452,9 +452,9 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
*/
debug_assert(shadow->track->batch_mask == 0);
foreach_batch (batch, &ctx->screen->batch_cache, rsc->track->batch_mask) {
struct set_entry *entry = _mesa_set_search(batch->resources, rsc);
struct set_entry *entry = _mesa_set_search_pre_hashed(batch->resources, rsc->hash, rsc);
_mesa_set_remove(batch->resources, entry);
_mesa_set_add(batch->resources, shadow);
_mesa_set_add_pre_hashed(batch->resources, shadow->hash, shadow);
}
swap(rsc->track, shadow->track);
@ -1092,6 +1092,7 @@ alloc_resource_struct(struct pipe_screen *pscreen,
pipe_reference_init(&prsc->reference, 1);
prsc->screen = pscreen;
rsc->hash = _mesa_hash_pointer(rsc);
util_range_init(&rsc->valid_buffer_range);
simple_mtx_init(&rsc->lock, mtx_plain);

View file

@ -118,6 +118,7 @@ struct fd_resource {
struct threaded_resource b;
struct fd_bo *bo; /* use fd_resource_set_bo() to write */
enum pipe_format internal_format;
uint32_t hash; /* _mesa_hash_pointer() on this resource's address. */
struct fdl_layout layout;
/* buffer range that has been initialized */