summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-07-04 13:17:07 +0200
committerMarek Olšák <[email protected]>2015-07-22 23:56:00 +0200
commit8141b4cee514bb673e394f6fbe2cbe02e5b0faf2 (patch)
tree6eaa3943105fcd069390c02ed0960b3580d10d5e /src/gallium/auxiliary/tgsi
parentd082c5324914212f76e45be497229c7a0681f706 (diff)
tgsi: allow dumping to a file directly
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c19
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.h5
2 files changed, 20 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index c80d7a20481..8ceb5b47584 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -48,6 +48,7 @@ struct dump_ctx
int indent;
uint indentation;
+ FILE *file;
void (*dump_printf)(struct dump_ctx *ctx, const char *format, ...);
};
@@ -58,7 +59,10 @@ dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
va_list ap;
(void)ctx;
va_start(ap, format);
- _debug_vprintf(format, ap);
+ if (ctx->file)
+ vfprintf(ctx->file, format, ap);
+ else
+ _debug_vprintf(format, ap);
va_end(ap);
}
@@ -659,9 +663,7 @@ prolog(
}
void
-tgsi_dump(
- const struct tgsi_token *tokens,
- uint flags )
+tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file)
{
struct dump_ctx ctx;
@@ -677,10 +679,17 @@ tgsi_dump(
ctx.indent = 0;
ctx.dump_printf = dump_ctx_printf;
ctx.indentation = 0;
+ ctx.file = file;
tgsi_iterate_shader( tokens, &ctx.iter );
}
+void
+tgsi_dump(const struct tgsi_token *tokens, uint flags)
+{
+ tgsi_dump_to_file(tokens, flags, NULL);
+}
+
struct str_dump_ctx
{
struct dump_ctx base;
@@ -733,6 +742,7 @@ tgsi_dump_str(
ctx.base.indent = 0;
ctx.base.dump_printf = &str_dump_ctx_printf;
ctx.base.indentation = 0;
+ ctx.base.file = NULL;
ctx.str = str;
ctx.str[0] = 0;
@@ -756,6 +766,7 @@ tgsi_dump_instruction_str(
ctx.base.indent = 0;
ctx.base.dump_printf = &str_dump_ctx_printf;
ctx.base.indentation = 0;
+ ctx.base.file = NULL;
ctx.str = str;
ctx.str[0] = 0;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.h b/src/gallium/auxiliary/tgsi/tgsi_dump.h
index bc873a54ae9..7c8f92ee7bc 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h
@@ -32,6 +32,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include <stdio.h>
+
#if defined __cplusplus
extern "C" {
#endif
@@ -44,6 +46,9 @@ tgsi_dump_str(
size_t size);
void
+tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file);
+
+void
tgsi_dump(
const struct tgsi_token *tokens,
uint flags );