aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/opt_conditional_discard.cpp
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-07-26 10:04:57 +0200
committerNicolai Hähnle <[email protected]>2016-07-28 10:47:04 +0100
commit21556d86fc74d91ab58a7496a876ad33e0f950df (patch)
treed98c25d0b24644cadac29b12a5aa819cc981ae59 /src/compiler/glsl/opt_conditional_discard.cpp
parent185b0c15abfba8b011f5b009e9f1890305e40ff6 (diff)
glsl: fix optimization of discard nested multiple levels
The order of optimizations can lead to the conditional discard optimization being applied twice to the same discard statement. In this case, we must ensure that both conditions are applied. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96762 Cc: [email protected] Tested-by: Kai Wasserbäch <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/opt_conditional_discard.cpp')
-rw-r--r--src/compiler/glsl/opt_conditional_discard.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/glsl/opt_conditional_discard.cpp b/src/compiler/glsl/opt_conditional_discard.cpp
index 03665c37364..6d8a23460d9 100644
--- a/src/compiler/glsl/opt_conditional_discard.cpp
+++ b/src/compiler/glsl/opt_conditional_discard.cpp
@@ -72,7 +72,14 @@ opt_conditional_discard_visitor::visit_leave(ir_if *ir)
/* Move the condition and replace the ir_if with the ir_discard. */
ir_discard *discard = (ir_discard *) ir->then_instructions.get_head_raw();
- discard->condition = ir->condition;
+ if (!discard->condition)
+ discard->condition = ir->condition;
+ else {
+ void *ctx = ralloc_parent(ir);
+ discard->condition = new(ctx) ir_expression(ir_binop_logic_and,
+ ir->condition,
+ discard->condition);
+ }
ir->replace_with(discard);
progress = true;