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
parent 7e0904d3
......@@ -3100,7 +3100,7 @@ void OutputHLSL::declareUniform(const TType &type, const TString &name, int inde
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
{
......
......@@ -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;
......
......@@ -19,14 +19,14 @@ namespace sh
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;
......
......@@ -742,7 +742,7 @@ void ProgramBinary::applyUniforms()
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 @@ void ProgramBinary::applyUniforms()
}
}
if (targetUniform->vsRegisterIndex >= 0)
if (targetUniform->isReferencedByVertexShader())
{
unsigned int firstIndex = targetUniform->vsRegisterIndex;
......
......@@ -20,8 +20,8 @@ Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigne
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 @@ unsigned int Uniform::elementCount() const
return arraySize > 0 ? arraySize : 1;
}
bool Uniform::isReferencedByVertexShader() const
{
return vsRegisterIndex != GL_INVALID_INDEX;
}
bool Uniform::isReferencedByFragmentShader() const
{
return psRegisterIndex != GL_INVALID_INDEX;
}
}
......@@ -28,6 +28,8 @@ struct Uniform
bool isArray() const;
unsigned int elementCount() const;
bool isReferencedByVertexShader() const;
bool isReferencedByFragmentShader() const;
const GLenum type;
const GLenum precision;
......@@ -37,8 +39,8 @@ struct Uniform
unsigned char *data;
bool dirty;
int psRegisterIndex;
int vsRegisterIndex;
unsigned int psRegisterIndex;
unsigned int vsRegisterIndex;
unsigned int registerCount;
};
......
......@@ -1364,13 +1364,13 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
{
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 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
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]));
}
......
......@@ -1727,12 +1727,12 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
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);
}
......
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