<div dir="ltr">You'll need to add this to all.py<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 22, 2015 at 10:05 AM, <span dir="ltr"><<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Roland Scheidegger <<a href="mailto:sroland@vmware.com">sroland@vmware.com</a>><br>
<br>
This test is quite mean to mesa's draw pipe. llvmpipe/softpipe fail even if<br>
front and back fill mode is the same (for points and aa lines as the latter<br>
get rendered as tris finally again). Most everything else fails too, before<br>
the driver dies in a fire...<br>
---<br>
tests/general/CMakeLists.gl.txt | 1 +<br>
tests/general/polygon-mode-facing.c | 381 ++++++++++++++++++++++++++++++++++++<br>
2 files changed, 382 insertions(+)<br>
create mode 100644 tests/general/polygon-mode-facing.c<br>
<br>
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt<br>
index 298f59c..8f291db 100644<br>
--- a/tests/general/CMakeLists.gl.txt<br>
+++ b/tests/general/CMakeLists.gl.txt<br>
@@ -86,6 +86,7 @@ piglit_add_executable (pbo-teximage-tiling-2 pbo-teximage-tiling-2.c)<br>
piglit_add_executable (point-line-no-cull point-line-no-cull.c)<br>
piglit_add_executable (point-vertex-id point-vertex-id.c)<br>
piglit_add_executable (polygon-mode-offset polygon-mode-offset.c)<br>
+piglit_add_executable (polygon-mode-facing polygon-mode-facing.c)<br>
piglit_add_executable (polygon-mode polygon-mode.c)<br>
piglit_add_executable (polygon-offset polygon-offset.c)<br>
piglit_add_executable (primitive-restart primitive-restart.c)<br>
diff --git a/tests/general/polygon-mode-facing.c b/tests/general/polygon-mode-facing.c<br>
new file mode 100644<br>
index 0000000..f107616<br>
--- /dev/null<br>
+++ b/tests/general/polygon-mode-facing.c<br>
@@ -0,0 +1,381 @@<br>
+/*<br>
+ * Copyright (c) 2011 VMware, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * on the rights to use, copy, modify, merge, publish, distribute, sub<br>
+ * license, and/or sell copies of the Software, and to permit persons to whom<br>
+ * the Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br>
+ * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS<br>
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br>
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br>
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
+ * SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * Tests glPolygonMode wrt facing.<br>
+ * Roland Scheidegger<br>
+ * December 2015<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 20;<br>
+<br>
+ config.window_width = 400;<br>
+ config.window_height = 100;<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const char *TestName = "polygon-mode-facing";<br>
+<br>
+static const char *vstext =<br>
+ "#version 130\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"<br>
+ "}\n";<br>
+<br>
+static const char *fstext =<br>
+ "#version 130\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " vec4 color = gl_FrontFacing ? vec4(1.0, 0.0, 0.0, 1.0)\n"<br>
+ " : vec4(0.0, 1.0, 0.0, 1.0);\n"<br>
+ " gl_FragColor = color;\n"<br>
+ "}\n";<br>
+<br>
+<br>
+static const GLfloat Colors[2][4] = {<br>
+ /* back color */<br>
+ {0, 1, 0, 1},<br>
+ /* front color */<br>
+ {1, 0, 0, 1},<br>
+};<br>
+<br>
+static const GLfloat Positions[16][2] = {<br>
+ {10, 10},<br>
+ {90, 10},<br>
+ {90, 90},<br>
+ {10, 90},<br>
+<br>
+ {190, 10},<br>
+ {110, 10},<br>
+ {110, 90},<br>
+ {190, 90},<br>
+<br>
+ {290, 10},<br>
+ {210, 10},<br>
+ {210, 90},<br>
+ {290, 90},<br>
+<br>
+ {310, 10},<br>
+ {390, 10},<br>
+ {390, 90},<br>
+ {310, 90},<br>
+};<br>
+<br>
+static const char *<br>
+get_mode_str(GLenum mode)<br>
+{<br>
+ switch (mode) {<br>
+ case GL_POINT:<br>
+ return "GL_POINT";<br>
+ case GL_LINE:<br>
+ return "GL_LINE";<br>
+ case GL_FILL:<br>
+ return "GL_FILL";<br>
+ default:<br>
+ return NULL;<br>
+ }<br>
+}<br>
+<br>
+<br>
+static GLenum<br>
+get_prim_mode(GLenum mode)<br>
+{<br>
+ switch (mode) {<br>
+ case GL_POINT:<br>
+ return GL_POINTS;<br>
+ case GL_LINE:<br>
+ return GL_LINE_LOOP;<br>
+ case GL_FILL:<br>
+ return GL_QUADS;<br>
+ default:<br>
+ return 0;<br>
+ }<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Probe a 3x3 pixel region to see if any of the pixels matches the<br>
+ * expected color.<br>
+ */<br>
+static GLboolean<br>
+probe_region(float px, float py, const GLfloat expectedColor[4])<br>
+{<br>
+ GLfloat img[3][3][4];<br>
+ int i, j;<br>
+<br>
+ glReadPixels(px-1, py-1, 3, 3, GL_RGBA, GL_FLOAT, img);<br>
+<br>
+ /* see if any of the pixels matches the expected color */<br>
+ for (i = 0; i < 3; i++) {<br>
+ for (j = 0; j < 3; j++) {<br>
+ if (img[i][j][0] == expectedColor[0] &&<br>
+ img[i][j][1] == expectedColor[1] &&<br>
+ img[i][j][2] == expectedColor[2]) {<br>
+ return GL_TRUE;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ return GL_FALSE;<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Examine the pixels drawn by a rect using the four vertex positions<br>
+ * and determine if it was drawn filled, outlined, or as four points.<br>
+ * \return GL_FILL, GL_LINE, GL_POINT or GL_NONE<br>
+ */<br>
+static GLenum<br>
+identify_primitive(const GLfloat positions[4][2],<br>
+ const GLfloat expectedColor[4])<br>
+{<br>
+ /* center */<br>
+ float cx = (positions[0][0] + positions[2][0]) / 2.0;<br>
+ float cy = (positions[0][1] + positions[2][1]) / 2.0;<br>
+ /* left edge */<br>
+ float lx = MIN2(positions[0][0], positions[2][0]);<br>
+ float ly = cy;<br>
+ /* right edge */<br>
+ float rx = MAX2(positions[0][0], positions[2][0]);<br>
+ float ry = cy;<br>
+ /* bottom edge */<br>
+ float bx = cx;<br>
+ float by = positions[0][1];<br>
+ /* top edge */<br>
+ float tx = cx;<br>
+ float ty = positions[1][1];<br>
+<br>
+ /* probe center */<br>
+ if (probe_region(cx, cy, expectedColor))<br>
+ return GL_FILL;<br>
+<br>
+ /* probe left edge */<br>
+ if (probe_region(lx, ly, expectedColor)) {<br>
+ /* and bottom edge */<br>
+ if (probe_region(bx, by, expectedColor)) {<br>
+ /* and right edge */<br>
+ if (probe_region(rx, ry, expectedColor)) {<br>
+ /* and top edge */<br>
+ if (probe_region(tx, ty, expectedColor)) {<br>
+ return GL_LINE;<br>
+ }<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ /* probe lower-left corner */<br>
+ if (probe_region(lx, by, expectedColor)) {<br>
+ /* probe lower-right corner */<br>
+ if (probe_region(rx, by, expectedColor)) {<br>
+ /* probe top-left corner */<br>
+ if (probe_region(lx, ty, expectedColor)) {<br>
+ /* probe top-right corner */<br>
+ if (probe_region(rx, ty, expectedColor)) {<br>
+ return GL_POINT;<br>
+ }<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ return GL_NONE;<br>
+}<br>
+<br>
+<br>
+<br>
+static GLboolean<br>
+test_combo(GLenum frontMode, GLenum backMode)<br>
+{<br>
+ GLenum frontPrim = get_prim_mode(frontMode);<br>
+ GLenum backPrim = get_prim_mode(backMode);<br>
+ GLboolean pass = GL_TRUE;<br>
+ GLenum expectedPrims[4];<br>
+ int i;<br>
+ int expectFrontColorRef[4] = {1,1,1,1};<br>
+<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ /*<br>
+ * Drawing 4 quads. The first and 3rd should always be red (front facing).<br>
+ * The 2nd and 4th are green with FILL backMode (lines/points are always<br>
+ * front facing).<br>
+ */<br>
+ if (backMode == GL_FILL) {<br>
+ expectFrontColorRef[1] = expectFrontColorRef[3] = 0;<br>
+ }<br>
+<br>
+ /* Draw reference image */<br>
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);<br>
+ glFrontFace(GL_CCW);<br>
+ glDrawArrays(frontPrim, 0, 4);<br>
+ glDrawArrays(backPrim, 4, 4);<br>
+ glFrontFace(GL_CW);<br>
+ glDrawArrays(frontPrim, 8, 4);<br>
+ glDrawArrays(backPrim, 12, 4);<br>
+<br>
+ /* determine what kind of primitives were drawn */<br>
+ for (i = 0; i < 4; i++) {<br>
+ bool err = false;<br>
+ expectedPrims[i] = identify_primitive(Positions[4*i], Colors[expectFrontColorRef[i]]);<br>
+ if (i & 1) {<br>
+ if (expectedPrims[i] != backMode) {<br>
+ err = true;<br>
+ }<br>
+ }<br>
+ else {<br>
+ if (expectedPrims[i] != frontMode) {<br>
+ err = true;<br>
+ }<br>
+ }<br>
+ if (err) {<br>
+ /* we didn't get the expected reference primitive */<br>
+ fprintf(stderr,<br>
+ "%s: reference drawing failed for frontPrim=%s, backPrim=%s\n",<br>
+ TestName, get_mode_str(frontMode), get_mode_str(backMode));<br>
+ return GL_FALSE;<br>
+ }<br>
+ }<br>
+<br>
+ /* Draw test image */<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+ glPolygonMode(GL_FRONT, frontMode);<br>
+ glPolygonMode(GL_BACK, backMode);<br>
+ glFrontFace(GL_CCW);<br>
+ glDrawArrays(GL_QUADS, 0, 8);<br>
+ glFrontFace(GL_CW);<br>
+ glDrawArrays(GL_QUADS, 8, 8);<br>
+<br>
+ /* check that these prims match expectations */<br>
+ /*<br>
+ * The first and 3rd should always be red (front-facing), the 2nd and 4th<br>
+ * green (back-facing).<br>
+ */<br>
+ for (i = 0; i < 4; i++) {<br>
+ GLenum prim = identify_primitive(&Positions[4 * i], Colors[!(i % 2)]);<br>
+ if (prim != expectedPrims[i]) {<br>
+ fprintf(stderr, "%s: glPolygonMode(front=%s, back=%s) failed\n",<br>
+ TestName, get_mode_str(frontMode), get_mode_str(backMode));<br>
+ pass = GL_FALSE;<br>
+ }<br>
+ }<br>
+<br>
+ piglit_present_results();<br>
+<br>
+ return pass;<br>
+}<br>
+<br>
+<br>
+static GLboolean<br>
+test_polygonmode(void)<br>
+{<br>
+ GLenum pass = GL_TRUE;<br>
+<br>
+ glVertexPointer(2, GL_FLOAT, 0, Positions);<br>
+ glEnableClientState(GL_VERTEX_ARRAY);<br>
+<br>
+ /*<br>
+ * First test with same front/back mode.<br>
+ * Those are probably more important to get right...<br>
+ */<br>
+ if (!test_combo(GL_FILL, GL_FILL))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_POINT, GL_POINT))<br>
+ pass = GL_FALSE;<br>
+<br>
+ /*<br>
+ * Be extra mean to mesa draw stage interactions turning lines back<br>
+ * to tris...<br>
+ */<br>
+ glEnable(GL_LINE_SMOOTH);<br>
+<br>
+ if (!test_combo(GL_LINE, GL_LINE))<br>
+ pass = GL_FALSE;<br>
+<br>
+ glDisable(GL_LINE_SMOOTH);<br>
+<br>
+ if (!test_combo(GL_FILL, GL_POINT))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_POINT, GL_LINE))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_POINT, GL_FILL))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_LINE, GL_FILL))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_LINE, GL_POINT))<br>
+ pass = GL_FALSE;<br>
+<br>
+<br>
+ /*<br>
+ * Be really mean to mesa draw stage interactions turning lines back<br>
+ * to tris...<br>
+ */<br>
+ glEnable(GL_LINE_SMOOTH);<br>
+<br>
+ if (!test_combo(GL_FILL, GL_LINE))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_POINT, GL_LINE))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_LINE, GL_FILL))<br>
+ pass = GL_FALSE;<br>
+<br>
+ if (!test_combo(GL_LINE, GL_POINT))<br>
+ pass = GL_FALSE;<br>
+<br>
+ return pass;<br>
+}<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ if (!test_polygonmode())<br>
+ return PIGLIT_FAIL;<br>
+<br>
+ return PIGLIT_PASS;<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ GLuint prog;<br>
+ piglit_require_GLSL_version(130);<br>
+ piglit_ortho_projection(piglit_width, piglit_height, false);<br>
+ prog = piglit_build_simple_program(vstext, fstext);<br>
+ glUseProgram(prog);<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div>