Mesa (7.11): glsl: Move type_contains_sampler() into glsl_type for later reuse.

Ian Romanick idr at kemper.freedesktop.org
Tue Jul 19 23:41:07 UTC 2011


Module: Mesa
Branch: 7.11
Commit: ae11fb02dd267fa103093290b3fe51022eb16d57
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae11fb02dd267fa103093290b3fe51022eb16d57

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Mon Jul 11 16:44:13 2011 -0700

glsl: Move type_contains_sampler() into glsl_type for later reuse.

The new location, as a member function of glsl_type, is more
consistent with queries like is_sampler(), is_boolean(), is_float(),
etc.  Placing the function inside glsl_type also makes it available to
any code that uses glsl_types.
(cherry picked from commit ddc1c96390b685bb95f7431e862c3a64fcefa085)

---

 src/glsl/glsl_types.cpp |   16 ++++++++++++++++
 src/glsl/glsl_types.h   |    6 ++++++
 src/glsl/ir.cpp         |   17 +----------------
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 78d10bd..a5e21bb 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -111,6 +111,22 @@ add_types_to_symbol_table(glsl_symbol_table *symtab,
    }
 }
 
+bool
+glsl_type::contains_sampler() const
+{
+   if (this->is_array()) {
+      return this->fields.array->contains_sampler();
+   } else if (this->is_record()) {
+      for (unsigned int i = 0; i < this->length; i++) {
+	 if (this->fields.structure[i].type->contains_sampler())
+	    return true;
+      }
+      return false;
+   } else {
+      return this->is_sampler();
+   }
+}
+
 void
 glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
 {
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 1b069df..87f57e7 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -296,6 +296,12 @@ struct glsl_type {
    }
 
    /**
+    * Query whether or not type is a sampler, or for struct and array
+    * types, contains a sampler.
+    */
+   bool contains_sampler() const;
+
+   /**
     * Query whether or not a type is an array
     */
    bool is_array() const
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index a3623b3..4e4cfdc 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1087,21 +1087,6 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }
 
-bool type_contains_sampler(const glsl_type *type)
-{
-   if (type->is_array()) {
-      return type_contains_sampler(type->fields.array);
-   } else if (type->is_record()) {
-      for (unsigned int i = 0; i < type->length; i++) {
-	 if (type_contains_sampler(type->fields.structure[i].type))
-	    return true;
-      }
-      return false;
-   } else {
-      return type->is_sampler();
-   }
-}
-
 bool
 ir_dereference::is_lvalue()
 {
@@ -1121,7 +1106,7 @@ ir_dereference::is_lvalue()
     *     as out or inout function parameters, nor can they be
     *     assigned into."
     */
-   if (type_contains_sampler(this->type))
+   if (this->type->contains_sampler())
       return false;
 
    return true;




More information about the mesa-commit mailing list