test for C++ vector arithmetic
clang seems to have shuffle but not mixed vector and scalar
This commit is contained in:
parent
5f16c676db
commit
9f62b963b9
23
configure.ac
23
configure.ac
|
@ -365,6 +365,29 @@ if test x$ax_cv_have_var_attribute_vector_size = x"yes"; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# we also need to be able to mix vector and scalar arithmetic
|
||||||
|
if test x$have_vector_shuffle = x"yes"; then
|
||||||
|
AC_MSG_CHECKING([for C++ vector arithmetic])
|
||||||
|
AC_LANG_PUSH([C++])
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
typedef float v4f __attribute__((vector_size(4 * sizeof(float))));
|
||||||
|
],[
|
||||||
|
v4f f = {1, 2, 3, 4}; f *= 12.0;
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
have_vector_arith=yes
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
have_vector_arith=no
|
||||||
|
])
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
|
||||||
|
if test x$have_vector_arith = x"yes"; then
|
||||||
|
AC_DEFINE_UNQUOTED(HAVE_VECTOR_ARITH, 1,
|
||||||
|
[define if your C++ can mix vector and scalar arithmetic])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_MMAP
|
AC_FUNC_MMAP
|
||||||
|
|
|
@ -489,7 +489,7 @@ vips_composite_blend_mul( VipsBlendMode mode,
|
||||||
|
|
||||||
/* We have a vector path with gcc's vector attr.
|
/* We have a vector path with gcc's vector attr.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_VECTOR_SHUFFLE
|
#ifdef HAVE_VECTOR_ARITH
|
||||||
/* A vector of four floats.
|
/* A vector of four floats.
|
||||||
*/
|
*/
|
||||||
typedef float v4f __attribute__((vector_size(4 * sizeof(float))));
|
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;
|
B[3] = aR;
|
||||||
}
|
}
|
||||||
#endif /*HAVE_VECTOR_SHUFFLE*/
|
#endif /*HAVE_VECTOR_ARITH*/
|
||||||
|
|
||||||
/* A is the new pixel coming in, B is the double pixel we are accumulating.
|
/* 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];
|
tq[bands] = B[bands];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_VECTOR_SHUFFLE
|
#ifdef HAVE_VECTOR_ARITH
|
||||||
static void
|
static void
|
||||||
vips_combine_pixels_3float( VipsComposite *composite,
|
vips_combine_pixels_3float( VipsComposite *composite,
|
||||||
VipsPel *q, VipsPel **p )
|
VipsPel *q, VipsPel **p )
|
||||||
|
@ -743,7 +743,7 @@ vips_combine_pixels_3float( VipsComposite *composite,
|
||||||
*((v4f *) tq) = R;
|
*((v4f *) tq) = R;
|
||||||
tq[3] = B[3];
|
tq[3] = B[3];
|
||||||
}
|
}
|
||||||
#endif /*HAVE_VECTOR_SHUFFLE*/
|
#endif /*HAVE_VECTOR_ARITH*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vips_composite_gen( VipsRegion *output_region,
|
vips_composite_gen( VipsRegion *output_region,
|
||||||
|
@ -773,12 +773,12 @@ vips_composite_gen( VipsRegion *output_region,
|
||||||
for( x = 0; x < r->width; x++ ) {
|
for( x = 0; x < r->width; x++ ) {
|
||||||
switch( input_regions[0]->im->BandFmt ) {
|
switch( input_regions[0]->im->BandFmt ) {
|
||||||
case VIPS_FORMAT_FLOAT:
|
case VIPS_FORMAT_FLOAT:
|
||||||
#ifdef HAVE_VECTOR_SHUFFLE
|
#ifdef HAVE_VECTOR_ARITH
|
||||||
if( composite->bands == 3 )
|
if( composite->bands == 3 )
|
||||||
vips_combine_pixels_3float( composite,
|
vips_combine_pixels_3float( composite,
|
||||||
q, p );
|
q, p );
|
||||||
else
|
else
|
||||||
#endif /*HAVE_VECTOR_SHUFFLE*/
|
#endif /*HAVE_VECTOR_ARITH*/
|
||||||
vips_combine_pixels<float>( composite,
|
vips_combine_pixels<float>( composite,
|
||||||
q, p );
|
q, p );
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue