There is existing code to handle sampler uniform initializers. Prior to
GLSL 4.20's "binding" keyword, sampler uniforms don't have initializers
at all, so this is somewhat surprising.
The existing code is broken into two cases: one where both the variable and
initializer are arrays, and a second where the variable and initializer are
scalars.
The first case should never occur, since array-typed initializers do not
exist for sampler uniforms. Even with the binding keyword, the
initializer is a single integer which represents the texture unit to use
for the first array element.
The second is apparently used for some fixed-function code.
v2: Rewrite the commit message - suggested by Paul.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
idx += elements;
}
-
- if (base_type == GLSL_TYPE_SAMPLER) {
- for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) {
- gl_shader *shader = prog->_LinkedShaders[sh];
-
- if (shader && storage->sampler[sh].active) {
- for (unsigned i = 0; i < storage->array_elements; i++) {
- unsigned index = storage->sampler[sh].index + i;
-
- shader->SamplerUnits[index] = storage->storage[i].i;
- }
- }
- }
- }
} else {
copy_constant_to_storage(storage->storage,
val,