summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
diff options
context:
space:
mode:
authorNicolai Hähnle <nhaehnle@gmail.com>2009-07-23 21:38:28 +0200
committerNicolai Hähnle <nhaehnle@gmail.com>2009-07-27 20:32:06 +0200
commit8bcb6ef786dc41049b56e6efeca0f5788cfefe5a (patch)
treef9ee8b1b20dd80390351e22b67989d2b0933596d /src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
parentc5cb9a337881229f1db462632fa1d64e2677f316 (diff)
r300/compiler: Lay groundwork for better error handling
Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
Diffstat (limited to 'src/mesa/drivers/dri/r300/compiler/radeon_compiler.c')
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_compiler.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
index 17c9b17682..7b8322c201 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
@@ -22,6 +22,8 @@
#include "radeon_compiler.h"
+#include <stdarg.h>
+
void rc_init(struct radeon_compiler * c)
{
@@ -36,4 +38,52 @@ void rc_init(struct radeon_compiler * c)
void rc_destroy(struct radeon_compiler * c)
{
memory_pool_destroy(&c->Pool);
+ free(c->ErrorMsg);
+}
+
+void rc_debug(struct radeon_compiler * c, const char * fmt, ...)
+{
+ va_list ap;
+
+ if (!c->Debug)
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+void rc_error(struct radeon_compiler * c, const char * fmt, ...)
+{
+ va_list ap;
+
+ c->Error = GL_TRUE;
+
+ if (!c->ErrorMsg) {
+ /* Only remember the first error */
+ char buf[1024];
+ int written;
+
+ va_start(ap, fmt);
+ written = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ if (written < sizeof(buf)) {
+ c->ErrorMsg = strdup(buf);
+ } else {
+ c->ErrorMsg = malloc(written + 1);
+
+ va_start(ap, fmt);
+ vsnprintf(c->ErrorMsg, written + 1, fmt, ap);
+ va_end(ap);
+ }
+ }
+
+ if (c->Debug) {
+ fprintf(stderr, "r300compiler error: ");
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
}