From de2afd8688ceb45013d15be7c6e0995199b80e5a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 8 Mar 2009 13:49:57 -0600 Subject: swrast: do texture sampling/combining in floating point The code's cleaner and a step toward supporting float-valued texture sampling. Some optimizations for common cases can be added and re-enabled... --- src/mesa/swrast/s_fragprog.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/mesa/swrast/s_fragprog.c') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index ae1dea16a0..5f032bbd69 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -37,20 +37,17 @@ * and return results in 'colorOut'. */ static INLINE void -swizzle_texel(const GLchan texel[4], GLfloat colorOut[4], GLuint swizzle) +swizzle_texel(const GLfloat texel[4], GLfloat colorOut[4], GLuint swizzle) { if (swizzle == SWIZZLE_NOOP) { - colorOut[0] = CHAN_TO_FLOAT(texel[0]); - colorOut[1] = CHAN_TO_FLOAT(texel[1]); - colorOut[2] = CHAN_TO_FLOAT(texel[2]); - colorOut[3] = CHAN_TO_FLOAT(texel[3]); + COPY_4V(colorOut, texel); } else { GLfloat vector[6]; - vector[SWIZZLE_X] = CHAN_TO_FLOAT(texel[0]); - vector[SWIZZLE_Y] = CHAN_TO_FLOAT(texel[1]); - vector[SWIZZLE_Z] = CHAN_TO_FLOAT(texel[2]); - vector[SWIZZLE_W] = CHAN_TO_FLOAT(texel[3]); + vector[SWIZZLE_X] = texel[0]; + vector[SWIZZLE_Y] = texel[1]; + vector[SWIZZLE_Z] = texel[2]; + vector[SWIZZLE_W] = texel[3]; vector[SWIZZLE_ZERO] = 0.0F; vector[SWIZZLE_ONE] = 1.0F; colorOut[0] = vector[GET_SWZ(swizzle, 0)]; @@ -73,7 +70,7 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, if (texObj) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLchan rgba[4]; + GLfloat rgba[4]; lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); @@ -108,7 +105,7 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], const GLfloat texW = (GLfloat) texImg->WidthScale; const GLfloat texH = (GLfloat) texImg->HeightScale; GLfloat lambda; - GLchan rgba[4]; + GLfloat rgba[4]; lambda = _swrast_compute_lambda(texdx[0], texdy[0], /* ds/dx, ds/dy */ texdx[1], texdy[1], /* dt/dx, dt/dy */ -- cgit v1.2.3