Bug 1218559. Implement FindUniformBlockByMappedName. r=jgilbert

This commit is contained in:
Jeff Muizelaar 2015-11-03 11:02:29 -05:00
parent d1242d2bc6
commit 800b8139e0
3 changed files with 29 additions and 2 deletions

View File

@ -357,8 +357,16 @@ WebGLShader::FindUniformBlockByMappedName(const nsACString& mappedName,
nsCString* const out_userName,
bool* const out_isArray) const
{
// TODO: Extract block information from shader validator.
return false;
if (!mValidator)
return false;
const std::string mappedNameStr(mappedName.BeginReading(), mappedName.Length());
std::string userNameStr;
if (!mValidator->FindUniformBlockByMappedName(mappedNameStr, &userNameStr))
return false;
*out_userName = userNameStr.c_str();
return true;
}
void

View File

@ -392,6 +392,22 @@ ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
return true;
}
return false;
}
bool
ShaderValidator::FindUniformBlockByMappedName(const std::string& mappedName,
std::string* const out_userName) const
{
const std::vector<sh::InterfaceBlock>& interfaces = *ShGetInterfaceBlocks(mHandle);
for (const auto& interface : interfaces) {
if (mappedName == interface.mappedName) {
*out_userName = interface.name;
return true;
}
}
return false;
}

View File

@ -56,6 +56,9 @@ public:
bool FindUniformByMappedName(const std::string& mappedName,
std::string* const out_userName,
bool* const out_isArray) const;
bool FindUniformBlockByMappedName(const std::string& mappedName,
std::string* const out_userName) const;
};
} // namespace webgl