[Piglit] [PATCH 1/2] util: Add function piglit_get_gl_error_name
Chad Versace
chad at chad-versace.us
Wed Aug 17 17:25:43 PDT 2011
It maps the error's GLenum to a string. For example, given
GL_INVALID_ENUM, it returns "GL_INVALID_ENUM".
Signed-off-by: Chad Versace <chad at chad-versace.us>
---
tests/util/piglit-util.c | 30 ++++++++++++++++++++++++++++++
tests/util/piglit-util.h | 11 +++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 78722d9..c3689d2 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -150,6 +150,36 @@ void piglit_require_not_extension(const char *name)
}
}
+static struct {
+ GLenum value;
+ const char *name;
+} piglit_gl_error_table[] = {
+#define F(x) { x, #x }
+ F(GL_NO_ERROR),
+ F(GL_INVALID_ENUM),
+ F(GL_INVALID_VALUE),
+ F(GL_INVALID_OPERATION),
+ F(GL_STACK_OVERFLOW),
+ F(GL_STACK_UNDERFLOW),
+ F(GL_OUT_OF_MEMORY)
+#undef F
+};
+
+const char* piglit_get_gl_error_name(GLenum error)
+{
+ int i;
+ int n = sizeof(piglit_gl_error_table)
+ / sizeof(*piglit_gl_error_table);
+
+ for (i = 0; i < n; ++i) {
+ if (error == piglit_gl_error_table[i].value) {
+ return piglit_gl_error_table[i].name;
+ }
+ }
+
+ return NULL;
+}
+
/* These texture coordinates should have 1 or -1 in the major axis selecting
* the face, and a nearly-1-or-negative-1 value in the other two coordinates
* which will be used to produce the s,t values used to sample that face's
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 015f960..2173148 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -115,6 +115,17 @@ void piglit_get_glsl_version(bool *es, int* major, int* minor);
*/
bool piglit_is_extension_supported(const char *name);
+/**
+ * \brief Convert a GL error to a string.
+ *
+ * For example, given GL_INVALID_ENUM, return "GL_INVALID_ENUM".
+ *
+ * Return null if the enum is not recognized.
+ *
+ * \todo Create a more general function that stringifies any GLenum.
+ */
+const char* piglit_get_gl_error_name(GLenum error);
+
int FindLine(const char *program, int position);
void piglit_report_result(enum piglit_result result);
void piglit_require_extension(const char *name);
--
1.7.6
More information about the Piglit
mailing list