<div dir="ltr">Looks good overall. Just a bunch of nit-picks below...<br><br><br>On Mon, Aug 24, 2015 at 5:19 PM, Juliet Fru <span dir="ltr"><<a href="mailto:julietfru@gmail.com" target="_blank">julietfru@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
tests/all.py | 1 +<br>
tests/spec/gl-1.0/CMakeLists.gl.txt | 1 +<br>
tests/spec/gl-1.0/no-op-paths.c | 370 ++++++++++++++++++++++++++++++++++++<br>
3 files changed, 372 insertions(+)<br>
create mode 100644 tests/spec/gl-1.0/no-op-paths.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index fe088f5..a9822d3 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -1000,6 +1000,7 @@ with profile.group_manager(<br>
g(['gl-1.0-ortho-pos'])<br>
g(['gl-1.0-readpixsanity'])<br>
g(['gl-1.0-logicop'])<br>
+ g(['gl-1.0-no-op-paths'])<br>
<br>
with profile.group_manager(<br>
PiglitGLTest,<br>
diff --git a/tests/spec/gl-1.0/CMakeLists.gl.txt b/tests/spec/gl-1.0/CMakeLists.gl.txt<br>
index d04b835..7a7f508 100644<br>
--- a/tests/spec/gl-1.0/CMakeLists.gl.txt<br>
+++ b/tests/spec/gl-1.0/CMakeLists.gl.txt<br>
@@ -22,6 +22,7 @@ piglit_add_executable (gl-1.0-front-invalidate-back front-invalidate-back.c)<br>
piglit_add_executable (gl-1.0-logicop logicop.c)<br>
piglit_add_executable (gl-1.0-long-dlist long-dlist.c)<br>
piglit_add_executable (gl-1.0-ortho-pos orthpos.c)<br>
+piglit_add_executable (gl-1.0-no-op-paths no-op-paths.c)<br>
piglit_add_executable (gl-1.0-polygon-line-aa polygon-line-aa.c)<br>
piglit_add_executable (gl-1.0-push-no-attribs push-no-attribs.c)<br>
piglit_add_executable (gl-1.0-readpixsanity readpix.c)<br>
diff --git a/tests/spec/gl-1.0/no-op-paths.c b/tests/spec/gl-1.0/no-op-paths.c<br>
new file mode 100644<br>
index 0000000..9a76baf<br>
--- /dev/null<br>
+++ b/tests/spec/gl-1.0/no-op-paths.c<br>
@@ -0,0 +1,370 @@<br>
+/* BEGIN_COPYRIGHT -*- glean -*-<br>
+ *<br>
+ * Copyright (C) 1999 Allen Akin All Rights Reserved.<br>
+ * Copyright (C) 2015 Intel Corporation.<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>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * 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, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ * END_COPYRIGHT<br>
+ */<br>
+/** @file paths.c<br>
+ *<br>
+ * Test basic GL rendering paths.<br>
+ *<br>
+ *<br>
+ * This test verifies that basic, trival OpenGL paths work as expected.<br>
+ * For example, glAlphaFunc(GL_GEQUAL, 0.0) should always pass and<br>
+ * glAlphaFunc(GL_LESS, 0.0) should always fail. We setup trivial<br>
+ * pass and fail conditions for each of alpha test, blending, color mask,<br>
+ * depth test, logic ops, scissor, stencil, stipple, and texture and<br>
+ * make sure they work as expected. We also setup trival-pass for all<br>
+ * these paths simultaneously and test that as well.<br>
+ *<br>
+ * To test for pass/fail we examine the color buffer for white or black,<br>
+ * respectively.<br>
+ *<br></blockquote><div><br></div><div>Here, I'd add an additional comment saying that this Piglit test is based on the original Glean tpaths.cpp test.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+<br>
+#include <stdlib.h><br></blockquote><div><br></div><div>Is stdlib.h really needed?<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 10;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA |<br>
+ PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+<br>
+typedef enum {<br>
+ ALPHA,<br>
+ BLEND,<br>
+ COLOR_MASK,<br>
+ DEPTH,<br>
+ LOGIC,<br>
+ SCISSOR,<br>
+ STENCIL,<br>
+ STIPPLE,<br>
+ TEXTURE,<br>
+ ZZZ /* end-of-list token */<br>
+} Path;<br>
+<br>
+typedef enum {<br>
+ DISABLE,<br>
+ ALWAYS_PASS,<br>
+ ALWAYS_FAIL<br>
+<br></blockquote><div><br></div><div>Unneeded empty line.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+} State;<br>
+<br>
+<br>
+const char *<br></blockquote><div><br></div><div>Could be static.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+path_name(Path path) {<br></blockquote><div><br></div><div>Opening brace goes on next line.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ switch (path) {<br>
+ case ALPHA:<br>
+ return "Alpha Test";<br></blockquote><div><br></div><div>We use 8-column tabs for indenting in Piglit, not spaces.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ case BLEND:<br>
+ return "Blending";<br>
+ case COLOR_MASK:<br>
+ return "Color Mask";<br>
+ case DEPTH:<br>
+ return "Depth Test";<br>
+ case LOGIC:<br>
+ return "LogicOp";<br>
+ case SCISSOR:<br>
+ return "Scissor Test";<br>
+ case STENCIL:<br>
+ return "Stencil Test";<br>
+ case STIPPLE:<br>
+ return "Polygon Stipple";<br>
+ case TEXTURE:<br>
+ return "Modulated Texture";<br>
+ case ZZZ:<br>
+ return "paths";<br>
+ default:<br>
+ return "???";<br>
+ }<br>
+}<br>
+<br>
+<br>
+void<br>
+set_path_state(Path path, State state) {<br></blockquote><div><br></div><div>Same comments as above.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ int i;<br>
+ switch (path) {<br>
+ case ALPHA:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glAlphaFunc(GL_GEQUAL, 0.0);<br>
+ glEnable(GL_ALPHA_TEST);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glAlphaFunc(GL_GREATER, 1.0);<br>
+ glEnable(GL_ALPHA_TEST);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_ALPHA_TEST);<br>
+ }<br>
+ break;<br>
+ case BLEND:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glBlendFunc(GL_ONE, GL_ZERO);<br>
+ glEnable(GL_BLEND);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glBlendFunc(GL_ZERO, GL_ONE);<br>
+ glEnable(GL_BLEND);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_BLEND);<br>
+ }<br>
+ break;<br>
+ case COLOR_MASK:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);<br>
+ }<br>
+ else {<br>
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);<br>
+ }<br>
+ break;<br>
+ case DEPTH:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glDepthFunc(GL_ALWAYS);<br>
+ glEnable(GL_DEPTH_TEST);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glDepthFunc(GL_NEVER);<br>
+ glEnable(GL_DEPTH_TEST);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_DEPTH_TEST);<br>
+ }<br>
+ break;<br>
+ case LOGIC:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glLogicOp(GL_OR);<br>
+ glEnable(GL_COLOR_LOGIC_OP);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glLogicOp(GL_AND);<br>
+ glEnable(GL_COLOR_LOGIC_OP);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_COLOR_LOGIC_OP);<br>
+ }<br>
+ break;<br>
+ case SCISSOR:<br>
+ if (state == ALWAYS_PASS) {<br>
+ glScissor(0, 0, 10, 10);<br>
+ glEnable(GL_SCISSOR_TEST);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ glScissor(0, 0, 0, 0);<br>
+ glEnable(GL_SCISSOR_TEST);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_SCISSOR_TEST);<br>
+ }<br>
+ break;<br>
+ case STENCIL:<br>
+ if (state == ALWAYS_PASS) {<br>
+ /* pass if reference <= stencil value (ref = 0) */<br>
+ glStencilFunc(GL_LEQUAL, 0, ~0);<br>
+ glEnable(GL_STENCIL_TEST);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ /* pass if reference > stencil value (ref = 0) */<br>
+ glStencilFunc(GL_GREATER, 0, ~0);<br>
+ glEnable(GL_STENCIL_TEST);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_STENCIL_TEST);<br>
+ }<br>
+ break;<br>
+ case STIPPLE:<br>
+ if (state == ALWAYS_PASS) {<br>
+ GLubyte stipple[4*32];<br>
+ for (i = 0; i < 4*32; i++)<br>
+ stipple[i] = 0xff;<br>
+ glPolygonStipple(stipple);<br>
+ glEnable(GL_POLYGON_STIPPLE);<br>
+ }<br>
+ else if (state == ALWAYS_FAIL) {<br>
+ GLubyte stipple[4*32];<br>
+ for (i = 0; i < 4*32; i++)<br>
+ stipple[i] = 0x0;<br>
+ glPolygonStipple(stipple);<br>
+ glEnable(GL_POLYGON_STIPPLE);<br>
+ }<br>
+ else {<br>
+ glDisable(GL_POLYGON_STIPPLE);<br>
+ }<br>
+ break;<br>
+ case TEXTURE:<br>
+ if (state == DISABLE) {<br>
+ glDisable(GL_TEXTURE_2D);<br>
+ }<br>
+ else {<br>
+ GLubyte val = (state == ALWAYS_PASS) ? 0xff : 0x00;<br>
+ GLubyte texImage[4*4*4];<br>
+ for (i = 0; i < 4*4*4; i++)<br>
+ texImage[i] = val;<br>
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0,<br>
+ GL_RGBA, GL_UNSIGNED_BYTE, texImage);<br>
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,<br>
+ GL_NEAREST);<br>
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,<br>
+ GL_NEAREST);<br>
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,<br>
+ GL_MODULATE);<br>
+ glEnable(GL_TEXTURE_2D);<br>
+ }<br>
+ break;<br>
+ default:<br>
+ abort(); /* error */<br>
+ }<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ /* No init */<br>
+} /* piglit_init */<br></blockquote><div><br></div><div>You can drop the closing /* piglit_init */ comment.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ bool pass = true;<br>
+ Path p, paths[1000];<br>
+ int i, numPaths = 0;<br>
+<br>
+ /* draw 10x10 pixel quads */<br>
+ glViewport(0, 0, 10, 10);<br>
+<br>
+ glDisable(GL_DITHER);<br>
+<br>
+ /* Build the list of paths to exercise.<br>
+ * Skip depth test if we have no depth buffer. */<br>
+ /* Skip stencil test if we have no stencil buffer. */<br>
+ for (p = ALPHA; p != ZZZ; p = (Path) (p + 1)) {<br>
+ paths[numPaths++] = p;<br>
+ }<br>
+<br>
+ /* test always-pass paths */<br>
+ for (i = 0; i < numPaths; i++) {<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ set_path_state(paths[i], ALWAYS_PASS);<br>
+<br>
+ /* draw polygon */<br>
+ glColor4f(1, 1, 1, 1);<br>
+ glBegin(GL_POLYGON);<br>
+ glVertex2f(-1, -1);<br>
+ glVertex2f( 1, -1);<br>
+ glVertex2f( 1, 1);<br>
+ glVertex2f(-1, 1);<br>
+ glEnd();<br></blockquote><div><br></div><div>I think there's a piglit_draw_rect() function that could be used there.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ set_path_state(paths[i], DISABLE);<br>
+<br>
+ /* test buffer */<br>
+ GLfloat pixel[3];<br>
+ glReadPixels(4, 4, 1, 1, GL_RGB, GL_FLOAT, pixel);<br>
+ if (pixel[0] != 1.0 || pixel[1] != 1.0 || pixel[2] != 1.0) {<br></blockquote><div><br></div><div>I think you can replace that code with piglit_probe_rect_rgb().<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ printf("\nFAIL: %s, should have had no effect"<br>
+ " (1, 1, 1) but actually modified the fragment"<br>
+ " ( %f, %f, %f)\n", path_name(paths[i]), pixel[0], pixel[1], pixel[2]);<br>
+ return PIGLIT_FAIL;<br>
+ }<br>
+ }<br>
+<br>
+ /* enable all always-pass paths */<br>
+ {<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ for (i = 0; i < numPaths; i++) {<br>
+ set_path_state(paths[i], ALWAYS_PASS);<br>
+ }<br>
+<br>
+ /* draw polygon */<br>
+ glColor4f(1, 1, 1, 1);<br>
+ glBegin(GL_POLYGON);<br>
+ glVertex2f(-1, -1);<br>
+ glVertex2f( 1, -1);<br>
+ glVertex2f( 1, 1);<br>
+ glVertex2f(-1, 1);<br>
+ glEnd();<br></blockquote><div><br></div><div>piglit_draw_rect()<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ for (i = 0; i < numPaths; i++) {<br>
+ set_path_state(paths[i], DISABLE);<br>
+ }<br>
+<br>
+ /* test buffer */<br>
+ GLfloat pixel[3];<br>
+ glReadPixels(4, 4, 1, 1, GL_RGB, GL_FLOAT, pixel);<br>
+ if (pixel[0] != 1.0 || pixel[1] != 1.0 || pixel[2] != 1.0) {<br></blockquote><div><br></div><div>piglit_probe_rect_rgb()<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ printf("\nFAIL: %s, should have had no effect"<br>
+ " (1, 1, 1) but actually modified the fragment"<br>
+ " ( %f, %f, %f)\n", path_name(paths[i]), pixel[0], pixel[1], pixel[2]);<br>
+ return PIGLIT_FAIL;<br>
+ }<br>
+ }<br>
+<br>
+ /* test never-pass paths */<br>
+ for (i = 0; i < numPaths; i++) {<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ set_path_state(paths[i], ALWAYS_FAIL);<br>
+<br>
+ /* draw polygon */<br>
+ glColor4f(1, 1, 1, 1);<br>
+ glBegin(GL_POLYGON);<br>
+ glVertex2f(-1, -1);<br>
+ glVertex2f( 1, -1);<br>
+ glVertex2f( 1, 1);<br>
+ glVertex2f(-1, 1);<br>
+ glEnd();<br>
+<br>
+ set_path_state(paths[i], DISABLE);<br>
+<br>
+ /* test buffer */<br>
+ GLfloat pixel[3];<br>
+ glReadPixels(4, 4, 1, 1, GL_RGB, GL_FLOAT, pixel);<br>
+ if (pixel[0] != 0.0 || pixel[1] != 0.0 || pixel[2] != 0.0) {<br>
+ printf("\nFAIL: %s, should have had no effect"<br>
+ " (1, 1, 1) but actually modified the fragment"<br>
+ " ( %f, %f, %f)\n", path_name(paths[i]), pixel[0], pixel[1], pixel[2]);<br>
+ return PIGLIT_FAIL;<br>
+ }<br>
+ }<br>
+<br>
+ /* success */<br>
+ pass = true;<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br></blockquote><div><br></div><div>Remove the 'pass' var and just return PIGLIT_PASS here.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.3<br>
<br>
</font></span></blockquote></div><br></div></div>