summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-04-29 20:33:37 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-04-29 20:48:14 +0100
commit9bfe1a3d505733489f7583fe603b7d192f38fa8c (patch)
treec665fb36b4b1597cdb0085fb9dfde6d5217183f0 /src/gallium
parent733bc4df1a53bb1899933685e06c52109d096bee (diff)
gallium: add debug_print_format() make it easier to print format error messages
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/p_debug.c97
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h9
-rw-r--r--src/gallium/include/pipe/p_debug.h11
-rw-r--r--src/gallium/include/pipe/p_format.h83
4 files changed, 111 insertions, 89 deletions
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index cd612e23b3..eaf2c9bd98 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -41,6 +41,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "pipe/p_format.h"
#include "util/u_string.h"
@@ -324,3 +325,99 @@ debug_dump_flags(const struct debug_named_value *names,
}
+
+
+
+
+char *pf_sprint_name( char *str, enum pipe_format format )
+{
+ strcpy( str, "PIPE_FORMAT_" );
+ switch (pf_layout( format )) {
+ case PIPE_FORMAT_LAYOUT_RGBAZS:
+ {
+ pipe_format_rgbazs_t rgbazs = (pipe_format_rgbazs_t) format;
+ uint i;
+ uint scale = 1 << (pf_exp8( rgbazs ) * 3);
+
+ for (i = 0; i < 4; i++) {
+ uint size = pf_size_xyzw( rgbazs, i );
+
+ if (size == 0) {
+ break;
+ }
+ switch (pf_swizzle_xyzw( rgbazs, i )) {
+ case PIPE_FORMAT_COMP_R:
+ strcat( str, "R" );
+ break;
+ case PIPE_FORMAT_COMP_G:
+ strcat( str, "G" );
+ break;
+ case PIPE_FORMAT_COMP_B:
+ strcat( str, "B" );
+ break;
+ case PIPE_FORMAT_COMP_A:
+ strcat( str, "A" );
+ break;
+ case PIPE_FORMAT_COMP_0:
+ strcat( str, "0" );
+ break;
+ case PIPE_FORMAT_COMP_1:
+ strcat( str, "1" );
+ break;
+ case PIPE_FORMAT_COMP_Z:
+ strcat( str, "Z" );
+ break;
+ case PIPE_FORMAT_COMP_S:
+ strcat( str, "S" );
+ break;
+ }
+ util_snprintf( &str[strlen( str )], 32, "%u", size * scale );
+ }
+ if (i != 0) {
+ strcat( str, "_" );
+ }
+ switch (pf_type( rgbazs )) {
+ case PIPE_FORMAT_TYPE_UNKNOWN:
+ strcat( str, "NONE" );
+ break;
+ case PIPE_FORMAT_TYPE_FLOAT:
+ strcat( str, "FLOAT" );
+ break;
+ case PIPE_FORMAT_TYPE_UNORM:
+ strcat( str, "UNORM" );
+ break;
+ case PIPE_FORMAT_TYPE_SNORM:
+ strcat( str, "SNORM" );
+ break;
+ case PIPE_FORMAT_TYPE_USCALED:
+ strcat( str, "USCALED" );
+ break;
+ case PIPE_FORMAT_TYPE_SSCALED:
+ strcat( str, "SSCALED" );
+ break;
+ }
+ }
+ break;
+ case PIPE_FORMAT_LAYOUT_YCBCR:
+ {
+ pipe_format_ycbcr_t ycbcr = (pipe_format_ycbcr_t) format;
+
+ strcat( str, "YCBCR" );
+ if (pf_rev( ycbcr )) {
+ strcat( str, "_REV" );
+ }
+ }
+ break;
+ }
+ return str;
+}
+
+
+void debug_print_format(const char *msg, enum pipe_format fmt )
+{
+ char fmtstr[80];
+
+ pf_sprint_name(fmtstr, fmt);
+
+ debug_printf("%s: %s\n", msg, fmtstr);
+}
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 8296f1291c..7e26b1642a 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -91,7 +91,8 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
return;
/* XXX lots more cases to add */
default:
- debug_printf("gallium: unhandled format in util_pack_color_ub()\n");
+ debug_print_format("gallium: unhandled format in util_pack_color_ub()", format);
+ assert(0);
}
}
@@ -174,7 +175,8 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
return;
/* XXX lots more cases to add */
default:
- debug_printf("gallium: unhandled format in util_pack_color()\n");
+ debug_print_format("gallium: unhandled format in util_pack_color()", format);
+ assert(0);
}
}
@@ -201,7 +203,8 @@ util_pack_z(enum pipe_format format, double z)
case PIPE_FORMAT_Z24X8_UNORM:
return ((uint) (z * 0xffffff)) << 8;
default:
- debug_printf("gallium: unhandled format in util_pack_z()\n");
+ debug_print_format("gallium: unhandled format in util_pack_z()", format);
+ assert(0);
return 0;
}
}
diff --git a/src/gallium/include/pipe/p_debug.h b/src/gallium/include/pipe/p_debug.h
index 235c47abac..f87247994b 100644
--- a/src/gallium/include/pipe/p_debug.h
+++ b/src/gallium/include/pipe/p_debug.h
@@ -103,16 +103,19 @@ debug_printf(const char *format, ...)
#endif
+#ifdef DEBUG
/**
* Dump a blob in hex to the same place that debug_printf sends its
* messages.
*/
-#ifdef DEBUG
-void debug_print_blob( const char *name,
- const void *blob,
- unsigned size );
+void debug_print_blob( const char *name, const void *blob, unsigned size );
+
+/* Print a message along with a prettified format string
+ */
+void debug_print_format(const char *msg, enum pipe_format fmt );
#else
#define debug_print_blob(_name, _blob, _size) ((void)0)
+#define debug_print_format(_msg, _fmt) ((void)0)
#endif
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index 94c2eeb62b..bc23fe142e 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -337,88 +337,7 @@ enum pipe_format {
/**
* Builds pipe format name from format token.
*/
-static INLINE char *pf_sprint_name( char *str, enum pipe_format format )
-{
- strcpy( str, "PIPE_FORMAT_" );
- switch (pf_layout( format )) {
- case PIPE_FORMAT_LAYOUT_RGBAZS:
- {
- pipe_format_rgbazs_t rgbazs = (pipe_format_rgbazs_t) format;
- uint i;
- uint scale = 1 << (pf_exp8( rgbazs ) * 3);
-
- for (i = 0; i < 4; i++) {
- uint size = pf_size_xyzw( rgbazs, i );
-
- if (size == 0) {
- break;
- }
- switch (pf_swizzle_xyzw( rgbazs, i )) {
- case PIPE_FORMAT_COMP_R:
- strcat( str, "R" );
- break;
- case PIPE_FORMAT_COMP_G:
- strcat( str, "G" );
- break;
- case PIPE_FORMAT_COMP_B:
- strcat( str, "B" );
- break;
- case PIPE_FORMAT_COMP_A:
- strcat( str, "A" );
- break;
- case PIPE_FORMAT_COMP_0:
- strcat( str, "0" );
- break;
- case PIPE_FORMAT_COMP_1:
- strcat( str, "1" );
- break;
- case PIPE_FORMAT_COMP_Z:
- strcat( str, "Z" );
- break;
- case PIPE_FORMAT_COMP_S:
- strcat( str, "S" );
- break;
- }
- util_snprintf( &str[strlen( str )], 32, "%u", size * scale );
- }
- if (i != 0) {
- strcat( str, "_" );
- }
- switch (pf_type( rgbazs )) {
- case PIPE_FORMAT_TYPE_UNKNOWN:
- strcat( str, "NONE" );
- break;
- case PIPE_FORMAT_TYPE_FLOAT:
- strcat( str, "FLOAT" );
- break;
- case PIPE_FORMAT_TYPE_UNORM:
- strcat( str, "UNORM" );
- break;
- case PIPE_FORMAT_TYPE_SNORM:
- strcat( str, "SNORM" );
- break;
- case PIPE_FORMAT_TYPE_USCALED:
- strcat( str, "USCALED" );
- break;
- case PIPE_FORMAT_TYPE_SSCALED:
- strcat( str, "SSCALED" );
- break;
- }
- }
- break;
- case PIPE_FORMAT_LAYOUT_YCBCR:
- {
- pipe_format_ycbcr_t ycbcr = (pipe_format_ycbcr_t) format;
-
- strcat( str, "YCBCR" );
- if (pf_rev( ycbcr )) {
- strcat( str, "_REV" );
- }
- }
- break;
- }
- return str;
-}
+extern char *pf_sprint_name( char *str, enum pipe_format format );
/**
* Return bits for a particular component.