[Mesa-dev] [PATCH] glsl: remove GCC construct from VECN macro

Ian Romanick idr at freedesktop.org
Mon Mar 26 20:33:46 UTC 2018


As much as I'm not a fan of C++ templates, I don't see how this
preprocessor macro reinvention of that mechanism is an improvement.

On 03/26/2018 09:45 AM, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Update the macro to have the explic return. Using the current GCC
> specific macro breaks other compilers such as the Intel one or MSVC.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105740
> Fixes: f407edf3407396379e16b0be74b8d3b85d2ad7f0
> Cc: Rob Clark <robdclark at gmail.com>
> Cc: Timothy Arceri <tarceri at itsqueeze.com>
> Cc: Roland Scheidegger <sroland at vmware.com>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/compiler/glsl_types.cpp | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
> index b8caddb406..ab356cb5a0 100644
> --- a/src/compiler/glsl_types.cpp
> +++ b/src/compiler/glsl_types.cpp
> @@ -509,88 +509,88 @@ glsl_type::vec(unsigned components, const glsl_type *const ts[])
>     return ts[n - 1];
>  }
>  
> -#define VECN(components, sname, vname) ({        \
> +#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);            \
> -   })
> +      return glsl_type::vec(components, ts);     \
> +   }
>  
>  const glsl_type *
>  glsl_type::vec(unsigned components)
>  {
> -   return VECN(components, float, vec);
> +   VECN(components, float, vec);
>  }
>  
>  const glsl_type *
>  glsl_type::f16vec(unsigned components)
>  {
> -   return VECN(components, float16_t, f16vec);
> +   VECN(components, float16_t, f16vec);
>  }
>  
>  const glsl_type *
>  glsl_type::dvec(unsigned components)
>  {
> -   return VECN(components, double, dvec);
> +   VECN(components, double, dvec);
>  }
>  
>  const glsl_type *
>  glsl_type::ivec(unsigned components)
>  {
> -   return VECN(components, int, ivec);
> +   VECN(components, int, ivec);
>  }
>  
>  const glsl_type *
>  glsl_type::uvec(unsigned components)
>  {
> -   return VECN(components, uint, uvec);
> +   VECN(components, uint, uvec);
>  }
>  
>  const glsl_type *
>  glsl_type::bvec(unsigned components)
>  {
> -   return VECN(components, bool, bvec);
> +   VECN(components, bool, bvec);
>  }
>  
>  const glsl_type *
>  glsl_type::i64vec(unsigned components)
>  {
> -   return VECN(components, int64_t, i64vec);
> +   VECN(components, int64_t, i64vec);
>  }
>  
>  
>  const glsl_type *
>  glsl_type::u64vec(unsigned components)
>  {
> -   return VECN(components, uint64_t, u64vec);
> +   VECN(components, uint64_t, u64vec);
>  }
>  
>  const glsl_type *
>  glsl_type::i16vec(unsigned components)
>  {
> -   return VECN(components, int16_t, i16vec);
> +   VECN(components, int16_t, i16vec);
>  }
>  
>  
>  const glsl_type *
>  glsl_type::u16vec(unsigned components)
>  {
> -   return VECN(components, uint16_t, u16vec);
> +   VECN(components, uint16_t, u16vec);
>  }
>  
>  const glsl_type *
>  glsl_type::i8vec(unsigned components)
>  {
> -   return VECN(components, int8_t, i8vec);
> +   VECN(components, int8_t, i8vec);
>  }
>  
>  
>  const glsl_type *
>  glsl_type::u8vec(unsigned components)
>  {
> -   return VECN(components, uint8_t, u8vec);
> +   VECN(components, uint8_t, u8vec);
>  }
>  
>  const glsl_type *
> 



More information about the mesa-dev mailing list