On 03/26/2018 02:01 PM, Rob Clark wrote: > correct me if I'm wrong, but I don't see how you could do the ## stuff > to construct the built-in type name with templates. So I think the > options are tons of copy/pasta code (ie. what we had before) or > macros.
That is true... I don't know why my eyes just glazed over that. I think there actually is a way when the table is outside the function, but that wanders pretty far out of the original intent... maybe best to ignore my grumpiness today. > I agree that could just construct the whole method with the macro.. I > like that better than changing VECN() macro to contain the return > (which I was explicitly trying to avoid in the original version, since > macros that contain return statements are evil) > > BR, > -R > > On Mon, Mar 26, 2018 at 4:33 PM, Ian Romanick <i...@freedesktop.org> wrote: >> 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.veli...@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 <robdcl...@gmail.com> >>> Cc: Timothy Arceri <tarc...@itsqueeze.com> >>> Cc: Roland Scheidegger <srol...@vmware.com> >>> Signed-off-by: Emil Velikov <emil.veli...@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 * >>> >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev