From: Brian Paul Date: Wed, 3 Jun 2009 23:03:11 +0000 (-0600) Subject: vbo: move/refactor debug code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa18e54ac9a70883a98f803c097d45f8ee84e717;p=mesa.git vbo: move/refactor debug code --- diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 74d3e19baf8..ca24fb443f3 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -233,6 +233,52 @@ check_draw_arrays_data(GLcontext *ctx, GLint start, GLsizei count) } +/** + * Print info/data for glDrawArrays(). + */ +static void +print_draw_arrays(GLcontext *ctx, struct vbo_exec_context *exec, + GLenum mode, GLint start, GLsizei count) +{ + int i; + + _mesa_printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", + mode, start, count); + + for (i = 0; i < 32; i++) { + GLuint bufName = exec->array.inputs[i]->BufferObj->Name; + GLint stride = exec->array.inputs[i]->Stride; + _mesa_printf("attr %2d: size %d stride %d enabled %d " + "ptr %p Bufobj %u\n", + i, + exec->array.inputs[i]->Size, + stride, + /*exec->array.inputs[i]->Enabled,*/ + exec->array.legacy_array[i]->Enabled, + exec->array.inputs[i]->Ptr, + bufName); + + if (bufName) { + struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName); + GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, + GL_READ_ONLY_ARB, buf); + int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr; + float *f = (float *) (p + offset); + int *k = (int *) f; + int i; + int n = (count * stride) / 4; + if (n > 32) + n = 32; + _mesa_printf(" Data at offset %d:\n", offset); + for (i = 0; i < n; i++) { + _mesa_printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); + } + ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf); + } + } +} + + /** * Just translate the arrayobj into a sane layout. */ @@ -455,44 +501,9 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) start, start + count - 1 ); #if 0 - { - int i; - - _mesa_printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", - mode, start, count); - - for (i = 0; i < 32; i++) { - GLuint bufName = exec->array.inputs[i]->BufferObj->Name; - GLint stride = exec->array.inputs[i]->Stride; - _mesa_printf("attr %2d: size %d stride %d enabled %d " - "ptr %p Bufobj %u\n", - i, - exec->array.inputs[i]->Size, - stride, - /*exec->array.inputs[i]->Enabled,*/ - exec->array.legacy_array[i]->Enabled, - exec->array.inputs[i]->Ptr, - bufName); - - if (bufName) { - struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName); - GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, - GL_READ_ONLY_ARB, buf); - int offset = (int) exec->array.inputs[i]->Ptr; - float *f = (float *) (p + offset); - int *k = (int *) f; - int i; - int n = (count * stride) / 4; - if (n > 32) - n = 32; - _mesa_printf(" Data at offset %d:\n", offset); - for (i = 0; i < n; i++) { - _mesa_printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); - } - ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf); - } - } - } + print_draw_arrays(ctx, exec, mode, start, count); +#else + (void) print_draw_arrays; #endif }