summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2010-09-09 12:59:14 -0400
committerKristian Høgsberg <[email protected]>2010-09-09 13:21:15 -0400
commitb9abc6139a310677a37754ea7172d976dbf56979 (patch)
treedd42377907938fe8a5e9eb3c24ec3df678a0fe25 /src/mesa/main/context.c
parent94118fe2d4b1e5d0b9f39d9d2c44706db462e97e (diff)
glapi: Implement optional dispatch logging
There's a useful feature buried in glapi to log all API calls to stderr. Unfortunately it requires editing the code and then it's enabled unconditionally for that build. This patch builds in API logging for debug builds and makes it run-time switchable by setting MESA_DEBUG=dispatch.
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8e34ec4124f..73d96e8d212 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1367,6 +1367,26 @@ _mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height)
}
}
+static void
+dispatch_logger(void *data, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+void
+_mesa_set_dispatch(void *table)
+{
+ if (table && (MESA_VERBOSE & VERBOSE_DISPATCH)) {
+ _glapi_set_dispatch(table);
+ _glapi_enable_logging(dispatch_logger, stderr);
+ } else {
+ _glapi_set_dispatch(table);
+ }
+}
/**
* Bind the given context to the given drawBuffer and readBuffer and
@@ -1411,10 +1431,10 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
ASSERT(_mesa_get_current_context() == newCtx);
if (!newCtx) {
- _glapi_set_dispatch(NULL); /* none current */
+ _mesa_set_dispatch(NULL); /* none current */
}
else {
- _glapi_set_dispatch(newCtx->CurrentDispatch);
+ _mesa_set_dispatch(newCtx->CurrentDispatch);
if (drawBuffer && readBuffer) {
/* TODO: check if newCtx and buffer's visual match??? */