summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-02-23 23:12:39 -0800
committerKenneth Graunke <[email protected]>2015-02-24 15:24:52 -0800
commitd77b186871389be10a68546da0e3ada8134ae539 (patch)
tree84877adfb0fc85564cff1b1074472dad39582ed2 /src
parent44b45da994c5d827eb123fb18b501d712822baae (diff)
glsl: Handle conditional discards in lower_discard_flow().
This pass wasn't prepared to handle conditional discards. Instead of initializing the "discarded" temporary to "true", set it to the condition. Then, refer to the variable for the condition, to avoid duplicating the expression tree. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/lower_discard_flow.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/glsl/lower_discard_flow.cpp b/src/glsl/lower_discard_flow.cpp
index 1bc56d79e98..ee45bf22155 100644
--- a/src/glsl/lower_discard_flow.cpp
+++ b/src/glsl/lower_discard_flow.cpp
@@ -90,7 +90,14 @@ ir_visitor_status
lower_discard_flow_visitor::visit_enter(ir_discard *ir)
{
ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(discarded);
- ir_rvalue *rhs = new(mem_ctx) ir_constant(true);
+ ir_rvalue *rhs;
+ if (ir->condition) {
+ /* discarded <- condition, use (var_ref discarded) as the condition */
+ rhs = ir->condition;
+ ir->condition = new(mem_ctx) ir_dereference_variable(discarded);
+ } else {
+ rhs = new(mem_ctx) ir_constant(true);
+ }
ir_assignment *assign = new(mem_ctx) ir_assignment(lhs, rhs);
ir->insert_before(assign);