From a3cf531c6aff17c131cc28d2c950ed6ce4d193a1 Mon Sep 17 00:00:00 2001 From: Vadim Girlin Date: Sat, 28 Apr 2012 22:13:00 +0400 Subject: [PATCH] glsl: initialize samplers mapping with 0 According to GLSL 1.30 specification, initial value for all uniforms without initializer is 0. Some applications rely on this behaviour, e.g. google's MapGL doesn't set all sampler uniforms. (see https://bugs.freedesktop.org/show_bug.cgi?id=49088 ) Signed-off-by: Vadim Girlin --- Tested with r600g only - no regressions. src/glsl/link_uniforms.cpp | 4 +--- src/mesa/program/ir_to_mesa.cpp | 1 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 2f1c9f5..cb80caf 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -329,9 +329,7 @@ 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; - } + 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 diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 840648e..685c1b9 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2865,6 +2865,7 @@ get_mesa_program(struct gl_context *ctx, prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name); if (!prog) return NULL; + memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits)); prog->Parameters = _mesa_new_parameter_list(); v.ctx = ctx; v.prog = prog; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9e68deb..7c4275a 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4779,6 +4779,7 @@ get_mesa_program(struct gl_context *ctx, prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name); if (!prog) return NULL; + memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits)); prog->Parameters = _mesa_new_parameter_list(); v->ctx = ctx; v->prog = prog; -- 1.7.7.6