[Piglit] [PATCH v2 04/17] shader_runner: add support for glGetProgram queries
Alejandro PiƱeiro
apinheiro at igalia.com
Thu Sep 27 09:54:54 UTC 2018
Similar to the already existing verify program_interface_query, but
with the glGetProgramiv queries.
Useful, for example, to verify the current number of active (via
GL_ACTIVE_UNIFORMS).
Note that now there are two ways to verify link success. With the
already existing "link succes" shader runner query, or using this one:
vefiry program_query GL_LINK_STATUS GL_TRUE
Although internally they are checked in a different way. It is pending
to check if there are corner cases where they return a different
value.
---
tests/shaders/shader_runner.c | 78 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index e359f97ad..4ba1d326d 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2783,6 +2783,82 @@ set_subroutine_uniform(const char *line)
return;
}
+/**
+ * Query values from current program using glGetProgram.
+ *
+ * Format of the command:
+ * verify program_query GL_PNAME_ENUM integer
+ *
+ * or
+ *
+ * verify program_query GL_PNAME_ENUM <enum>
+ *
+ * Note: GL_COMPUTE_WORK_GROUP_SIZE is not supported, as is the only
+ * query that requires a params with more than one component, and we
+ * want to keep things simple.
+ *
+ */
+static void
+verify_program_query(const char *line)
+{
+ static const struct string_to_enum all_pnames[] = {
+ ENUM_STRING(GL_DELETE_STATUS),
+ ENUM_STRING(GL_LINK_STATUS),
+ ENUM_STRING(GL_VALIDATE_STATUS),
+ ENUM_STRING(GL_INFO_LOG_LENGTH),
+ ENUM_STRING(GL_ATTACHED_SHADERS),
+ ENUM_STRING(GL_ACTIVE_ATOMIC_COUNTER_BUFFERS),
+ ENUM_STRING(GL_ACTIVE_ATTRIBUTES),
+ ENUM_STRING(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH),
+ ENUM_STRING(GL_ACTIVE_UNIFORMS),
+ ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCKS),
+ ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH),
+ ENUM_STRING(GL_ACTIVE_UNIFORM_MAX_LENGTH),
+ ENUM_STRING(GL_COMPUTE_WORK_GROUP_SIZE),
+ ENUM_STRING(GL_PROGRAM_BINARY_LENGTH),
+ ENUM_STRING(GL_TRANSFORM_FEEDBACK_BUFFER_MODE),
+ ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYINGS),
+ ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH),
+ ENUM_STRING(GL_GEOMETRY_VERTICES_OUT),
+ ENUM_STRING(GL_GEOMETRY_INPUT_TYPE),
+ ENUM_STRING(GL_GEOMETRY_OUTPUT_TYPE),
+ { NULL, 0 }
+ };
+
+ static const struct string_to_enum all_possible_param_enums[] = {
+ ENUM_STRING(GL_TRUE),
+ ENUM_STRING(GL_FALSE),
+ ENUM_STRING(GL_SEPARATE_ATTRIBS),
+ ENUM_STRING(GL_INTERLEAVED_ATTRIBS),
+ ENUM_STRING(GL_POINTS),
+ ENUM_STRING(GL_LINES),
+ ENUM_STRING(GL_LINES_ADJACENCY),
+ ENUM_STRING(GL_TRIANGLES),
+ ENUM_STRING(GL_TRIANGLES_ADJACENCY),
+ { NULL, 0 }
+ };
+
+ unsigned pname;
+ int expected;
+ int value;
+
+ REQUIRE(parse_enum_tab(all_pnames, line,
+ &pname, &line),
+ "Bad glGetProgram pname at: %s\n", line);
+
+ REQUIRE(parse_enum_tab(all_possible_param_enums, line, (unsigned *)&expected, &line) ||
+ parse_int(line, &expected, &line),
+ "Bad expected value at: %s\n", line);
+
+ glGetProgramiv(prog, pname, &value);
+
+ if (expected != value) {
+ fprintf(stderr, "glGetProgram(%s): expected %d, got %d\n",
+ piglit_get_gl_enum_name(pname), expected, value);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+}
+
/**
* Query a uniform using glGetActiveUniformsiv
*
@@ -4607,6 +4683,8 @@ piglit_display(void)
parse_ints(rest, &block_data.row_major, 1, NULL);
} else if (parse_str(line, "active uniform ", &rest)) {
active_uniform(rest);
+ } else if (parse_str(line, "verify program_query", &rest)) {
+ verify_program_query(rest);
} else if (parse_str(line, "verify program_interface_query ", &rest)) {
active_program_interface(rest, block_data);
} else if (parse_str(line, "vertex attrib ", &rest)) {
--
2.14.1
More information about the Piglit
mailing list