[Piglit] [v4 06/11] arb_transform_feedback3: add test trying to set invalid separate mode
Topi Pohjolainen
topi.pohjolainen at intel.com
Thu Nov 14 04:20:29 PST 2013
Passes on NVIDIA (304.88 on GTX 660) and on Ivy Bridge.
v2 (Ian):
- drop "piglit_require_GLSL_version(150)" as the test already
requires 3.2
- drop doxygen comment style where not necessary
- let 'asprintf()' allocate space for the generated varying
names insetad of using one larger chunk and managing it
manually
- added the mandatory (max_vertices = 1) into the output layout
declaration
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
tests/all.tests | 1 +
.../spec/arb_transform_feedback3/CMakeLists.gl.txt | 1 +
.../arb_transform_feedback3/set_invalid_varyings.c | 182 +++++++++++++++++++++
3 files changed, 184 insertions(+)
create mode 100644 tests/spec/arb_transform_feedback3/set_invalid_varyings.c
diff --git a/tests/all.tests b/tests/all.tests
index 38ee637..3ae92d2 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2489,6 +2489,7 @@ arb_transform_feedback3['arb_transform_feedback3-query_with_invalid_index'] = Pl
arb_transform_feedback3['arb_transform_feedback3-end_query_with_name_zero'] = PlainExecTest(['arb_transform_feedback3-end_query_with_name_zero', '-auto'])
arb_transform_feedback3['arb_transform_feedback3-draw_using_invalid_stream_index'] = PlainExecTest(['arb_transform_feedback3-draw_using_invalid_stream_index', '-auto'])
arb_transform_feedback3['arb_transform_feedback3-set_varyings_with_invalid_args'] = PlainExecTest(['arb_transform_feedback3-set_varyings_with_invalid_args', '-auto'])
+arb_transform_feedback3['arb_transform_feedback3-set_invalid_varyings'] = PlainExecTest(['arb_transform_feedback3-set_invalid_varyings', '-auto'])
arb_uniform_buffer_object = Group()
spec['ARB_uniform_buffer_object'] = arb_uniform_buffer_object
diff --git a/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
index 46809be..1205a07 100644
--- a/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
@@ -13,5 +13,6 @@ piglit_add_executable (arb_transform_feedback3-query_with_invalid_index query_wi
piglit_add_executable (arb_transform_feedback3-end_query_with_name_zero end_query_with_name_zero.c)
piglit_add_executable (arb_transform_feedback3-draw_using_invalid_stream_index draw_using_invalid_stream_index.c)
piglit_add_executable (arb_transform_feedback3-set_varyings_with_invalid_args set_varyings_with_invalid_args.c)
+piglit_add_executable (arb_transform_feedback3-set_invalid_varyings set_invalid_varyings.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback3/set_invalid_varyings.c b/tests/spec/arb_transform_feedback3/set_invalid_varyings.c
new file mode 100644
index 0000000..06362e5
--- /dev/null
+++ b/tests/spec/arb_transform_feedback3/set_invalid_varyings.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "xfb3_common.h"
+
+/**
+ * @file set_invalid_varyings.c
+ *
+ * Tests that varyings for separate attributes cannot be set using keywords
+ * reserved solely for the interleaved use. The spec:
+ *
+ * "The error INVALID_OPERATION is generated by TransformFeedbackVaryings
+ * if any pointer in <varyings> identifies the special names "gl_NextBuffer",
+ * "gl_SkipComponents1", "gl_SkipComponents2", "gl_SkipComponents3", or
+ * "gl_SkipComponents4" and <bufferMode> is not INTERLEAVED_ATTRIBS_NV, or if
+ * the number of "gl_NextBuffer" pointers in <varyings> is greater than or
+ * equal to the value of MAX_TRANSFORM_FEEDBACK_BUFFERS."
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 32;
+ config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char gs_simple_text[] =
+ "#version 150\n"
+ "layout(points) in;\n"
+ "layout(points, max_vertices = 1) out;\n"
+ "out float x1_out;\n"
+ "void main() {\n"
+ " gl_Position = gl_in[0].gl_Position;\n"
+ " x1_out = 1.0;\n"
+ "}";
+
+static const struct {
+ const char *description;
+ const char *varyings[2];
+} invalid_for_separated[] = {
+ {
+ "gl_NextBuffer should not be accepted in separate mode",
+ { "x1_out", "gl_NextBuffer" }
+ },
+ {
+ "gl_SkipComponents1 should not be accepted in separate mode",
+ { "gl_SkipComponents1", "x1_out" }
+ },
+ {
+ "gl_SkipComponents2 should not be accepted in separate mode",
+ { "gl_SkipComponents2", "x1_out" }
+ },
+ {
+ "gl_SkipComponents3 should not be accepted in separate mode",
+ { "gl_SkipComponents3", "x1_out" }
+ },
+ {
+ "gl_SkipComponents4 should not be accepted in separate mode",
+ { "gl_SkipComponents4", "x1_out" }
+ }
+};
+
+static bool
+try_invalid_separate_mode(GLuint prog)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE(invalid_for_separated); ++i) {
+ glTransformFeedbackVaryings(prog,
+ ARRAY_SIZE(invalid_for_separated[i].varyings),
+ invalid_for_separated[i].varyings,
+ GL_SEPARATE_ATTRIBS);
+
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+ printf("fail: %s\n",
+ invalid_for_separated[i].description);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Dynamically reserve space and setup an array of 'n + n + 1' string pointers
+ * having the following layout:
+ *
+ * [0]: "x_0x00000000"
+ * [1]: "gl_NextBuffer"
+ * [2]: "x_0x00000001"
+ * [3]: "gl_NextBuffer"
+ * ...
+ * [2n]: "x_0x..n"
+ *
+ * For testing the upper bound of sepators (gl_NextBuffer) the varying names
+ * need to be mutually unique as the driver could simply bail out before
+ * encountering 'n' separators simply because the driver did not except already
+ * declared varying.
+ */
+static bool
+try_max_separators(GLuint prog, unsigned n)
+{
+ /* 'n' + 1 varying names and 'n' separators */
+ const unsigned var_n = 2 * n + 1;
+ const char **vars;
+ unsigned i;
+
+ vars = (const char **)malloc(var_n * sizeof(const char *));
+
+ for (i = 0; i <= n; ++i) {
+ asprintf((char **)&vars[2 * i + 0], "x_0x%08x", i);
+
+ if (i < n) {
+ static const char separator[] = "gl_NextBuffer";
+ vars[2 * i + 1] = separator;
+ }
+ }
+
+ glTransformFeedbackVaryings(prog, var_n, vars, GL_INTERLEAVED_ATTRIBS);
+
+ for (i = 0; i <= n; ++i)
+ free((char *)vars[2 * i + 0]);
+
+ free(vars);
+
+ return piglit_check_gl_error(GL_INVALID_OPERATION);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+ GLuint prog;
+ GLint max_attrib_n;
+
+ piglit_require_extension("GL_ARB_transform_feedback3");
+
+ glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
+ &max_attrib_n);
+ if (!max_attrib_n) {
+ printf("Maximum number of separete attributes is zero\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ prog = piglit_build_simple_program_multiple_shaders(
+ GL_VERTEX_SHADER, vs_pass_thru_text,
+ GL_GEOMETRY_SHADER, gs_simple_text, 0);
+
+ /* Try too many attributes */
+ pass = try_invalid_separate_mode(prog) && pass;
+ pass = try_max_separators(prog, max_attrib_n) && pass;
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ /* Should never be reached */
+ return PIGLIT_FAIL;
+}
--
1.8.3.1
More information about the Piglit
mailing list