glsl/standalone: Add the ability to generate ir_builder code

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
This commit is contained in:
Ian Romanick
2016-09-15 11:37:32 -07:00
parent 191d9a5195
commit e9acae8486
3 changed files with 14 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ const struct option compiler_opts[] = {
{ "dump-ast", no_argument, &options.dump_ast, 1 },
{ "dump-hir", no_argument, &options.dump_hir, 1 },
{ "dump-lir", no_argument, &options.dump_lir, 1 },
{ "dump-builder", no_argument, &options.dump_builder, 1 },
{ "link", no_argument, &options.do_link, 1 },
{ "just-log", no_argument, &options.just_log, 1 },
{ "version", required_argument, NULL, 'v' },

View File

@@ -40,6 +40,7 @@
#include "util/set.h"
#include "linker.h"
#include "glsl_parser_extras.h"
#include "ir_builder_print_visitor.h"
#include "opt_add_neg_to_sub.h"
class dead_variable_visitor : public ir_hierarchical_visitor {
@@ -550,6 +551,17 @@ standalone_compile_shader(const struct standalone_options *_options,
shader->Program = rzalloc(shader, gl_program);
init_gl_program(shader->Program, shader->Stage);
}
if (options->dump_builder) {
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *shader = whole_program->_LinkedShaders[i];
if (!shader)
continue;
_mesa_print_builder_for_ir(stdout, shader->ir);
}
}
}
return whole_program;

View File

@@ -33,6 +33,7 @@ struct standalone_options {
int dump_ast;
int dump_hir;
int dump_lir;
int dump_builder;
int do_link;
int just_log;
};