Commit d1e78c9c by Jamie Madill Committed by Shannon Woods

Implement GetFragDataLocation, often used by applications with MRT shaders in GLSL ES version 300.

TRAC #22704 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Authored-by: Jamie Madill
parent 46131a38
...@@ -372,6 +372,25 @@ UniformBlock *ProgramBinary::getUniformBlockByIndex(GLuint blockIndex) ...@@ -372,6 +372,25 @@ UniformBlock *ProgramBinary::getUniformBlockByIndex(GLuint blockIndex)
return mUniformBlocks[blockIndex]; return mUniformBlocks[blockIndex];
} }
GLint ProgramBinary::getFragDataLocation(const char *name) const
{
std::string baseName(name);
unsigned int arrayIndex;
arrayIndex = parseAndStripArrayIndex(&baseName);
for (auto locationIt = mOutputVariables.begin(); locationIt != mOutputVariables.end(); locationIt++)
{
const VariableLocation &outputVariable = locationIt->second;
if (outputVariable.name == baseName && (arrayIndex == GL_INVALID_INDEX || arrayIndex == outputVariable.element))
{
return static_cast<GLint>(locationIt->first);
}
}
return -1;
}
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)
{ {
......
...@@ -132,6 +132,8 @@ class ProgramBinary : public RefCountObject ...@@ -132,6 +132,8 @@ class ProgramBinary : public RefCountObject
GLuint getActiveUniformBlockMaxLength() const; GLuint getActiveUniformBlockMaxLength() const;
UniformBlock *getUniformBlockByIndex(GLuint blockIndex); UniformBlock *getUniformBlockByIndex(GLuint blockIndex);
GLint getFragDataLocation(const char *name) const;
void validate(InfoLog &infoLog); void validate(InfoLog &infoLog);
bool validateSamplers(InfoLog *infoLog); bool validateSamplers(InfoLog *infoLog);
bool isValidated() const; bool isValidated() const;
......
...@@ -9804,10 +9804,28 @@ GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) ...@@ -9804,10 +9804,28 @@ GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
{ {
if (context->getClientVersion() < 3) if (context->getClientVersion() < 3)
{ {
return gl::error(GL_INVALID_OPERATION, 0); return gl::error(GL_INVALID_OPERATION, -1);
} }
UNIMPLEMENTED(); if (program == 0)
{
return gl::error(GL_INVALID_VALUE, -1);
}
gl::Program *programObject = context->getProgram(program);
if (!programObject || !programObject->isLinked())
{
return gl::error(GL_INVALID_OPERATION, -1);
}
gl::ProgramBinary *programBinary = programObject->getProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION, -1);
}
return programBinary->getFragDataLocation(name);
} }
} }
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