[Piglit] [PATCH 2/4] arb_direct_state_access: Added glTransformFeedbackBufferBase tests
Martin Peres
martin.peres at linux.intel.com
Thu Jan 29 04:51:27 PST 2015
---
tests/all.py | 1 +
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +
tests/spec/arb_direct_state_access/dsa-utils.h | 7 +
.../transformfeedback-bufferbase.c | 224 +++++++++++++++++++++
4 files changed, 233 insertions(+)
create mode 100644 tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c
diff --git a/tests/all.py b/tests/all.py
index 8806a1f..c5406db 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4402,6 +4402,7 @@ import_glsl_parser_tests(arb_derivative_control,
spec['ARB_direct_state_access'] = {}
spec['ARB_direct_state_access']['create-transformfeedbacks'] = PiglitGLTest(['arb_direct_state_access-create-transformfeedbacks'], run_concurrent=True)
+spec['ARB_direct_state_access']['transformfeedback-bufferbase'] = PiglitGLTest(['arb_direct_state_access-transformfeedback-bufferbase'], run_concurrent=True)
spec['ARB_direct_state_access']['dsa-textures'] = PiglitGLTest(['arb_direct_state_access-dsa-textures'], run_concurrent=True)
spec['ARB_direct_state_access']['texturesubimage'] = PiglitGLTest(['arb_direct_state_access-texturesubimage'], run_concurrent=True)
spec['ARB_direct_state_access']['bind-texture-unit'] = PiglitGLTest(['arb_direct_state_access-bind-texture-unit'], run_concurrent=True)
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index 3449cb1..e01894f 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
)
piglit_add_executable (arb_direct_state_access-create-transformfeedbacks create-transformfeedbacks.c)
+piglit_add_executable (arb_direct_state_access-transformfeedback-bufferbase transformfeedback-bufferbase.c)
piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
diff --git a/tests/spec/arb_direct_state_access/dsa-utils.h b/tests/spec/arb_direct_state_access/dsa-utils.h
index 3fb6707..13a1cb9 100644
--- a/tests/spec/arb_direct_state_access/dsa-utils.h
+++ b/tests/spec/arb_direct_state_access/dsa-utils.h
@@ -47,6 +47,13 @@ do { \
(format), ##args); \
} while (0)
+#define SUBTESTCONDITION(condition, global, format, args...) \
+do { \
+ global &= (condition); \
+ piglit_report_subtest_result((condition) ? PIGLIT_PASS : PIGLIT_FAIL, \
+ (format), ##args); \
+} while (0)
+
void dsa_init_program(void);
void dsa_texture_with_unit(GLuint);
diff --git a/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c b/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c
new file mode 100644
index 0000000..7d110fb
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/transformfeedback-bufferbase.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright © 2014 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** @file transformfeedback-bufferbase.c
+ * Simple transform feedback test drawing GL_POINTS and making use of the
+ * transform-feedback-related direct state access entry points.
+ *
+ * Greatly inspired from ext_transform_feedback/points.c.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ config.supports_gl_compat_version = 10;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static GLuint prog;
+static GLuint xfb_buf[3], vert_buf;
+static const int xfb_buf_size = 500;
+
+static const char *vstext = {
+ "void main() {"
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
+ " gl_FrontColor = vec4(0.9, 0.8, 0.7, 0.6);"
+ "}"
+};
+
+#define NUM_VERTS 3
+static const GLfloat verts[NUM_VERTS][3] =
+{
+ {-1.0, 0.2, 0},
+ {0, 0.2, 0},
+ {1, 0.2, 0}
+};
+
+static const GLfloat verts_ret[NUM_VERTS][3] =
+{
+ {-0.5, 0.1, 0},
+ { 0.0, 0.1, 0},
+ { 0.5, 0.1, 0}
+};
+
+static const GLfloat color_ret[NUM_VERTS][3] =
+{
+ {0.9, 0.8, 0.7},
+ {0.9, 0.8, 0.7},
+ {0.9, 0.8, 0.7}
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ static const char *varyings[] = { "gl_Position", "gl_FrontColor" };
+ GLuint vs;
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glScalef(0.5, 0.5, 1.0);
+
+ /* Check the driver. */
+ piglit_require_gl_version(15);
+ piglit_require_GLSL();
+ piglit_require_extension("GL_ARB_transform_feedback3");
+ piglit_require_extension("GL_ARB_direct_state_access");
+
+ /* Create shaders. */
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+ prog = glCreateProgram();
+ glAttachShader(prog, vs);
+ glTransformFeedbackVaryings(prog, 2, varyings,
+ GL_SEPARATE_ATTRIBS);
+ glLinkProgram(prog);
+ if (!piglit_link_check_status(prog)) {
+ glDeleteProgram(prog);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ glUseProgram(prog);
+
+ /* Set up the vertex data buffer */
+ glGenBuffers(1, &vert_buf);
+ glBindBuffer(GL_ARRAY_BUFFER, vert_buf);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
+
+ glClearColor(0.2, 0.2, 0.2, 1.0);
+}
+
+static bool
+equal(float a, float b)
+{
+ return fabsf(a - b) < 0.0001;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLint max_bind_points = 0;
+ GLuint q, num_prims;
+ bool pass = true, test = true;
+ GLfloat *v, *w;
+ int i, j;
+
+ /* init the transform feedback buffers */
+ glCreateTransformFeedbacks(3, xfb_buf);
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[2]);
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ /* Fetch the number of bind points */
+ glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max_bind_points);
+ SUBTEST(GL_NO_ERROR, pass, "fetch maximum number of bind points");
+
+ /* bind a non-existing transform feedback BO */
+ glTransformFeedbackBufferBase(1337, 0, 0);
+ SUBTEST(GL_INVALID_OPERATION, pass,
+ "bind non-existing transform feedback BO");
+
+ /* bind a non-existing output BO */
+ glTransformFeedbackBufferBase(0, 0, 1337);
+ SUBTEST(GL_INVALID_VALUE, pass, "bind a non-existing output BO");
+
+ /* bind to a negative index */
+ glTransformFeedbackBufferBase(0, -1, xfb_buf[2]);
+ SUBTEST(GL_INVALID_VALUE, pass, "bind negative index");
+
+ /* bind to an index == max */
+ glTransformFeedbackBufferBase(0, max_bind_points, xfb_buf[2]);
+ SUBTEST(GL_INVALID_VALUE, pass, "bind to index == max_bind_points (%i)",
+ max_bind_points);
+
+ /* Set up the transform feedback buffer */
+ for (i = 0; i < 2; i++) {
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[i]);
+ glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
+ xfb_buf_size, NULL, GL_STREAM_READ);
+ glTransformFeedbackBufferBase(0, i, xfb_buf[i]);
+ piglit_check_gl_error(GL_NO_ERROR);
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glGenQueries(1, &q);
+ glBeginQuery(GL_PRIMITIVES_GENERATED, q);
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ glBeginTransformFeedback(GL_POINTS);
+ glBindBuffer(GL_ARRAY_BUFFER, vert_buf);
+ glVertexPointer(3, GL_FLOAT, 0, 0);
+ glEnable(GL_VERTEX_ARRAY);
+ glDrawArrays(GL_POINTS, 0, 3);
+ glEndTransformFeedback();
+
+ glEndQuery(GL_PRIMITIVES_GENERATED);
+
+ glGetQueryObjectuiv(q, GL_QUERY_RESULT, &num_prims);
+ glDeleteQueries(1, &q);
+ printf("%u primitives generated:\n", num_prims);
+
+ if (num_prims != NUM_VERTS) {
+ printf("Incorrect number of prims generated.\n");
+ printf("Found %u, expected %u\n", num_prims, NUM_VERTS);
+ pass = false;
+ }
+
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[0]);
+ v = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY);
+ piglit_check_gl_error(GL_NO_ERROR);
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[1]);
+ w = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY);
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ for (i = 0; i < num_prims; i++) {
+ printf("vertex %2d: pos %5.2g, %5.2g, %5.2g, %5.2g "
+ "color %5.2g, %5.2g, %5.2g, %5.2g\n", i,
+ v[i*4+0], v[i*4+1], v[i*4+2], v[i*4+3],
+ w[i*4+0], w[i*4+1], w[i*4+2], w[i*4+3]);
+
+ for(j = 0; j < 3; j++) {
+ if (!equal(v[i*4+j], verts_ret[i][j])) {
+ printf(" Incorrect coord %i for point %d: "
+ "%f instead of %f\n",
+ j, i, v[i*4+j], verts_ret[i][j]);
+ test = false;
+ }
+ if (!equal(w[i*4+j], color_ret[i][j])) {
+ printf(" Incorrect color component %i for point %d: "
+ "%f instead of %f\n",
+ j, i, w[i*4+j], color_ret[i][j]);
+ test = false;
+ }
+ }
+ }
+ SUBTESTCONDITION(test, pass, "general test");
+
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[0]);
+ glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[1]);
+ glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
--
2.2.2
More information about the Piglit
mailing list