[Piglit] [PATCH 2/2] point-line-no-cull: probe two pixels instead of one

Brian Paul brianp at vmware.com
Fri Mar 9 09:54:36 PST 2012


If the OpenGL max line width is really only one pixel (despite requesting
width=3) the black_pixel() probe function could miss the line because of
rasterization differences.  We'd report a false failure in that case.
Probing two pixels instead of one avoids that issue.
---
 tests/general/point-line-no-cull.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/general/point-line-no-cull.c b/tests/general/point-line-no-cull.c
index 9c7dd35..14d56ce 100644
--- a/tests/general/point-line-no-cull.c
+++ b/tests/general/point-line-no-cull.c
@@ -37,17 +37,23 @@ int piglit_width = 120, piglit_height = 120;
 int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
 
 
-/** test if the pixel at (x,y) is black */
+/** Test if the pixels at (x,y) and (x,y+1) are black.
+ * We test two pixels to be sure we hit the primitive we drew.  We could
+ * be off by one and miss the line if it's only one pixel wide otherwise.
+ */
 static GLboolean
 black_pixel(float x, float y)
 {
-   GLfloat pixel[4];
+   GLfloat pixel[2][4];
 
-   glReadPixels((int) x, (int) y, 1, 1, GL_RGB, GL_FLOAT, pixel);
+   glReadPixels((int) x, (int) (y-0.5), 1, 2, GL_RGB, GL_FLOAT, pixel);
 
-   if (pixel[0] == 0.0 &&
-       pixel[1] == 0.0 &&
-       pixel[2] == 0.0)
+   if (pixel[0][0] == 0.0 &&
+       pixel[0][1] == 0.0 &&
+       pixel[0][2] == 0.0 &&
+       pixel[1][0] == 0.0 &&
+       pixel[1][1] == 0.0 &&
+       pixel[2][2] == 0.0)
       return GL_TRUE;
    else
       return GL_FALSE;
-- 
1.7.3.4



More information about the Piglit mailing list