Bug 1244611 - "Using named uniform buffer objects in the fragment shader fails". r=jgilbert

This commit is contained in:
Brad Kotsopoulos 2016-03-23 08:18:00 +01:00
parent c4c70b48cb
commit 8fb57a831d

View File

@ -474,14 +474,44 @@ ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
return true;
}
const size_t dotPos = mappedName.find(".");
const std::vector<sh::InterfaceBlock>& interfaces = *ShGetInterfaceBlocks(mHandle);
for (const auto& interface : interfaces) {
std::string mappedFieldName;
const bool hasInstanceName = !interface.instanceName.empty();
// If the InterfaceBlock has an instanceName, all variables defined
// within the block are qualified with the block name, as opposed
// to being placed in the global scope.
if (hasInstanceName) {
// If mappedName has no block name prefix, skip
if (std::string::npos == dotPos)
continue;
// If mappedName has a block name prefix that doesn't match, skip
const std::string mappedInterfaceBlockName = mappedName.substr(0, dotPos);
if (interface.mappedName != mappedInterfaceBlockName)
continue;
mappedFieldName = mappedName.substr(dotPos + 1);
} else {
mappedFieldName = mappedName;
}
for (const auto& field : interface.fields) {
const sh::ShaderVariable* found;
if (!field.findInfoByMappedName(mappedName, &found, out_userName))
if (!field.findInfoByMappedName(mappedFieldName, &found, out_userName))
continue;
if (hasInstanceName) {
// Prepend the user name of the interface that matched
*out_userName = interface.name + "." + *out_userName;
}
*out_isArray = found->isArray();
return true;
}