aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-04-10 10:40:11 -0700
committerIan Romanick <[email protected]>2012-05-23 11:42:07 -0700
commitb610881317a7775a7ffe5f032099d8b2dc45eff0 (patch)
tree76bcf256e9998f96236488b940a642ddb35cab6f /src/glsl
parenta2e623054b5d8eafebc7499efe93e4bceae16ead (diff)
glsl: Initialize samplers to 0, propagate sampler values to the gl_program
The spec requires that samplers be initialized to 0. Since this differs from the 1-to-1 mapping of samplers to texture units assumed by ARB assembly shaders (and the gl_program structure), be sure to propagate this date from the gl_shader_program to the gl_program. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> CC: Vadim Girlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49088
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/link_uniforms.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 81a995e92bd..92e2a1fa548 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -329,9 +329,16 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
prog->UniformHash = new string_to_uint_map;
}
- for (unsigned i = 0; i < Elements(prog->SamplerUnits); 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."
+ */
+ memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits));
/* First pass: Count the uniform resources used by the user-defined
* uniforms. While this happens, each active uniform will have an index