OSDN Git Service

Fix evaluating empty loop condition to true.
authorNicolas Capens <capn@google.com>
Thu, 25 Feb 2016 14:45:24 +0000 (09:45 -0500)
committerNicolas Capens <capn@google.com>
Thu, 25 Feb 2016 16:45:59 +0000 (16:45 +0000)
Bug 27351438

Change-Id: If15f0f91931f34af6e78ad773036b91ff5d57d01
Reviewed-on: https://swiftshader-review.googlesource.com/4902
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/compiler/OutputASM.cpp

index dbc3919..a632bde 100644 (file)
@@ -1676,11 +1676,11 @@ namespace glsl
                TIntermTyped *condition = node->getCondition();\r
                TIntermTyped *expression = node->getExpression();\r
                TIntermNode *body = node->getBody();\r
+               Constant True(true);\r
 \r
                if(node->getType() == ELoopDoWhile)\r
                {\r
                        Temporary iterate(this);\r
-                       Constant True(true);\r
                        emit(sw::Shader::OPCODE_MOV, &iterate, &True);\r
 \r
                        emit(sw::Shader::OPCODE_WHILE, 0, &iterate);   // FIXME: Implement real do-while\r
@@ -1727,6 +1727,10 @@ namespace glsl
                                {\r
                                        condition->traverse(this);\r
                                }\r
+                               else\r
+                               {\r
+                                       condition = &True;\r
+                               }\r
 \r
                                emit(sw::Shader::OPCODE_WHILE, 0, condition);\r
 \r