[Mesa-dev] [PATCH 51/70] mesa/glsl: remove hack to reset sampler units to zero
Timothy Arceri
timothy.arceri at collabora.com
Fri Nov 11 00:46:33 UTC 2016
Now that we have the is_arb_asm flag we can just skip the
initialisation.
---
src/compiler/glsl/link_uniforms.cpp | 11 -----------
src/mesa/program/program.c | 21 ++++++++++++++++-----
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 38b4cb4..3f8d81f 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1305,17 +1305,6 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
if (sh == NULL)
continue;
- /* 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(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
-
link_update_uniform_buffer_variables(sh, i);
/* Reset various per-shader target counts.
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index fc6dea1..d54f7f8 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;
@@ -194,9 +192,22 @@ _mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
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;
}
--
2.7.4
More information about the mesa-dev
mailing list