diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-05-11 16:50:45 +0100 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-05-11 16:50:45 +0100 |
commit | 049a8178675310901d504a508445e73c87acd634 (patch) | |
tree | 9a99ca61962aa737d813d073d1190cdc62b64df0 | |
parent | f368b357a76ef17ebcbd7478847b86767a487a2c (diff) |
Move CheckGLError to -debug.[ch]
The shader code will want to use this too. It's not strictly
debug-related, but hey.
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/videocore-debug.c | 50 | ||||
-rw-r--r-- | src/videocore-debug.h | 20 | ||||
-rw-r--r-- | src/videocore-exa.c | 43 |
4 files changed, 71 insertions, 43 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 242665c..724ae42 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,7 @@ videocore_drv_ladir = @moduledir@/drivers videocore_drv_la_SOURCES = \ videocore.c \ videocore.h \ + videocore-debug.c \ videocore-debug.h \ videocore-exa.c \ videocore-exa.h \ diff --git a/src/videocore-debug.c b/src/videocore-debug.c new file mode 100644 index 0000000..f804227 --- /dev/null +++ b/src/videocore-debug.c @@ -0,0 +1,50 @@ +/* vim: set noet sw=8 sts=8 cino=:0,t0,(0 : + * + * Copyright © 2012 Collabora Ltd. + * + * 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 fur- + * nished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice 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, FIT- + * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "videocore-debug.h" + +#include <GLES2/gl2.h> + +const char * +GetGLErrorString(void) +{ + GLenum error_code = glGetError (); + static char unknown_error_code[sizeof(GLenum) * 2 + 1]; + + switch (error_code) + { + case GL_NO_ERROR: + return NULL; + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY"; + default: + snprintf(unknown_error_code, sizeof(unknown_error_code), + "%x", error_code); + return unknown_error_code; + } +} diff --git a/src/videocore-debug.h b/src/videocore-debug.h index d7ead4a..99a96c8 100644 --- a/src/videocore-debug.h +++ b/src/videocore-debug.h @@ -53,4 +53,24 @@ extern Bool videoCoreDebug; do { xf86Msg(X_ERROR, "ERROR: " fmt "\n",\ ##__VA_ARGS__); } while (0) +const char *GetGLErrorString(void); + +/** + * CheckGLError: + * @context: a string giving additional context for the error + * + * If an error has occurred, evaluates to FALSE and logs a warning naming the + * error. If no error has occurred, evaluates to TRUE. + * + * Since this uses WARNING_MSG, ScrnInfoPtr pScrn must be in scope. + */ +#define CheckGLError(context) \ + ({ \ + const char *_error = GetGLErrorString(); \ + if (_error) { \ + WARNING_MSG("%s: %s\n", context, _error); \ + } \ + (_error == NULL); \ + }) + #endif /* VIDEOCORE_DEBUG_H */ diff --git a/src/videocore-exa.c b/src/videocore-exa.c index caa9037..f3303ac 100644 --- a/src/videocore-exa.c +++ b/src/videocore-exa.c @@ -58,49 +58,6 @@ pix2scrn(PixmapPtr pPixmap) return xf86Screens[(pPixmap)->drawable.pScreen->myNum]; } -static const char * -GetGLErrorString(void) -{ - GLenum error_code = glGetError (); - static char unknown_error_code[sizeof(GLenum) * 2 + 1]; - - switch (error_code) - { - case GL_NO_ERROR: - return NULL; - case GL_INVALID_ENUM: - return "GL_INVALID_ENUM"; - case GL_INVALID_VALUE: - return "GL_INVALID_VALUE"; - case GL_INVALID_OPERATION: - return "GL_INVALID_OPERATION"; - case GL_OUT_OF_MEMORY: - return "GL_OUT_OF_MEMORY"; - default: - snprintf(unknown_error_code, sizeof(unknown_error_code), - "%x", error_code); - return unknown_error_code; - } -} - -/** - * CheckGLError: - * @context: a string giving additional context for the error - * - * If an error has occurred, evaluates to FALSE and logs a warning naming the - * error. If no error has occurred, evaluates to TRUE. - * - * Since this uses WARNING_MSG, ScrnInfoPtr pScrn must be in scope. - */ -#define CheckGLError(context) \ - ({ \ - const char *_error = GetGLErrorString(); \ - if (_error) { \ - WARNING_MSG("%s: %s\n", context, _error); \ - } \ - (_error == NULL); \ - }) - Bool VideoCoreExaGetScreenSize(ScrnInfoPtr pScrn, uint32_t *width, uint32_t *height) |