r300g: print errors even on non-debug builds
authorMarek Olšák <maraeo@gmail.com>
Sat, 27 Mar 2010 21:25:13 +0000 (22:25 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 27 Mar 2010 21:28:25 +0000 (22:28 +0100)
We really need to get these into bug reports.

src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_query.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/gallium/drivers/r300/r300_vs.c

index 92de297..4171986 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "util/u_debug.h"
 
+#include <stdio.h>
+
 /* r300_chipset: A file all to itself for deducing the various properties of
  * Radeons. */
 
@@ -365,8 +367,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
             break;
 
         default:
-            debug_printf("r300: Warning: Unknown chipset 0x%x\n",
-                caps->pci_id);
-            break;
+            fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\n",
+                    caps->pci_id);
     }
 }
index d617757..016e8d6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "r300_context.h"
 
+#include <stdio.h>
 
 struct debug_option {
     const char * name;
@@ -69,7 +70,7 @@ void r300_init_debug(struct r300_screen * screen)
             }
 
             if (!opt->name) {
-                debug_printf("Unknown debug option: %s\n", options);
+                fprintf(stderr, "Unknown debug option: %s\n", options);
                 printhint = TRUE;
             }
 
@@ -81,10 +82,13 @@ void r300_init_debug(struct r300_screen * screen)
     }
 
     if (printhint || screen->debug & DBG_HELP) {
-        debug_printf("You can enable debug output by setting the RADEON_DEBUG environment variable\n"
-                     "to a comma-separated list of debug options. Available options are:\n");
+        fprintf(stderr, "You can enable debug output by setting "
+                        "the RADEON_DEBUG environment variable\n"
+                        "to a comma-separated list of debug options. "
+                        "Available options are:\n");
+
         for(opt = debug_options; opt->name; ++opt) {
-            debug_printf("    %s: %s\n", opt->name, opt->description);
+            fprintf(stderr, "    %s: %s\n", opt->name, opt->description);
         }
     }
 }
