From 795492247369199d5e79f2503c40920ff8a9b686 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 18:38:28 -0700 Subject: [PATCH] IR print visitor: Finish printing constants --- ir_print_visitor.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 2c9debc7d72..ca9f7592520 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -163,13 +163,30 @@ void ir_print_visitor::visit(ir_assignment *ir) void ir_print_visitor::visit(ir_constant *ir) { - (void) ir; + const glsl_type *const base_type = ir->type->get_base_type(); printf("(constant ("); - print_type(ir->type); - printf(") "); - printf("(FINISHME: value goes here)"); + print_type(base_type); printf(") "); + + const unsigned num_values = 1 + * ((ir->type->vector_elements > 0) ? ir->type->vector_elements : 1) + * ((ir->type->matrix_columns > 0) ? ir->type->matrix_columns : 1); + + printf("(%d) (", num_values); + for (unsigned i = 0; i < num_values; i++) { + if (i != 0) + printf(", "); + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; + case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; + default: assert(0); + } + } + printf(")) "); } -- 2.30.2