From eae4c6df8ded2354f3f1e034ddef2177988ce688 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 15 Jul 2019 13:46:53 +0200 Subject: [PATCH] softpipe: Correct repeat-mirror evaluation when mirroring the texture corrdinates the indices must be mirrored as well and the half pixel shift must be applied in reverse. Fixes a number of tests from: dEQP-GLES31.functional.texture.gather.offset.* dEQP-GLES31.functional.texture.gather.offsets.* Signed-off-by: Gert Wollny Reviewed-by: Roland Scheidegger --- src/gallium/drivers/softpipe/sp_tex_sample.c | 24 ++++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 45d4eda5377..a3a047b9502 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -333,20 +333,34 @@ wrap_linear_mirror_repeat(float s, unsigned size, int offset, { int flr; float u; + bool no_mirror; s += (float)offset / size; flr = util_ifloor(s); + no_mirror = !(flr & 1); + u = frac(s); - if (flr & 1) + if (no_mirror) { + u = u * size - 0.5F; + } else { u = 1.0F - u; - u = u * size - 0.5F; + u = u * size + 0.5F; + } + *icoord0 = util_ifloor(u); - *icoord1 = *icoord0 + 1; + *icoord1 = (no_mirror) ? *icoord0 + 1 : *icoord0 - 1; + if (*icoord0 < 0) - *icoord0 = 0; + *icoord0 = 1 + *icoord0; + if (*icoord0 >= (int) size) + *icoord0 = size - 1; + if (*icoord1 >= (int) size) *icoord1 = size - 1; - *w = frac(u); + if (*icoord1 < 0) + *icoord1 = 1 + *icoord1; + + *w = (no_mirror) ? frac(u) : frac(1.0f - u); } -- 2.30.2