[Mesa-dev] [PATCH 04/21] intel: Rewrite the world of push/pull params

Jason Ekstrand jason at jlekstrand.net
Thu Oct 19 14:03:46 UTC 2017


On October 18, 2017 10:18:11 PM Matt Turner <mattst88 at gmail.com> wrote:

> On Fri, Sep 29, 2017 at 2:25 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>> diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c 
>> b/src/mesa/drivers/dri/i965/gen6_constant_state.c
>> index b2e357f..93a12c7 100644
>> --- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
>> +++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
>> @@ -24,21 +24,84 @@
>>  #include "brw_context.h"
>>  #include "brw_state.h"
>>  #include "brw_defines.h"
>> +#include "brw_program.h"
>>  #include "intel_batchbuffer.h"
>>  #include "intel_buffer_objects.h"
>>  #include "program/prog_parameter.h"
>>
>> +static uint32_t
>> +f_as_u32(float f)
>> +{
>> +   return *(uint32_t *)&f;
>> +}
>
> PSA: This breaks C's aliasing rules and is not allowed in Mesa. GCC
> warns about this, at least when optimizing.
>
> I've pushed a trivial patch that uses a union instead:
>
> -   return *(uint32_t *)&f;
> +   union fi fi = { .f = f };
> +   return fi.ui;

Hmm, I wonder why I didn't see that warning.  Maybe because I'm building 
with clang these days?  In any case, thanks for fixing it.




More information about the mesa-dev mailing list