summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-09 23:50:07 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:42 +1100
commit5ceedefd6c32fa31e6a35831a8a7a315e009ccc3 (patch)
tree55ebe3c9667c7a2d210c28035f49c00b947aa1dd /src/mesa
parent238486884e74888d32d64ea9d934ba6b07e79eb2 (diff)
mesa/glsl: remove hack to reset sampler units to zero
Now that we have the is_arb_asm flag we can just skip the initialisation. V2: remove hack from standalone compiler where it was never needed since it only compiles glsl shaders. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/program/program.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 3edeec81730..0e499c655fe 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -181,8 +181,6 @@ struct gl_program *
_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
bool is_arb_asm)
{
- GLuint i;
-
if (!prog)
return NULL;
@@ -195,9 +193,22 @@ _mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
prog->info.stage = _mesa_program_enum_to_shader_stage(target);
prog->is_arb_asm = is_arb_asm;
- /* default mapping from samplers to texture units */
- for (i = 0; i < MAX_SAMPLERS; i++)
- prog->SamplerUnits[i] = i;
+ /* Uniforms that lack an initializer in the shader code have an initial
+ * value of zero. This includes sampler uniforms.
+ *
+ * Page 24 (page 30 of the PDF) of the GLSL 1.20 spec says:
+ *
+ * "The link time initial value is either the value of the variable's
+ * initializer, if present, or 0 if no initializer is present. Sampler
+ * types cannot have initializers."
+ *
+ * So we only initialise ARB assembly style programs.
+ */
+ if (is_arb_asm) {
+ /* default mapping from samplers to texture units */
+ for (unsigned i = 0; i < MAX_SAMPLERS; i++)
+ prog->SamplerUnits[i] = i;
+ }
return prog;
}