[Mesa-dev] [PATCH v2 1/4] glsl: be more consistent about printing constants

Connor Abbott cwabbott0 at gmail.com
Tue May 27 18:23:02 PDT 2014


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 <cwabbott0 at gmail.com>
---
 src/glsl/ir_print_visitor.cpp                                  |  2 +-
 src/glsl/tests/lower_jumps/lower_breaks_1.opt_test             |  3 +--
 src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected    |  3 +--
 src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected    |  2 +-
 src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected    |  2 +-
 src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected    |  2 +-
 src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected    |  2 +-
 src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected    | 10 +++++-----
 .../lower_guarded_conditional_break.opt_test.expected          |  6 +++---
 .../tests/lower_jumps/lower_pulled_out_jump.opt_test.expected  |  8 ++++----
 src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected   |  4 ++--
 src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected   |  2 +-
 .../lower_jumps/lower_returns_main_false.opt_test.expected     |  4 ++--
 .../lower_jumps/lower_returns_main_true.opt_test.expected      |  4 ++--
 .../lower_jumps/lower_returns_sub_false.opt_test.expected      |  4 ++--
 .../tests/lower_jumps/lower_returns_sub_true.opt_test.expected |  4 ++--
 .../tests/lower_jumps/lower_unified_returns.opt_test.expected  |  8 ++++----
 .../tests/lower_jumps/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 +--
 .../return_void_at_end_of_loop_lower_nothing.opt_test.expected |  3 +--
 .../return_void_at_end_of_loop_lower_return.opt_test           |  3 +--
 .../return_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 0a7695a..a3d851e 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 b412ba8..e2d4ed1 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 56ef3e4..270a43d 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 dc231f9..73a1d56 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 8131b66..53d5392 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 94dcb37..ecf28c4 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 5b46ccb..418f879 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 967ce64..5582d08 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 841073e..0379206 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 cf2ef3f..47e8c79 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 5b62bbc..d4835e9 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 07c6842..b551a06 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 7e3fe31..e8b36f1 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 b47f5a4..e15a97d 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 7424968..07db6e7 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 1a3eae5..3110980 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 c0b51e1..271cd3b 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 8403bb2..5fa1134 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 98b74d7..2a7ec2e 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 0408282..7944243 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 569213e..156e95e 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 a7e65c8..76469f7 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 7a5efe5..1d145b4 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
-- 
1.8.3.1



More information about the mesa-dev mailing list