summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-27 13:59:32 -0600
committerBrian Paul <[email protected]>2009-10-27 17:00:31 -0600
commit403181b91355c733883d0a6d7f48440212226d45 (patch)
tree2893228851899d1549a0391aedf39895c361cba5 /src/mesa
parent58a4328e96160ad6c529edb321cdc5ea929a3f02 (diff)
mesa: more texture debug code changes, improvements
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/debug.c93
-rw-r--r--src/mesa/main/debug.h6
2 files changed, 69 insertions, 30 deletions
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 0e35617575e..24ced0d6c96 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -58,6 +58,31 @@ const char *_mesa_prim_name[GL_POLYGON+4] = {
"unknown state"
};
+
+static const char *
+tex_target_name(GLenum tgt)
+{
+ static const struct {
+ GLenum target;
+ const char *name;
+ } tex_targets[] = {
+ { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
+ { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
+ { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
+ { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
+ { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
+ { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
+ { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
+ };
+ GLuint i;
+ for (i = 0; i < Elements(tex_targets); i++) {
+ if (tex_targets[i].target == tgt)
+ return tex_targets[i].name;
+ }
+ return "UNKNOWN TEX TARGET";
+}
+
+
void
_mesa_print_state( const char *msg, GLuint state )
{
@@ -291,7 +316,7 @@ write_texture_image(struct gl_texture_object *texObj,
buffer, texObj, img);
/* make filename */
- _mesa_sprintf(s, "/tmp/teximage%u.ppm", texObj->Name);
+ _mesa_sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
_mesa_printf(" Writing image level %u to %s\n", level, s);
write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
@@ -342,27 +367,36 @@ write_renderbuffer_image(const struct gl_renderbuffer *rb)
}
-static GLboolean DumpImages;
+/** How many texture images (mipmap levels, faces) to write to files */
+#define WRITE_NONE 0
+#define WRITE_ONE 1
+#define WRITE_ALL 2
+
+static GLuint WriteImages;
static void
-dump_texture(struct gl_texture_object *texObj)
+dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
{
- int i;
+ const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
GLboolean written = GL_FALSE;
+ GLuint i, j;
_mesa_printf("Texture %u\n", texObj->Name);
- _mesa_printf(" Target 0x%x\n", texObj->Target);
+ _mesa_printf(" Target %s\n", tex_target_name(texObj->Target));
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- struct gl_texture_image *texImg = texObj->Image[0][i];
- if (texImg) {
- _mesa_printf(" Image %u: %d x %d x %d, format %u at %p\n", i,
- texImg->Width, texImg->Height, texImg->Depth,
- texImg->TexFormat->MesaFormat, texImg->Data);
- if (DumpImages && !written) {
- GLuint face = 0;
- write_texture_image(texObj, face, i);
- written = GL_TRUE;
+ for (j = 0; j < numFaces; j++) {
+ struct gl_texture_image *texImg = texObj->Image[j][i];
+ if (texImg) {
+ _mesa_printf(" Face %u level %u: %d x %d x %d, format %u at %p\n",
+ j, i,
+ texImg->Width, texImg->Height, texImg->Depth,
+ texImg->TexFormat->MesaFormat, texImg->Data);
+ if (writeImages == WRITE_ALL ||
+ (writeImages == WRITE_ONE && !written)) {
+ write_texture_image(texObj, j, i);
+ written = GL_TRUE;
+ }
}
}
}
@@ -373,13 +407,12 @@ dump_texture(struct gl_texture_object *texObj)
* Dump a single texture.
*/
void
-_mesa_dump_texture(GLuint texture, GLboolean dumpImages)
+_mesa_dump_texture(GLuint texture, GLuint writeImages)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
if (texObj) {
- DumpImages = dumpImages;
- dump_texture(texObj);
+ dump_texture(texObj, writeImages);
}
}
@@ -389,7 +422,7 @@ dump_texture_cb(GLuint id, void *data, void *userData)
{
struct gl_texture_object *texObj = (struct gl_texture_object *) data;
(void) userData;
- dump_texture(texObj);
+ dump_texture(texObj, WriteImages);
}
@@ -398,38 +431,44 @@ dump_texture_cb(GLuint id, void *data, void *userData)
* If dumpImages is true, write PPM of level[0] image to a file.
*/
void
-_mesa_dump_textures(GLboolean dumpImages)
+_mesa_dump_textures(GLuint writeImages)
{
GET_CURRENT_CONTEXT(ctx);
- DumpImages = dumpImages;
+ WriteImages = writeImages;
_mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
}
static void
-dump_renderbuffer_cb(GLuint id, void *data, void *userData)
+dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
{
- const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
- (void) userData;
-
_mesa_printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
rb->Name, rb->Width, rb->Height,
_mesa_lookup_enum_by_nr(rb->InternalFormat));
- if (DumpImages) {
+ if (writeImage) {
write_renderbuffer_image(rb);
}
}
+static void
+dump_renderbuffer_cb(GLuint id, void *data, void *userData)
+{
+ const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
+ (void) userData;
+ dump_renderbuffer(rb, WriteImages);
+}
+
+
/**
* Print basic info about all renderbuffers to stdout.
* If dumpImages is true, write PPM of level[0] image to a file.
*/
void
-_mesa_dump_renderbuffers(GLboolean dumpImages)
+_mesa_dump_renderbuffers(GLboolean writeImages)
{
GET_CURRENT_CONTEXT(ctx);
- DumpImages = dumpImages;
+ WriteImages = writeImages;
_mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
}
diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h
index f66f774a45d..d12ea602dd7 100644
--- a/src/mesa/main/debug.h
+++ b/src/mesa/main/debug.h
@@ -58,13 +58,13 @@ extern void _mesa_init_debug( GLcontext *ctx );
#endif
extern void
-_mesa_dump_texture(GLuint texture, GLboolean dumpImages);
+_mesa_dump_texture(GLuint texture, GLuint writeImages);
extern void
-_mesa_dump_textures(GLboolean dumpImages);
+_mesa_dump_textures(GLuint writeImages);
extern void
-_mesa_dump_renderbuffers(GLboolean dumpImages);
+_mesa_dump_renderbuffers(GLboolean writeImages);
extern void
_mesa_dump_color_buffer(const char *filename);