[Nouveau] [PATCH 05/11] glsl: Add a helper to see if an array was unsize in the shader

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Sun May 24 10:58:03 PDT 2015


Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 src/glsl/glsl_types.cpp |  8 ++++----
 src/glsl/glsl_types.h   | 10 ++++++++--
 src/glsl/linker.cpp     |  2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index f675e90..4bc7324 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -340,12 +340,12 @@ _mesa_glsl_release_types(void)
 }
 
 
-glsl_type::glsl_type(const glsl_type *array, unsigned length) :
+glsl_type::glsl_type(const glsl_type *array, unsigned length, bool was_unsized) :
    base_type(GLSL_TYPE_ARRAY),
    sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
    sampler_type(0), interface_packing(0),
    vector_elements(0), matrix_columns(0),
-   length(length), name(NULL)
+   length(length), name(NULL), was_unsized(was_unsized)
 {
    this->fields.array = array;
    /* Inherit the gl type of the base. The GL type is used for
@@ -635,7 +635,7 @@ glsl_type::get_sampler_instance(enum glsl_sampler_dim dim,
 }
 
 const glsl_type *
-glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
+glsl_type::get_array_instance(const glsl_type *base, unsigned array_size, bool was_unsized)
 {
    /* Generate a name using the base type pointer in the key.  This is
     * done because the name of the base type may not be unique across
@@ -656,7 +656,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
 
    if (t == NULL) {
       mtx_unlock(&glsl_type::mutex);
-      t = new glsl_type(base, array_size);
+      t = new glsl_type(base, array_size, was_unsized);
       mtx_lock(&glsl_type::mutex);
 
       hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index f54a939..d6ad450 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -183,6 +183,12 @@ struct glsl_type {
    } fields;
 
    /**
+    * For \c GLSL_TYPE_ARRAY this determines if an array was unsized and
+    * got changed to a sized array.
+    */
+   bool was_unsized;
+
+   /**
     * \name Pointers to various public type singletons
     */
    /*@{*/
@@ -246,7 +252,7 @@ struct glsl_type {
     * Get the instance of an array type
     */
    static const glsl_type *get_array_instance(const glsl_type *base,
-					      unsigned elements);
+					      unsigned elements, bool was_unsized = false);
 
    /**
     * Get the instance of a record type
@@ -677,7 +683,7 @@ private:
 	     enum glsl_interface_packing packing, const char *name);
 
    /** Constructor for array types */
-   glsl_type(const glsl_type *array, unsigned length);
+   glsl_type(const glsl_type *array, unsigned length, bool was_unsized);
 
    /** Hash table containing the known array types. */
    static struct hash_table *array_types;
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 9798afe..8eace14 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1261,7 +1261,7 @@ private:
    {
       if ((*type)->is_unsized_array()) {
          *type = glsl_type::get_array_instance((*type)->fields.array,
-                                               max_array_access + 1);
+                                               max_array_access + 1, true);
          assert(*type != NULL);
       }
    }
-- 
2.4.1



More information about the Nouveau mailing list