Refactor ProgramBinary::setUniform[XX] to use a generic template function,…

Refactor ProgramBinary::setUniform[XX] to use a generic template function, reducing duplicated code. TRAC #22842 Signed-off-by: Geoff Lang Signed-off-by: Shanon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2141 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8431b9c8
......@@ -142,6 +142,9 @@ class ProgramBinary : public RefCountObject
std::string generateGeometryShaderHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
std::string generatePointSpriteHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
template <typename T>
bool setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
template <int cols, int rows>
bool setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType);
......
......@@ -102,6 +102,29 @@ size_t UniformExternalSize(GLenum type)
return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
}
GLenum UniformBoolVectorType(GLenum type)
{
switch (type)
{
case GL_FLOAT:
case GL_INT:
return GL_BOOL;
case GL_FLOAT_VEC2:
case GL_INT_VEC2:
return GL_BOOL_VEC2;
case GL_FLOAT_VEC3:
case GL_INT_VEC3:
return GL_BOOL_VEC3;
case GL_FLOAT_VEC4:
case GL_INT_VEC4:
return GL_BOOL_VEC4;
default:
UNREACHABLE();
return GL_NONE;
}
}
int VariableRowCount(GLenum type)
{
switch (type)
......
......@@ -26,6 +26,7 @@ int UniformComponentCount(GLenum type);
GLenum UniformComponentType(GLenum type);
size_t UniformInternalSize(GLenum type);
size_t UniformExternalSize(GLenum type);
GLenum UniformBoolVectorType(GLenum type);
int VariableRowCount(GLenum type);
int VariableColumnCount(GLenum type);
......
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