[Piglit] [PATCH RESEND] Add a simple edge flag test

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Sep 22 18:31:46 PDT 2011


On Thu, Sep 22, 2011 at 03:28:31PM -0700, Ian Romanick wrote:
> On 09/20/2011 10:32 PM, Yuanhan Liu wrote:
> >Signed-off-by: Yuanhan Liu<yuanhan.liu at linux.intel.com>
> >---
> >  tests/all.tests                 |    1 +
> >  tests/general/CMakeLists.gl.txt |    1 +
> >  tests/general/edge-flag.c       |   82 +++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 84 insertions(+), 0 deletions(-)
> >  create mode 100644 tests/general/edge-flag.c
> >
> >diff --git a/tests/all.tests b/tests/all.tests
> >index 03dcd59..ccb2b56 100644
> >--- a/tests/all.tests
> >+++ b/tests/all.tests
> >@@ -231,6 +231,7 @@ add_plain_test(general, 'draw-instanced-divisor')
> >  add_plain_test(general, 'draw-vertices')
> >  add_plain_test(general, 'draw-vertices-half-float')
> >  add_plain_test(general, 'early-z')
> >+add_plain_test(general, 'edge-flag')
> 
> White space

I don't know. The patch style looks fine on my side, both on the patch I
send. Anyway, I just copied the above line and pasted to a new line then
change 'early-z' to 'edge-flag'.

> 
> >  add_plain_test(general, 'fog-modes')
> >  add_plain_test(general, 'fragment-center')
> >  add_plain_test(general, 'framebuffer-srgb')
> >diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
> >index d6e73cf..5e3f97f 100644
> >--- a/tests/general/CMakeLists.gl.txt
> >+++ b/tests/general/CMakeLists.gl.txt
> >@@ -43,6 +43,7 @@ add_executable (draw-instanced-divisor draw-instanced-divisor.c)
> >  add_executable (draw-sync draw-sync.c)
> >  add_executable (draw-vertices draw-vertices.c)
> >  add_executable (draw-vertices-half-float draw-vertices-half-float.c)
> >+add_executable (edge-flag edge-flag.c)
> 
> White space
> 
> >  add_executable (fog-modes fog-modes.c)
> >  IF (UNIX)
> >  	target_link_libraries (fog-modes m)
> >diff --git a/tests/general/edge-flag.c b/tests/general/edge-flag.c
> >new file mode 100644
> >index 0000000..36f2dd2
> >--- /dev/null
> >+++ b/tests/general/edge-flag.c
> >@@ -0,0 +1,82 @@
> >+/*
> >+ * Copyright © 2011 Intel Corporation
> >+ *
> >+ * Permission is hereby granted, free of charge, to any person obtaining a
> >+ * copy of this software and associated documentation files (the "Software"),
> >+ * to deal in the Software without restriction, including without limitation
> >+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> >+ * and/or sell copies of the Software, and to permit persons to whom the
> >+ * Software is furnished to do so, subject to the following conditions:
> >+ *
> >+ * The above copyright notice and this permission notice (including the next
> >+ * paragraph) shall be included in all copies or substantial portions of the
> >+ * Software.
> >+ *
> >+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> >+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> >+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> >+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> >+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> >+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> >+ * IN THE SOFTWARE.
> >+ *
> >+ * Authors:
> >+ *    Yuanhan Liu<yuanhan.liu at linux.intel.com>
> >+ */
> >+
> >+#include "piglit-util.h"
> >+
> >+int piglit_width = 100, piglit_height = 100;
> >+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
> >+
> >+struct edge_flag_test {
> >+	float x;
> >+	float y;
> >+	GLboolean edage_flag;
> >+};
> >+
> >+enum piglit_result
> >+piglit_display(void)
> >+{
> >+	int err = 0;
> >+	GLfloat blue[3] = {0.0, 0.0, 1.0};
> >+	GLfloat black[3] = {0.0, 0.0, 0.0};
> >+	struct edge_flag_test test[] = {
> >+		{20, 20, GL_FALSE},
> >+		{20, 60, GL_FALSE},
> >+		{60, 20, GL_TRUE},
> >+	};
> >+
> >+	glClearColor(0.0, 0.0, 0.0, 1.0);
> >+	glClear(GL_COLOR_BUFFER_BIT);
> >+
> >+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> >+
> >+	glLineWidth(4);
> >+	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
> >+
> >+	glColor3fv(blue);
> 
> Move everything above, except the call to glClear, to piglit_init.

Got it. Thanks.

> 
> >+	glBegin(GL_TRIANGLES);
> >+	  glEdgeFlag(test[0].edage_flag);
> >+	  glVertex2f(test[0].x, test[0].y);
> >+
> >+	  glEdgeFlag(test[1].edage_flag);
> >+	  glVertex2f(test[1].x, test[1].y);
> >+
> >+	  glEdgeFlag(test[2].edage_flag);
> >+	  glVertex2f(test[2].x, test[2].y);
> >+	glEnd();
> 
> My recollection is that the GL rasterization rules are loose enough
> that this test could fail on valid implementations.  I think that
> you'll need to probe two pixels to (x +/- 0.5 for vertical lines, y
> +/- 0.5 for horizontal).

Thanks for this info. But I have set the line width to 4. I guess it
would be enough to make sure the point we want to probe is rasterized.
Right?

BTW, I could set the line width a bit bigger, like 10. Anyway, it's a
test case.

Is this OK to you?

> 
> >+
> >+	err += !piglit_probe_pixel_rgb(40, 20, blue);
> >+	err += !piglit_probe_pixel_rgb(20, 40, black);
> >+	err += !piglit_probe_pixel_rgb(40, 40, black);
> 
> The usual piglit idiom is:
> 
> 	bool pass;
> 
> 	...
> 
> 	pass = piglit_probe_pixel_rgb(40, 20, blue);
> 	pass = piglit_probe_pixel_rgb(20, 40, black) && pass;
> 	pass = piglit_probe_pixel_rgb(40, 40, black) && pass;
> 
> 	...
> 
> 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;

Ok, will change that.

Thanks,
Yuanahan Liu
> 
> >+
> >+	glutSwapBuffers();
> >+
> >+	return err ? PIGLIT_FAIL : PIGLIT_PASS;
> >+}
> >+
> >+void
> >+piglit_init(int argc, char **argv)
> >+{
> >+}


More information about the Piglit mailing list