<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 29, 2015 at 4:51 AM, Martin Peres <span dir="ltr"><<a href="mailto:martin.peres@linux.intel.com" target="_blank">martin.peres@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
tests/all.py | 1 +<br>
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +<br>
tests/spec/arb_direct_state_access/dsa-utils.h | 7 +<br>
.../transformfeedback-bufferbase.c | 224 +++++++++++++++++++++<br>
4 files changed, 233 insertions(+)<br>
create mode 100644 tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index 8806a1f..c5406db 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -4402,6 +4402,7 @@ import_glsl_parser_tests(arb_derivative_control,<br>
<br>
spec['ARB_direct_state_access'] = {}<br>
spec['ARB_direct_state_access']['create-transformfeedbacks'] = PiglitGLTest(['arb_direct_state_access-create-transformfeedbacks'], run_concurrent=True)<br>
+spec['ARB_direct_state_access']['transformfeedback-bufferbase'] = PiglitGLTest(['arb_direct_state_access-transformfeedback-bufferbase'], run_concurrent=True)<br>
spec['ARB_direct_state_access']['dsa-textures'] = PiglitGLTest(['arb_direct_state_access-dsa-textures'], run_concurrent=True)<br>
spec['ARB_direct_state_access']['texturesubimage'] = PiglitGLTest(['arb_direct_state_access-texturesubimage'], run_concurrent=True)<br>
spec['ARB_direct_state_access']['bind-texture-unit'] = PiglitGLTest(['arb_direct_state_access-bind-texture-unit'], run_concurrent=True)<br>
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
index 3449cb1..e01894f 100644<br>
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
@@ -10,6 +10,7 @@ link_libraries (<br>
)<br>
<br>
piglit_add_executable (arb_direct_state_access-create-transformfeedbacks create-transformfeedbacks.c)<br>
+piglit_add_executable (arb_direct_state_access-transformfeedback-bufferbase transformfeedback-bufferbase.c)<br>
piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)<br>
piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)<br>
piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)<br>
diff --git a/tests/spec/arb_direct_state_access/dsa-utils.h b/tests/spec/arb_direct_state_access/dsa-utils.h<br>
index 3fb6707..13a1cb9 100644<br>
--- a/tests/spec/arb_direct_state_access/dsa-utils.h<br>
+++ b/tests/spec/arb_direct_state_access/dsa-utils.h<br>
@@ -47,6 +47,13 @@ do { \<br>
(format), ##args); \<br>
} while (0)<br>
<br>
+#define SUBTESTCONDITION(condition, global, format, args...) \<br>
+do { \<br></blockquote><div>global = global && (condition); \ <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ global &= (condition); \<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ piglit_report_subtest_result((condition) ? PIGLIT_PASS : PIGLIT_FAIL, \<br>
+ (format), ##args); \<br>
+} while (0)<br>
+<br>
void dsa_init_program(void);<br>
<br>
void dsa_texture_with_unit(GLuint);<br>
diff --git a/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c b/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c<br>
new file mode 100644<br>
index 0000000..7d110fb<br>
--- /dev/null<br>
+++ b/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c<br>
@@ -0,0 +1,224 @@<br>
+/*<br>
+ * Copyright © 2014 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>
+ * 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>
+<br>
+/** @file transformfeedback-bufferbase.c<br>
+ * Simple transform feedback test drawing GL_POINTS and making use of the<br>
+ * transform-feedback-related direct state access entry points.<br>
+ *<br>
+ * Greatly inspired from ext_transform_feedback/points.c.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#include "dsa-utils.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+ config.supports_gl_compat_version = 10;<br>
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+<br>
+static GLuint prog;<br>
+static GLuint xfb_buf[3], vert_buf;<br>
+static const int xfb_buf_size = 500;<br>
+<br>
+static const char *vstext = {<br>
+ "void main() {"<br>
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"<br>
+ " gl_FrontColor = vec4(0.9, 0.8, 0.7, 0.6);"<br>
+ "}"<br>
+};<br>
+<br>
+#define NUM_VERTS 3<br>
+static const GLfloat verts[NUM_VERTS][3] =<br>
+{<br>
+ {-1.0, 0.2, 0},<br>
+ {0, 0.2, 0},<br>
+ {1, 0.2, 0}<br>
+};<br>
+<br>
+static const GLfloat verts_ret[NUM_VERTS][3] =<br>
+{<br>
+ {-0.5, 0.1, 0},<br>
+ { 0.0, 0.1, 0},<br>
+ { 0.5, 0.1, 0}<br>
+};<br>
+<br>
+static const GLfloat color_ret[NUM_VERTS][3] =<br>
+{<br>
+ {0.9, 0.8, 0.7},<br>
+ {0.9, 0.8, 0.7},<br>
+ {0.9, 0.8, 0.7}<br>
+};<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ static const char *varyings[] = { "gl_Position", "gl_FrontColor" };<br>
+ GLuint vs;<br>
+<br>
+ glMatrixMode(GL_MODELVIEW);<br>
+ glLoadIdentity();<br>
+ glScalef(0.5, 0.5, 1.0);<br>
+<br>
+ /* Check the driver. */<br>
+ piglit_require_gl_version(15);<br>
+ piglit_require_GLSL();<br>
+ piglit_require_extension("GL_ARB_transform_feedback3");<br>
+ piglit_require_extension("GL_ARB_direct_state_access");<br>
+<br>
+ /* Create shaders. */<br>
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);<br>
+ prog = glCreateProgram();<br>
+ glAttachShader(prog, vs);<br>
+ glTransformFeedbackVaryings(prog, 2, varyings,<br>
+ GL_SEPARATE_ATTRIBS);<br>
+ glLinkProgram(prog);<br>
+ if (!piglit_link_check_status(prog)) {<br>
+ glDeleteProgram(prog);<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+ glUseProgram(prog);<br>
+<br>
+ /* Set up the vertex data buffer */<br>
+ glGenBuffers(1, &vert_buf);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, vert_buf);<br>
+ glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);<br>
+<br>
+ glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+}<br>
+<br>
+static bool<br>
+equal(float a, float b)<br>
+{<br>
+ return fabsf(a - b) < 0.0001;<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ GLint max_bind_points = 0;<br>
+ GLuint q, num_prims;<br>
+ bool pass = true, test = true;<br>
+ GLfloat *v, *w;<br>
+ int i, j;<br>
+<br>
+ /* init the transform feedback buffers */<br>
+ glCreateTransformFeedbacks(3, xfb_buf);<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[2]);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+ /* Fetch the number of bind points */<br>
+ glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max_bind_points);<br>
+ SUBTEST(GL_NO_ERROR, pass, "fetch maximum number of bind points");<br>
+<br>
+ /* bind a non-existing transform feedback BO */<br>
+ glTransformFeedbackBufferBase(1337, 0, 0);<br>
+ SUBTEST(GL_INVALID_OPERATION, pass,<br>
+ "bind non-existing transform feedback BO");<br>
+<br>
+ /* bind a non-existing output BO */<br>
+ glTransformFeedbackBufferBase(0, 0, 1337);<br>
+ SUBTEST(GL_INVALID_VALUE, pass, "bind a non-existing output BO");<br>
+<br>
+ /* bind to a negative index */<br>
+ glTransformFeedbackBufferBase(0, -1, xfb_buf[2]);<br>
+ SUBTEST(GL_INVALID_VALUE, pass, "bind negative index");<br>
+<br>
+ /* bind to an index == max */<br>
+ glTransformFeedbackBufferBase(0, max_bind_points, xfb_buf[2]);<br>
+ SUBTEST(GL_INVALID_VALUE, pass, "bind to index == max_bind_points (%i)",<br>
+ max_bind_points);<br>
+<br>
+ /* Set up the transform feedback buffer */<br>
+ for (i = 0; i < 2; i++) {<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[i]);<br>
+ glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,<br>
+ xfb_buf_size, NULL, GL_STREAM_READ);<br>
+ glTransformFeedbackBufferBase(0, i, xfb_buf[i]);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ }<br>
+<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ glGenQueries(1, &q);<br>
+ glBeginQuery(GL_PRIMITIVES_GENERATED, q);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+ glBeginTransformFeedback(GL_POINTS);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, vert_buf);<br>
+ glVertexPointer(3, GL_FLOAT, 0, 0);<br>
+ glEnable(GL_VERTEX_ARRAY);<br>
+ glDrawArrays(GL_POINTS, 0, 3);<br>
+ glEndTransformFeedback();<br>
+<br>
+ glEndQuery(GL_PRIMITIVES_GENERATED);<br>
+<br>
+ glGetQueryObjectuiv(q, GL_QUERY_RESULT, &num_prims);<br>
+ glDeleteQueries(1, &q);<br>
+ printf("%u primitives generated:\n", num_prims);<br>
+<br>
+ if (num_prims != NUM_VERTS) {<br>
+ printf("Incorrect number of prims generated.\n");<br>
+ printf("Found %u, expected %u\n", num_prims, NUM_VERTS);<br>
+ pass = false;<br>
+ }<br>
+<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[0]);<br>
+ v = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[1]);<br>
+ w = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+ for (i = 0; i < num_prims; i++) {<br>
+ printf("vertex %2d: pos %5.2g, %5.2g, %5.2g, %5.2g "<br>
+ "color %5.2g, %5.2g, %5.2g, %5.2g\n", i,<br>
+ v[i*4+0], v[i*4+1], v[i*4+2], v[i*4+3],<br>
+ w[i*4+0], w[i*4+1], w[i*4+2], w[i*4+3]);<br>
+<br>
+ for(j = 0; j < 3; j++) {<br>
+ if (!equal(v[i*4+j], verts_ret[i][j])) {<br>
+ printf(" Incorrect coord %i for point %d: "<br>
+ "%f instead of %f\n",<br>
+ j, i, v[i*4+j], verts_ret[i][j]);<br>
+ test = false;<br>
+ }<br>
+ if (!equal(w[i*4+j], color_ret[i][j])) {<br>
+ printf(" Incorrect color component %i for point %d: "<br>
+ "%f instead of %f\n",<br>
+ j, i, w[i*4+j], color_ret[i][j]);<br>
+ test = false;<br>
+ }<br>
+ }<br>
+ }<br>
+ SUBTESTCONDITION(test, pass, "general test");<br>
+<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[0]);<br>
+ glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[1]);<br>
+ glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);<br>
+<br>
+ piglit_present_results();<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.2.2<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" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>