summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-07-27 15:20:44 +1000
committerTimothy Arceri <[email protected]>2016-08-11 08:33:30 +1000
commit549222f5f8ef4616f5e6ddeb5c29ea6446684e5e (patch)
tree943867460a46d24bfdf9ca32c54f7e13a74b585f
parent82e153daff954a9bf09c8fb7e1adfeedb17a1fc3 (diff)
glsl: use UniformHash to find storage location
There is no need to be looping over all the uniforms. Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/compiler/glsl/link_uniform_initializers.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
index 17660a75741..3750021033f 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -22,6 +22,7 @@
*/
#include "main/core.h"
+#include "program/hash_table.h"
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
@@ -33,14 +34,13 @@
namespace linker {
gl_uniform_storage *
-get_storage(gl_uniform_storage *storage, unsigned num_storage,
- const char *name)
+get_storage(struct gl_shader_program *prog, const char *name)
{
- for (unsigned int i = 0; i < num_storage; i++) {
- if (strcmp(name, storage[i].name) == 0)
- return &storage[i];
- }
+ unsigned id;
+ if (prog->UniformHash->get(id, name))
+ return &prog->UniformStorage[id];
+ assert(!"No uniform storage found!");
return NULL;
}
@@ -108,13 +108,10 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
element_name, binding);
}
} else {
- struct gl_uniform_storage *const storage =
- get_storage(prog->UniformStorage, prog->NumUniformStorage, name);
+ struct gl_uniform_storage *const storage = get_storage(prog, name);
- if (storage == NULL) {
- assert(storage != NULL);
+ if (!storage)
return;
- }
const unsigned elements = MAX2(storage->array_elements, 1);
@@ -207,14 +204,10 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
return;
}
- struct gl_uniform_storage *const storage =
- get_storage(prog->UniformStorage,
- prog->NumUniformStorage,
- name);
- if (storage == NULL) {
- assert(storage != NULL);
+ struct gl_uniform_storage *const storage = get_storage(prog, name);
+
+ if (!storage)
return;
- }
if (val->type->is_array()) {
const enum glsl_base_type base_type =