[Mesa-dev] [PATCH] glsl_types: fix build break with intel/msvc compiler

Roland Scheidegger sroland at vmware.com
Mon Mar 26 23:16:15 UTC 2018


Looks nicer in any case.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>

Am 27.03.2018 um 00:49 schrieb Rob Clark:
> The VECN() macro was taking advantage of a GCC specific feature that is
> not available on lesser compilers, mostly for the purposes of avoiding a
> macro that encoded a return statement.
> 
> But as suggested by Ian, we could just have the macro produce the entire
> method body and avoid the need for this.  So let's do that instead.
> 
> Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D105740&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=_QIjpv-UJ77xEQY8fIYoQtr5qv8wKrPJc7v7_-CYAb0&m=eRT_I_3VoCDxWw_I8noUCJeFaGWagLBmzE6HG6--xTQ&s=UHvkTixq7N04Wy2N6znh7Cawv6FkBYnnmytu-3lYiAM&e=
> Fixes: f407edf3407396379e16b0be74b8d3b85d2ad7f0
> Cc: Emil Velikov <emil.velikov at collabora.com>
> Cc: Timothy Arceri <tarceri at itsqueeze.com>
> Cc: Roland Scheidegger <sroland at vmware.com>
> Cc: Ian Romanick <idr at freedesktop.org>
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  src/compiler/glsl_types.cpp | 107 ++++++++++----------------------------------
>  1 file changed, 24 insertions(+), 83 deletions(-)
> 
> diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
> index e92e03421f4..f18e131cf18 100644
> --- a/src/compiler/glsl_types.cpp
> +++ b/src/compiler/glsl_types.cpp
> @@ -509,89 +509,30 @@ glsl_type::vec(unsigned components, const glsl_type *const ts[])
>     return ts[n - 1];
>  }
>  
> -#define VECN(components, sname, vname) ({        \
> -      static const glsl_type *const ts[] = {     \
> -         sname ## _type, vname ## 2_type,        \
> -         vname ## 3_type, vname ## 4_type,       \
> -         vname ## 8_type, vname ## 16_type,      \
> -      };                                         \
> -      glsl_type::vec(components, ts);            \
> -   })
> -
> -const glsl_type *
> -glsl_type::vec(unsigned components)
> -{
> -   return VECN(components, float, vec);
> -}
> -
> -const glsl_type *
> -glsl_type::f16vec(unsigned components)
> -{
> -   return VECN(components, float16_t, f16vec);
> -}
> -
> -const glsl_type *
> -glsl_type::dvec(unsigned components)
> -{
> -   return VECN(components, double, dvec);
> -}
> -
> -const glsl_type *
> -glsl_type::ivec(unsigned components)
> -{
> -   return VECN(components, int, ivec);
> -}
> -
> -const glsl_type *
> -glsl_type::uvec(unsigned components)
> -{
> -   return VECN(components, uint, uvec);
> -}
> -
> -const glsl_type *
> -glsl_type::bvec(unsigned components)
> -{
> -   return VECN(components, bool, bvec);
> -}
> -
> -const glsl_type *
> -glsl_type::i64vec(unsigned components)
> -{
> -   return VECN(components, int64_t, i64vec);
> -}
> -
> -
> -const glsl_type *
> -glsl_type::u64vec(unsigned components)
> -{
> -   return VECN(components, uint64_t, u64vec);
> -}
> -
> -const glsl_type *
> -glsl_type::i16vec(unsigned components)
> -{
> -   return VECN(components, int16_t, i16vec);
> -}
> -
> -
> -const glsl_type *
> -glsl_type::u16vec(unsigned components)
> -{
> -   return VECN(components, uint16_t, u16vec);
> -}
> -
> -const glsl_type *
> -glsl_type::i8vec(unsigned components)
> -{
> -   return VECN(components, int8_t, i8vec);
> -}
> -
> -
> -const glsl_type *
> -glsl_type::u8vec(unsigned components)
> -{
> -   return VECN(components, uint8_t, u8vec);
> -}
> +#define VECN(components, sname, vname)           \
> +const glsl_type *                                \
> +glsl_type:: vname (unsigned components)          \
> +{                                                \
> +   static const glsl_type *const ts[] = {        \
> +      sname ## _type, vname ## 2_type,           \
> +      vname ## 3_type, vname ## 4_type,          \
> +      vname ## 8_type, vname ## 16_type,         \
> +   };                                            \
> +   return glsl_type::vec(components, ts);        \
> +}
> +
> +VECN(components, float, vec)
> +VECN(components, float16_t, f16vec)
> +VECN(components, double, dvec)
> +VECN(components, int, ivec)
> +VECN(components, uint, uvec)
> +VECN(components, bool, bvec)
> +VECN(components, int64_t, i64vec)
> +VECN(components, uint64_t, u64vec)
> +VECN(components, int16_t, i16vec)
> +VECN(components, uint16_t, u16vec)
> +VECN(components, int8_t, i8vec)
> +VECN(components, uint8_t, u8vec)
>  
>  const glsl_type *
>  glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
> 



More information about the mesa-dev mailing list