Commit 79d059f8 by Geoff Lang

Fix uniform array handling in ProgramGL.

Our validation wouldn't correctly handle single-element arrays because it was checking size > 1 instead of isArray(). This caused issues in ProgramGL on some drivers that optimized the array size (AMD) if some elements were unused. BUG=angleproject:882 Change-Id: I417d13cd86380e2c6caa688f6398709a74692e21 Reviewed-on: https://chromium-review.googlesource.com/289201Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b5f88853
...@@ -134,12 +134,15 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog, ...@@ -134,12 +134,15 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog,
GLenum uniformType = GL_NONE; GLenum uniformType = GL_NONE;
mFunctions->getActiveUniform(mProgramID, i, uniformNameBuffer.size(), &uniformNameLength, &uniformSize, &uniformType, &uniformNameBuffer[0]); mFunctions->getActiveUniform(mProgramID, i, uniformNameBuffer.size(), &uniformNameLength, &uniformSize, &uniformType, &uniformNameBuffer[0]);
std::string uniformName = gl::ParseUniformName(std::string(&uniformNameBuffer[0], uniformNameLength), nullptr); size_t subscript = 0;
std::string uniformName = gl::ParseUniformName(std::string(&uniformNameBuffer[0], uniformNameLength), &subscript);
bool isArray = uniformSize > 1 || subscript != GL_INVALID_INDEX;
for (size_t arrayIndex = 0; arrayIndex < static_cast<size_t>(uniformSize); arrayIndex++) for (size_t arrayIndex = 0; arrayIndex < static_cast<size_t>(uniformSize); arrayIndex++)
{ {
std::string locationName = uniformName; std::string locationName = uniformName;
if (uniformSize > 1) if (isArray)
{ {
locationName += "[" + Str(arrayIndex) + "]"; locationName += "[" + Str(arrayIndex) + "]";
} }
...@@ -161,7 +164,7 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog, ...@@ -161,7 +164,7 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog,
} }
// ANGLE uses 0 to identify an non-array uniform. // ANGLE uses 0 to identify an non-array uniform.
unsigned int arraySize = (uniformSize > 1) ? static_cast<unsigned int>(uniformSize) : 0; unsigned int arraySize = isArray ? static_cast<unsigned int>(uniformSize) : 0;
// TODO: determine uniform precision // TODO: determine uniform precision
mUniforms.push_back(new gl::LinkedUniform(uniformType, GL_NONE, uniformName, arraySize, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); mUniforms.push_back(new gl::LinkedUniform(uniformType, GL_NONE, uniformName, arraySize, -1, sh::BlockMemberInfo::getDefaultBlockInfo()));
......
...@@ -1126,7 +1126,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform ...@@ -1126,7 +1126,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform
LinkedUniform *uniform = program->getUniformByLocation(location); LinkedUniform *uniform = program->getUniformByLocation(location);
// attempting to write an array to a non-array uniform is an INVALID_OPERATION // attempting to write an array to a non-array uniform is an INVALID_OPERATION
if (uniform->elementCount() == 1 && count > 1) if (!uniform->isArray() && count > 1)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
......
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