[Mesa-dev] r600/sb loop issue

Matt Turner mattst88 at gmail.com
Fri Dec 5 21:01:20 PST 2014


On Fri, Dec 5, 2014 at 8:56 PM, Vadim Girlin <vadimgirlin at gmail.com> wrote:
> On 12/06/2014 07:50 AM, Matt Turner wrote:
>>
>> On Fri, Dec 5, 2014 at 8:13 PM, Vadim Girlin <vadimgirlin at gmail.com>
>> wrote:
>>>
>>> I suspect we should rather get rid of such loops somehow, i.e. convert to
>>> something else, the loop that never repeats is not really a loop anyway.
>>> AFAICS "continue" is not supported in switch statements according to GLSL
>>> specs, so the loops generated for switch will never be repeated. Am I
>>> missing something? Even if repeating is possible somehow, at least we can
>>> get rid of the loops that are not repeated.
>>
>>
>> I don't think that's true. I don't see anything in the spec that would
>> lead me to believe continue cannot occur in a switch statement.
>
>
> I've double-checked some versions of GLSL spec (1.30, 1.50, 3.30, 4.40) and
> all of them say the same (section "6.4 Jumps"):
>
> "The continue jump is used only in loops."

Sure, but isn't the continue below in a loop?

do {
   switch (...) {
   case ...:
      continue;
   }
} while (...);

The grammar is pretty unambiguous.

 jump_statement:
    CONTINUE SEMICOLON
    BREAK SEMICOLON
    RETURN SEMICOLON
    RETURN expression SEMICOLON
    DISCARD SEMICOLON // Fragment shader only.

If continue can't be in a switch, neither can break. :)


More information about the mesa-dev mailing list