Mesa (7.11): glsl: Fix depth unbalancing problem in if-statement flattening
Ian Romanick
idr at kemper.freedesktop.org
Sat Jul 9 01:53:37 UTC 2011
Module: Mesa
Branch: 7.11
Commit: 530c68d616dd2fb9fc5252f41877d5587fbaff17
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=530c68d616dd2fb9fc5252f41877d5587fbaff17
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Thu Jun 2 12:42:48 2011 -0700
glsl: Fix depth unbalancing problem in if-statement flattening
Previously, if max_depth were 1, the following code would see the
first if-statement (correctly) not get flattened, but the second
if-statement would (incorrectly) get flattened:
void main()
{
if (a)
gl_Position = vec4(0);
if (b)
gl_Position = vec4(1);
}
This is because the visit_leave(ir_if*) method would not decrement the
depth before returning on the first if-statement.
NOTE: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit d2c6cef18aa37d197eb323a0795969d271d02819)
---
src/glsl/lower_if_to_cond_assign.cpp | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/glsl/lower_if_to_cond_assign.cpp b/src/glsl/lower_if_to_cond_assign.cpp
index e3a1065..b637eb4 100644
--- a/src/glsl/lower_if_to_cond_assign.cpp
+++ b/src/glsl/lower_if_to_cond_assign.cpp
@@ -149,11 +149,9 @@ ir_visitor_status
ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
{
/* Only flatten when beyond the GPU's maximum supported nesting depth. */
- if (this->depth <= this->max_depth)
+ if (this->depth-- <= this->max_depth)
return visit_continue;
- this->depth--;
-
bool found_control_flow = false;
ir_variable *cond_var;
ir_assignment *assign;
More information about the mesa-commit
mailing list