[Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements
Kenneth Graunke
kenneth at whitecape.org
Mon Jun 27 16:40:04 PDT 2011
Here's another case that I'm not sure you're handling
correctly...conditional breaks:
switch (expr) {
case c0:
case c1:
stmt0;
case c2:
case c3:
stmt1;
break;
case c4:
stmt2;
if (foo)
break;
stmt3; // happens if !foo
case c5:
default:
stmt4; // happens if (expr != c4 || foo)
};
The easiest solution I can think of is to (in C++) track whether a break
-might- have been taken and emit a guard around further statements:
stmt2;
if (foo)
has_break_tmp = true; // hit the break statement
if (has_break_tmp) { // could have potentially hit "break", must check
stmt3;
}
More information about the mesa-dev
mailing list