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/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);
}