aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <[email protected]>2020-04-24 18:32:02 +0200
committerPierre-Eric Pelloux-Prayer <[email protected]>2020-05-05 12:26:02 +0200
commitea289d1502dc5739ec9bf69328c037b72dc02789 (patch)
tree6940b2864756497f0ed34b4fd3dd06c18ec4f919 /src/compiler/glsl
parent679421628bf89067b4cbfa85530f196ca2835717 (diff)
mesa: extend GLSLZeroInit semantics
This commit introduces a new way to zero-init variables but keep the old one to not break any existing behavior. With this change GLSLZeroInit becomes an integer, with the following possible values: - 0: no 0 init - 1: current behavior - 2: new behavior. Similar to 1, except ir_var_function_out type are 0 initialized but ir_var_shader_out. The rationale behind 2 is: zero initializing ir_var_shader_out can prevent some optimization where out variables are completely eliminated when not written to. On the other hand, zero initializing "ir_var_function_out" has no effect on correct shaders but typically helps shadertoy since the main function is: void mainImage(out vec4 fragColor) { ... } So with this change we're sure that fragColor will always get a value. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4607>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 5b8e5b4c48f..e610fda002c 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -84,6 +84,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->forced_language_version = ctx->Const.ForceGLSLVersion;
if (ctx->Const.GLSLZeroInit == 1) {
this->zero_init = (1u << ir_var_auto) | (1u << ir_var_temporary) | (1u << ir_var_shader_out);
+ } else if (ctx->Const.GLSLZeroInit == 2) {
+ this->zero_init = (1u << ir_var_auto) | (1u << ir_var_temporary) | (1u << ir_var_function_out);
} else {
this->zero_init = 0;
}