[PATCH 07/11] etnaviv: add etna_shader_key and generate variants if needed
Christian Gmeiner
christian.gmeiner at gmail.com
Tue Mar 28 20:06:09 UTC 2017
Hi Lucas
>> diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.h b/src/gallium/drivers/etnaviv/etnaviv_shader.h
>> index 9f26bef..b0d97a7 100644
>> --- a/src/gallium/drivers/etnaviv/etnaviv_shader.h
>> +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.h
>> @@ -32,6 +32,21 @@
>> struct etna_context;
>> struct etna_shader_variant;
>>
>> +struct etna_shader_key
>> +{
>> + union {
>> + struct {
>> + };
>> + uint32_t global;
>> + };
>> +};
>
> There should probably be an assert somewhere in the code, which checks
> that sizeof(struct etna_shader_key) <= sizeof(etna_shader_key.global),
> to avoid the key getting ambiguous by overflowing global size.
>
Makes sense - what about something like this:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.h
b/src/gallium/drivers/etnaviv/etnaviv_shader.h
index 2b8618f..121d581 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_shader.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_shader.h
@@ -50,6 +50,8 @@ struct etna_shader_key
static inline bool
etna_shader_key_equal(struct etna_shader_key *a, struct etna_shader_key *b)
{
+ STATIC_ASSERT(sizeof(struct etna_shader_key) <= sizeof(a->global));
+
return a->global == b->global;
}
greets
--
Christian Gmeiner, MSc
https://www.youtube.com/user/AloryOFFICIAL
https://soundcloud.com/christian-gmeiner
More information about the etnaviv
mailing list