Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com> --- src/mesa/main/pixeltransfer.c | 62 ++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 19 deletions(-)
diff --git a/src/mesa/main/pixeltransfer.c b/src/mesa/main/pixeltransfer.c index 8bbeeb8..99eed38 100644 --- a/src/mesa/main/pixeltransfer.c +++ b/src/mesa/main/pixeltransfer.c @@ -35,7 +35,8 @@ #include "pixeltransfer.h" #include "imports.h" #include "mtypes.h" - +#include "x86/common_x86_asm.h" +#include "main/x86/sse2_clamping.h" /* * Apply scale and bias factors to an array of RGBA pixels. @@ -80,25 +81,39 @@ _mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], void _mesa_map_rgba( const struct gl_context *ctx, GLuint n, GLfloat rgba[][4] ) { - const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); - const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); - const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); - const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); const GLfloat *rMap = ctx->PixelMaps.RtoR.Map; const GLfloat *gMap = ctx->PixelMaps.GtoG.Map; const GLfloat *bMap = ctx->PixelMaps.BtoB.Map; const GLfloat *aMap = ctx->PixelMaps.AtoA.Map; GLuint i; - for (i=0;i<n;i++) { - GLfloat r = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); - GLfloat g = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); - GLfloat b = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); - GLfloat a = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); - rgba[i][RCOMP] = rMap[F_TO_I(r * rscale)]; - rgba[i][GCOMP] = gMap[F_TO_I(g * gscale)]; - rgba[i][BCOMP] = bMap[F_TO_I(b * bscale)]; - rgba[i][ACOMP] = aMap[F_TO_I(a * ascale)]; + GLfloat scale[4]; + + scale[RCOMP] = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); + scale[GCOMP] = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); + scale[BCOMP] = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); + scale[ACOMP] = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); + +#if defined(USE_SSE2) + if (cpu_has_xmm2) { + _mesa_clamp_float_rgba_scale_and_map(n, rgba, rgba, 0.0F, 1.0F, scale, + rMap, gMap, bMap, aMap); } + else { +#endif + for (i=0;i<n;i++) { + GLfloat rgba_temp[4]; + rgba_temp[RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); + rgba_temp[GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); + rgba_temp[BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); + rgba_temp[ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); + rgba[i][RCOMP] = rMap[F_TO_I(rgba_temp[RCOMP] * scale[RCOMP])]; + rgba[i][GCOMP] = gMap[F_TO_I(rgba_temp[GCOMP] * scale[GCOMP])]; + rgba[i][BCOMP] = bMap[F_TO_I(rgba_temp[BCOMP] * scale[BCOMP])]; + rgba[i][ACOMP] = aMap[F_TO_I(rgba_temp[ACOMP] * scale[ACOMP])]; + } +#if defined(USE_SSE2) + } +#endif } /* @@ -179,12 +194,21 @@ _mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, /* clamping to [0,1] */ if (transferOps & IMAGE_CLAMP_BIT) { GLuint i; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); - rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); - rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); - rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); +#if defined(USE_SSE2) + if (cpu_has_xmm2) { + _mesa_streaming_clamp_float_rgba(n, rgba, rgba, 0.0F, 1.0F); + } + else { +#endif + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); + } +#if defined(USE_SSE2) } +#endif } } -- 1.8.5.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev