diff options
author | Brian Paul <[email protected]> | 2012-04-06 15:44:56 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-04-11 07:00:01 -0600 |
commit | 223654b81ddb50cc42ed8cd722b389b302a26980 (patch) | |
tree | 91dc3bce386d5ecdb347e3d6a47e8d0459dac01c | |
parent | 5154b45217695e5daf24110bcff043fa1959d0a5 (diff) |
mesa: new _mesa_total_buffer_object_memory() debug function
This function can be called in gdb to find out how much memory is used
by buffer objects.
-rw-r--r-- | src/mesa/main/bufferobj.c | 30 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.h | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index eef10c42213..ae7bac14dbd 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -347,6 +347,36 @@ _mesa_initialize_buffer_object( struct gl_context *ctx, } + +/** + * Callback called from _mesa_HashWalk() + */ +static void +count_buffer_size(GLuint key, void *data, void *userData) +{ + const struct gl_buffer_object *bufObj = + (const struct gl_buffer_object *) data; + GLuint *total = (GLuint *) userData; + + *total = *total + bufObj->Size; +} + + +/** + * Compute total size (in bytes) of all buffer objects for the given context. + * For debugging purposes. + */ +GLuint +_mesa_total_buffer_object_memory(struct gl_context *ctx) +{ + GLuint total = 0; + + _mesa_HashWalk(ctx->Shared->BufferObjects, count_buffer_size, &total); + + return total; +} + + /** * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If \c data is \c NULL, diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index a7ce3792898..66343c3cd44 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -89,6 +89,8 @@ _mesa_reference_buffer_object(struct gl_context *ctx, _mesa_reference_buffer_object_(ctx, ptr, bufObj); } +extern GLuint +_mesa_total_buffer_object_memory(struct gl_context *ctx); extern void _mesa_init_buffer_object_functions(struct dd_function_table *driver); |