freedreno: Use a real type instead of void * for the fd_batch->key.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8729>
This commit is contained in:
Eric Anholt 2021-01-25 10:42:42 -08:00
parent 695d3bcb12
commit d1a0eba241
2 changed files with 15 additions and 14 deletions

View file

@ -43,6 +43,7 @@
#endif
struct fd_resource;
struct fd_batch_key;
/* A batch tracks everything about a cmdstream batch/submit, including the
* ringbuffers used for binning, draw, and gmem cmds, list of associated
@ -229,7 +230,7 @@ struct fd_batch {
struct set *resources;
/** key in batch-cache (if not null): */
const void *key;
const struct fd_batch_key *key;
uint32_t hash;
/** set of dependent batches.. holds refs to dependent batches: */

View file

@ -76,7 +76,7 @@
* not have been destroyed.
*/
struct key {
struct fd_batch_key {
uint32_t width;
uint32_t height;
uint16_t layers;
@ -91,20 +91,20 @@ struct key {
} surf[0];
};
static struct key *
static struct fd_batch_key *
key_alloc(unsigned num_surfs)
{
struct key *key =
CALLOC_VARIANT_LENGTH_STRUCT(key, sizeof(key->surf[0]) * num_surfs);
struct fd_batch_key *key =
CALLOC_VARIANT_LENGTH_STRUCT(fd_batch_key, sizeof(key->surf[0]) * num_surfs);
return key;
}
static uint32_t
key_hash(const void *_key)
{
const struct key *key = _key;
const struct fd_batch_key *key = _key;
uint32_t hash = 0;
hash = XXH32(key, offsetof(struct key, surf[0]), hash);
hash = XXH32(key, offsetof(struct fd_batch_key, surf[0]), hash);
hash = XXH32(key->surf, sizeof(key->surf[0]) * key->num_surfs , hash);
return hash;
}
@ -112,9 +112,9 @@ key_hash(const void *_key)
static bool
key_equals(const void *_a, const void *_b)
{
const struct key *a = _a;
const struct key *b = _b;
return (memcmp(a, b, offsetof(struct key, surf[0])) == 0) &&
const struct fd_batch_key *a = _a;
const struct fd_batch_key *b = _b;
return (memcmp(a, b, offsetof(struct fd_batch_key, surf[0])) == 0) &&
(memcmp(a->surf, b->surf, sizeof(a->surf[0]) * a->num_surfs) == 0);
}
@ -264,7 +264,7 @@ fd_bc_invalidate_batch(struct fd_batch *batch, bool remove)
return;
struct fd_batch_cache *cache = &batch->ctx->screen->batch_cache;
struct key *key = (struct key *)batch->key;
struct fd_batch_key *key = (struct fd_batch_key *)batch->key;
fd_screen_assert_locked(batch->ctx->screen);
@ -413,7 +413,7 @@ fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool non
}
static struct fd_batch *
batch_from_key(struct fd_batch_cache *cache, struct key *key,
batch_from_key(struct fd_batch_cache *cache, struct fd_batch_key *key,
struct fd_context *ctx)
{
struct fd_batch *batch = NULL;
@ -463,7 +463,7 @@ batch_from_key(struct fd_batch_cache *cache, struct key *key,
}
static void
key_surf(struct key *key, unsigned idx, unsigned pos, struct pipe_surface *psurf)
key_surf(struct fd_batch_key *key, unsigned idx, unsigned pos, struct pipe_surface *psurf)
{
key->surf[idx].texture = psurf->texture;
key->surf[idx].u = psurf->u;
@ -477,7 +477,7 @@ fd_batch_from_fb(struct fd_batch_cache *cache, struct fd_context *ctx,
const struct pipe_framebuffer_state *pfb)
{
unsigned idx = 0, n = pfb->nr_cbufs + (pfb->zsbuf ? 1 : 0);
struct key *key = key_alloc(n);
struct fd_batch_key *key = key_alloc(n);
key->width = pfb->width;
key->height = pfb->height;