summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGert Wollny <[email protected]>2019-07-15 13:46:53 +0200
committerGert Wollny <[email protected]>2019-07-18 05:47:23 +0200
commiteae4c6df8ded2354f3f1e034ddef2177988ce688 (patch)
treec61d55c9e30faa41cdfc937ef2b053d7c1bd356c /src
parentfff624fca42ae39322e8f82c262e1b2bb33eea79 (diff)
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]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c24
1 files 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);
}