From bbaec0f76c714a369014a47cca588fa3c2c9ce1e Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 27 May 2014 21:23:02 -0400 Subject: [PATCH] glsl: be more consistent about printing constants Make sure that we print the same number of digits when printing 0.0 as any other floating-point number. This will make generating expected output files for tests easier. To avoid breaking "make check," update the generated tests for lower_jumps before the next commit which will bring create_test_cases.py in line with them. Signed-off-by: Connor Abbott Reviewed-by: Kenneth Graunke Reviewed-by: Matt Turner --- src/glsl/ir_print_visitor.cpp | 2 +- src/glsl/tests/lower_jumps/lower_breaks_1.opt_test | 3 +-- .../tests/lower_jumps/lower_breaks_1.opt_test.expected | 3 +-- .../tests/lower_jumps/lower_breaks_2.opt_test.expected | 2 +- .../tests/lower_jumps/lower_breaks_3.opt_test.expected | 2 +- .../tests/lower_jumps/lower_breaks_4.opt_test.expected | 2 +- .../tests/lower_jumps/lower_breaks_5.opt_test.expected | 2 +- .../tests/lower_jumps/lower_breaks_6.opt_test.expected | 10 +++++----- .../lower_guarded_conditional_break.opt_test.expected | 6 +++--- .../lower_pulled_out_jump.opt_test.expected | 8 ++++---- .../lower_jumps/lower_returns_3.opt_test.expected | 4 ++-- .../lower_jumps/lower_returns_4.opt_test.expected | 2 +- .../lower_returns_main_false.opt_test.expected | 4 ++-- .../lower_returns_main_true.opt_test.expected | 4 ++-- .../lower_returns_sub_false.opt_test.expected | 4 ++-- .../lower_returns_sub_true.opt_test.expected | 4 ++-- .../lower_unified_returns.opt_test.expected | 8 ++++---- .../remove_continue_at_end_of_loop.opt_test | 3 +-- .../remove_continue_at_end_of_loop.opt_test.expected | 3 +-- .../return_void_at_end_of_loop_lower_nothing.opt_test | 3 +-- ...void_at_end_of_loop_lower_nothing.opt_test.expected | 3 +-- .../return_void_at_end_of_loop_lower_return.opt_test | 3 +-- ...void_at_end_of_loop_lower_return_and_break.opt_test | 3 +-- 23 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 418f0515153..c4a6f9c9f1c 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -430,7 +430,7 @@ void ir_print_visitor::visit(ir_constant *ir) case GLSL_TYPE_FLOAT: if (ir->value.f[i] == 0.0f) /* 0.0 == -0.0, so print with %f to get the proper sign. */ - fprintf(f, "%.1f", ir->value.f[i]); + fprintf(f, "%f", ir->value.f[i]); else if (fabs(ir->value.f[i]) < 0.000001f) fprintf(f, "%a", ir->value.f[i]); else if (fabs(ir->value.f[i]) > 1000000.0f) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test index b412ba8f29f..e2d4ed1f343 100755 --- a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test +++ b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test @@ -8,6 +8,5 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) EOF diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected index 56ef3e42465..270a43d9058 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected @@ -1,5 +1,4 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) break)))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected index dc231f9753b..73a1d56fa5f 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected @@ -3,5 +3,5 @@ (signature void (parameters) ((loop ((assign (x) (var_ref a) (constant float (1.000000))) - (if (expression bool > (var_ref b) (constant float (0.0))) (break) + (if (expression bool > (var_ref b) (constant float (0.000000))) (break) ()))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected index 8131b66ff4b..53d5392d05e 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected @@ -3,6 +3,6 @@ (signature void (parameters) ((loop ((assign (x) (var_ref a) (constant float (1.000000))) - (if (expression bool > (var_ref b) (constant float (0.0))) + (if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref c) (constant float (1.000000))) break) ()))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected index 94dcb37be04..ecf28c4e5ab 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected @@ -3,5 +3,5 @@ (signature void (parameters) ((loop ((assign (x) (var_ref a) (constant float (1.000000))) - (if (expression bool > (var_ref b) (constant float (0.0))) () + (if (expression bool > (var_ref b) (constant float (0.000000))) () (break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected index 5b46ccb6773..418f8798cf4 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected @@ -3,5 +3,5 @@ (signature void (parameters) ((loop ((assign (x) (var_ref a) (constant float (1.000000))) - (if (expression bool > (var_ref b) (constant float (0.0))) () + (if (expression bool > (var_ref b) (constant float (0.000000))) () ((assign (x) (var_ref c) (constant float (1.000000))) break)))))))) diff --git a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected index 967ce642a4b..5582d08b236 100644 --- a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected @@ -8,15 +8,15 @@ (loop ((declare (temporary) bool execute_flag) (assign (x) (var_ref execute_flag) (constant bool (1))) - (if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref ba) (constant float (0.0))) - ((if (expression bool > (var_ref bb) (constant float (0.0))) + (if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref ba) (constant float (0.000000))) + ((if (expression bool > (var_ref bb) (constant float (0.000000))) ((assign (x) (var_ref execute_flag) (constant bool (0)))) ())) ()) (if (var_ref execute_flag) - ((if (expression bool > (var_ref ca) (constant float (0.0))) - ((if (expression bool > (var_ref cb) (constant float (0.0))) + ((if (expression bool > (var_ref ca) (constant float (0.000000))) + ((if (expression bool > (var_ref cb) (constant float (0.000000))) ((assign (x) (var_ref break_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) diff --git a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected index 841073ed909..037920668e9 100644 --- a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected @@ -6,13 +6,13 @@ (loop ((declare (temporary) bool execute_flag) (assign (x) (var_ref execute_flag) (constant bool (1))) - (if (expression bool > (var_ref aa) (constant float (0.0))) - ((if (expression bool > (var_ref ab) (constant float (0.0))) + (if (expression bool > (var_ref aa) (constant float (0.000000))) + ((if (expression bool > (var_ref ab) (constant float (0.000000))) ((assign (x) (var_ref execute_flag) (constant bool (0)))) ())) ()) (if (var_ref execute_flag) - ((if (expression bool > (var_ref b) (constant float (0.0))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref break_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) diff --git a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected index cf2ef3f080a..47e8c795c45 100644 --- a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected @@ -7,16 +7,16 @@ (assign (x) (var_ref execute_flag) (constant bool (1))) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref aa) (constant float (0.0))) - ((if (expression bool > (var_ref ab) (constant float (0.0))) + (if (expression bool > (var_ref aa) (constant float (0.000000))) + ((if (expression bool > (var_ref ab) (constant float (0.000000))) ((assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) ()) (if (var_ref execute_flag) ((loop - ((if (expression bool > (var_ref b) (constant float (0.0))) - ((if (expression bool > (var_ref c) (constant float (0.0))) () + ((if (expression bool > (var_ref b) (constant float (0.000000))) + ((if (expression bool > (var_ref c) (constant float (0.000000))) () (continue))) ((assign (x) (var_ref return_flag) (constant bool (1))))) break)) diff --git a/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected index 5b62bbcde99..d4835e96b7c 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected @@ -6,8 +6,8 @@ (declare (temporary) float return_value) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref b) (constant float (0.0))) + (if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref return_value) (constant float (1.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) diff --git a/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected index 07c6842d20c..b551a066f43 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected @@ -6,7 +6,7 @@ (declare (temporary) float return_value) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref a) (constant float (0.0))) + (if (expression bool > (var_ref a) (constant float (0.000000))) ((assign (x) (var_ref return_value) (constant float (1.000000))) (assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected index 7e3fe314f96..e8b36f14478 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected @@ -1,8 +1,8 @@ ((declare (in) float a) (declare (in) float b) (function main (signature void (parameters) - ((if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref b) (constant float (0.0))) + ((if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((return)) ())) ()))))) diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected index b47f5a433de..e15a97d1db2 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected @@ -5,8 +5,8 @@ (assign (x) (var_ref execute_flag) (constant bool (1))) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref b) (constant float (0.0))) + (if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected index 7424968b248..07db6e708f4 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected @@ -1,8 +1,8 @@ ((declare (in) float a) (declare (in) float b) (function sub (signature void (parameters) - ((if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref b) (constant float (0.0))) + ((if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((return)) ())) ()))))) diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected index 1a3eae5da76..31109802351 100644 --- a/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected @@ -5,8 +5,8 @@ (assign (x) (var_ref execute_flag) (constant bool (1))) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref a) (constant float (0.0))) - ((if (expression bool > (var_ref b) (constant float (0.0))) + (if (expression bool > (var_ref a) (constant float (0.000000))) + ((if (expression bool > (var_ref b) (constant float (0.000000))) ((assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) diff --git a/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected b/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected index c0b51e1baaa..271cd3b462e 100644 --- a/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected +++ b/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected @@ -6,15 +6,15 @@ (assign (x) (var_ref execute_flag) (constant bool (1))) (declare (temporary) bool return_flag) (assign (x) (var_ref return_flag) (constant bool (0))) - (if (expression bool > (var_ref aa) (constant float (0.0))) - ((if (expression bool > (var_ref ab) (constant float (0.0))) + (if (expression bool > (var_ref aa) (constant float (0.000000))) + ((if (expression bool > (var_ref ab) (constant float (0.000000))) ((assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) ()) (if (var_ref execute_flag) - ((if (expression bool > (var_ref b) (constant float (0.0))) - ((if (expression bool > (var_ref c) (constant float (0.0))) () ()) + ((if (expression bool > (var_ref b) (constant float (0.000000))) + ((if (expression bool > (var_ref c) (constant float (0.000000))) () ()) (assign (x) (var_ref return_flag) (constant bool (1))) (assign (x) (var_ref execute_flag) (constant bool (0)))) ())) diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test index 8403bb2041b..5fa1134f985 100755 --- a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test +++ b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test @@ -8,6 +8,5 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) continue)))))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) continue)))))) EOF diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected index 98b74d71e76..2a7ec2ecbec 100644 --- a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected +++ b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected @@ -1,5 +1,4 @@ ((declare (out) float a) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))))))))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))))))))) diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test index 0408282d0d5..79442433c08 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test @@ -8,7 +8,6 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) (return))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected index 569213e99f8..156e95edf7d 100644 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected @@ -1,6 +1,5 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) (return))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test index a7e65c86ced..76469f73d6a 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test @@ -8,7 +8,6 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) (return))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test index 7a5efe5811e..1d145b4fcb7 100755 --- a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test +++ b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test @@ -8,7 +8,6 @@ ((declare (out) float a) (declare (out) float b) (function main (signature void (parameters) - ((loop - ((assign (x) (var_ref a) (constant float (1.000000))) (return))) + ((loop ((assign (x) (var_ref a) (constant float (1.000000))) (return))) (assign (x) (var_ref b) (constant float (2.000000))))))) EOF -- 2.30.2