[Piglit] [PATCH 4/5] sparse-samplers: Increase precision of expected color.
Fabian Bieler
fabianbieler at fastmail.fm
Fri May 3 02:06:21 PDT 2013
The expected green and blue channels at the probed pixel are 0.51. with the
previous approximated value of 0.5 and the default absolute piglit tolerance of
0.01 the expected value was on the edge of the tolerated range.
---
tests/spec/arb_fragment_program/sparse-samplers.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tests/spec/arb_fragment_program/sparse-samplers.c b/tests/spec/arb_fragment_program/sparse-samplers.c
index dc70eed..40d2408 100644
--- a/tests/spec/arb_fragment_program/sparse-samplers.c
+++ b/tests/spec/arb_fragment_program/sparse-samplers.c
@@ -64,13 +64,20 @@ test_linear(int x)
float average[4];
int i;
- /* Figure out what the blended middle pixel of the magnified
- * texture ought to be. Given a default piglit tolerance of
- * .02, the texture needs to be at least around 64x64 for this
- * to probably work out.
+ /* For an even framebuffer size we don't sample exactly at the center
+ * of the texture. The centers of the texels are a quarter framebuffer
+ * (25 pixels) to the sides of the center of the framebuffer. We sample
+ * half a pixel off the center of the framebuffer. The lerp factors for
+ * the expected color are thus 0.5 +/- 0.5/25.
*/
+ const float offset = 1.0f/(float)texrect_w;
+ const float lfm = 0.5f - offset;
+ const float lfp = 0.5f + offset;
for (i = 0; i < 4; i++)
- average[i] = (r[i] + g[i] + b[i] + w[i]) / 4;
+ average[i] = (r[i] *lfm*lfm +
+ g[i] *lfm*lfp +
+ b[i] *lfp*lfm +
+ w[i] *lfp*lfp);
return (piglit_probe_pixel_rgba(x,
0,
--
1.8.1.2
More information about the Piglit
mailing list