Fix the incorrect calculation for MAX_NAME_LENGTH
The old implementation forgot to consider the instance array situation.
This change will use unified method to calculate the interface block's
MAX_NAME_LENGTH. It also removes some cases which have already passed
from expectation files.
BUG=angleproject:1920
TEST=angle_end2end_tests
*program_interface_query.uniform_block.resource_list.block_array*
*program_interface_query.shader_storage_block.resource_list.block_array*
Change-Id: I6ef53951487e6366d69ecaa43e4df6824baad042
Reviewed-on: https://chromium-review.googlesource.com/890386
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index c756a92..fffaaab 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -1910,19 +1910,18 @@
GetInterfaceBlockName(blockIndex, mState.mShaderStorageBlocks, bufSize, length, blockName);
}
-GLint Program::getActiveUniformBlockMaxLength() const
+template <typename T>
+GLint Program::getActiveInterfaceBlockMaxNameLength(const std::vector<T> &resources) const
{
int maxLength = 0;
if (mLinked)
{
- unsigned int numUniformBlocks = static_cast<unsigned int>(mState.mUniformBlocks.size());
- for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++)
+ for (const T &resource : resources)
{
- const InterfaceBlock &uniformBlock = mState.mUniformBlocks[uniformBlockIndex];
- if (!uniformBlock.name.empty())
+ if (!resource.name.empty())
{
- int length = static_cast<int>(uniformBlock.nameWithArrayIndex().length());
+ int length = static_cast<int>(resource.nameWithArrayIndex().length());
maxLength = std::max(length + 1, maxLength);
}
}
@@ -1931,6 +1930,16 @@
return maxLength;
}
+GLint Program::getActiveUniformBlockMaxNameLength() const
+{
+ return getActiveInterfaceBlockMaxNameLength(mState.mUniformBlocks);
+}
+
+GLint Program::getActiveShaderStorageBlockMaxNameLength() const
+{
+ return getActiveInterfaceBlockMaxNameLength(mState.mShaderStorageBlocks);
+}
+
GLuint Program::getUniformBlockIndex(const std::string &name) const
{
return GetInterfaceBlockIndex(mState.mUniformBlocks, name);