diff --git a/configure.ac b/configure.ac index 948d1e1a..0c3fea3b 100644 --- a/configure.ac +++ b/configure.ac @@ -257,9 +257,6 @@ AC_PROG_AWK AC_PROG_CC AC_PROG_CC_STDC AC_PROG_CXX -AC_C_CONST -AC_C_RESTRICT -AX_GCC_VAR_ATTRIBUTE(vector_size) AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S @@ -338,11 +335,34 @@ AC_PROVIDE([AC_LIBTOOL_WIN32_DLL]) AC_PROG_LIBTOOL # Checks for typedefs, structures, and compiler characteristics. +AC_C_RESTRICT +AX_GCC_VAR_ATTRIBUTE(vector_size) AC_C_CONST AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_SIZE_T +# we need to be able to shuffle vectors in C++ +if test x$ax_cv_have_var_attribute_vector_size = x"yes"; then + AC_MSG_CHECKING([for vector shuffle]) + AC_TRY_COMPILE([ + typedef float v4f __attribute__((vector_size(4 * sizeof(float)))); + ],[ + v4f f; f[3] = 99; + ],[ + AC_MSG_RESULT([yes]) + have_vector_shuffle=yes + ], [ + AC_MSG_RESULT([no]) + have_vector_shuffle=no + ]) + + if test x$have_vector_shuffle = x"yes"; then + AC_DEFINE_UNQUOTED(HAVE_VECTOR_SHUFFLE, 1, + [define if your C++ can shuffle vectors]) + fi +fi + # Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_MMAP diff --git a/libvips/conversion/composite.cpp b/libvips/conversion/composite.cpp index 58196298..4e9f6c00 100644 --- a/libvips/conversion/composite.cpp +++ b/libvips/conversion/composite.cpp @@ -489,7 +489,7 @@ vips_composite_blend_mul( VipsBlendMode mode, /* We have a vector path with gcc's vector attr. */ -#ifdef HAVE_VAR_ATTRIBUTE_VECTOR_SIZE +#ifdef HAVE_VECTOR_SHUFFLE /* A vector of four floats. */ typedef float v4f __attribute__((vector_size(4 * sizeof(float)))); @@ -677,7 +677,7 @@ vips_composite_blend_mul_3float( VipsBlendMode mode, v4f &B, float *A_memory ) B[3] = aR; } -#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/ +#endif /*HAVE_VECTOR_SHUFFLE*/ /* A is the new pixel coming in, B is the double pixel we are accumulating. */ @@ -720,7 +720,7 @@ static void vips_combine_pixels( VipsComposite *composite, tq[bands] = B[bands]; } -#ifdef HAVE_VAR_ATTRIBUTE_VECTOR_SIZE +#ifdef HAVE_VECTOR_SHUFFLE static void vips_combine_pixels_3float( VipsComposite *composite, VipsPel *q, VipsPel **p ) @@ -743,7 +743,7 @@ vips_combine_pixels_3float( VipsComposite *composite, *((v4f *) tq) = R; tq[3] = B[3]; } -#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/ +#endif /*HAVE_VECTOR_SHUFFLE*/ static int vips_composite_gen( VipsRegion *output_region, @@ -773,12 +773,12 @@ vips_composite_gen( VipsRegion *output_region, for( x = 0; x < r->width; x++ ) { switch( input_regions[0]->im->BandFmt ) { case VIPS_FORMAT_FLOAT: -#ifdef HAVE_VAR_ATTRIBUTE_VECTOR_SIZE +#ifdef HAVE_VECTOR_SHUFFLE if( composite->bands == 3 ) vips_combine_pixels_3float( composite, q, p ); else -#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/ +#endif /*HAVE_VECTOR_SHUFFLE*/ vips_combine_pixels( composite, q, p ); break;