diff options
author | Kenneth Graunke <[email protected]> | 2013-07-18 14:28:05 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2013-07-18 16:57:24 -0700 |
commit | 67038c6ba27ea55d8d65557922bfe758a01101ef (patch) | |
tree | dab073827cc2313a407689c949dfcd8150ca82a3 /src | |
parent | 0a23ec2b6e3742281a0047da9246039e86e4a7b6 (diff) |
glsl: Add plumbing for handling uniform binding qualifiers.
Sampler uniforms and uniform blocks do not have a var->constant_value.
Instead, they have an integer var->binding value.
This makes extending set_uniform_initializer() somewhat problematic: it
assumes that there is an ir_constant * which represents the initializer,
and that it's safe to dereference that without any NULL checks.
Instead, this patch creates an analogous function for binding
qualifiers, and calls one or the other as appropriate.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/link_uniform_initializers.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp index f46f6e2db15..4efa1b44ae9 100644 --- a/src/glsl/link_uniform_initializers.cpp +++ b/src/glsl/link_uniform_initializers.cpp @@ -82,6 +82,21 @@ copy_constant_to_storage(union gl_constant_value *storage, } void +set_uniform_binding(void *mem_ctx, gl_shader_program *prog, + const char *name, const glsl_type *type, int binding) +{ + struct gl_uniform_storage *const storage = + get_storage(prog->UniformStorage, prog->NumUserUniformStorage, name); + + if (storage == NULL) { + assert(storage != NULL); + return; + } + + storage->initialized = true; +} + +void set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, const char *name, const glsl_type *type, ir_constant *val) @@ -173,14 +188,19 @@ link_set_uniform_initializers(struct gl_shader_program *prog) foreach_list(node, shader->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (!var || var->mode != ir_var_uniform || !var->constant_value) + if (!var || var->mode != ir_var_uniform) continue; if (!mem_ctx) mem_ctx = ralloc_context(NULL); - linker::set_uniform_initializer(mem_ctx, prog, var->name, - var->type, var->constant_value); + if (var->explicit_binding) { + linker::set_uniform_binding(mem_ctx, prog, var->name, + var->type, var->binding); + } else if (var->constant_value) { + linker::set_uniform_initializer(mem_ctx, prog, var->name, + var->type, var->constant_value); + } } } |