Add support for arrays of aggregates (aka structs) in uniform blocks.
TRAC #23018
Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Jamie Madill
git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2388 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Uniform.cpp b/src/compiler/Uniform.cpp
index 917e08f..9a643ba 100644
--- a/src/compiler/Uniform.cpp
+++ b/src/compiler/Uniform.cpp
@@ -92,7 +92,17 @@
{
if (!uniform.fields.empty())
{
- getBlockLayoutInfo(uniform.fields, currentOffset);
+ if (uniform.arraySize > 0)
+ {
+ for (unsigned int arrayElement = 0; arrayElement < uniform.arraySize; arrayElement++)
+ {
+ getBlockLayoutInfo(uniform.fields, currentOffset);
+ }
+ }
+ else
+ {
+ getBlockLayoutInfo(uniform.fields, currentOffset);
+ }
return false;
}
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index afac81f..0656f80 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -2370,7 +2370,18 @@
if (!uniform.fields.empty())
{
- defineUniformBlockMembers(uniform.fields, uniform.name, blockIndex, blockInfoItr, blockUniformIndexes);
+ if (uniform.arraySize > 0)
+ {
+ for (unsigned int arrayElement = 0; arrayElement < uniform.arraySize; arrayElement++)
+ {
+ const std::string uniformElementName = uniform.name + "[" + str(arrayElement) + "]";
+ defineUniformBlockMembers(uniform.fields, uniformElementName, blockIndex, blockInfoItr, blockUniformIndexes);
+ }
+ }
+ else
+ {
+ defineUniformBlockMembers(uniform.fields, uniform.name, blockIndex, blockInfoItr, blockUniformIndexes);
+ }
}
else
{