From: Brian Paul Date: Thu, 11 Mar 2010 23:23:36 +0000 (-0700) Subject: softpipe: further tighen up sample_cube() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c72a3b4f2ffe0673e753ad144d1b5557a42c670f;p=mesa.git softpipe: further tighen up sample_cube() The code can fairly easily be translated to llvm... --- diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 1ce21b6ca05..fa9e19b282b 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -1647,57 +1647,33 @@ sample_cube(struct tgsi_sampler *tgsi_sampler, const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); if (arx >= ary && arx >= arz) { - if (rx >= 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(s[j]); - ssss[j] = (-p[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_X; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(s[j]); - ssss[j] = ( p[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_X; - } + float sign = (rx >= 0.0F) ? 1.0F : -1.0F; + uint face = (rx >= 0.0F) ? PIPE_TEX_FACE_POS_X : PIPE_TEX_FACE_NEG_X; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5F / fabsf(s[j]); + ssss[j] = sign * p[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + samp->faces[j] = face; } } else if (ary >= arx && ary >= arz) { - if (ry >= 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(t[j]); - ssss[j] = (s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (p[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_Y; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(t[j]); - ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-p[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_Y; - } + float sign = (ry >= 0.0F) ? 1.0F : -1.0F; + uint face = (ry >= 0.0F) ? PIPE_TEX_FACE_POS_Y : PIPE_TEX_FACE_NEG_Y; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5F / fabsf(t[j]); + ssss[j] = -s[j] * ima + 0.5F; + tttt[j] = sign * -p[j] * ima + 0.5F; + samp->faces[j] = face; } } else { - if (rz > 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(p[j]); - ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_Z; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(p[j]); - ssss[j] = (-s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_Z; - } + float sign = (rz >= 0.0F) ? 1.0F : -1.0F; + uint face = (rz >= 0.0F) ? PIPE_TEX_FACE_POS_Z : PIPE_TEX_FACE_NEG_Z; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5 / fabsf(p[j]); + ssss[j] = sign * -s[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + samp->faces[j] = face; } } }