aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-18 08:23:14 +0200
committermarha <marha@users.sourceforge.net>2013-06-18 08:23:14 +0200
commitb071050b9eda9d5e5185e582dbe9f4adba863ccc (patch)
tree6da290f7da04f9afc96691608b65967f2ee0e0fa /mesalib/src/glsl/link_uniforms.cpp
parent150771e7aabf4c864b0b970c5b8d773634793abe (diff)
downloadvcxsrv-b071050b9eda9d5e5185e582dbe9f4adba863ccc.tar.gz
vcxsrv-b071050b9eda9d5e5185e582dbe9f4adba863ccc.tar.bz2
vcxsrv-b071050b9eda9d5e5185e582dbe9f4adba863ccc.zip
libX11 libXmu libxcb/xcb-proto mesa mkfontscale pixman xkeyboard-config git update 18 June 2013
libxcb/xcb-proto commit e5f7c750815cb5170db363a2e5b09639b7354733 xkeyboard-config commit 30d804538462213ed01e8efc0b44a8e5a0aff990 libX11 commit 9dfb0f3c0a761590bcdc1f3396b1e064da4e18e8 pixman commit 279bdcda7ec3af8ac06312f4514b1b082a279544 mkfontscale commit f731c5c36f28ddd0f25f474d2991c96f9a7a915c libXmu commit e46ecb4e02b7f919b11efa79448d4db71d1deb69 mesa commit eb2021507556633cd6ba64cda26653e3c43e80df
Diffstat (limited to 'mesalib/src/glsl/link_uniforms.cpp')
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index ad636681f..208778e4a 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/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.
@@ -640,7 +644,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
*/
count_uniform_size uniform_size(prog->UniformHash);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
- if (prog->_LinkedShaders[i] == NULL)
+ struct gl_shader *sh = prog->_LinkedShaders[i];
+
+ if (sh == NULL)
continue;
/* Uniforms that lack an initializer in the shader code have an initial
@@ -652,16 +658,15 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
* initializer, if present, or 0 if no initializer is present. Sampler
* types cannot have initializers."
*/
- memset(prog->_LinkedShaders[i]->SamplerUnits, 0,
- sizeof(prog->_LinkedShaders[i]->SamplerUnits));
+ memset(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
- link_update_uniform_buffer_variables(prog->_LinkedShaders[i]);
+ link_update_uniform_buffer_variables(sh);
/* Reset various per-shader target counts.
*/
uniform_size.start_shader();
- foreach_list(node, prog->_LinkedShaders[i]->ir) {
+ foreach_list(node, sh->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if ((var == NULL) || (var->mode != ir_var_uniform))
@@ -678,9 +683,14 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
uniform_size.process(var);
}
- prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers;
- prog->_LinkedShaders[i]->num_uniform_components =
- uniform_size.num_shader_uniform_components;
+ 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;
@@ -729,6 +739,20 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
sizeof(prog->_LinkedShaders[i]->SamplerTargets));
}
+ /* Determine the size of the largest uniform array queryable via
+ * glGetUniformLocation. Using this as the location scale guarantees that
+ * there is enough "room" for the array index to be stored in the low order
+ * part of the uniform location. It also makes the locations be more
+ * tightly packed.
+ */
+ unsigned max_array_size = 1;
+ for (unsigned i = 0; i < num_user_uniforms; i++) {
+ if (uniforms[i].array_elements > max_array_size)
+ max_array_size = uniforms[i].array_elements;
+ }
+
+ prog->UniformLocationBaseScale = max_array_size;
+
#ifndef NDEBUG
for (unsigned i = 0; i < num_user_uniforms; i++) {
assert(uniforms[i].storage != NULL);