From 7d5c8d3589633eb8f5ee760faa5c0ba950db44b9 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 19 Apr 2019 09:26:49 +0200 Subject: [PATCH] softpipe: evaluate cube the faces on a per sample bases Now that the LOD is evaluated up front the cube faces can also be evauate on a per sample basis instead of using the quad. This fixes a large number of deqp gles 3 and 31 cube texture tests. Signed-off-by: Gert Wollny Reviewed-by: Roland Scheidegger --- src/gallium/drivers/softpipe/sp_tex_sample.c | 40 ++++++++------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 41bd57c9241..a4470e6cb07 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -3253,45 +3253,36 @@ convert_cube(const struct sp_sampler_view *sp_sview, * deriviates to compute the LOD. Doing so (near cube edges * anyway) gives us pretty much random values. */ - { - /* use the average of the four pixel's texcoords to choose the face */ - const float rx = 0.25F * (s[0] + s[1] + s[2] + s[3]); - const float ry = 0.25F * (t[0] + t[1] + t[2] + t[3]); - const float rz = 0.25F * (p[0] + p[1] + p[2] + p[3]); + for (j = 0; j < TGSI_QUAD_SIZE; j++) { + const float rx = s[j], ry = t[j], rz = p[j]; const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); if (arx >= ary && arx >= arz) { const float sign = (rx >= 0.0F) ? 1.0F : -1.0F; const uint face = (rx >= 0.0F) ? PIPE_TEX_FACE_POS_X : PIPE_TEX_FACE_NEG_X; - for (j = 0; j < TGSI_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; - faces[j] = face; - } + const float ima = -0.5F / fabsf(s[j]); + ssss[j] = sign * p[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + faces[j] = face; } else if (ary >= arx && ary >= arz) { const float sign = (ry >= 0.0F) ? 1.0F : -1.0F; const uint face = (ry >= 0.0F) ? PIPE_TEX_FACE_POS_Y : PIPE_TEX_FACE_NEG_Y; - for (j = 0; j < TGSI_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; - faces[j] = face; - } + const float ima = -0.5F / fabsf(t[j]); + ssss[j] = -s[j] * ima + 0.5F; + tttt[j] = sign * -p[j] * ima + 0.5F; + faces[j] = face; } else { const float sign = (rz >= 0.0F) ? 1.0F : -1.0F; const uint face = (rz >= 0.0F) ? PIPE_TEX_FACE_POS_Z : PIPE_TEX_FACE_NEG_Z; - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - const float ima = -0.5F / fabsf(p[j]); - ssss[j] = sign * -s[j] * ima + 0.5F; - tttt[j] = t[j] * ima + 0.5F; - faces[j] = face; - } + const float ima = -0.5F / fabsf(p[j]); + ssss[j] = sign * -s[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + faces[j] = face; } } } @@ -3571,9 +3562,10 @@ softpipe_get_lambda_func(const struct pipe_sampler_view *view, case PIPE_TEXTURE_2D: case PIPE_TEXTURE_2D_ARRAY: case PIPE_TEXTURE_RECT: + return compute_lambda_2d; case PIPE_TEXTURE_CUBE: case PIPE_TEXTURE_CUBE_ARRAY: - return compute_lambda_2d; + return compute_lambda_cube; case PIPE_TEXTURE_3D: return compute_lambda_3d; default: -- 2.30.2