<div dir="ltr">Same comments as on the previous patch, otherwise good :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 7:31 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"><span class="">v2: review from Tapani<br>
- add the copyright for Intel<br>
- add some documentation<br>
- set the minimum GL version to 2.0<br>
- use piglit_build_simple_program_unlinked<br>
<br>
</span>Reviewed-by: Tapani Pälli <<a href="mailto:tapani.palli@intel.com">tapani.palli@intel.com</a>><br>
<br>
v3:<br>
- rewrite the test for GL 3.1 core (Ilia)<br>
- delete the copyright from vmware as none of the code is left<br>
- improve the cleanup at the end of the test<br>
<span class=""><br>
Signed-off-by: Martin Peres <<a href="mailto:martin.peres@linux.intel.com">martin.peres@linux.intel.com</a>><br>
---<br>
tests/all.py | 1 +<br>
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +<br>
</span> .../arb_direct_state_access/gettransformfeedback.c | 270 +++++++++++++++++++++<br>
3 files changed, 272 insertions(+)<br>
<div><div class="h5"> create mode 100644 tests/spec/arb_direct_state_access/gettransformfeedback.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index 31c65e4..2208e8c 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -3999,6 +3999,7 @@ arb_shader_atomic_counters['respecify-buffer'] = PiglitGLTest(['arb_shader_atomi<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']['transformfeedback-bufferrange'] = PiglitGLTest(['arb_direct_state_access-transformfeedback-bufferrange'], run_concurrent=True)<br>
+spec['ARB_direct_state_access']['gettransformfeedback'] = PiglitGLTest(['arb_direct_state_access-gettransformfeedback'], 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 8ae8275..a6232e3 100644<br>
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt<br>
@@ -12,6 +12,7 @@ link_libraries (<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-transformfeedback-bufferrange transformfeedback-bufferrange.c)<br>
+piglit_add_executable (arb_direct_state_access-gettransformfeedback gettransformfeedback.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/gettransformfeedback.c b/tests/spec/arb_direct_state_access/gettransformfeedback.c<br>
new file mode 100644<br>
</div></div>index 0000000..dafc235<br>
--- /dev/null<br>
+++ b/tests/spec/arb_direct_state_access/gettransformfeedback.c<br>
@@ -0,0 +1,270 @@<br>
+/*<br>
<div><div class="h5">+ * Copyright © 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>
+<br>
+/** @file gettransformfeedback.c<br>
+ * Simple transform feedback test drawing GL_POINTS and checking that all the<br>
+ * state is well reported by the GetTransformFeedback*() functions.<br>
+ *<br>
+ * Greatly inspired from ext_transform_feedback/points.c.<br>
+ *<br>
+ * From OpenGL 4.5, section 22.4 "Transform Feedback State Queries", page 552:<br>
+ *<br>
+ * "void GetTransformFeedbackiv(uint xfb, enum pname, int *param);<br>
+ * void GetTransformFeedbacki v(uint xfb, enum pname, uint index, int *param);<br>
+ * void GetTransformFeedbacki64 v(uint xfb, enum pname,uint index,<br>
+ * int64 *param);<br>
+ *<br>
+ * xfb must be zero, indicating the default transform feedback object, or the<br>
+ * name of an existing transform feedback object. pname must be one of the<br>
+ * tokens listed in table 23.48, depending on the command name as shown in the<br>
+ * errors section below. For indexed state, index is the index of the transform<br>
+ * feedback stream. param is the address of a variable to receive the result of<br>
+ * the query.<br>
+ *<br>
+ * Errors<br>
+ * An INVALID_OPERATION error is generated by GetTransformFeedback* if xfb is<br>
+ * not zero or the name of an existing transform feedback object.<br>
+ * An INVALID_ENUM error is generated by GetTransformFeedbackiv if pname is not<br>
+ * TRANSFORM_FEEDBACK_PAUSED or TRANSFORM_FEEDBACK_ACTIVE.<br>
+ * An INVALID_ENUM error is generated by GetTransformFeedbacki v if pname is<br>
+ * not TRANSFORM_FEEDBACK_BUFFER_BINDING.<br>
+ * An INVALID_ENUM error is generated by GetTransformFeedbacki64 v if pname is<br>
+ * not TRANSFORM_FEEDBACK_BUFFER_START or TRANSFORM_FEEDBACK_BUFFER_SIZE.<br>
+ * An INVALID_VALUE error is generated by GetTransformFeedbacki v and<br>
+ * GetTransformFeedbacki64 v if index is greater than or equal to the number<br>
+ * of binding points for transform feedback, as described in section 6.7.1."<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#include "dsa-utils.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
</div></div>+ config.supports_gl_core_version = 31;<br>
<span class="">+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+<br>
+static GLuint prog;<br>
</span>+static GLuint xfb_buf[3], input_buf, vao;<br>
<span class="">+static bool pass = true;<br>
+<br>
+static const char *vstext = {<br>
</span>+ "#version 140\n"<br>
+ "in float valIn;"<br>
+ "out float valOut1;"<br>
+ "out float valOut2;"<br>
+ "void main() {"<br>
+ " valOut1 = valIn + 1;"<br>
+ " valOut2 = valIn * 2;"<br>
+ "}"<br>
+};<br>
+<br>
+#define NUM_INPUTS 4<br>
+static const GLfloat inputs[NUM_INPUTS] = {-1.0, 0.0, 1.0, 3.0};<br>
+static const GLfloat out1_ret[NUM_INPUTS] = { 0.0, 1.0, 2.0, 4.0};<br>
+static const GLfloat out2_ret[NUM_INPUTS] = {-2.0, 0.0, 2.0, 6.0};<br>
<div><div class="h5">+<br>
+struct context_t {<br>
+ struct tbo_state_t {<br>
+ GLuint binding;<br>
+ GLint64 start;<br>
+ GLint64 size;<br>
+ } bo_state[3];<br>
+ bool active;<br>
+ bool paused;<br>
+} ctx;<br>
+<br>
+void<br>
+check_active_paused_state(const char *test_name)<br>
+{<br>
+ GLint param;<br>
+<br>
+ glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_PAUSED, ¶m);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ SUBTESTCONDITION(param == ctx.paused, pass, "%s: paused state valid",<br>
+ test_name);<br>
+<br>
+ glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_ACTIVE, ¶m);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ SUBTESTCONDITION(param == ctx.active, pass, "%s: active state valid",<br>
+ test_name);<br>
+}<br>
+<br>
+void<br>
+check_binding_state(const char *test_name)<br>
+{<br>
+ GLint64 param64;<br>
+ GLint param;<br>
+ int i;<br>
+<br>
+ for (i = 0; i < 3; i++) {<br>
+ glGetTransformFeedbacki_v(0,<br>
+ GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,<br>
+ i, ¶m);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ SUBTESTCONDITION(param == ctx.bo_state[i].binding, pass,<br>
+ "%s: bound buffer %i valid", test_name, i);<br>
+<br>
+ glGetTransformFeedbacki64_v(0,<br>
+ GL_TRANSFORM_FEEDBACK_BUFFER_START,<br>
+ i, ¶m64);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ SUBTESTCONDITION(param64 == ctx.bo_state[i].start, pass,<br>
+ "%s: bound buffer %i start valid", test_name,<br>
+ i);<br>
+<br>
+ glGetTransformFeedbacki64_v(0,<br>
+ GL_TRANSFORM_FEEDBACK_BUFFER_SIZE,<br>
+ i, ¶m64);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ SUBTESTCONDITION(param64 == ctx.bo_state[i].size, pass,<br>
+ "%s: bound buffer %i size valid", test_name,<br>
+ i);<br>
+ }<br>
+}<br>
+<br>
+void<br>
+check_invalid_queries()<br>
+{<br>
+ GLint64 param64;<br>
+ GLint param;<br>
+<br>
+ glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_BINDING, ¶m);<br>
+ SUBTEST(GL_INVALID_ENUM, pass,<br>
+ "glGetTransformFeedbackiv: fetch invalid attribute");<br>
+<br>
+ glGetTransformFeedbacki_v(0, GL_TRANSFORM_FEEDBACK_ACTIVE, 0, ¶m);<br>
+ SUBTEST(GL_INVALID_ENUM, pass,<br>
+ "glGetTransformFeedbacki_v: fetch invalid attribute");<br>
+<br>
+ glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,<br>
+ 0, ¶m64);<br>
+ SUBTEST(GL_INVALID_ENUM, pass,<br>
+ "glGetTransformFeedbacki64_v: fetch invalid attribute");<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
</div></div>+ static const char *varyings[] = { "valOut1", "valOut2" };<br>
+ GLuint size, start;<br>
+ GLint inAttrib;<br>
+ int i;<br>
+<br>
<span class="">+ /* Check the driver. */<br>
</span><span class="">+ piglit_require_extension("GL_ARB_transform_feedback3");<br>
+ piglit_require_extension("GL_ARB_direct_state_access");<br>
+<br>
+ /* Create shaders. */<br>
+ prog = piglit_build_simple_program_unlinked(vstext, NULL);<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>
</span>+ /* Set up the Vertex Array Buffer */<br>
+ glEnable(GL_VERTEX_ARRAY);<br>
+ glGenVertexArrays(1, &vao);<br>
+ glBindVertexArray(vao);<br>
+<br>
+ /* Set up the input data buffer */<br>
+ glGenBuffers(1, &input_buf);<br>
+ glBindBuffer(GL_ARRAY_BUFFER, input_buf);<br>
+ glBufferData(GL_ARRAY_BUFFER, sizeof(inputs), inputs, GL_STATIC_DRAW);<br>
+ inAttrib = glGetAttribLocation(prog, "valIn");<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ glVertexAttribPointer(inAttrib, 1, GL_FLOAT, GL_FALSE, 0, 0);<br>
+ glEnableVertexAttribArray(inAttrib);<br>
<span class="">+<br>
+ /* set the initial state */<br>
+ ctx.active = false;<br>
+ ctx.paused = false;<br>
+ for (i = 0; i < 3; i++) {<br>
+ ctx.bo_state[i].binding = 0;<br>
+ ctx.bo_state[i].start = 0;<br>
+ ctx.bo_state[i].size = 0;<br>
+ }<br>
+ check_active_paused_state("initial state");<br>
+ check_binding_state("initial state");<br>
+<br>
+ /* Set up the transform feedback buffer */<br>
</span>+ glGenBuffers(3, xfb_buf);<br>
<span class="">+ for (i = 0; i < 2; i++) {<br>
+ start = rand() & 0xFC;<br>
+ size = 0x100 + (rand() & 0xFFC);<br>
+<br>
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[i]);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,<br>
+ size, NULL, GL_STREAM_READ);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+ glTransformFeedbackBufferRange(0, i, xfb_buf[i], start, size);<br>
+ piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+ ctx.bo_state[i].binding = xfb_buf[i];<br>
+ ctx.bo_state[i].start = start;<br>
+ ctx.bo_state[i].size = size;<br>
+ }<br>
+<br>
+ check_binding_state("post-binding state");<br>
+}<br>
+<br>
</span><span class="">+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ check_invalid_queries();<br>
+<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ glBeginTransformFeedback(GL_POINTS);<br>
+<br>
+ ctx.active = true;<br>
+ check_active_paused_state("TransformFeedback started");<br>
+<br>
+ glPauseTransformFeedback();<br>
+<br>
+ ctx.paused = true;<br>
+ check_active_paused_state("TransformFeedback paused");<br>
+<br>
+ glResumeTransformFeedback();<br>
+<br>
+ ctx.paused = false;<br>
+ check_active_paused_state("TransformFeedback resumed");<br>
+<br>
</span><span class="">+ glEndTransformFeedback();<br>
+<br>
+ ctx.active = false;<br>
+ check_active_paused_state("TransformFeedback ended");<br>
+<br>
</span>+ /* clean-up everything */<br>
+ glDeleteBuffers(3, xfb_buf);<br>
+ glDeleteBuffers(1, &input_buf);<br>
+ glDeleteVertexArrays(1, &vao);<br>
+ glDeleteProgram(prog);<br>
<span class="">+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
--<br>
</span>2.3.1<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div>