[gtk+/wip/otte/shader: 89/101] gsksltype: Make sure blocks can't be compared



commit 8947ad45de18ab8beaed1f6d3a053779319cbc7a
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 24 07:37:16 2017 +0200

    gsksltype: Make sure blocks can't be compared
    
    Testcase included

 gsk/gsksltype.c                                    |   12 +++++++++---
 .../errors/block-array-member-comparison.glsl      |    8 ++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gsksltype.c b/gsk/gsksltype.c
index ed144f4..4668d70 100644
--- a/gsk/gsksltype.c
+++ b/gsk/gsksltype.c
@@ -1195,7 +1195,7 @@ gsk_sl_type_array_get_n_members (const GskSlType *type)
 
 static const GskSlTypeMember *
 gsk_sl_type_array_get_member (const GskSlType *type,
-                               guint            n)
+                              guint            n)
 {
   return NULL;
 }
@@ -1204,7 +1204,13 @@ static gboolean
 gsk_sl_type_array_can_convert (const GskSlType *target,
                                const GskSlType *source)
 {
-  return gsk_sl_type_equal (target, source);
+  const GskSlTypeArray *target_array = (const GskSlTypeArray *) target;
+  const GskSlTypeArray *source_array = (const GskSlTypeArray *) source;
+
+  /* Blocks are equal but cannot be converted to each other.
+   * So arrays (of arrays) of blocks... */
+  return gsk_sl_type_equal (target, source)
+      && gsk_sl_type_can_convert (target_array->type, source_array->type);
 }
 
 static gboolean
@@ -1854,7 +1860,7 @@ static gboolean
 gsk_sl_type_block_can_convert (const GskSlType *target,
                                const GskSlType *source)
 {
-  return gsk_sl_type_equal (target, source);
+  return FALSE;
 }
 
 static guint32
diff --git a/testsuite/gsksl/errors/block-array-member-comparison.glsl 
b/testsuite/gsksl/errors/block-array-member-comparison.glsl
new file mode 100644
index 0000000..0d26bf6
--- /dev/null
+++ b/testsuite/gsksl/errors/block-array-member-comparison.glsl
@@ -0,0 +1,8 @@
+uniform Foo {
+  int x;
+} x[2][3][4];
+
+void main()
+{
+  bool t = x[1] == x[0];
+}


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