broadcom/compiler: add a couple of shader key helpers
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 26 Sep 2023 08:15:17 +0000 (09:15 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 2 Oct 2023 06:35:06 +0000 (06:35 +0000)
Our shader key includes a void pointer that we can't just memcmp,
so add helpers that allow us toget the 'static' portion and size
of a key. We will use this to fix up the shader cache in v3d in
a later patch.

Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25418>

src/broadcom/compiler/v3d_compiler.h

index eda80d1..449ca3f 100644 (file)
@@ -392,8 +392,29 @@ static inline uint8_t v3d_slot_get_component(struct v3d_varying_slot slot)
         return slot.slot_and_component & 3;
 }
 
+/* Given a v3d_key start address, skips over the 'void *'
+ * shader_state pointer to get the 'static' portion of the
+ * key.
+ */
+static inline uint8_t *
+v3d_key_static_addr(const void *key_addr)
+{
+        return ((uint8_t *)key_addr) + sizeof(void*);
+}
+
+/* Returns the size of the key adjusted to the static
+ * portion.
+ */
+static inline uint32_t
+v3d_key_static_size(uint32_t key_size)
+{
+        return key_size - sizeof(void *);
+}
+
 struct v3d_key {
+        /* Keep this field first */
         void *shader_state;
+
         struct {
                 uint8_t swizzle[4];
         } tex[V3D_MAX_TEXTURE_SAMPLERS];