diff options
author | Ian Romanick <[email protected]> | 2013-01-22 01:09:16 -0500 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2013-01-25 09:07:36 -0500 |
commit | 514f8c7ec7cc1ab18be93cebb5b9bf970b1955a9 (patch) | |
tree | 7dd462bc3360ff2fced2186fc65550ccb6603fda /src/glsl/link_uniforms.cpp | |
parent | 0ab7399822b480f6e07cc566a2e50fabedc8258d (diff) |
glsl: Calculate UBO data at link-time
Use the function added in the previous commit.
This temporarily causes gles3conform
uniform_buffer_object_index_of_not_active_block,
uniform_buffer_object_inherit_and_override_layouts, and
uniform_buffer_object_repeat_global_scope_layouts to assertion fail.
This is fixed in the next commit.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 68cafbf3946..3e24842a026 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -539,10 +539,41 @@ link_update_uniform_buffer_variables(struct gl_shader *shader) assert(var->mode == ir_var_uniform); + if (var->is_interface_instance()) { + var->location = 0; + continue; + } + bool found = false; + char sentinel = '\0'; + + if (var->type->is_record()) { + sentinel = '.'; + } else if (var->type->is_array() + && var->type->fields.array->is_record()) { + sentinel = '['; + } + + const unsigned l = strlen(var->name); for (unsigned i = 0; i < shader->NumUniformBlocks; i++) { for (unsigned j = 0; j < shader->UniformBlocks[i].NumUniforms; j++) { - if (!strcmp(var->name, shader->UniformBlocks[i].Uniforms[j].Name)) { + if (sentinel) { + const char *begin = shader->UniformBlocks[i].Uniforms[j].Name; + const char *end = strchr(begin, sentinel); + + if (end == NULL) + continue; + + if (l != (end - begin)) + continue; + + if (strncmp(var->name, begin, l) == 0) { + found = true; + var->location = j; + break; + } + } else if (!strcmp(var->name, + shader->UniformBlocks[i].Uniforms[j].Name)) { found = true; var->uniform_block = i; var->location = j; @@ -614,13 +645,6 @@ link_assign_uniform_locations(struct gl_shader_program *prog) */ memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits)); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - link_update_uniform_buffer_variables(prog->_LinkedShaders[i]); - } - /* First pass: Count the uniform resources used by the user-defined * uniforms. While this happens, each active uniform will have an index * assigned to it. @@ -633,6 +657,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; + link_update_uniform_buffer_variables(prog->_LinkedShaders[i]); + /* Reset various per-shader target counts. */ uniform_size.start_shader(); |