[gtk+/wip/otte/shader: 54/101] gskslexpression: Function arguments are evaluated randomly



commit dd1112c00124c87ec8ea7e34aa30c8979839076d
Author: Benjamin Otte <otte redhat com>
Date:   Mon Oct 16 02:31:45 2017 +0200

    gskslexpression: Function arguments are evaluated randomly
    
    The C spec doesn't guarantee an order of evaluation for function
    arguments. In fact, gcc evaluates them last to first while clang
    evaluated them first to last.
    
    We would like the left argument to be written into the SPIRV file first
    (the GLSL spec wants that), so enforce this by calling the functions
    before.

 gsk/gskslexpression.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index 60c88ac..148acd2 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -266,14 +266,18 @@ gsk_sl_expression_binary_write_spv (const GskSlExpression *expression,
                                     GskSpvWriter          *writer)
 {
   const GskSlExpressionBinary *binary = (const GskSlExpressionBinary *) expression;
+  guint left_id, right_id;
+
+  left_id = gsk_sl_expression_write_spv (binary->left, writer);
+  right_id = gsk_sl_expression_write_spv (binary->right, writer);
 
   return gsk_sl_binary_write_spv (binary->binary,
                                   writer,
                                   binary->type,
                                   gsk_sl_expression_get_return_type (binary->left),
-                                  gsk_sl_expression_write_spv (binary->left, writer),
+                                  left_id,
                                   gsk_sl_expression_get_return_type (binary->right),
-                                  gsk_sl_expression_write_spv (binary->right, writer));
+                                  right_id);
 }
 
 static const GskSlExpressionClass GSK_SL_EXPRESSION_BINARY = {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]