[Mesa-dev] [PATCH 04/12] glsl: Add a helper to see if an array was unsize in the shader

Dave Airlie airlied at gmail.com
Mon Apr 4 02:15:30 UTC 2016


From: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>

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

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index ed9ef98..3469ed6 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1481,7 +1481,7 @@ private:
    {
       if (!from_ssbo_unsized_array && (*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);
       }
    }
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 39585bf..e2f2bf1 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -435,12 +435,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),
    sampled_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
@@ -817,7 +817,7 @@ glsl_type::get_image_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
@@ -837,7 +837,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
    const struct hash_entry *entry = _mesa_hash_table_search(array_types, key);
    if (entry == NULL) {
       mtx_unlock(&glsl_type::mutex);
-      const glsl_type *t = new glsl_type(base, array_size);
+      const glsl_type *t = new glsl_type(base, array_size, was_unsized);
       mtx_lock(&glsl_type::mutex);
 
       entry = _mesa_hash_table_insert(array_types,
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index dd46479..d9d3644 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -193,6 +193,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
     */
    /*@{*/
@@ -258,7 +264,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
@@ -779,7 +785,7 @@ private:
              const glsl_function_param *params, unsigned num_params);
 
    /** Constructor for array types */
-   glsl_type(const glsl_type *array, unsigned length);
+   glsl_type(const glsl_type *array, unsigned length, bool was_unsized);
 
    /** Constructor for subroutine types */
    glsl_type(const char *name);
-- 
2.5.0



More information about the mesa-dev mailing list