Module: Mesa
Branch: master
Commit: 3f4292a6e361c03abe922e025d24cba17e0ab305
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f4292a6e361c03abe922e025d24cba17e0ab305

Author: Paul Berry <stereotype...@gmail.com>
Date:   Wed Sep 18 14:15:36 2013 -0700

glsl: Add an ir_variable::max_ifc_array_access field.

For interface blocks that contain arrays, this field will contain the
maximum element of each contained array that is accessed by the
shader.  This is a first step toward supporting unsized arrays in
interface blocks.

Reviewed-by: Jordan Justen <jordan.l.jus...@intel.com>

---

 src/glsl/ir.cpp       |    3 ++-
 src/glsl/ir.h         |   17 +++++++++++++++++
 src/glsl/ir_clone.cpp |    6 ++++++
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index ead7456..de9613e 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1584,7 +1584,8 @@ ir_swizzle::variable_referenced() const
 
 ir_variable::ir_variable(const struct glsl_type *type, const char *name,
                         ir_variable_mode mode)
-   : max_array_access(0), read_only(false), centroid(false), invariant(false),
+   : max_array_access(0), max_ifc_array_access(NULL),
+     read_only(false), centroid(false), invariant(false),
      mode(mode), interpolation(INTERP_QUALIFIER_NONE)
 {
    this->ir_type = ir_type_variable;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index a277857..eb24d4e 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -398,6 +398,10 @@ public:
    {
       assert(this->interface_type == NULL);
       this->interface_type = type;
+      if (this->is_interface_instance()) {
+         this->max_ifc_array_access =
+            rzalloc_array(this, unsigned, type->length);
+      }
    }
 
    const glsl_type *get_interface_type() const
@@ -423,6 +427,19 @@ public:
    unsigned max_array_access;
 
    /**
+    * For variables which satisfy the is_interface_instance() predicate, this
+    * points to an array of integers such that if the ith member of the
+    * interface block is an array, max_ifc_array_access[i] is the maximum
+    * array element of that member that has been accessed.  If the ith member
+    * of the interface block is not an array, max_ifc_array_access[i] is
+    * unused.
+    *
+    * For variables whose type is not an interface block, this pointer is
+    * NULL.
+    */
+   unsigned *max_ifc_array_access;
+
+   /**
     * Is the variable read-only?
     *
     * This is set for variables declared as \c const, shader inputs,
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index dde22e0..105f906 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -44,6 +44,12 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) 
const
                                               (ir_variable_mode) this->mode);
 
    var->max_array_access = this->max_array_access;
+   if (this->is_interface_instance()) {
+      var->max_ifc_array_access =
+         rzalloc_array(var, unsigned, this->interface_type->length);
+      memcpy(var->max_ifc_array_access, this->max_ifc_array_access,
+             this->interface_type->length * sizeof(unsigned));
+   }
    var->read_only = this->read_only;
    var->centroid = this->centroid;
    var->invariant = this->invariant;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to