Commit 1e3bd9f9 authored by Eric Anholt's avatar Eric Anholt

glsl: Add a file argument to the IR printer.

While we want to be able to print to stdout for glsl_compiler, for
debugging drivers we want to be able to dump to stderr because that's
where other driver debug (like LIBGL_DEBUG) tends to go, and because some
apps actually close stdout to shut up their own messages (such as the X
Server, or NWN).
Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
Reviewed-by: default avatarKenneth Graunke <kenneth@whitecape.org>
Reviewed-by: default avatarMatt Turner <mattst88@gmail.com>
parent f28c9208
......@@ -1434,7 +1434,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
/* Print out the unoptimized IR. */
if (dump_hir) {
_mesa_print_ir(shader->ir, state);
_mesa_print_ir(stdout, shader->ir, state);
}
}
......
......@@ -106,6 +106,7 @@ public:
/** ir_print_visitor helper for debugging. */
void print(void) const;
void fprint(FILE *f) const;
virtual void accept(ir_visitor *) = 0;
virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0;
......@@ -2353,7 +2354,7 @@ mode_string(const ir_variable *var);
extern "C" {
#endif /* __cplusplus */
extern void _mesa_print_ir(struct exec_list *instructions,
extern void _mesa_print_ir(FILE *f, struct exec_list *instructions,
struct _mesa_glsl_parse_state *state);
#ifdef __cplusplus
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ extern "C" {
*/
class ir_print_visitor : public ir_visitor {
public:
ir_print_visitor();
ir_print_visitor(FILE *f);
virtual ~ir_print_visitor();
void indent(void);
......@@ -87,6 +87,7 @@ private:
_mesa_symbol_table *symbols;
void *mem_ctx;
FILE *f;
int indentation;
};
......
......@@ -294,7 +294,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
/* Print out the resulting IR */
if (!state->error && dump_lir) {
_mesa_print_ir(shader->ir, state);
_mesa_print_ir(stdout, shader->ir, state);
}
return;
......
......@@ -400,7 +400,7 @@ optimize_split_arrays(exec_list *instructions, bool linked)
visit_list_elements(&split, instructions);
if (debug)
_mesa_print_ir(instructions, NULL);
_mesa_print_ir(stdout, instructions, NULL);
ralloc_free(mem_ctx);
......
......@@ -235,7 +235,7 @@ int test_optpass(int argc, char **argv)
/* Print out the initial IR */
if (!state->error && !quiet) {
printf("*** pre-optimization IR:\n");
_mesa_print_ir(shader->ir, state);
_mesa_print_ir(stdout, shader->ir, state);
printf("\n--\n");
}
......@@ -255,7 +255,7 @@ int test_optpass(int argc, char **argv)
if (!quiet) {
printf("*** resulting IR:\n");
}
_mesa_print_ir(shader->ir, state);
_mesa_print_ir(stdout, shader->ir, state);
if (!quiet) {
printf("\n--\n");
}
......
......@@ -593,7 +593,7 @@ brw_dump_ir(struct brw_context *brw, const char *stage,
{
if (shader_prog) {
printf("GLSL IR for native %s shader %d:\n", stage, shader_prog->Name);
_mesa_print_ir(shader->ir, NULL);
_mesa_print_ir(stdout, shader->ir, NULL);
printf("\n\n");
} else {
printf("ARB_%s_program %d ir for native %s shader\n",
......
......@@ -255,7 +255,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
printf("GLSL IR for linked %s program %d:\n",
_mesa_shader_stage_to_string(shader->base.Stage),
shProg->Name);
_mesa_print_ir(shader->base.ir, NULL);
_mesa_print_ir(stdout, shader->base.ir, NULL);
printf("\n");
}
}
......
......@@ -855,7 +855,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (ctx->Shader.Flags & GLSL_DUMP) {
if (sh->CompileStatus) {
printf("GLSL IR for shader %d:\n", sh->Name);
_mesa_print_ir(sh->ir, NULL);
_mesa_print_ir(stdout, sh->ir, NULL);
printf("\n\n");
} else {
printf("GLSL shader %d failed to compile.\n", sh->Name);
......
......@@ -2921,7 +2921,7 @@ get_mesa_program(struct gl_context *ctx,
printf("\n");
printf("GLSL IR for linked %s program %d:\n", target_string,
shader_program->Name);
_mesa_print_ir(shader->ir, NULL);
_mesa_print_ir(stdout, shader->ir, NULL);
printf("\n");
printf("\n");
printf("Mesa IR for linked %s program %d:\n", target_string,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment