glsl: ignore buffer variables when counting uniform components
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Fri, 15 May 2015 10:26:42 +0000 (12:26 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Fri, 25 Sep 2015 06:39:22 +0000 (08:39 +0200)
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/glsl/link_uniforms.cpp

index 7d6b51d..50a8073 100644 (file)
@@ -322,7 +322,8 @@ public:
       : num_active_uniforms(0), num_hidden_uniforms(0), num_values(0),
         num_shader_samplers(0), num_shader_images(0),
         num_shader_uniform_components(0), num_shader_subroutines(0),
-        is_ubo_var(false), map(map), hidden_map(hidden_map)
+        is_ubo_var(false), is_shader_storage(false), map(map),
+        hidden_map(hidden_map)
    {
       /* empty */
    }
@@ -339,6 +340,7 @@ public:
    {
       this->current_var = var;
       this->is_ubo_var = var->is_in_buffer_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);
@@ -379,6 +381,7 @@ public:
    unsigned num_shader_subroutines;
 
    bool is_ubo_var;
+   bool is_shader_storage;
 
    struct string_to_uint_map *map;
 
@@ -409,13 +412,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;
       }
 
@@ -1118,8 +1122,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;
+         }
       }
    }