From adc63d25032b8cc784b25922201de14a8eb5bec1 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 26 Sep 2023 09:15:17 +0100 Subject: [PATCH] broadcom/compiler: add a couple of shader key helpers 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 Part-of: --- src/broadcom/compiler/v3d_compiler.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index eda80d1997e..449ca3fee32 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -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];