index c8d9899..15bcf89 100644 (file)
@@ -186,13 +186,13 @@ static const float * get_shader_constant(
                     break;
 
                 default:
-                    debug_printf("r300: Implementation error: "
+                    fprintf(stderr, "r300: Implementation error: "
                         "Unknown RC_CONSTANT type %d\n", constant->u.State[0]);
             }
             break;
 
         default:
-            debug_printf("r300: Implementation error: "
+            fprintf(stderr, "r300: Implementation error: "
                 "Unhandled constant type %d\n", constant->Type);
     }
 
@@ -514,9 +514,9 @@ static void r300_emit_query_finish(struct r300_context *r300,
                     0, RADEON_GEM_DOMAIN_GTT, 0);
             break;
         default:
-            debug_printf("r300: Implementation error: Chipset reports %d"
+            fprintf(stderr, "r300: Implementation error: Chipset reports %d"
                     " pixel pipes!\n", caps->num_frag_pipes);
-            assert(0);
+            abort();
     }
 
     /* And, finally, reset it to normal... */
@@ -1077,8 +1077,8 @@ validate:
         r300->context.flush(&r300->context, 0, NULL);
         if (invalid) {
             /* Well, hell. */
-            debug_printf("r300: Stuck in validation loop, gonna quit now.");
-            exit(1);
+            fprintf(stderr, "r300: Stuck in validation loop, gonna quit now.\n");
+            abort();
         }
         invalid = TRUE;
         goto validate;
index 9e71e61..e23fef8 100644 (file)
@@ -204,9 +204,8 @@ static void r300_translate_fragment_shader(
     r3xx_compile_fragment_program(&compiler);
     if (compiler.Base.Error) {
         /* XXX failover maybe? */
-        DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n",
-            compiler.Base.ErrorMsg);
-        assert(0);
+        fprintf(stderr, "r300 FP: Compiler Error:\n%s",
+                compiler.Base.ErrorMsg);
         abort();
     }
 
index 9822e6b..f8b52d5 100644 (file)
@@ -30,6 +30,8 @@
 #include "r300_query.h"
 #include "r300_reg.h"
 
+#include <stdio.h>
+
 static struct pipe_query *r300_create_query(struct pipe_context *pipe,
                                             unsigned query_type)
 {
@@ -137,8 +139,8 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
         if (*map == ~0U) {
             /* Looks like our results aren't ready yet. */
             if (wait) {
-                debug_printf("r300: Despite waiting, OQ results haven't"
-                        come in yet.\n");
+                fprintf(stderr, "r300: Despite waiting, OQ results haven't "
+                                "come in yet.\n");
             }
             temp = ~0U;
             break;
index bcb8b20..e46f836 100644 (file)
@@ -164,7 +164,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
             return 0;
         default:
-            debug_printf("r300: Implementation error: Bad param %d\n",
+            fprintf(stderr, "r300: Implementation error: Bad param %d\n",
                 param);
             return 0;
     }
@@ -193,7 +193,7 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
             return 16.0f;
         default:
-            debug_printf("r300: Implementation error: Bad paramf %d\n",
+            fprintf(stderr, "r300: Implementation error: Bad paramf %d\n",
                 param);
             return 0.0f;
     }
@@ -212,7 +212,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
     boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM;
 
     if (target >= PIPE_MAX_TEXTURE_TYPES) {
-        debug_printf("r300: Implementation error: Received bogus texture "
+        fprintf(stderr, "r300: Implementation error: Received bogus texture "
             "target %d in %s\n", target, __FUNCTION__);
         return FALSE;
     }
index 1fc9f39..b7b5e1e 100644 (file)
@@ -575,9 +575,8 @@ static void
     unsigned max_width, max_height;
     uint32_t zbuffer_bpp = 0;
 
-
     if (state->nr_cbufs > 4) {
-        debug_printf("r300: Implementation error: Too many MRTs in %s, "
+        fprintf(stderr, "r300: Implementation error: Too many MRTs in %s, "
             "refusing to bind framebuffer state!\n", __FUNCTION__);
         return;
     }
@@ -591,7 +590,7 @@ static void
     }
 
     if (state->width > max_width || state->height > max_height) {
-        debug_printf("r300: Implementation error: Render targets are too "
+        fprintf(stderr, "r300: Implementation error: Render targets are too "
         "big in %s, refusing to bind framebuffer state!\n", __FUNCTION__);
         return;
     }
@@ -1353,7 +1352,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
 
     /* XXX Subtract immediates and RC_STATE_* variables. */
     if (buf->size > (sizeof(float) * 4 * max_size)) {
-        debug_printf("r300: Max size of the constant buffer is "
+        fprintf(stderr, "r300: Max size of the constant buffer is "
                       "%i*4 floats.\n", max_size);
         abort();
     }
index 8485d4f..02d09c0 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "r300_reg.h"
 
+#include <stdio.h>
+
 /* Some maths. These should probably find their way to u_math, if needed. */
 
 static INLINE int pack_float_16_6x(float f) {
@@ -54,7 +56,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func)
         case PIPE_BLEND_MAX:
             return R300_COMB_FCN_MAX;
         default:
-            debug_printf("r300: Unknown blend function %d\n", blend_func);
+            fprintf(stderr, "r300: Unknown blend function %d\n", blend_func);
             assert(0);
             break;
     }
@@ -100,13 +102,13 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact)
         case PIPE_BLENDFACTOR_SRC1_ALPHA:
         case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
         case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-            debug_printf("r300: Implementation error: "
+            fprintf(stderr, "r300: Implementation error: "
                 "Bad blend factor %d not supported!\n", blend_fact);
             assert(0);
             break;
 
         default:
-            debug_printf("r300: Unknown blend factor %d\n", blend_fact);
+            fprintf(stderr, "r300: Unknown blend factor %d\n", blend_fact);
             assert(0);
             break;
     }
@@ -135,7 +137,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func)
         case PIPE_FUNC_ALWAYS:
             return R300_ZS_ALWAYS;
         default:
-            debug_printf("r300: Unknown depth/stencil function %d\n",
+            fprintf(stderr, "r300: Unknown depth/stencil function %d\n",
                 zs_func);
             assert(0);
             break;
@@ -163,7 +165,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op)
         case PIPE_STENCIL_OP_INVERT:
             return R300_ZS_INVERT;
         default:
-            debug_printf("r300: Unknown stencil op %d", s_op);
+            fprintf(stderr, "r300: Unknown stencil op %d", s_op);
             assert(0);
             break;
     }
@@ -190,7 +192,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func)
         case PIPE_FUNC_ALWAYS:
             return R300_FG_ALPHA_FUNC_ALWAYS;
         default:
-            debug_printf("r300: Unknown alpha function %d", alpha_func);
+            fprintf(stderr, "r300: Unknown alpha function %d", alpha_func);
             assert(0);
             break;
     }
@@ -209,7 +211,7 @@ r300_translate_polygon_mode_front(unsigned mode) {
             return R300_GA_POLY_MODE_FRONT_PTYPE_POINT;
 
         default:
-            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+            fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode,
                 __FUNCTION__);
             return R300_GA_POLY_MODE_FRONT_PTYPE_TRI;
     }
