Commit 930b700a by Nicolas Capens

Fix determining the loop iteration count.

Bug b/34128224 Change-Id: I4aebcda840baa8ceef2ae99c98a80a83e32b89b3 Reviewed-on: https://swiftshader-review.googlesource.com/8376Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent f53adbde
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#include <stdlib.h>
namespace glsl namespace glsl
{ {
// Integer to TString conversion // Integer to TString conversion
...@@ -3599,11 +3601,16 @@ namespace glsl ...@@ -3599,11 +3601,16 @@ namespace glsl
if(comparator == EOpLessThan) if(comparator == EOpLessThan)
{ {
int iterations = (limit - initial) / increment; if(!(initial < limit)) // Never loops
{
return 0;
}
int iterations = (limit - initial + abs(increment) - 1) / increment; // Ceiling division
if(iterations <= 0) if(iterations < 0)
{ {
iterations = 0; return ~0u;
} }
return iterations; return iterations;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment