"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 )
{
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);
}
-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;
+ }
}
}
}
* 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);
}
}
{
struct gl_texture_object *texObj = (struct gl_texture_object *) data;
(void) userData;
- dump_texture(texObj);
+ dump_texture(texObj, WriteImages);
}
* 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);
}