summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-07-26 10:04:57 +0200
committerEmil Velikov <[email protected]>2016-07-28 17:05:28 +0100
commit178b889823d1df50bd7000e16dcf814febc31424 (patch)
tree48f48abfbc6bf93d154de85350c87516c14013ec /src/compiler
parent7208d82dfb2a1709c7a5487f21778aa17685d129 (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]> (cherry picked from commit 21556d86fc74d91ab58a7496a876ad33e0f950df) [Emil Velikov: s/get_head_raw()/head/] Signed-off-by: Emil Velikov <[email protected]> Conflicts: src/compiler/glsl/opt_conditional_discard.cpp
Diffstat (limited to 'src/compiler')
-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 1ca8803f643..a27bead78f6 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.head;
- 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;