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



commit 4cbeae6eefbe9d42a54603c45bbb131c3d8049bf
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 2063ab2..bdabdbc 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]