[gtk+/wip/otte/shader: 205/226] gsksl: Add a special case for vector-to-vector casts



commit ac95c0606ab7a769b2a525874f8d87af47e923e0
Author: Benjamin Otte <otte redhat com>
Date:   Sun Oct 22 18:20:14 2017 +0200

    gsksl: Add a special case for vector-to-vector casts
    
    We don't have to extract all components and fold them back together if
    the vectors already have the same size. Just cast them.

 gsk/gskslexpression.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index fcbeb3c..b4d18a5 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -978,6 +978,12 @@ gsk_sl_expression_constructor_write_spv (const GskSlExpression *expression,
         }
       return gsk_spv_writer_composite_construct (writer, type, ids, cols);
     }
+  else if (constructor->n_arguments == 1 && gsk_sl_type_is_vector (type) && gsk_sl_type_is_vector 
(value_type)
+      && gsk_sl_type_get_length (type) == gsk_sl_type_get_length (value_type))
+    {
+      value_id = gsk_sl_expression_write_spv (constructor->arguments[0], writer);
+      return gsk_spv_writer_convert (writer, value_id, value_type, type);
+    }
   else
     {
       gsize n_components = gsk_sl_type_get_n_components (type);


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