Mesa (master): freedreno: Use a real type instead of void * for the fd_batch->key.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 23:03:30 UTC 2021
Module: Mesa
Branch: master
Commit: d1a0eba2417919a48aebabe041797ff2a4d7f68a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1a0eba2417919a48aebabe041797ff2a4d7f68a
Author: Eric Anholt <eric at anholt.net>
Date: Mon Jan 25 10:42:42 2021 -0800
freedreno: Use a real type instead of void * for the fd_batch->key.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8729>
---
src/gallium/drivers/freedreno/freedreno_batch.h | 3 ++-
.../drivers/freedreno/freedreno_batch_cache.c | 26 +++++++++++-----------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h
index 64b944d65e0..bc317719281 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch.h
@@ -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: */
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index 4f918932e27..bd62f82c9ae 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -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;
More information about the mesa-commit
mailing list