[gtk+/wip/otte/shader: 68/98] gskslexpression: Function arguments are evaluated randomly



commit 7c271f37706e9bee86d4d973b99ee51251627728
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 de822ba..c324f08 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]