Mesa (master): mesa: added buffer object debug code (disabled)

Brian Paul brianp at kemper.freedesktop.org
Wed Jun 3 23:18:43 UTC 2009


Module: Mesa
Branch: master
Commit: e7927626c13b8cd3743ba52a407b8f3736eae8a1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7927626c13b8cd3743ba52a407b8f3736eae8a1

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Jun  3 15:38:57 2009 -0600

mesa: added buffer object debug code (disabled)

---

 src/mesa/main/bufferobj.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 5fa13d9..3e011ef 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!  <data> 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;




More information about the mesa-commit mailing list