add a configure test for vector_size

This commit is contained in:
John Cupitt 2017-10-02 08:17:11 +01:00
parent 645618592c
commit 99568356ab
3 changed files with 10 additions and 1 deletions

View File

@ -259,6 +259,7 @@ 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

View File

@ -172,7 +172,7 @@ from gi.repository import Vips
You can now use all of the libvips introspection machinery, as noted above.
</para>
<para>
Unfortunately g-o-i has some strong disadvantages. It is not very portable, since you will need a g-o-i layer for whatever platform you are targetting, it does not cross-compile well since typelibs include a lot of very-low level data (such as exact structure layouts), and installation for your users is likely to be tricky.
Unfortunately g-o-i has some strong disadvantages. It is not very portable, since you will need a g-o-i layer for whatever platform you are targetting; it does not cross-compile well, since typelibs include a lot of very-low level data (such as exact structure layouts); and installation for your users is likely to be tricky.
</para>
<para>
If you have a choice, I would recommend simply using FFI.

View File

@ -487,6 +487,9 @@ vips_composite_blend_mul( VipsBlendMode mode,
B[bands] = aR;
}
/* We have a vector path with gcc's vector attr.
*/
#ifdef HAVE_VAR_ATTRIBUTE_VECTOR_SIZE
/* A vector of four floats.
*/
typedef float v4f __attribute__((vector_size(4 * sizeof(float))));
@ -674,6 +677,7 @@ vips_composite_blend_mul_3float( VipsBlendMode mode, v4f &B, float *A_memory )
B[3] = aR;
}
#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/
/* A is the new pixel coming in, B is the double pixel we are accumulating.
*/
@ -716,6 +720,7 @@ static void vips_combine_pixels( VipsComposite *composite,
tq[bands] = B[bands];
}
#ifdef HAVE_VAR_ATTRIBUTE_VECTOR_SIZE
static void
vips_combine_pixels_3float( VipsComposite *composite,
VipsPel *q, VipsPel **p )
@ -738,6 +743,7 @@ vips_combine_pixels_3float( VipsComposite *composite,
*((v4f *) tq) = R;
tq[3] = B[3];
}
#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/
static int
vips_composite_gen( VipsRegion *output_region,
@ -767,10 +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
if( composite->bands == 3 )
vips_combine_pixels_3float( composite,
q, p );
else
#endif /*HAVE_VAR_ATTRIBUTE_VECTOR_SIZE*/
vips_combine_pixels<float>( composite,
q, p );
break;