summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-06-24 14:28:51 -0400
committerRob Clark <[email protected]>2016-07-02 09:00:19 -0400
commitf78a6b1ce398a537d77c25b1a93f156109086975 (patch)
tree0d891e0156328ae8462f1e7cad56b373e7ab8607 /src/compiler/glsl/ast_to_hir.cpp
parent202710d11057dfe4416770752cf5fd5b3f766999 (diff)
glsl: add driconf to zero-init unintialized vars
Some games are sloppy.. perhaps because it is defined behavior for DX or perhaps because nv blob driver defaults things to zero. So add driconf param to force uninitialized variables to default to zero. This issue was observed with rust, from steam store. But has surfaced elsewhere in the past. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ast_to_hir.cpp')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 0cfce6893ee..8ddc084cab7 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4697,6 +4697,14 @@ ast_declarator_list::hir(exec_list *instructions,
apply_layout_qualifier_to_variable(&this->type->qualifier, var, state,
&loc);
+ if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary)
+ && (var->type->is_numeric() || var->type->is_boolean())
+ && state->zero_init) {
+ const ir_constant_data data = {0};
+ var->data.has_initializer = true;
+ var->constant_initializer = new(var) ir_constant(var->type, &data);
+ }
+
if (this->type->qualifier.flags.q.invariant) {
if (!is_varying_var(var, state->stage)) {
_mesa_glsl_error(&loc, state,