freedreno/batch: Add a way to clone a batch key

For autotune, the lifetime of it's hashtable keys doesn't match the
batch, so we'll need to clone the key before inserting into the
hashtable.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9535>
This commit is contained in:
Rob Clark
2021-03-10 12:14:29 -08:00
committed by Marge Bot
parent aa7dd6ff43
commit 1c24e9500b
2 changed files with 10 additions and 0 deletions

View File

@@ -285,6 +285,7 @@ void fd_batch_check_size(struct fd_batch *batch) assert_dt;
uint32_t fd_batch_key_hash(const void *_key);
bool fd_batch_key_equals(const void *_a, const void *_b);
struct fd_batch_key * fd_batch_key_clone(void *mem_ctx, const struct fd_batch_key *key);
/* not called directly: */
void __fd_batch_describe(char* buf, const struct fd_batch *batch) assert_dt;

View File

@@ -118,6 +118,15 @@ fd_batch_key_equals(const void *_a, const void *_b)
(memcmp(a->surf, b->surf, sizeof(a->surf[0]) * a->num_surfs) == 0);
}
struct fd_batch_key *
fd_batch_key_clone(void *mem_ctx, const struct fd_batch_key *key)
{
unsigned sz = sizeof(struct fd_batch_key) + (sizeof(key->surf[0]) * key->num_surfs);
struct fd_batch_key *new_key = rzalloc_size(mem_ctx, sz);
memcpy(new_key, key, sz);
return new_key;
}
void
fd_bc_init(struct fd_batch_cache *cache)
{