From e7927626c13b8cd3743ba52a407b8f3736eae8a1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Jun 2009 15:38:57 -0600 Subject: [PATCH] mesa: added buffer object debug code (disabled) --- src/mesa/main/bufferobj.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 5fa13d9b542..3e011ef5b23 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1014,6 +1014,11 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, bufObj->Written = GL_TRUE; +#ifdef VBO_DEBUG + _mesa_printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", + bufObj->Name, size, data, usage); +#endif + /* Give the buffer object to the driver! may be null! */ ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj ); } @@ -1103,6 +1108,17 @@ _mesa_MapBufferARB(GLenum target, GLenum access) if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB) bufObj->Written = GL_TRUE; +#ifdef VBO_DEBUG + _mesa_printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", + bufObj->Name, bufObj->Size, access); + if (access == GL_WRITE_ONLY_ARB) { + GLuint i; + GLubyte *b = (GLubyte *) bufObj->Pointer; + for (i = 0; i < bufObj->Size; i++) + b[i] = i & 0xff; + } +#endif + return bufObj->Pointer; } @@ -1129,6 +1145,26 @@ _mesa_UnmapBufferARB(GLenum target) return GL_FALSE; } +#ifdef VBO_DEBUG + if (bufObj->Access == GL_WRITE_ONLY_ARB) { + GLuint i, unchanged = 0; + GLubyte *b = (GLubyte *) bufObj->Pointer; + GLint pos = -1; + /* check which bytes changed */ + for (i = 0; i < bufObj->Size - 1; i++) { + if (b[i] == (i & 0xff) && b[i+1] == ((i+1) & 0xff)) { + unchanged++; + if (pos == -1) + pos = i; + } + } + if (unchanged) { + _mesa_printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", + bufObj->Name, unchanged, bufObj->Size, pos); + } + } +#endif + status = ctx->Driver.UnmapBuffer( ctx, target, bufObj ); bufObj->Access = DEFAULT_ACCESS; bufObj->Pointer = NULL; -- 2.30.2