Refactor Uniform::[vp]sRegisterIndex to unsigned integers.

TRAC #22858

Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Jamie Madill

git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2305 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 04918b3..fd5daa9 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -3100,7 +3100,7 @@
 
     if (!structure)
     {
-        mActiveUniforms.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), type.getArraySize(), index));
+        mActiveUniforms.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), (unsigned int)index));
     }
     else
     {
diff --git a/src/compiler/Uniform.cpp b/src/compiler/Uniform.cpp
index f367db2..6337d05 100644
--- a/src/compiler/Uniform.cpp
+++ b/src/compiler/Uniform.cpp
@@ -9,7 +9,7 @@
 namespace sh
 {
 
-Uniform::Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex)
+Uniform::Uniform(GLenum type, GLenum precision, const char *name, unsigned int arraySize, unsigned int registerIndex)
 {
     this->type = type;
     this->precision = precision;
diff --git a/src/compiler/Uniform.h b/src/compiler/Uniform.h
index ab32d03..c4f56a6 100644
--- a/src/compiler/Uniform.h
+++ b/src/compiler/Uniform.h
@@ -19,14 +19,14 @@
 
 struct Uniform
 {
-    Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex);
+    Uniform(GLenum type, GLenum precision, const char *name, unsigned int arraySize, unsigned int registerIndex);
 
     GLenum type;
     GLenum precision;
     std::string name;
     unsigned int arraySize;
 
-    int registerIndex;
+    unsigned int registerIndex;
 };
 
 typedef std::vector<Uniform> ActiveUniforms;
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index eeea9c4..90d4fab 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -742,7 +742,7 @@
                 int count = targetUniform->elementCount();
                 GLint (*v)[4] = (GLint(*)[4])targetUniform->data;
 
-                if (targetUniform->psRegisterIndex >= 0)
+                if (targetUniform->isReferencedByFragmentShader())
                 {
                     unsigned int firstIndex = targetUniform->psRegisterIndex;
 
@@ -758,7 +758,7 @@
                     }
                 }
 
-                if (targetUniform->vsRegisterIndex >= 0)
+                if (targetUniform->isReferencedByVertexShader())
                 {
                     unsigned int firstIndex = targetUniform->vsRegisterIndex;
 
diff --git a/src/libGLESv2/Uniform.cpp b/src/libGLESv2/Uniform.cpp
index 5424e27..ed8d490 100644
--- a/src/libGLESv2/Uniform.cpp
+++ b/src/libGLESv2/Uniform.cpp
@@ -20,8 +20,8 @@
     memset(data, 0, bytes);
     dirty = true;
 
-    psRegisterIndex = -1;
-    vsRegisterIndex = -1;
+    psRegisterIndex = GL_INVALID_INDEX;
+    vsRegisterIndex = GL_INVALID_INDEX;
     registerCount = VariableRowCount(type) * elementCount();
 }
 
@@ -40,4 +40,14 @@
     return arraySize > 0 ? arraySize : 1;
 }
 
+bool Uniform::isReferencedByVertexShader() const
+{
+    return vsRegisterIndex != GL_INVALID_INDEX;
+}
+
+bool Uniform::isReferencedByFragmentShader() const
+{
+    return psRegisterIndex != GL_INVALID_INDEX;
+}
+
 }
diff --git a/src/libGLESv2/Uniform.h b/src/libGLESv2/Uniform.h
index 252a1d2..12e8e03 100644
--- a/src/libGLESv2/Uniform.h
+++ b/src/libGLESv2/Uniform.h
@@ -28,6 +28,8 @@
 
     bool isArray() const;
     unsigned int elementCount() const;
+    bool isReferencedByVertexShader() const;
+    bool isReferencedByFragmentShader() const;
 
     const GLenum type;
     const GLenum precision;
@@ -37,8 +39,8 @@
     unsigned char *data;
     bool dirty;
 
-    int psRegisterIndex;
-    int vsRegisterIndex;
+    unsigned int psRegisterIndex;
+    unsigned int vsRegisterIndex;
     unsigned int registerCount;
 };
 
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index ab517b6..26174eb 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -1364,13 +1364,13 @@
     {
         const gl::Uniform *uniform = *uniform_iterator;
 
-        if (uniform->vsRegisterIndex >= 0)
+        if (uniform->isReferencedByVertexShader())
         {
             totalRegisterCountVS += uniform->registerCount;
             vertexUniformsDirty = vertexUniformsDirty || uniform->dirty;
         }
 
-        if (uniform->psRegisterIndex >= 0)
+        if (uniform->isReferencedByFragmentShader())
         {
             totalRegisterCountPS += uniform->registerCount;
             pixelUniformsDirty = pixelUniformsDirty || uniform->dirty;
@@ -1405,12 +1405,12 @@
 
         if (uniform->type !=  GL_SAMPLER_2D && uniform->type != GL_SAMPLER_CUBE)
         {
-            if (uniform->vsRegisterIndex >= 0 && mapVS)
+            if (uniform->isReferencedByVertexShader() && mapVS)
             {
                 memcpy(mapVS + uniform->vsRegisterIndex, uniform->data, uniform->registerCount * sizeof(float[4]));
             }
 
-            if (uniform->psRegisterIndex >= 0 && mapPS)
+            if (uniform->isReferencedByFragmentShader() && mapPS)
             {
                 memcpy(mapPS + uniform->psRegisterIndex, uniform->data, uniform->registerCount * sizeof(float[4]));
             }
diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp
index 6df49c6..a61affb 100644
--- a/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/libGLESv2/renderer/Renderer9.cpp
@@ -1727,12 +1727,12 @@
 
 void Renderer9::applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v)
 {
-    if (targetUniform->psRegisterIndex >= 0)
+    if (targetUniform->isReferencedByFragmentShader())
     {
         mDevice->SetPixelShaderConstantF(targetUniform->psRegisterIndex, v, targetUniform->registerCount);
     }
 
-    if (targetUniform->vsRegisterIndex >= 0)
+    if (targetUniform->isReferencedByVertexShader())
     {
         mDevice->SetVertexShaderConstantF(targetUniform->vsRegisterIndex, v, targetUniform->registerCount);
     }