From: Pierre-Eric Pelloux-Prayer Date: Fri, 24 Apr 2020 10:17:14 +0000 (+0200) Subject: glsl: init gl_FragColor if zero_init=true X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84f58a08634d0ea07f557ffa5b91c9c8777a2b04;p=mesa.git glsl: init gl_FragColor if zero_init=true This fixes shaders doing "gl_FragColor += ..." and doesn't hurt correct shaders, because the zero init is discarded. Reviewed-by: Marek Olšák Part-of: --- diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 630d807e114..9cd3af83a48 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -8797,8 +8797,14 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, if (!var || !var->data.assigned) continue; - if (strcmp(var->name, "gl_FragColor") == 0) + if (strcmp(var->name, "gl_FragColor") == 0) { gl_FragColor_assigned = true; + if (!var->constant_initializer && state->zero_init) { + const ir_constant_data data = { { 0 } }; + var->data.has_initializer = true; + var->constant_initializer = new(var) ir_constant(var->type, &data); + } + } else if (strcmp(var->name, "gl_FragData") == 0) gl_FragData_assigned = true; else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0)