OSDN Git Service

Fix deterministic loops within conditional blocks.
[android-x86/external-swiftshader.git] / src / Shader / VertexProgram.cpp
index ad4e37b..0eb8441 100644 (file)
@@ -978,24 +978,26 @@ namespace sw
 
        Int4 VertexProgram::enableMask(const Shader::Instruction *instruction)
        {
+               if(whileTest)
+               {
+                       return Int4(0xFFFFFFFF);
+               }
+
                Int4 enable = instruction->analysisBranch ? Int4(enableStack[enableIndex]) : Int4(0xFFFFFFFF);
 
-               if(!whileTest)
+               if(shader->containsBreakInstruction() && instruction->analysisBreak)
                {
-                       if(shader->containsBreakInstruction() && instruction->analysisBreak)
-                       {
-                               enable &= enableBreak;
-                       }
+                       enable &= enableBreak;
+               }
 
-                       if(shader->containsContinueInstruction() && instruction->analysisContinue)
-                       {
-                               enable &= enableContinue;
-                       }
+               if(shader->containsContinueInstruction() && instruction->analysisContinue)
+               {
+                       enable &= enableContinue;
+               }
 
-                       if(shader->containsLeaveInstruction() && instruction->analysisLeave)
-                       {
-                               enable &= enableLeave;
-                       }
+               if(shader->containsLeaveInstruction() && instruction->analysisLeave)
+               {
+                       enable &= enableLeave;
                }
 
                return enable;
@@ -1495,6 +1497,7 @@ namespace sw
                Nucleus::setInsertBlock(loopBlock);
 
                loopRepDepth++;
+               whileTest = false;
        }
 
        void VertexProgram::SWITCH()