shairai / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Implement support for switch statements in the ESSL3 compiler #921

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
ESSL3 shader compiler needs to support switch statements. They have an exact 
equivalent in HLSL.

Changes are needed in the parser, IntermNode tree and output classes.

Original issue reported on code.google.com by oetu...@nvidia.com on 17 Feb 2015 at 2:15

GoogleCodeExporter commented 9 years ago
Parsing code is almost complete. When starting to test output code, I ran into 
a major problem: switch fall-through is not supported in HLSL. Empty case 
statements are fine, but fall-through from cases that have code is not allowed. 
[forcecase] doesn't have an effect on this.

The most straightforward way of working around this is to copy code from below 
case statements to case statements that have some code and fall through. The 
compiler could generate an info message when it has to do this.

It might also be possible to sometimes replace switch/case with if statements, 
but that has nasty edge cases (conditional break inside a case for example).

Original comment by oetu...@nvidia.com on 26 Feb 2015 at 3:50

GoogleCodeExporter commented 9 years ago
The HLSL limitation was worked around by copying code to under non-empty labels 
that have fall-through.

An info message could still be added to communicate to the user when the 
compiler has to do this.

Original comment by oetu...@nvidia.com on 4 Mar 2015 at 1:58