0:128 76.000000
0:128 59.000000
0:128 88.000000
+0:138 Function Definition: foo4( (global void)
+0:138 Function Parameters:
+0:140 Sequence
+0:140 Sequence
+0:140 move second child to first child (temp int)
+0:140 'a' (temp int)
+0:140 Constant:
+0:140 9 (const int)
0:? Linker Objects
0:? 'a' (const int)
0:? 1 (const int)
0:? 13.000000
0:? 14.000000
0:? 15.000000
+0:? 'a0' (const 3-element array of structure{global int i, global float f, global bool b})
+0:? 3 (const int)
+0:? 2.000000
+0:? true (const bool)
+0:? 1 (const int)
+0:? 5.000000
+0:? true (const bool)
+0:? 1 (const int)
+0:? 9.000000
+0:? false (const bool)
Linked fragment stage:
0:128 76.000000
0:128 59.000000
0:128 88.000000
+0:138 Function Definition: foo4( (global void)
+0:138 Function Parameters:
+0:140 Sequence
+0:140 Sequence
+0:140 move second child to first child (temp int)
+0:140 'a' (temp int)
+0:140 Constant:
+0:140 9 (const int)
0:? Linker Objects
0:? 'a' (const int)
0:? 1 (const int)
0:? 13.000000
0:? 14.000000
0:? 15.000000
+0:? 'a0' (const 3-element array of structure{global int i, global float f, global bool b})
+0:? 3 (const int)
+0:? 2.000000
+0:? true (const bool)
+0:? 1 (const int)
+0:? 5.000000
+0:? true (const bool)
+0:? 1 (const int)
+0:? 9.000000
+0:? false (const bool)
{\r
mat3x2 r32 = mm2 * mm32;\r
}\r
+\r
+struct cag {\r
+ int i;\r
+ float f;\r
+ bool b;\r
+};\r
+const cag a0[3] = cag[3](cag(3, 2.0, true), cag(1, 5.0, true), cag(1, 9.0, false));\r
+\r
+void foo4()\r
+{\r
+ int a = int(a0[2].f);\r
+}
\ No newline at end of file
//
// Constant folding of a bracket (array-style) dereference or struct-like dot
-// dereference. Can handle any thing except a multi-character swizzle, though
+// dereference. Can handle anything except a multi-character swizzle, though
// all swizzles may go to foldSwizzle().
//
TIntermTyped* TIntermediate::foldDereference(TIntermTyped* node, int index, const TSourceLoc& loc)
dereferencedType.getQualifier().storage = EvqConst;
TIntermTyped* result = 0;
int size = dereferencedType.computeNumComponents();
-
+
+ // arrays, vectors, matrices, all use simple multiplicative math
+ // while structures need to add up heterogeneous members
int start;
- if (node->isStruct()) {
+ if (node->isArray() || ! node->isStruct())
+ start = size * index;
+ else {
+ // it is a structure
+ assert(node->isStruct());
start = 0;
for (int i = 0; i < index; ++i)
start += (*node->getType().getStruct())[i].type->computeNumComponents();
- } else
- start = size * index;
+ }
result = addConstantUnion(TConstUnionArray(node->getAsConstantUnion()->getConstArray(), start, size), node->getType(), loc);