mesa: renumber remaining DD_ constants
[mesa.git] / src / mesa / main / debug.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #include "mtypes.h"
27 #include "attrib.h"
28 #include "colormac.h"
29 #include "enums.h"
30 #include "formats.h"
31 #include "hash.h"
32 #include "imports.h"
33 #include "debug.h"
34 #include "get.h"
35 #include "pixelstore.h"
36 #include "readpix.h"
37 #include "texobj.h"
38
39
40 static const char *
41 tex_target_name(GLenum tgt)
42 {
43 static const struct {
44 GLenum target;
45 const char *name;
46 } tex_targets[] = {
47 { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
48 { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
49 { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
50 { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
51 { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
52 { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
53 { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" },
54 { GL_TEXTURE_EXTERNAL_OES, "GL_TEXTURE_EXTERNAL_OES" }
55 };
56 GLuint i;
57 for (i = 0; i < Elements(tex_targets); i++) {
58 if (tex_targets[i].target == tgt)
59 return tex_targets[i].name;
60 }
61 return "UNKNOWN TEX TARGET";
62 }
63
64
65 void
66 _mesa_print_state( const char *msg, GLuint state )
67 {
68 _mesa_debug(NULL,
69 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
70 msg,
71 state,
72 (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
73 (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
74 (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
75 (state & _NEW_COLOR) ? "ctx->Color, " : "",
76 (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
77 (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
78 (state & _NEW_FOG) ? "ctx->Fog, " : "",
79 (state & _NEW_HINT) ? "ctx->Hint, " : "",
80 (state & _NEW_LIGHT) ? "ctx->Light, " : "",
81 (state & _NEW_LINE) ? "ctx->Line, " : "",
82 (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
83 (state & _NEW_POINT) ? "ctx->Point, " : "",
84 (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
85 (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
86 (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
87 (state & _NEW_STENCIL) ? "ctx->Stencil, " : "",
88 (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
89 (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
90 (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
91 (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
92 (state & _NEW_ARRAY) ? "ctx->Array, " : "",
93 (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
94 (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
95 }
96
97
98
99 void
100 _mesa_print_tri_caps( const char *name, GLuint flags )
101 {
102 _mesa_debug(NULL,
103 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s\n",
104 name,
105 flags,
106 (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
107 (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
108 (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
109 (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
110 (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
111 (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
112 (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
113 (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
114 (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
115 (flags & DD_POINT_ATTEN) ? "point-atten, " : ""
116 );
117 }
118
119
120 /**
121 * Print information about this Mesa version and build options.
122 */
123 void _mesa_print_info( void )
124 {
125 _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
126 (char *) _mesa_GetString(GL_VERSION));
127 _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
128 (char *) _mesa_GetString(GL_RENDERER));
129 _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
130 (char *) _mesa_GetString(GL_VENDOR));
131 _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
132 (char *) _mesa_GetString(GL_EXTENSIONS));
133 #if defined(THREADS)
134 _mesa_debug(NULL, "Mesa thread-safe: YES\n");
135 #else
136 _mesa_debug(NULL, "Mesa thread-safe: NO\n");
137 #endif
138 #if defined(USE_X86_ASM)
139 _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
140 #else
141 _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
142 #endif
143 #if defined(USE_SPARC_ASM)
144 _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
145 #else
146 _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
147 #endif
148 }
149
150
151 /**
152 * Set the debugging flags.
153 *
154 * \param debug debug string
155 *
156 * If compiled with debugging support then search for keywords in \p debug and
157 * enables the verbose debug output of the respective feature.
158 */
159 static void add_debug_flags( const char *debug )
160 {
161 #ifdef DEBUG
162 struct debug_option {
163 const char *name;
164 GLbitfield flag;
165 };
166 static const struct debug_option debug_opt[] = {
167 { "varray", VERBOSE_VARRAY },
168 { "tex", VERBOSE_TEXTURE },
169 { "mat", VERBOSE_MATERIAL },
170 { "pipe", VERBOSE_PIPELINE },
171 { "driver", VERBOSE_DRIVER },
172 { "state", VERBOSE_STATE },
173 { "api", VERBOSE_API },
174 { "list", VERBOSE_DISPLAY_LIST },
175 { "lighting", VERBOSE_LIGHTING },
176 { "disassem", VERBOSE_DISASSEM },
177 { "draw", VERBOSE_DRAW },
178 { "swap", VERBOSE_SWAPBUFFERS }
179 };
180 GLuint i;
181
182 MESA_VERBOSE = 0x0;
183 for (i = 0; i < Elements(debug_opt); i++) {
184 if (strstr(debug, debug_opt[i].name) || strcmp(debug, "all") == 0)
185 MESA_VERBOSE |= debug_opt[i].flag;
186 }
187
188 /* Debug flag:
189 */
190 if (strstr(debug, "flush"))
191 MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
192
193 #else
194 (void) debug;
195 #endif
196 }
197
198
199 void
200 _mesa_init_debug( struct gl_context *ctx )
201 {
202 char *c;
203 c = _mesa_getenv("MESA_DEBUG");
204 if (c)
205 add_debug_flags(c);
206
207 c = _mesa_getenv("MESA_VERBOSE");
208 if (c)
209 add_debug_flags(c);
210 }
211
212
213 /*
214 * Write ppm file
215 */
216 static void
217 write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
218 int comps, int rcomp, int gcomp, int bcomp, GLboolean invert)
219 {
220 FILE *f = fopen( filename, "w" );
221 if (f) {
222 int x, y;
223 const GLubyte *ptr = buffer;
224 fprintf(f,"P6\n");
225 fprintf(f,"# ppm-file created by osdemo.c\n");
226 fprintf(f,"%i %i\n", width,height);
227 fprintf(f,"255\n");
228 fclose(f);
229 f = fopen( filename, "ab" ); /* reopen in binary append mode */
230 for (y=0; y < height; y++) {
231 for (x = 0; x < width; x++) {
232 int yy = invert ? (height - 1 - y) : y;
233 int i = (yy * width + x) * comps;
234 fputc(ptr[i+rcomp], f); /* write red */
235 fputc(ptr[i+gcomp], f); /* write green */
236 fputc(ptr[i+bcomp], f); /* write blue */
237 }
238 }
239 fclose(f);
240 }
241 else {
242 fprintf(stderr, "Unable to create %s in write_ppm()\n", filename);
243 }
244 }
245
246
247 /**
248 * Write a texture image to a ppm file.
249 * \param face cube face in [0,5]
250 * \param level mipmap level
251 */
252 static void
253 write_texture_image(struct gl_texture_object *texObj,
254 GLuint face, GLuint level)
255 {
256 struct gl_texture_image *img = texObj->Image[face][level];
257 if (img) {
258 GET_CURRENT_CONTEXT(ctx);
259 struct gl_pixelstore_attrib store;
260 GLubyte *buffer;
261 char s[100];
262
263 buffer = (GLubyte *) malloc(img->Width * img->Height
264 * img->Depth * 4);
265
266 store = ctx->Pack; /* save */
267 ctx->Pack = ctx->DefaultPacking;
268
269 ctx->Driver.GetTexImage(ctx, GL_RGBA, GL_UNSIGNED_BYTE, buffer, img);
270
271 /* make filename */
272 _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
273
274 printf(" Writing image level %u to %s\n", level, s);
275 write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
276
277 ctx->Pack = store; /* restore */
278
279 free(buffer);
280 }
281 }
282
283
284 /**
285 * Write renderbuffer image to a ppm file.
286 */
287 void
288 _mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb)
289 {
290 GET_CURRENT_CONTEXT(ctx);
291 GLubyte *buffer;
292 char s[100];
293 GLenum format, type;
294
295 if (rb->_BaseFormat == GL_RGB ||
296 rb->_BaseFormat == GL_RGBA) {
297 format = GL_RGBA;
298 type = GL_UNSIGNED_BYTE;
299 }
300 else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
301 format = GL_DEPTH_STENCIL;
302 type = GL_UNSIGNED_INT_24_8;
303 }
304 else {
305 _mesa_debug(NULL,
306 "Unsupported BaseFormat 0x%x in "
307 "_mesa_write_renderbuffer_image()\n",
308 rb->_BaseFormat);
309 return;
310 }
311
312 buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
313
314 ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
315 format, type, &ctx->DefaultPacking, buffer);
316
317 /* make filename */
318 _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
319 _mesa_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name);
320
321 printf(" Writing renderbuffer image to %s\n", s);
322
323 _mesa_debug(NULL, " Writing renderbuffer image to %s\n", s);
324
325 write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
326
327 free(buffer);
328 }
329
330
331 /** How many texture images (mipmap levels, faces) to write to files */
332 #define WRITE_NONE 0
333 #define WRITE_ONE 1
334 #define WRITE_ALL 2
335
336 static GLuint WriteImages;
337
338
339 static void
340 dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
341 {
342 const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
343 GLboolean written = GL_FALSE;
344 GLuint i, j;
345
346 printf("Texture %u\n", texObj->Name);
347 printf(" Target %s\n", tex_target_name(texObj->Target));
348 for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
349 for (j = 0; j < numFaces; j++) {
350 struct gl_texture_image *texImg = texObj->Image[j][i];
351 if (texImg) {
352 printf(" Face %u level %u: %d x %d x %d, format %s\n",
353 j, i,
354 texImg->Width, texImg->Height, texImg->Depth,
355 _mesa_get_format_name(texImg->TexFormat));
356 if (writeImages == WRITE_ALL ||
357 (writeImages == WRITE_ONE && !written)) {
358 write_texture_image(texObj, j, i);
359 written = GL_TRUE;
360 }
361 }
362 }
363 }
364 }
365
366
367 /**
368 * Dump a single texture.
369 */
370 void
371 _mesa_dump_texture(GLuint texture, GLuint writeImages)
372 {
373 GET_CURRENT_CONTEXT(ctx);
374 struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
375 if (texObj) {
376 dump_texture(texObj, writeImages);
377 }
378 }
379
380
381 static void
382 dump_texture_cb(GLuint id, void *data, void *userData)
383 {
384 struct gl_texture_object *texObj = (struct gl_texture_object *) data;
385 (void) userData;
386 dump_texture(texObj, WriteImages);
387 }
388
389
390 /**
391 * Print basic info about all texture objext to stdout.
392 * If dumpImages is true, write PPM of level[0] image to a file.
393 */
394 void
395 _mesa_dump_textures(GLuint writeImages)
396 {
397 GET_CURRENT_CONTEXT(ctx);
398 WriteImages = writeImages;
399 _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
400 }
401
402
403 static void
404 dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
405 {
406 printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
407 rb->Name, rb->Width, rb->Height,
408 _mesa_lookup_enum_by_nr(rb->InternalFormat));
409 if (writeImage) {
410 _mesa_write_renderbuffer_image(rb);
411 }
412 }
413
414
415 static void
416 dump_renderbuffer_cb(GLuint id, void *data, void *userData)
417 {
418 const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
419 (void) userData;
420 dump_renderbuffer(rb, WriteImages);
421 }
422
423
424 /**
425 * Print basic info about all renderbuffers to stdout.
426 * If dumpImages is true, write PPM of level[0] image to a file.
427 */
428 void
429 _mesa_dump_renderbuffers(GLboolean writeImages)
430 {
431 GET_CURRENT_CONTEXT(ctx);
432 WriteImages = writeImages;
433 _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
434 }
435
436
437
438 void
439 _mesa_dump_color_buffer(const char *filename)
440 {
441 GET_CURRENT_CONTEXT(ctx);
442 const GLuint w = ctx->DrawBuffer->Width;
443 const GLuint h = ctx->DrawBuffer->Height;
444 GLubyte *buf;
445
446 buf = (GLubyte *) malloc(w * h * 4);
447
448 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
449 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
450 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
451
452 _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
453
454 printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n",
455 (void *) ctx->ReadBuffer->_ColorReadBuffer,
456 ctx->ReadBuffer->ColorReadBuffer,
457 (void *) ctx->DrawBuffer->_ColorDrawBuffers[0],
458 ctx->DrawBuffer->ColorDrawBuffer[0]);
459 printf("Writing %d x %d color buffer to %s\n", w, h, filename);
460 write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE);
461
462 _mesa_PopClientAttrib();
463
464 free(buf);
465 }
466
467
468 void
469 _mesa_dump_depth_buffer(const char *filename)
470 {
471 GET_CURRENT_CONTEXT(ctx);
472 const GLuint w = ctx->DrawBuffer->Width;
473 const GLuint h = ctx->DrawBuffer->Height;
474 GLuint *buf;
475 GLubyte *buf2;
476 GLuint i;
477
478 buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
479 buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
480
481 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
482 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
483 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
484
485 _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
486
487 /* spread 24 bits of Z across R, G, B */
488 for (i = 0; i < w * h; i++) {
489 buf2[i*3+0] = (buf[i] >> 24) & 0xff;
490 buf2[i*3+1] = (buf[i] >> 16) & 0xff;
491 buf2[i*3+2] = (buf[i] >> 8) & 0xff;
492 }
493
494 printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
495 write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
496
497 _mesa_PopClientAttrib();
498
499 free(buf);
500 free(buf2);
501 }
502
503
504 void
505 _mesa_dump_stencil_buffer(const char *filename)
506 {
507 GET_CURRENT_CONTEXT(ctx);
508 const GLuint w = ctx->DrawBuffer->Width;
509 const GLuint h = ctx->DrawBuffer->Height;
510 GLubyte *buf;
511 GLubyte *buf2;
512 GLuint i;
513
514 buf = (GLubyte *) malloc(w * h); /* 1 bpp */
515 buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
516
517 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
518 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
519 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
520
521 _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
522
523 for (i = 0; i < w * h; i++) {
524 buf2[i*3+0] = buf[i];
525 buf2[i*3+1] = (buf[i] & 127) * 2;
526 buf2[i*3+2] = (buf[i] - 128) * 2;
527 }
528
529 printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
530 write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
531
532 _mesa_PopClientAttrib();
533
534 free(buf);
535 free(buf2);
536 }
537
538
539 void
540 _mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
541 GLenum format, GLenum type)
542 {
543 GLboolean invert = GL_TRUE;
544
545 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
546 write_ppm(filename, image, w, h, 4, 0, 1, 2, invert);
547 }
548 else if (format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
549 write_ppm(filename, image, w, h, 4, 2, 1, 0, invert);
550 }
551 else if (format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE) {
552 write_ppm(filename, image, w, h, 2, 1, 0, 0, invert);
553 }
554 else if (format == GL_RED && type == GL_UNSIGNED_BYTE) {
555 write_ppm(filename, image, w, h, 1, 0, 0, 0, invert);
556 }
557 else if (format == GL_RGBA && type == GL_FLOAT) {
558 /* convert floats to ubyte */
559 GLubyte *buf = (GLubyte *) malloc(w * h * 4 * sizeof(GLubyte));
560 const GLfloat *f = (const GLfloat *) image;
561 GLuint i;
562 for (i = 0; i < w * h * 4; i++) {
563 UNCLAMPED_FLOAT_TO_UBYTE(buf[i], f[i]);
564 }
565 write_ppm(filename, buf, w, h, 4, 0, 1, 2, invert);
566 free(buf);
567 }
568 else if (format == GL_RED && type == GL_FLOAT) {
569 /* convert floats to ubyte */
570 GLubyte *buf = (GLubyte *) malloc(w * h * sizeof(GLubyte));
571 const GLfloat *f = (const GLfloat *) image;
572 GLuint i;
573 for (i = 0; i < w * h; i++) {
574 UNCLAMPED_FLOAT_TO_UBYTE(buf[i], f[i]);
575 }
576 write_ppm(filename, buf, w, h, 1, 0, 0, 0, invert);
577 free(buf);
578 }
579 else {
580 _mesa_problem(NULL,
581 "Unsupported format 0x%x / type 0x%x in _mesa_dump_image()",
582 format, type);
583 }
584 }
585
586
587 /**
588 * Quick and dirty function to "print" a texture to stdout.
589 */
590 void
591 _mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img)
592 {
593 const GLint slice = 0;
594 GLint srcRowStride;
595 GLuint i, j, c;
596 GLubyte *data;
597
598 ctx->Driver.MapTextureImage(ctx, img, slice,
599 0, 0, img->Width, img->Height, GL_MAP_READ_BIT,
600 &data, &srcRowStride);
601
602 if (!data) {
603 printf("No texture data\n");
604 }
605 else {
606 /* XXX add more formats or make into a new format utility function */
607 switch (img->TexFormat) {
608 case MESA_FORMAT_A8:
609 case MESA_FORMAT_L8:
610 case MESA_FORMAT_I8:
611 c = 1;
612 break;
613 case MESA_FORMAT_AL88:
614 case MESA_FORMAT_AL88_REV:
615 c = 2;
616 break;
617 case MESA_FORMAT_RGB888:
618 case MESA_FORMAT_BGR888:
619 c = 3;
620 break;
621 case MESA_FORMAT_RGBA8888:
622 case MESA_FORMAT_ARGB8888:
623 c = 4;
624 break;
625 default:
626 _mesa_problem(NULL, "error in PrintTexture\n");
627 return;
628 }
629
630 for (i = 0; i < img->Height; i++) {
631 for (j = 0; j < img->Width; j++) {
632 if (c==1)
633 printf("%02x ", data[0]);
634 else if (c==2)
635 printf("%02x%02x ", data[0], data[1]);
636 else if (c==3)
637 printf("%02x%02x%02x ", data[0], data[1], data[2]);
638 else if (c==4)
639 printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
640 data += (srcRowStride - img->Width) * c;
641 }
642 /* XXX use img->ImageStride here */
643 printf("\n");
644
645 }
646 }
647
648 ctx->Driver.UnmapTextureImage(ctx, img, slice);
649 }