[Piglit] [PATCH 02/14] util: Add piglit_glx_error_string to convert a GLX error to a printable string

Ian Romanick idr at freedesktop.org
Thu Dec 8 17:42:14 PST 2011


On 12/08/2011 03:56 PM, Brian Paul wrote:
> On 12/08/2011 04:41 PM, Ian Romanick wrote:
>> From: Ian Romanick<ian.d.romanick at intel.com>
>>
>> Signed-off-by: Ian Romanick<ian.d.romanick at intel.com>
>> ---
>> tests/util/piglit-glx-util.c | 34 ++++++++++++++++++++++++++++++++++
>> tests/util/piglit-glx-util.h | 3 +++
>> 2 files changed, 37 insertions(+), 0 deletions(-)
>>
>> diff --git a/tests/util/piglit-glx-util.c b/tests/util/piglit-glx-util.c
>> index f8b0d2e..0900788 100644
>> --- a/tests/util/piglit-glx-util.c
>> +++ b/tests/util/piglit-glx-util.c
>> @@ -351,6 +351,40 @@ piglit_glx_get_error(Display *dpy, XErrorEvent *err)
>> return err->error_code - errbase;
>> }
>>
>> +/**
>> + * Convert a GLX error code to a printable string
>> + *
>> + * \sa piglit_glx_get_error
>> + */
>> +const char *
>> +piglit_glx_error_string(int err)
>> +{
>> + static const char *const error_table[] = {
>> + "GLXBadContext",
>> + "GLXBadContextState",
>> + "GLXBadDrawable",
>> + "GLXBadPixmap",
>> + "GLXBadContextTag",
>> + "GLXBadCurrentWindow",
>> + "GLXBadRenderRequest",
>> + "GLXBadLargeRequest",
>> + "GLXUnsupportedPrivateRequest",
>> + "GLXBadFBConfig",
>> + "GLXBadPbuffer",
>> + "GLXBadCurrentDrawable",
>> + "GLXBadWindow",
>> + "GLXBadProfileARB"
>> + };
>> +
>> + if (err < 0) {
>> + return "non-GLX error";
>> + } else if (err > ARRAY_SIZE(error_table)) {
>
> Shouldn't that be >= ?

Yes, of course. *blush*

>> + return "unknown GLX error";
>> + } else {
>> + return error_table[err];
>> + }
>> +}
>> +
>> /* Creates a GLX context for rendering into an FBO */
>> void
>> piglit_framework_fbo_init_glx()
>> diff --git a/tests/util/piglit-glx-util.h b/tests/util/piglit-glx-util.h
>> index dcd91cb..e05688c 100644
>> --- a/tests/util/piglit-glx-util.h
>> +++ b/tests/util/piglit-glx-util.h
>> @@ -52,3 +52,6 @@ GLXFBConfig
>> piglit_glx_get_fbconfig_for_visinfo(Display *dpy, XVisualInfo *visinfo);
>> int
>> piglit_glx_get_error(Display *dpy, XErrorEvent *err);
>> +
>> +const char *
>> +piglit_glx_error_string(int err);


More information about the Piglit mailing list