[Piglit] [PATCH 1/2] util: Add function piglit_get_gl_error_name

Eric Anholt eric at anholt.net
Wed Aug 17 18:01:02 PDT 2011


On Wed, 17 Aug 2011 17:25:43 -0700, Chad Versace <chad at chad-versace.us> wrote:
> 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);

There's the ARRAY_SIZE() macro for this.

> +
> +	for (i = 0; i < n; ++i) {
> +		if (error == piglit_gl_error_table[i].value) {
> +			return piglit_gl_error_table[i].name;
> +		}
> +	}
> +
> +	return NULL;
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20110817/c9039ad2/attachment.pgp>


More information about the Piglit mailing list