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

Matt Turner mattst88 at gmail.com
Thu Oct 19 05:17:50 UTC 2017


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;


More information about the mesa-dev mailing list