asahi: Put meta shader keys into the meta shader itself
authorAsahi Lina <lina@asahilina.net>
Wed, 14 Dec 2022 04:28:26 +0000 (13:28 +0900)
committerMarge Bot <emma+marge@anholt.net>
Sat, 17 Dec 2022 18:10:28 +0000 (18:10 +0000)
The hash table needs a key pointer with at least the lifetime of the
hash entry, which the key pointer we get does not have (since it is
stack-allocated by agx_build_meta). Copy it into the shader struct
itself and use that for the hash table.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>

src/asahi/lib/agx_meta.c
src/asahi/lib/agx_meta.h

index 8e624c6..e3f5cfd 100644 (file)
@@ -150,7 +150,8 @@ agx_get_meta_shader(struct agx_meta_cache *cache, struct agx_meta_key *key)
    if (!ret)
       ret = agx_build_background_shader(cache, key);
 
-   _mesa_hash_table_insert(cache->ht, key, ret);
+   ret->key = *key;
+   _mesa_hash_table_insert(cache->ht, &ret->key, ret);
    return ret;
 }
 
index 1b1b123..a7dac62 100644 (file)
@@ -30,6 +30,7 @@ struct agx_meta_key {
 };
 
 struct agx_meta_shader {
+   struct agx_meta_key key;
    struct agx_shader_info info;
    struct agx_bo *bo;
    uint32_t ptr;