Implement the API-side logic GetUniformBlockIndex. Functionality depends on shader support.

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@2307 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent d7784174
...@@ -296,6 +296,27 @@ GLuint ProgramBinary::getUniformIndex(std::string name) ...@@ -296,6 +296,27 @@ GLuint ProgramBinary::getUniformIndex(std::string name)
return GL_INVALID_INDEX; return GL_INVALID_INDEX;
} }
GLuint ProgramBinary::getUniformBlockIndex(std::string name)
{
unsigned int subscript = parseAndStripArrayIndex(&name);
unsigned int numUniformBlocks = mUniformBlocks.size();
for (unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
{
const UniformBlock &uniformBlock = *mUniformBlocks[blockIndex];
if (uniformBlock.name == name)
{
const bool arrayElementZero = (subscript == GL_INVALID_INDEX && uniformBlock.elementIndex == 0);
if (subscript == uniformBlock.elementIndex || arrayElementZero)
{
return blockIndex;
}
}
}
return GL_INVALID_INDEX;
}
template <typename T> template <typename T>
bool ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType) bool ProgramBinary::setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType)
{ {
......
...@@ -78,6 +78,7 @@ class ProgramBinary : public RefCountObject ...@@ -78,6 +78,7 @@ class ProgramBinary : public RefCountObject
GLint getUniformLocation(std::string name); GLint getUniformLocation(std::string name);
GLuint getUniformIndex(std::string name); GLuint getUniformIndex(std::string name);
GLuint getUniformBlockIndex(std::string name);
bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
......
...@@ -9684,11 +9684,31 @@ GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlo ...@@ -9684,11 +9684,31 @@ GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlo
{ {
if (context->getClientVersion() < 3) if (context->getClientVersion() < 3)
{ {
return gl::error(GL_INVALID_OPERATION, 0); return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
} }
}
UNIMPLEMENTED(); gl::Program *programObject = context->getProgram(program);
if (!programObject)
{
if (context->getShader(program))
{
return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
}
else
{
return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
}
}
gl::ProgramBinary *programBinary = programObject->getProgramBinary();
if (!programBinary)
{
return GL_INVALID_INDEX;
}
return programBinary->getUniformBlockIndex(uniformBlockName);
}
} }
catch(std::bad_alloc&) 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