[Mesa-dev] [PATCH 3/3][RFC v2] mesa/main: Clamp rgba with streamed sse
Erik Faye-Lund
kusmabite at gmail.com
Wed Nov 12 05:01:11 PST 2014
On Tue, Nov 4, 2014 at 1:05 PM, Juha-Pekka Heikkila
<juhapekka.heikkila at gmail.com> wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at 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);
return here, to avoid the latter ifdef?
More information about the mesa-dev
mailing list