aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2015-02-05 12:52:19 +0200
committerIlia Mirkin <[email protected]>2015-02-19 00:28:34 -0500
commit57c6c3d3bdc36a59937bdb8ca686e0e416ff11d2 (patch)
tree03ffe98bc25246d9f0f9092f73c3c281fcbd1520
parent5a69bdb599ee4eb422cba6a47517c376e9dc5faf (diff)
glsl/ir: Add printing support for doubles
Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
-rw-r--r--src/glsl/ir_print_visitor.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
index bd398052c3f..01f52e85f4a 100644
--- a/src/glsl/ir_print_visitor.cpp
+++ b/src/glsl/ir_print_visitor.cpp
@@ -436,6 +436,17 @@ void ir_print_visitor::visit(ir_constant *ir)
fprintf(f, "%f", ir->value.f[i]);
break;
case GLSL_TYPE_BOOL: fprintf(f, "%d", ir->value.b[i]); break;
+ case GLSL_TYPE_DOUBLE:
+ if (ir->value.d[i] == 0.0)
+ /* 0.0 == -0.0, so print with %f to get the proper sign. */
+ fprintf(f, "%.1f", ir->value.d[i]);
+ else if (fabs(ir->value.d[i]) < 0.000001)
+ fprintf(f, "%a", ir->value.d[i]);
+ else if (fabs(ir->value.d[i]) > 1000000.0)
+ fprintf(f, "%e", ir->value.d[i]);
+ else
+ fprintf(f, "%f", ir->value.d[i]);
+ break;
default: assert(0);
}
}