Module: Mesa
Branch: master
Commit: eae4c6df8ded2354f3f1e034ddef2177988ce688
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eae4c6df8ded2354f3f1e034ddef2177988ce688

Author: Gert Wollny <[email protected]>
Date:   Mon Jul 15 13:46:53 2019 +0200

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 <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>

---

 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);
 }
 
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to