[Mesa-dev] [PATCH] glsl: inspect interfaces in contains_foo()

Juan A. Suarez Romero jasuarez at igalia.com
Tue Oct 25 15:53:41 UTC 2016


When checking if a type contains doubles, integers, samples, etc. we
check if the current type is a record or array, but not if it is an
interface.

This commit also inspects if the type is an interface.

It fixes spec/arb_enhanced_layouts/compiler/transform-feedback-layout-qualifiers/xfb_offset/invalid-block-with-double.vert
piglit test.
---
 src/compiler/glsl_types.cpp | 11 ++++++-----
 src/compiler/glsl_types.h   | 16 ++++++++--------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 55e5285..44cd2ac 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -248,7 +248,7 @@ glsl_type::contains_sampler() const
 {
    if (this->is_array()) {
       return this->fields.array->contains_sampler();
-   } else if (this->is_record()) {
+   } else if (this->is_record() || this->is_interface()) {
       for (unsigned int i = 0; i < this->length; i++) {
          if (this->fields.structure[i].type->contains_sampler())
             return true;
@@ -265,7 +265,7 @@ glsl_type::contains_integer() const
 {
    if (this->is_array()) {
       return this->fields.array->contains_integer();
-   } else if (this->is_record()) {
+   } else if (this->is_record() || this->is_interface()) {
       for (unsigned int i = 0; i < this->length; i++) {
          if (this->fields.structure[i].type->contains_integer())
             return true;
@@ -281,7 +281,7 @@ glsl_type::contains_double() const
 {
    if (this->is_array()) {
       return this->fields.array->contains_double();
-   } else if (this->is_record()) {
+   } else if (this->is_record() || this->is_interface()) {
       for (unsigned int i = 0; i < this->length; i++) {
          if (this->fields.structure[i].type->contains_double())
             return true;
@@ -302,6 +302,7 @@ glsl_type::contains_opaque() const {
    case GLSL_TYPE_ARRAY:
       return fields.array->contains_opaque();
    case GLSL_TYPE_STRUCT:
+   case GLSL_TYPE_INTERFACE:
       for (unsigned int i = 0; i < length; i++) {
          if (fields.structure[i].type->contains_opaque())
             return true;
@@ -317,7 +318,7 @@ glsl_type::contains_subroutine() const
 {
    if (this->is_array()) {
       return this->fields.array->contains_subroutine();
-   } else if (this->is_record()) {
+   } else if (this->is_record() || this->is_interface()) {
       for (unsigned int i = 0; i < this->length; i++) {
          if (this->fields.structure[i].type->contains_subroutine())
             return true;
@@ -363,7 +364,7 @@ glsl_type::contains_image() const
 {
    if (this->is_array()) {
       return this->fields.array->contains_image();
-   } else if (this->is_record()) {
+   } else if (this->is_record() || this->is_interface()) {
       for (unsigned int i = 0; i < this->length; i++) {
          if (this->fields.structure[i].type->contains_image())
             return true;
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index e5b9f3b..f607dd8 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -473,14 +473,14 @@ struct glsl_type {
    }
 
    /**
-    * Query whether or not type is an integral type, or for struct and array
-    * types, contains an integral type.
+    * Query whether or not type is an integral type, or for struct, interface
+    * and array types, contains an integral type.
     */
    bool contains_integer() const;
 
    /**
-    * Query whether or not type is a double type, or for struct and array
-    * types, contains a double type.
+    * Query whether or not type is a double type, or for struct, interface and
+    * array types, contains a double type.
     */
    bool contains_double() const;
 
@@ -533,8 +533,8 @@ struct glsl_type {
    }
 
    /**
-    * Query whether or not type is a sampler, or for struct and array
-    * types, contains a sampler.
+    * Query whether or not type is a sampler, or for struct, interface and
+    * array types, contains a sampler.
     */
    bool contains_sampler() const;
 
@@ -544,8 +544,8 @@ struct glsl_type {
    gl_texture_index sampler_index() const;
 
    /**
-    * Query whether or not type is an image, or for struct and array
-    * types, contains an image.
+    * Query whether or not type is an image, or for struct, interface and
+    * array types, contains an image.
     */
    bool contains_image() const;
 
-- 
2.7.4



More information about the mesa-dev mailing list