diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2020-04-24 12:17:14 +0200 |
---|---|---|
committer | Pierre-Eric Pelloux-Prayer <[email protected]> | 2020-05-05 12:26:02 +0200 |
commit | 84f58a08634d0ea07f557ffa5b91c9c8777a2b04 (patch) | |
tree | 1cc0b9a120418fd9623f645a3251488a75aec432 /src | |
parent | 547e81655a0b9f6d7742e25f2e353e22c3a3b393 (diff) |
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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4607>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/ast_to_hir.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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) |