diff options
author | Eric Anholt <[email protected]> | 2013-05-23 11:10:15 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-06-06 14:37:41 -0700 |
commit | 38e77e545d06bf5ac0e185f2a1581a97bafdab56 (patch) | |
tree | a907d7de6f8cc8080539f21f90e04464089e5784 /src/glsl/link_uniforms.cpp | |
parent | 93c8692ce92d396f0a4db5bc91d8e7322fa7dd50 (diff) |
glsl: Fix uniform buffer object counting.
We were counting uniforms located in UBOs against the default uniform
block limit, while not doing any counting against the specific combined
limit.
Note that I couldn't quite find justification for the way I did this, but
I think it's the only sensible thing: The spec talks about components, so
each "float" in a std140 block would count as 1 component and a "vec4"
would count as 4, though they occupy the same amount of space. Since GPU
limits on uniform buffer loads are surely going to be about the size of
the blocks, I just counted them that way.
Fixes link failures in piglit
arb_uniform_buffer_object/maxuniformblocksize when ported to geometry
shaders on Paul's GS branch, since in that case the max block size is
bigger than the default uniform block component limit.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 7a3a2ebde03..010296b6b69 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -170,6 +170,7 @@ public: void process(ir_variable *var) { + this->is_ubo_var = var->is_in_uniform_block(); if (var->is_interface_instance()) program_resource_visitor::process(var->interface_type, var->interface_type->name); @@ -197,6 +198,8 @@ public: */ unsigned num_shader_uniform_components; + bool is_ubo_var; + private: virtual void visit_field(const glsl_type *type, const char *name, bool row_major) @@ -222,7 +225,8 @@ private: * Note that samplers do not count against this limit because they * don't use any storage on current hardware. */ - this->num_shader_uniform_components += values; + if (!is_ubo_var) + this->num_shader_uniform_components += values; } /* If the uniform is already in the map, there's nothing more to do. @@ -681,6 +685,12 @@ link_assign_uniform_locations(struct gl_shader_program *prog) sh->num_samplers = uniform_size.num_shader_samplers; sh->num_uniform_components = uniform_size.num_shader_uniform_components; + + 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; + } } const unsigned num_user_uniforms = uniform_size.num_active_uniforms; |