mesa: added _mesa_print_framebuffer() for debugging
authorBrian Paul <brianp@vmware.com>
Thu, 29 Apr 2010 18:26:24 +0000 (12:26 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 29 Apr 2010 21:50:30 +0000 (15:50 -0600)
src/mesa/main/framebuffer.c
src/mesa/main/framebuffer.h

index 5a654e5c2a3822239ac02fd30b2ee15d9d614f58..31689c8fe807defdcbcaad3194187f4b90642c26 100644 (file)
@@ -35,6 +35,7 @@
 #include "buffers.h"
 #include "context.h"
 #include "depthstencil.h"
+#include "enums.h"
 #include "formats.h"
 #include "macros.h"
 #include "mtypes.h"
@@ -1019,3 +1020,43 @@ _mesa_get_color_read_type(GLcontext *ctx)
       return GL_UNSIGNED_BYTE;
    }
 }
+
+
+/**
+ * Print framebuffer info to stderr, for debugging.
+ */
+void
+_mesa_print_framebuffer(const struct gl_framebuffer *fb)
+{
+   GLuint i;
+
+   fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb);
+   fprintf(stderr, "  Size: %u x %u  Status: %s\n", fb->Width, fb->Height,
+           _mesa_lookup_enum_by_nr(fb->_Status));
+   fprintf(stderr, "  Attachments:\n");
+
+   for (i = 0; i < BUFFER_COUNT; i++) {
+      const struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+      if (att->Type == GL_TEXTURE) {
+         const struct gl_texture_image *texImage;
+         fprintf(stderr,
+                 "  %2d: Texture %u, level %u, face %u, slice %u, complete %d\n",
+                 i, att->Texture->Name, att->TextureLevel, att->CubeMapFace,
+                 att->Zoffset, att->Complete);
+         texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+         fprintf(stderr, "       Size: %u x %u x %u  Format %s\n",
+                 texImage->Width, texImage->Height, texImage->Depth,
+                 _mesa_get_format_name(texImage->TexFormat));
+      }
+      else if (att->Type == GL_RENDERBUFFER) {
+         fprintf(stderr, "  %2d: Renderbuffer %u, complete %d\n",
+                 i, att->Renderbuffer->Name, att->Complete);
+         fprintf(stderr, "       Size: %u x %u  Format %s\n",
+                 att->Renderbuffer->Width, att->Renderbuffer->Height,
+                 _mesa_get_format_name(att->Renderbuffer->Format));
+      }
+      else {
+         fprintf(stderr, "  %2d: none\n", i);
+      }
+   }
+}
index 960513812cf67ac67cbd810049dd903e4854b82e..1b6e3b1f0cbe93241768c2c979f75840923f443a 100644 (file)
@@ -91,4 +91,7 @@ _mesa_get_color_read_type(GLcontext *ctx);
 extern GLenum
 _mesa_get_color_read_format(GLcontext *ctx);
 
+extern void
+_mesa_print_framebuffer(const struct gl_framebuffer *fb);
+
 #endif /* FRAMEBUFFER_H */