[Piglit] [PATCH 5/6] arb_transform_feedback3: add test trying to set invalid varyings
Topi Pohjolainen
topi.pohjolainen at intel.com
Tue Oct 22 15:48:23 CEST 2013
Non-existing program case crashes on NVIDIA (319.60 on GTX 660)
but exceeding maximum attribute case passes.
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
tests/all.tests | 1 +
.../spec/arb_transform_feedback3/CMakeLists.gl.txt | 1 +
.../set_varyings_with_invalid_args.c | 121 +++++++++++++++++++++
3 files changed, 123 insertions(+)
create mode 100644 tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c
diff --git a/tests/all.tests b/tests/all.tests
index 6e2fb2c..172bf04 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2359,6 +2359,7 @@ arb_transform_feedback3['arb_transform_feedback3-ext_interleaved_single_gs_many_
arb_transform_feedback3['arb_transform_feedback3-ext_interleaved_draw_streams'] = PlainExecTest(['arb_transform_feedback3-ext_interleaved_draw_streams', '-auto'])
arb_transform_feedback3['arb_transform_feedback3-bind_buffer_invalid_index'] = PlainExecTest(['arb_transform_feedback3-bind_buffer_invalid_index', '-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'])
for param in ['vs', 'gs', 'gs_max']:
arb_transform_feedback3['arb_transform_feedback3-ext_interleaved_two_bufs_vs'] = PlainExecTest(['arb_transform_feedback3-ext_interleaved_two_bufs', '-auto', param])
diff --git a/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
index ceb2cab..888683a 100644
--- a/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
@@ -16,5 +16,6 @@ piglit_add_executable (arb_transform_feedback3-bind_buffer_invalid_index bind_bu
piglit_add_executable (arb_transform_feedback3-query_with_invalid_index query_with_invalid_index.c)
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)
# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c b/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c
new file mode 100644
index 0000000..b9b085b
--- /dev/null
+++ b/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c
@@ -0,0 +1,121 @@
+/*
+ * 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_varyings_with_invalid_args.c
+ *
+ * Tests that TransformFeedbackVaryings() does not accept non-existing program
+ * and that the upper limit for the number of attributes is guarded. The spec:
+ *
+ * "The error INVALID_VALUE is generated by TransformFeedbackVaryings if
+ * <program> is not the name of a program object, or if <bufferMode> is
+ * SEPARATE_ATTRIBS and <count> is greater than the limit
+ * MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS."
+ */
+
+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) 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 char *varyings[] = { "x1_out" };
+
+/**
+ * Dynamically reserve space and setup an array of 'n' string pointers all
+ * referring to 'varyings'. For testing the upper bound of attributes expected
+ * the string values do not need to be mutually unique but in order to respect
+ * the API there should be as many strings available in the array as claimed.
+ */
+static void
+try_max_varyings(GLuint prog, unsigned n)
+{
+ const char **var_array;
+ const char **curr;
+ unsigned i;
+
+ curr = var_array = (const char**)malloc(n * sizeof(const char *));
+
+ for (i = 0; i < n; ++i) {
+ *curr++ = varyings[0];
+ }
+
+ glTransformFeedbackVaryings(prog, n, var_array, GL_SEPARATE_ATTRIBS);
+
+ free(var_array);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint prog;
+ GLint max_attrib_n;
+
+ piglit_require_GLSL_version(150);
+ 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 invalid program */
+ glTransformFeedbackVaryings(prog + 1, ARRAY_SIZE(varyings), varyings,
+ GL_INTERLEAVED_ATTRIBS);
+ if (!piglit_check_gl_error(GL_INVALID_VALUE))
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Try too many attributes */
+ try_max_varyings(prog, max_attrib_n + 1);
+ if (!piglit_check_gl_error(GL_INVALID_VALUE))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ /* Should never be reached */
+ return PIGLIT_FAIL;
+}
--
1.8.3.1
More information about the Piglit
mailing list