Implement glGetActiveUniformsiv, querying specific uniform properties.

TRAC #22865 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2294 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c2ed991c
......@@ -2223,6 +2223,34 @@ GLint ProgramBinary::getActiveUniformMaxLength() const
return maxLength;
}
GLint ProgramBinary::getActiveUniformi(GLuint index, GLenum pname) const
{
const gl::Uniform& uniform = *mUniforms[index];
switch (pname)
{
case GL_UNIFORM_TYPE: return static_cast<GLint>(uniform.type);
case GL_UNIFORM_SIZE: return static_cast<GLint>(uniform.elementCount());
case GL_UNIFORM_NAME_LENGTH: return static_cast<GLint>(uniform.name.size() + 1);
case GL_UNIFORM_BLOCK_INDEX:
case GL_UNIFORM_OFFSET:
case GL_UNIFORM_ARRAY_STRIDE:
case GL_UNIFORM_MATRIX_STRIDE:
// the default block gives a value of -1 for these parameters
return -1;
case GL_UNIFORM_IS_ROW_MAJOR:
// TODO: column/row major layout for uniform blocks
return 0;
default:
UNREACHABLE();
break;
}
return 0;
}
void ProgramBinary::validate(InfoLog &infoLog)
{
applyUniforms();
......
......@@ -121,6 +121,7 @@ class ProgramBinary : public RefCountObject
void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
GLint getActiveUniformCount() const;
GLint getActiveUniformMaxLength() const;
GLint getActiveUniformi(GLuint index, GLenum pname) const;
void validate(InfoLog &infoLog);
bool validateSamplers(InfoLog *infoLog);
......
......@@ -9590,9 +9590,64 @@ void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const
{
return gl::error(GL_INVALID_OPERATION);
}
}
UNIMPLEMENTED();
if (uniformCount < 0)
{
return gl::error(GL_INVALID_VALUE);
}
gl::Program *programObject = context->getProgram(program);
if (!programObject)
{
if (context->getShader(program))
{
return gl::error(GL_INVALID_OPERATION);
}
else
{
return gl::error(GL_INVALID_VALUE);
}
}
switch (pname)
{
case GL_UNIFORM_TYPE:
case GL_UNIFORM_SIZE:
case GL_UNIFORM_NAME_LENGTH:
case GL_UNIFORM_BLOCK_INDEX:
case GL_UNIFORM_OFFSET:
case GL_UNIFORM_ARRAY_STRIDE:
case GL_UNIFORM_MATRIX_STRIDE:
case GL_UNIFORM_IS_ROW_MAJOR:
break;
default:
return gl::error(GL_INVALID_ENUM);
}
gl::ProgramBinary *programBinary = programObject->getProgramBinary();
if (!programBinary && uniformCount > 0)
{
return gl::error(GL_INVALID_VALUE);
}
for (int uniformId = 0; uniformId < uniformCount; uniformId++)
{
const GLuint index = uniformIndices[uniformId];
if (index >= (GLuint)programBinary->getActiveUniformCount())
{
return gl::error(GL_INVALID_VALUE);
}
}
for (int uniformId = 0; uniformId < uniformCount; uniformId++)
{
const GLuint index = uniformIndices[uniformId];
params[uniformId] = programBinary->getActiveUniformi(index, pname);
}
}
}
catch(std::bad_alloc&)
{
......
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