diff options
author | Brian Paul <[email protected]> | 2010-03-11 16:23:36 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-03-11 16:23:37 -0700 |
commit | c72a3b4f2ffe0673e753ad144d1b5557a42c670f (patch) | |
tree | d058345d1ece0c2889dd8f9df40f8e96f918245b /src/gallium/drivers | |
parent | 9ffdc78d1a308bb21a8627abb7bfc9da8abd2f81 (diff) |
softpipe: further tighen up sample_cube()
The code can fairly easily be translated to llvm...
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 66 |
1 files changed, 21 insertions, 45 deletions
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; } } } |