<div dir="ltr">On 8 August 2013 15:02, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5">On 08/07/2013 01:28 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The transform feedback test "intervening-read" can now be invoked with<br>
a "use_gs" argument, that causes it to use a geometry shader.<br>
---<br>
tests/all.tests | 7 +-<br>
.../spec/ext_transform_<u></u>feedback/intervening-read.c | 129 +++++++++++++++++++--<br>
.../ext_transform_feedback/<u></u>overflow-edge-cases.c | 2 +-<br>
tests/util/piglit-framework-<u></u>gl.c | 3 +-<br>
4 files changed, 126 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index b1df541..2e483ef 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -2024,9 +2024,10 @@ for mode in ['main_binding', 'indexed_binding', 'buffer_start', 'buffer_size']:<br>
'ext_transform_feedback-{0}'.<u></u>format(test_name))<br>
ext_transform_feedback['<u></u>immediate-reuse'] = concurrent_test('ext_<u></u>transform_feedback-immediate-<u></u>reuse')<br>
for mode in ['output', 'prims_generated', 'prims_written']:<br>
- test_name = 'intervening-read {0}'.format(mode)<br>
- ext_transform_feedback[test_<u></u>name] = concurrent_test(<br>
- 'ext_transform_feedback-{0}'.<u></u>format(test_name))<br>
+ for use_gs in ['', ' use_gs']:<br>
+ test_name = 'intervening-read {0}{1}'.format(mode, use_gs)<br>
+ ext_transform_feedback[test_<u></u>name] = concurrent_test(<br>
+ 'ext_transform_feedback-{0}'.<u></u>format(test_name))<br>
ext_transform_feedback['max-<u></u>varyings'] = concurrent_test('ext_<u></u>transform_feedback-max-<u></u>varyings')<br>
ext_transform_feedback['<u></u>nonflat-integral'] = concurrent_test('ext_<u></u>transform_feedback-nonflat-<u></u>integral')<br>
ext_transform_feedback['<u></u>overflow-edge-cases'] = concurrent_test('ext_<u></u>transform_feedback-overflow-<u></u>edge-cases')<br>
diff --git a/tests/spec/ext_transform_<u></u>feedback/intervening-read.c b/tests/spec/ext_transform_<u></u>feedback/intervening-read.c<br>
index 7d7eece..a6baaf0 100644<br>
--- a/tests/spec/ext_transform_<u></u>feedback/intervening-read.c<br>
+++ b/tests/spec/ext_transform_<u></u>feedback/intervening-read.c<br>
@@ -44,14 +44,30 @@<br>
* but it requests that no more than 9 vertices be written to it.<br>
* This allows us to verify that the intervening glReadPixels call<br>
* doesn't interfere with overflow checking.<br>
+ *<br>
+ * The optional argument "use_gs" causes the test to use a geometry<br>
+ * shader. When this argument is given, the number of vertices output<br>
+ * by the geometry shader is in general different from the number of<br>
+ * vertices sent down the pipeline by the glDrawArrays() command.<br>
+ * Thus, the test verifies that the implementation uses the<br>
+ * post-geometry-shader vertex count to figure out where to resume<br>
+ * transform feedback after the glReadPixels call.<br>
*/<br>
<br>
#include "piglit-util-gl-common.h"<br>
<br>
+static bool use_gs;<br>
+<br>
PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
- config.supports_gl_compat_<u></u>version = 10;<br>
- config.supports_gl_core_<u></u>version = 31;<br>
+ use_gs = PIGLIT_STRIP_ARG("use_gs");<br>
+ if (use_gs) {<br>
+ config.supports_gl_compat_<u></u>version = 32;<br>
+ config.supports_gl_core_<u></u>version = 32;<br>
+ } else {<br>
+ config.supports_gl_compat_<u></u>version = 10;<br>
+ config.supports_gl_core_<u></u>version = 31;<br>
+ }<br>
<br>
config.window_width = 64;<br>
config.window_height = 32;<br>
@@ -65,7 +81,10 @@ static enum test_mode {<br>
TEST_MODE_PRIMS_WRITTEN<br>
} test_mode;<br>
<br>
-static const char *vstext =<br>
+/**<br>
+ * Vertex shader used when use_gs is false.<br>
+ */<br>
+static const char *vstext_nogs =<br>
"attribute vec4 in_position;\n"<br>
"attribute vec4 in_color;\n"<br>
"varying vec4 out_position;\n"<br>
@@ -78,7 +97,10 @@ static const char *vstext =<br>
" out_color = in_color;\n"<br>
"}\n";<br>
<br>
-static const char *fstext =<br>
+/**<br>
+ * Fragment shader used when use_gs is false.<br>
+ */<br>
+static const char *fstext_nogs =<br>
"varying vec4 out_color;\n"<br>
"\n"<br>
"void main()\n"<br>
@@ -86,6 +108,73 @@ static const char *fstext =<br>
" gl_FragColor = out_color;\n"<br>
"}\n";<br>
<br>
+/**<br>
+ * Vertex shader used when use_gs is true.<br>
+ */<br>
+static const char *vstext_gs =<br>
+ "#version 150\n"<br>
+ "in vec4 in_color;\n"<br>
+ "out vec4 color_to_gs;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " color_to_gs = in_color;\n"<br>
+ "}\n";<br>
+<br>
+/**<br>
+ * Geometry shader used when use_gs is true.<br>
+ */<br>
+static const char *gstext_gs =<br>
+ "#version 150\n"<br>
+ "layout(points) in;\n"<br>
+ "layout(triangle_strip, max_vertices=6) out;\n"<br>
+ "uniform int start_index;\n"<br>
+ "in vec4 color_to_gs[1];\n"<br>
+ "out vec4 out_position;\n"<br>
+ "out vec4 out_color;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " vec2 positions[12] = vec2[12](\n"<br>
</blockquote>
<br></div></div>
I might be inclined to use<br>
<br>
" const vec2 positions[] = vec2[12](\n"<br>
<br>
But that's a nearly infinitesimal nit.</blockquote><div><br></div><div>I can go along with that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ " vec2(-1.0, -1.0),\n"<br>
+ " vec2( 0.0, -1.0),\n"<br>
+ " vec2(-1.0, 1.0),\n"<br>
+ " vec2(-1.0, 1.0),\n"<br>
+ " vec2( 0.0, -1.0),\n"<br>
+ " vec2( 0.0, 1.0),\n"<br>
+ " vec2( 0.0, -1.0),\n"<br>
+ " vec2( 1.0, -1.0),\n"<br>
+ " vec2( 0.0, 1.0),\n"<br>
+ " vec2( 0.0, 1.0),\n"<br>
+ " vec2( 1.0, -1.0),\n"<br>
+ " vec2( 1.0, 1.0)\n"<br>
+ " );\n"<br>
+ " int index = start_index;\n"<br>
+ " for (int i = 0; i < 6; i++) {\n"<br>
+ " for (int j = 0; j < 3; j++) {\n"<br>
+ " vec4 position = vec4(positions[index], 0.0, 1.0);\n"<br>
</blockquote>
<br></div>
positions only has elements [0..11], but it looks like the loop will access elements [start_index..start_index+17]. Am I reading this right?</blockquote><div><br></div><div>Whoops, that first loop was supposed to be "for (int i = 0; i < 2; i++)". The only reason the test wasn't failing was because the geometry shader declared max_vertices=6, and my work-in-progress i965 gs implementation discards extra vertices beyond max_vertices. I'll fix that.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ " gl_Position = position;\n"<br>
+ " out_position = position;\n"<br>
+ " out_color = color_to_gs[0];\n"<br>
+ " EmitVertex();\n"<br>
+ " index++;\n"<br>
+ " }\n"<br>
+ " EndPrimitive();\n"<br>
+ " }\n"<br>
+ "}\n";<br>
+<br>
+/**<br>
+ * Fragment shader used when use_gs is false.<br>
+ */<br>
+static const char *fstext_gs =<br>
+ "#version 150\n"<br>
+ "in vec4 out_color;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_FragColor = out_color;\n"<br>
+ "}\n";<br>
+<br>
static const char *varyings[] = { "out_position", "out_color" };<br>
<br>
static GLuint xfb_buf, vao, array_buf;<br>
@@ -106,7 +195,7 @@ print_usage_and_exit(char *prog_name)<br>
void<br>
piglit_init(int argc, char **argv)<br>
{<br>
- GLuint vs, fs;<br>
+ GLuint vs, gs, fs;<br>
<br>
/* Interpret command line args */<br>
if (argc != 2)<br>
@@ -123,12 +212,22 @@ piglit_init(int argc, char **argv)<br>
piglit_require_GLSL();<br>
piglit_require_transform_<u></u>feedback();<br>
<br>
- vs = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER, vstext);<br>
- fs = piglit_compile_shader_text(GL_<u></u>FRAGMENT_SHADER, fstext);<br>
+ if (use_gs) {<br>
+ vs = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER, vstext_gs);<br>
+ gs = piglit_compile_shader_text(GL_<u></u>GEOMETRY_SHADER, gstext_gs);<br>
+ fs = piglit_compile_shader_text(GL_<u></u>FRAGMENT_SHADER, fstext_gs);<br>
+ } else {<br>
+ vs = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER, vstext_nogs);<br>
+ fs = piglit_compile_shader_text(GL_<u></u>FRAGMENT_SHADER,<br>
+ fstext_nogs);<br>
+ }<br>
prog = glCreateProgram();<br>
glAttachShader(prog, vs);<br>
+ if (use_gs)<br>
+ glAttachShader(prog, gs);<br>
glAttachShader(prog, fs);<br>
- glBindAttribLocation(prog, 0, "in_position");<br>
+ if (!use_gs)<br>
+ glBindAttribLocation(prog, 0, "in_position");<br>
glBindAttribLocation(prog, 1, "in_color");<br>
glTransformFeedbackVaryings(<u></u>prog, 2, varyings, GL_INTERLEAVED_ATTRIBS);<br>
glLinkProgram(prog);<br>
@@ -223,14 +322,24 @@ piglit_display(void)<br>
}<br>
<br>
/* First draw call */<br>
- glDrawArrays(GL_TRIANGLES, 0, 6);<br>
+ if (use_gs) {<br>
+ glUniform1i(<u></u>glGetUniformLocation(prog, "start_index"), 0);<br>
+ glDrawArrays(GL_POINTS, 0, 1);<br>
+ } else {<br>
+ glDrawArrays(GL_TRIANGLES, 0, 6);<br>
+ }<br>
<br>
/* Read pixels */<br>
pass = piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height,<br>
vertex_input[0].color) && pass;<br>
<br>
/* Second draw call */<br>
- glDrawArrays(GL_TRIANGLES, 6, 6);<br>
+ if (use_gs) {<br>
+ glUniform1i(<u></u>glGetUniformLocation(prog, "start_index"), 6);<br>
+ glDrawArrays(GL_POINTS, 6, 1);<br>
+ } else {<br>
+ glDrawArrays(GL_TRIANGLES, 6, 6);<br>
+ }<br>
<br>
/* Finish transform feedback and test correct behavior. */<br>
glEndTransformFeedback();<br>
diff --git a/tests/spec/ext_transform_<u></u>feedback/overflow-edge-cases.c b/tests/spec/ext_transform_<u></u>feedback/overflow-edge-cases.c<br>
index e29e20b..32c27bc 100644<br>
--- a/tests/spec/ext_transform_<u></u>feedback/overflow-edge-cases.c<br>
+++ b/tests/spec/ext_transform_<u></u>feedback/overflow-edge-cases.c<br>
@@ -40,7 +40,7 @@<br>
* - GL_TRANSFORM_FEEDBACK_<u></u>PRIMITIVES_WRITTEN is set correctly.<br>
* - GL_PRIMITIVES_GENERATED is set correctly.<br>
*<br>
- * The optional argument "use_gs" uses the test to use a geometry<br>
+ * The optional argument "use_gs" causes the test to use a geometry<br>
* shader. When this argument is given, the number of vertices output<br>
* by the geometry shader is in general different from the number of<br>
* vertices sent down the pipeline by the glDrawArrays() command.<br>
</blockquote>
<br></div></div>
I think this hunk belongs squashed with patch 4.</blockquote><div><br></div><div>Oops, you're right.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
diff --git a/tests/util/piglit-framework-<u></u>gl.c b/tests/util/piglit-framework-<u></u>gl.c<br>
index 1ce3a07..85dcac0 100644<br>
--- a/tests/util/piglit-framework-<u></u>gl.c<br>
+++ b/tests/util/piglit-framework-<u></u>gl.c<br>
@@ -188,7 +188,8 @@ piglit_strip_arg(int *argc, char *argv[], const char *arg)<br>
int i;<br>
for (i = 1; i < *argc; i++) {<br>
if (!strcmp(argv[i], arg)) {<br>
- delete_arg(argv, *argc--, i);<br>
+ delete_arg(argv, *argc, i);<br>
+ *argc -= 1;<br>
return true;<br>
}<br>
}<br>
<br>
</blockquote>
<br></div>
This last hunk seems spurious.<br>
<br>
</blockquote></div><br></div><div class="gmail_extra">Actually, it belongs in patch 1. Since postfix operators take precedence, "*argc--" gets interpreted as "*(argc--)", which isn't what we want. Rather than go with the awkward parenthesization "(*argc)--" I decided to use "-=" to avoid confusion, as process_args() does.<br>
<br></div><div class="gmail_extra">I'll move this hunk to where it belongs.<br></div></div>