@@ -227,7 +229,7 @@ r300_translate_polygon_mode_back(unsigned mode) {
             return R300_GA_POLY_MODE_BACK_PTYPE_POINT;
 
         default:
-            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+            fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode,
                 __FUNCTION__);
             return R300_GA_POLY_MODE_BACK_PTYPE_TRI;
     }
@@ -255,7 +257,7 @@ static INLINE uint32_t r300_translate_wrap(int wrap)
         case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
             return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
         default:
-            debug_printf("r300: Unknown texture wrap %d", wrap);
+            fprintf(stderr, "r300: Unknown texture wrap %d", wrap);
             assert(0);
             return 0;
     }
@@ -276,7 +278,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MIN_FILTER_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", min);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", min);
             assert(0);
             break;
         }
@@ -288,7 +290,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MAG_FILTER_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", mag);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", mag);
             assert(0);
             break;
         }
@@ -304,7 +306,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MIN_FILTER_MIP_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", mip);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", mip);
             assert(0);
             break;
     }
@@ -370,7 +372,7 @@ r300_translate_vertex_data_type(enum pipe_format format) {
     desc = util_format_description(format);
 
     if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
-        debug_printf("r300: Bad format %s in %s:%d\n", util_format_name(format),
+        fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format),
             __FUNCTION__, __LINE__);
         assert(0);
     }
@@ -391,7 +393,7 @@ r300_translate_vertex_data_type(enum pipe_format format) {
                     result = R300_DATA_TYPE_FLOAT_1 + (components - 1);
                     break;
                 default:
-                    debug_printf("r300: Bad format %s in %s:%d\n",
+                    fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                         util_format_name(format), __FUNCTION__, __LINE__);
                     assert(0);
             }
@@ -412,15 +414,15 @@ r300_translate_vertex_data_type(enum pipe_format format) {
                     }
                     break;
                 default:
-                    debug_printf("r300: Bad format %s in %s:%d\n",
+                    fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                         util_format_name(format), __FUNCTION__, __LINE__);
-                    debug_printf("r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
+                    fprintf(stderr, "r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
                         util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0));
                     assert(0);
             }
             break;
         default:
-            debug_printf("r300: Bad format %s in %s:%d\n",
+            fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                 util_format_name(format), __FUNCTION__, __LINE__);
             assert(0);
     }
@@ -442,7 +444,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) {
     assert(format);
 
     if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
-        debug_printf("r300: Bad format %s in %s:%d\n",
+        fprintf(stderr, "r300: Bad format %s in %s:%d\n",
             util_format_name(format), __FUNCTION__, __LINE__);
         return 0;
     }
index aff4ddd..1c90cc9 100644 (file)
@@ -25,6 +25,7 @@
 #include "radeon_compiler.h"
 #include "radeon_program.h"
 
+#include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
 #include "tgsi/tgsi_util.h"
@@ -145,7 +146,7 @@ static unsigned translate_opcode(unsigned opcode)
         case TGSI_OPCODE_KIL: return RC_OPCODE_KIL;
     }
 
-    debug_printf("r300: Unknown TGSI/RC opcode: %i\n", opcode);
+    fprintf(stderr, "r300: Unknown TGSI/RC opcode: %s\n", tgsi_get_opcode_name(opcode));
     return RC_OPCODE_ILLEGAL_OPCODE;
 }
 
index bd6b95d..d5690ca 100644 (file)
@@ -299,7 +299,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     r3xx_compile_vertex_program(&compiler);
     if (compiler.Base.Error) {
         /* XXX We should fallback using Draw. */
-        fprintf(stderr, "r300 VP: Compiler error\n");
+        fprintf(stderr, "r300 VP: Compiler error:\n%s", compiler.Base.ErrorMsg);
         abort();
     }