[Mesa-dev] [PATCH v2 50/82] glsl: ignore buffer variables when counting uniform components

Iago Toral Quiroga itoral at igalia.com
Wed Jun 3 00:01:40 PDT 2015


From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
---
 src/glsl/link_uniforms.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 715a8d5..b4b1181 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -290,7 +290,7 @@ public:
    count_uniform_size(struct string_to_uint_map *map)
       : num_active_uniforms(0), num_values(0), num_shader_samplers(0),
         num_shader_images(0), num_shader_uniform_components(0),
-        is_ubo_var(false), map(map)
+        is_ubo_var(false), is_shader_storage(false), map(map)
    {
       /* empty */
    }
@@ -305,6 +305,7 @@ public:
    void process(ir_variable *var)
    {
       this->is_ubo_var = var->is_in_uniform_block();
+      this->is_shader_storage = var->is_in_shader_storage_block();
       if (var->is_interface_instance())
          program_resource_visitor::process(var->get_interface_type(),
                                            var->get_interface_type()->name);
@@ -338,6 +339,7 @@ public:
    unsigned num_shader_uniform_components;
 
    bool is_ubo_var;
+   bool is_shader_storage;
 
 private:
    virtual void visit_field(const glsl_type *type, const char *name,
@@ -364,13 +366,14 @@ private:
           * components in the default block.  The spec allows image
           * uniforms to use up no more than one scalar slot.
           */
-         this->num_shader_uniform_components += values;
+         if(!is_shader_storage)
+            this->num_shader_uniform_components += values;
       } else {
 	 /* Accumulate the total number of uniform slots used by this shader.
 	  * Note that samplers do not count against this limit because they
 	  * don't use any storage on current hardware.
 	  */
-	 if (!is_ubo_var)
+	 if (!is_ubo_var && !is_shader_storage)
 	    this->num_shader_uniform_components += values;
       }
 
@@ -950,7 +953,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
 
 	 /* FINISHME: Update code to process built-in uniforms!
 	  */
-	 if (is_gl_identifier(var->name)) {
+	 if (is_gl_identifier(var->name) && var->data.mode == ir_var_uniform) {
 	    uniform_size.num_shader_uniform_components +=
 	       var->type->component_slots();
 	    continue;
@@ -965,8 +968,10 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
 
       sh->num_combined_uniform_components = sh->num_uniform_components;
       for (unsigned i = 0; i < sh->NumUniformBlocks; i++) {
-	 sh->num_combined_uniform_components +=
-	    sh->UniformBlocks[i].UniformBufferSize / 4;
+         if (!sh->UniformBlocks[i].IsShaderStorage) {
+	    sh->num_combined_uniform_components +=
+	       sh->UniformBlocks[i].UniformBufferSize / 4;
+         }
       }
    }
 
-- 
1.9.1



More information about the mesa-dev mailing list