Tests tricky cases of resource naming along with some error cases of
getprogramresourceindex. It also replaces the resource-index test that
was incomplete and did not consistently report the same number of
subtests depending on errors.
Signed-off-by: Martin Peres <martin.pe...@linux.intel.org>
---
tests/all.py | 2 +-
.../arb_program_interface_query/CMakeLists.gl.txt | 2 +-
tests/spec/arb_program_interface_query/common.h | 21 ++
.../getprogramresourceindex.c | 338
+++++++++++++++++++++
.../arb_program_interface_query/resource-index.c | 284
-----------------
5 files changed, 361 insertions(+), 286 deletions(-)
create mode 100755
tests/spec/arb_program_interface_query/getprogramresourceindex.c
delete mode 100644
tests/spec/arb_program_interface_query/resource-index.c
diff --git a/tests/all.py b/tests/all.py
index 86f2369..170d5b8 100755
--- a/tests/all.py
+++ b/tests/all.py
@@ -2273,9 +2273,9 @@ with profile.group_manager(
PiglitGLTest,
grouptools.join('spec', 'ARB_program_interface_query')) as g:
g(['arb_program_interface_query-resource-location'],
run_concurrent=False)
- g(['arb_program_interface_query-resource-index'],
run_concurrent=False)
g(['arb_program_interface_query-resource-query'],
run_concurrent=False)
g(['arb_program_interface_query-getprograminterfaceiv'],
run_concurrent=False)
+ g(['arb_program_interface_query-getprogramresourceindex'],
run_concurrent=False)
# Group ARB_explicit_uniform_location
with profile.group_manager(
diff --git a/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
b/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
index 91ace72..8b3bbd9 100755
--- a/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
@@ -10,6 +10,6 @@ link_libraries (
)
piglit_add_executable (arb_program_interface_query-resource-location
resource-location.c)
-piglit_add_executable (arb_program_interface_query-resource-index
resource-index.c)
piglit_add_executable (arb_program_interface_query-resource-query
resource-query.c)
piglit_add_executable
(arb_program_interface_query-getprograminterfaceiv
getprograminterfaceiv.c)
+piglit_add_executable
(arb_program_interface_query-getprogramresourceindex
getprogramresourceindex.c)
diff --git a/tests/spec/arb_program_interface_query/common.h
b/tests/spec/arb_program_interface_query/common.h
index cc0b2bd..457e79e 100755
--- a/tests/spec/arb_program_interface_query/common.h
+++ b/tests/spec/arb_program_interface_query/common.h
@@ -35,6 +35,27 @@ static const char fs_empty[] =
"void main() {\n"
"}";
+static const char vs_array[] =
+ "#version 150\n"
+ "in vec4 vs_input[2];\n"
+ "struct vs_struct {\n"
+ " vec4 hello;\n"
+ " vec4 world[2];\n"
+ "};\n"
+ "uniform vs_struct sa[2];\n"
+ "void main() {\n"
+ " gl_Position = vs_input[0] + sa[0].hello + sa[0].world[0];\n"
+ "}";
+
+static const char vs_aofa[] =
+ "#version 150\n"
+ "#extension GL_ARB_arrays_of_arrays : require\n"
+ "in vec4 vs_input2[2][2];\n"
+ "in vec4 vs_input3[2][2][2];\n"
+ "void main() {\n"
+ " gl_Position = vs_input2[0][0] + vs_input3[0][0][0];\n"
+ "}";
+
static const char vs_std[] =
"#version 150\n"
"struct vs_struct {\n"
diff --git
a/tests/spec/arb_program_interface_query/getprogramresourceindex.c
b/tests/spec/arb_program_interface_query/getprogramresourceindex.c
new file mode 100755
index 0000000..41aac3d
--- /dev/null
+++ b/tests/spec/arb_program_interface_query/getprogramresourceindex.c
@@ -0,0 +1,338 @@
+/*
+ * Copyright © 2015 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.
+ */
+
+/**
+ * \file getprogramresourceindex.c
+ *
+ * Tests the errors reported by the GetProgramResourceIndex interface
while also
+ * testing tricky naming cases. The real functional test is in
resource-query.c.
+ *
+ * From the GL_ARB_program_interface_query spec:
+ * "The command
+ *
+ * uint GetProgramResourceIndex(uint program, enum
programInterface,
+ * const char *name);
+ *
+ * returns the unsigned integer index assigned to a resource
named <name>
+ * in the interface type <programInterface> of program object
<program>.
+ * The error INVALID_ENUM is generated if <programInterface> is
+ * ATOMIC_COUNTER_BUFFER, since active atomic counter buffer
resources are
+ * not assigned name strings.
+ *
+ * If <name> exactly matches the name string of one of the
active resources
+ * for <programInterface>, the index of the matched resource is
returned.
+ * Additionally, if <name> would exactly match the name string
of an active
+ * resource if "[0]" were appended to <name>, the index of the
matched
+ * resource is returned. Otherwise, <name> is considered not to
be the
+ * name of an active resource, and INVALID_INDEX is returned.
Note that if
+ * an interface enumerates a single active resource list entry
for an array
+ * variable (e.g., "a[0]"), a <name> identifying any array
element other
+ * than the first (e.g., "a[1]") is not considered to match.
+ *
+ * For the interface TRANSFORM_FEEDBACK_VARYING, the value
INVALID_INDEX
+ * should be returned when querying the index assigned to the
special names
+ * "gl_NextBuffer", "gl_SkipComponents1", "gl_SkipComponents2",
+ * "gl_SkipComponents3", and "gl_SkipComponents4".
+ *
+ * [...]
+ *
+ * An INVALID_VALUE error is generated by GetProgramInterfaceiv,
+ * GetProgramResourceIndex, GetProgramResourceName,
GetProgramResourceiv,
+ * GetProgramResourceLocation, and
GetProgramResourceLocationIndex if
+ * <program> is not the name of either a shader or program object.
+ *
+ * An INVALID_OPERATION error is generated by
GetProgramInterfaceiv,
+ * GetProgramResourceIndex, GetProgramResourceName,
GetProgramResourceiv,
+ * GetProgramResourceLocation, and
GetProgramResourceLocationIndex if
+ * <program> is the name of a shader object.
+ *
+ * [...]
+ *
+ * INVALID_ENUM is generated by GetProgramResourceIndex if
+ * <programInterface> is ATOMIC_COUNTER_BUFFER."
+ */
+
+#include "piglit-util-gl.h"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/* Naming conventions, from the GL_ARB_program_interface_query
extension:
+ *
+ * "When building a list of active variable or interface blocks,
resources
+ * with aggregate types (such as arrays or structures) may produce
multiple
+ * entries in the active resource list for the corresponding interface.
+ * Additionally, each active variable, interface block, or subroutine
in the
+ * list is assigned an associated name string that can be used by
+ * applications to refer to the resources. For interfaces involving
+ * variables, interface blocks, or subroutines, the entries of active
+ * resource lists are generated as follows:
+ *
+ * * For an active variable declared as a single instance of a basic
type,
+ * a single entry will be generated, using the variable name from the
+ * shader source.
+ *
+ * * For an active variable declared as an array of basic types, a
single
+ * entry will be generated, with its name string formed by
concatenating
+ * the name of the array and the string "[0]".
+ *
+ * * For an active variable declared as a structure, a separate
entry will
+ * be generated for each active structure member. The name of
each entry
+ * is formed by concatenating the name of the structure, the "."
+ * character, and the name of the structure member. If a structure
+ * member to enumerate is itself a structure or array, these
enumeration
+ * rules are applied recursively.
+ *
+ * * For an active variable declared as an array of an aggregate
data type
+ * (structures or arrays), a separate entry will be generated for
each
+ * active array element, unless noted immediately below. The name of
+ * each entry is formed by concatenating the name of the array,
the "["
+ * character, an integer identifying the element number, and the "]"
+ * character. These enumeration rules are applied recursively,
treating
+ * each enumerated array element as a separate active variable.
+ *
+ * * For an active shader storage block member declared as an array, an
+ * entry will be generated only for the first array element,
regardless
+ * of its type. For arrays of aggregate types, the enumeration
rules are
+ * applied recursively for the single enumerated array element.
+ *
+ * * For an active interface block not declared as an array of block
+ * instances, a single entry will be generated, using the block
name from
+ * the shader source.
+ *
+ * * For an active interface block declared as an array of instances,
+ * separate entries will be generated for each active instance.
The name
+ * of the instance is formed by concatenating the block name, the "["
+ * character, an integer identifying the instance number, and the "]"
+ * character.
+ *
+ * * For an active subroutine, a single entry will be generated,
using the
+ * subroutine name from the shader source.
+ *
+ * When an integer array element or block instance number is part of
the name
+ * string, it will be specified in decimal form without a "+" or "-"
sign or
+ * any extra leading zeroes. Additionally, the name string will not
include
+ * white space anywhere in the string.
+ */
+
+struct subtest_index_t {
+ const char *vs_text;
+
+ GLenum programInterface;
+ const char *name;
+ GLint expect_value; /* 0 == any number >= 0, -1 == INVALID_INDEX */
+ GLenum expected_error;
+
+ const char *programInterface_str;
+ const char *error_str;
+};
+
+#define ST(vs_text, programInterface, name, value, error) { \
+ (vs_text), (programInterface), (name), (value), (error), \
+ #programInterface, #error \
+}
+
+/* Test for arrays of arrays */
+static const struct subtest_index_t index_subtests[] = {
+ ST(vs_empty, GL_ATOMIC_COUNTER_BUFFER, "dummy",
-1, GL_INVALID_ENUM),
+ ST(vs_empty, GL_UNIFORM, "dummy",
-1, GL_NO_ERROR),
+ ST(vs_empty, GL_TRUE, "vs_input",
0, GL_INVALID_ENUM),
+ ST(vs_array, GL_PROGRAM_INPUT, "vs_input",
0, GL_NO_ERROR),
+ ST(vs_array, GL_PROGRAM_INPUT, "vs_input[0]",
0, GL_NO_ERROR),
+ ST(vs_array, GL_PROGRAM_INPUT, "vs_input[1]",
-1, GL_NO_ERROR),
+ ST(vs_array, GL_UNIFORM, "hello",
-1, GL_NO_ERROR),
+ ST(vs_array, GL_UNIFORM, "sa[0].hello",
0, GL_NO_ERROR),
+ ST(vs_array, GL_UNIFORM, "sa[0].world",
0, GL_NO_ERROR),
+ ST(vs_array, GL_UNIFORM, "sa[0].world[0]",
0, GL_NO_ERROR),
+ ST(vs_array, GL_UNIFORM, "sa[1].hello",
-1, GL_NO_ERROR),
+ ST( vs_aofa, GL_PROGRAM_INPUT, "vs_input2",
-1, GL_NO_ERROR),
+ ST( vs_aofa, GL_PROGRAM_INPUT, "vs_input2[0]",
0, GL_NO_ERROR),
+ ST( vs_aofa, GL_PROGRAM_INPUT, "vs_input2[0][0]",
0, GL_NO_ERROR),
+ ST( vs_aofa, GL_PROGRAM_INPUT, "vs_input2[1][0]",
-1, GL_NO_ERROR),
+ ST( vs_aofa, GL_PROGRAM_INPUT, "vs_input2[0][1]",
-1, GL_NO_ERROR),