diff --git a/Test/baseLegalResults/hlsl.aliasOpaque.frag.out b/Test/baseLegalResults/hlsl.aliasOpaque.frag.out
index 779d5e1d25adf5e219125a56ad0ec45005ff9f10..752fbe9e0c99f8d450d2ad9f0c66ee4f2a245f98 100644
--- a/Test/baseLegalResults/hlsl.aliasOpaque.frag.out
+++ b/Test/baseLegalResults/hlsl.aliasOpaque.frag.out
@@ -2,49 +2,54 @@ hlsl.aliasOpaque.frag
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 81
+// Id's are bound by 87
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 57
+                              EntryPoint Fragment 4  "main" 62
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
-                              Name 37  "gss2"
-                              Name 39  "gss"
-                              Name 43  "gtex"
-                              Name 57  "@entryPointOutput"
-                              Decorate 37(gss2) DescriptorSet 0
-                              Decorate 39(gss) DescriptorSet 0
-                              Decorate 43(gtex) DescriptorSet 0
-                              Decorate 57(@entryPointOutput) Location 0
+                              Name 9  "OS"
+                              MemberName 9(OS) 0  "ss"
+                              MemberName 9(OS) 1  "a"
+                              MemberName 9(OS) 2  "tex"
+                              Name 44  "gss2"
+                              Name 47  "gss"
+                              Name 51  "gtex"
+                              Name 62  "@entryPointOutput"
+                              Decorate 44(gss2) DescriptorSet 0
+                              Decorate 47(gss) DescriptorSet 0
+                              Decorate 51(gtex) DescriptorSet 0
+                              Decorate 62(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               8:             TypeFloat 32
-              10:             TypeImage 8(float) 2D sampled format:Unknown
-              12:             TypeVector 8(float) 4
-              25:             TypeSampledImage 10
-              27:             TypeVector 8(float) 2
-              28:    8(float) Constant 1045220557
-              29:    8(float) Constant 1050253722
-              30:   27(fvec2) ConstantComposite 28 29
-              36:             TypePointer UniformConstant 6
-        37(gss2):     36(ptr) Variable UniformConstant
-         39(gss):     36(ptr) Variable UniformConstant
-              42:             TypePointer UniformConstant 10
-        43(gtex):     42(ptr) Variable UniformConstant
-              46:    8(float) Constant 1077936128
-              56:             TypePointer Output 12(fvec4)
-57(@entryPointOutput):     56(ptr) Variable Output
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+           9(OS):             TypeStruct 6 7(float) 8
+              11:             TypeVector 7(float) 4
+              32:             TypeSampledImage 8
+              34:             TypeVector 7(float) 2
+              35:    7(float) Constant 1045220557
+              36:    7(float) Constant 1050253722
+              37:   34(fvec2) ConstantComposite 35 36
+              43:             TypePointer UniformConstant 6
+        44(gss2):     43(ptr) Variable UniformConstant
+         47(gss):     43(ptr) Variable UniformConstant
+              50:             TypePointer UniformConstant 8
+        51(gtex):     50(ptr) Variable UniformConstant
+              54:    7(float) Constant 1077936128
+              61:             TypePointer Output 11(fvec4)
+62(@entryPointOutput):     61(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              68:           6 Load 39(gss)
-              69:          10 Load 43(gtex)
-              78:          25 SampledImage 69 68
-              79:   12(fvec4) ImageSampleImplicitLod 78 30
-              80:   12(fvec4) VectorTimesScalar 79 46
-                              Store 57(@entryPointOutput) 80
+              70:           6 Load 47(gss)
+              72:           8 Load 51(gtex)
+              84:          32 SampledImage 72 70
+              85:   11(fvec4) ImageSampleImplicitLod 84 37
+              86:   11(fvec4) VectorTimesScalar 85 54
+                              Store 62(@entryPointOutput) 86
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.flattenOpaque.frag.out b/Test/baseLegalResults/hlsl.flattenOpaque.frag.out
index 3c7d19831b6c9b7fe2f6e551d9331b498051cf75..11da7eb5f054e90a64546ff5855d5db027d2c8c1 100644
--- a/Test/baseLegalResults/hlsl.flattenOpaque.frag.out
+++ b/Test/baseLegalResults/hlsl.flattenOpaque.frag.out
@@ -1,65 +1,73 @@
 hlsl.flattenOpaque.frag
+WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 144
+// Id's are bound by 185
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 97
+                              EntryPoint Fragment 4  "main" 120
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
+                              Name 7  "os"
+                              MemberName 7(os) 0  "s2D"
+                              Name 23  "os2"
+                              MemberName 23(os2) 0  "s2D"
+                              MemberName 23(os2) 1  "tex"
                               Name 38  "tex"
-                              Name 70  "s.s2D"
-                              Name 79  "s2.s2D"
-                              Name 80  "s2.tex"
-                              Name 97  "@entryPointOutput"
+                              Name 82  "s.s2D"
+                              Name 97  "s2.s2D"
+                              Name 100  "s2.tex"
+                              Name 120  "@entryPointOutput"
                               Decorate 38(tex) DescriptorSet 0
-                              Decorate 70(s.s2D) DescriptorSet 0
-                              Decorate 79(s2.s2D) DescriptorSet 0
-                              Decorate 80(s2.tex) DescriptorSet 0
-                              Decorate 97(@entryPointOutput) Location 0
+                              Decorate 82(s.s2D) DescriptorSet 0
+                              Decorate 97(s2.s2D) DescriptorSet 0
+                              Decorate 100(s2.tex) DescriptorSet 0
+                              Decorate 120(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               8:             TypeFloat 32
-               9:             TypeVector 8(float) 4
-              14:             TypeVector 8(float) 2
-              21:             TypeImage 8(float) 2D sampled format:Unknown
-              37:             TypePointer UniformConstant 21
+           7(os):             TypeStruct 6
+               9:             TypeFloat 32
+              10:             TypeVector 9(float) 4
+              15:             TypeVector 9(float) 2
+              22:             TypeImage 9(float) 2D sampled format:Unknown
+         23(os2):             TypeStruct 6 22
+              37:             TypePointer UniformConstant 22
          38(tex):     37(ptr) Variable UniformConstant
-              41:             TypeSampledImage 21
-              43:    8(float) Constant 1045220557
-              44:    8(float) Constant 1050253722
-              45:   14(fvec2) ConstantComposite 43 44
-              69:             TypePointer UniformConstant 6
-       70(s.s2D):     69(ptr) Variable UniformConstant
-      79(s2.s2D):     69(ptr) Variable UniformConstant
-      80(s2.tex):     37(ptr) Variable UniformConstant
-              96:             TypePointer Output 9(fvec4)
-97(@entryPointOutput):     96(ptr) Variable Output
+              45:             TypeSampledImage 22
+              47:    9(float) Constant 1045220557
+              48:    9(float) Constant 1050253722
+              49:   15(fvec2) ConstantComposite 47 48
+              81:             TypePointer UniformConstant 6
+       82(s.s2D):     81(ptr) Variable UniformConstant
+      97(s2.s2D):     81(ptr) Variable UniformConstant
+     100(s2.tex):     37(ptr) Variable UniformConstant
+             119:             TypePointer Output 10(fvec4)
+120(@entryPointOutput):    119(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-             109:           6 Load 70(s.s2D)
-             123:          21 Load 38(tex)
-             125:          41 SampledImage 123 109
-             126:    9(fvec4) ImageSampleImplicitLod 125 45
-             111:           6 Load 70(s.s2D)
-             128:          21 Load 38(tex)
-             130:          41 SampledImage 128 111
-             132:    9(fvec4) ImageSampleImplicitLod 130 45
-             113:    9(fvec4) FAdd 126 132
-             114:           6 Load 79(s2.s2D)
-             115:          21 Load 80(s2.tex)
-             136:          41 SampledImage 115 114
-             137:    9(fvec4) ImageSampleImplicitLod 136 45
-             117:    9(fvec4) FAdd 113 137
-             118:           6 Load 79(s2.s2D)
-             119:          21 Load 80(s2.tex)
-             141:          41 SampledImage 119 118
-             143:    9(fvec4) ImageSampleImplicitLod 141 45
-             121:    9(fvec4) FAdd 117 143
-                              Store 97(@entryPointOutput) 121
+             134:           6 Load 82(s.s2D)
+             158:          22 Load 38(tex)
+             161:          45 SampledImage 158 134
+             162:   10(fvec4) ImageSampleImplicitLod 161 49
+             138:           6 Load 82(s.s2D)
+             164:          22 Load 38(tex)
+             167:          45 SampledImage 164 138
+             169:   10(fvec4) ImageSampleImplicitLod 167 49
+             142:   10(fvec4) FAdd 162 169
+             143:           6 Load 97(s2.s2D)
+             145:          22 Load 100(s2.tex)
+             175:          45 SampledImage 145 143
+             176:   10(fvec4) ImageSampleImplicitLod 175 49
+             149:   10(fvec4) FAdd 142 176
+             150:           6 Load 97(s2.s2D)
+             152:          22 Load 100(s2.tex)
+             182:          45 SampledImage 152 150
+             184:   10(fvec4) ImageSampleImplicitLod 182 49
+             156:   10(fvec4) FAdd 149 184
+                              Store 120(@entryPointOutput) 156
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out b/Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
index 1d33d056e4bcc78697088dd75ad7c45cb5b3bcf1..24c4121902f78211276af11a82f96f3766c0fa64 100644
--- a/Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
+++ b/Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
@@ -2,57 +2,56 @@ hlsl.flattenOpaqueInit.vert
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 176
+// Id's are bound by 134
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 99
+                              EntryPoint Vertex 4  "main" 80
                               Source HLSL 500
                               Name 4  "main"
-                              Name 17  "FxaaTex"
-                              MemberName 17(FxaaTex) 0  "smpl"
-                              MemberName 17(FxaaTex) 1  "tex"
-                              Name 38  "g_tInputTexture_sampler"
-                              Name 42  "g_tInputTexture"
-                              Name 99  "@entryPointOutput"
-                              Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
-                              Decorate 42(g_tInputTexture) DescriptorSet 0
-                              Decorate 99(@entryPointOutput) Location 0
+                              Name 9  "FxaaTex"
+                              MemberName 9(FxaaTex) 0  "smpl"
+                              MemberName 9(FxaaTex) 1  "tex"
+                              Name 43  "g_tInputTexture_sampler"
+                              Name 47  "g_tInputTexture"
+                              Name 80  "@entryPointOutput"
+                              Decorate 43(g_tInputTexture_sampler) DescriptorSet 0
+                              Decorate 47(g_tInputTexture) DescriptorSet 0
+                              Decorate 80(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               8:             TypeFloat 32
-               9:             TypeImage 8(float) 2D sampled format:Unknown
-              11:             TypeVector 8(float) 4
-     17(FxaaTex):             TypeStruct 6 9
-              26:             TypeSampledImage 9
-              28:             TypeVector 8(float) 2
-              29:    8(float) Constant 1050253722
-              30:    8(float) Constant 1053609165
-              31:   28(fvec2) ConstantComposite 29 30
-              32:    8(float) Constant 0
-              37:             TypePointer UniformConstant 6
-38(g_tInputTexture_sampler):     37(ptr) Variable UniformConstant
-              41:             TypePointer UniformConstant 9
-42(g_tInputTexture):     41(ptr) Variable UniformConstant
-              98:             TypePointer Output 11(fvec4)
-99(@entryPointOutput):     98(ptr) Variable Output
-             175: 17(FxaaTex) Undef
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+      9(FxaaTex):             TypeStruct 6 8
+              11:             TypeVector 7(float) 4
+              31:             TypeSampledImage 8
+              33:             TypeVector 7(float) 2
+              34:    7(float) Constant 1050253722
+              35:    7(float) Constant 1053609165
+              36:   33(fvec2) ConstantComposite 34 35
+              37:    7(float) Constant 0
+              42:             TypePointer UniformConstant 6
+43(g_tInputTexture_sampler):     42(ptr) Variable UniformConstant
+              46:             TypePointer UniformConstant 8
+47(g_tInputTexture):     46(ptr) Variable UniformConstant
+              79:             TypePointer Output 11(fvec4)
+80(@entryPointOutput):     79(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-             117:           6 Load 38(g_tInputTexture_sampler)
-             118:           9 Load 42(g_tInputTexture)
-             148:          26 SampledImage 118 117
-             149:   11(fvec4) ImageSampleExplicitLod 148 31 Lod 32
-             172:           6 CompositeExtract 175 0
-             174:           9 CompositeExtract 175 1
-             160:          26 SampledImage 174 172
-             161:   11(fvec4) ImageSampleExplicitLod 160 31 Lod 32
-             136:   11(fvec4) FAdd 149 161
-             165:          26 SampledImage 118 117
-             166:   11(fvec4) ImageSampleExplicitLod 165 31 Lod 32
-             143:   11(fvec4) FAdd 136 166
-                              Store 99(@entryPointOutput) 143
+              90:           6 Load 43(g_tInputTexture_sampler)
+              91:           8 Load 47(g_tInputTexture)
+             111:          31 SampledImage 91 90
+             112:   11(fvec4) ImageSampleExplicitLod 111 36 Lod 37
+             115:           6 Load 43(g_tInputTexture_sampler)
+             117:           8 Load 47(g_tInputTexture)
+             125:          31 SampledImage 117 115
+             126:   11(fvec4) ImageSampleExplicitLod 125 36 Lod 37
+              99:   11(fvec4) FAdd 112 126
+             132:          31 SampledImage 91 90
+             133:   11(fvec4) ImageSampleExplicitLod 132 36 Lod 37
+             104:   11(fvec4) FAdd 99 133
+                              Store 80(@entryPointOutput) 104
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out b/Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
index 0b056158271db0a373221e39a0d09503279ed9aa..900ed25e6c2aae50778a7cbcbe870fc2ffb4ea3a 100644
--- a/Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
+++ b/Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
@@ -2,48 +2,48 @@ hlsl.flattenOpaqueInitMix.vert
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 100
+// Id's are bound by 80
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 68
+                              EntryPoint Vertex 4  "main" 57
                               Source HLSL 500
                               Name 4  "main"
-                              Name 34  "FxaaTex"
-                              MemberName 34(FxaaTex) 0  "smpl"
-                              MemberName 34(FxaaTex) 1  "tex"
-                              MemberName 34(FxaaTex) 2  "f"
-                              Name 38  "g_tInputTexture_sampler"
-                              Name 41  "g_tInputTexture"
-                              Name 68  "@entryPointOutput"
-                              Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
-                              Decorate 41(g_tInputTexture) DescriptorSet 0
-                              Decorate 68(@entryPointOutput) Location 0
+                              Name 9  "FxaaTex"
+                              MemberName 9(FxaaTex) 0  "smpl"
+                              MemberName 9(FxaaTex) 1  "tex"
+                              MemberName 9(FxaaTex) 2  "f"
+                              Name 44  "g_tInputTexture_sampler"
+                              Name 47  "g_tInputTexture"
+                              Name 57  "@entryPointOutput"
+                              Decorate 44(g_tInputTexture_sampler) DescriptorSet 0
+                              Decorate 47(g_tInputTexture) DescriptorSet 0
+                              Decorate 57(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               8:             TypeFloat 32
-               9:             TypeImage 8(float) 2D sampled format:Unknown
-              12:             TypeVector 8(float) 4
-              24:             TypeSampledImage 9
-              28:             TypeVector 8(float) 2
-              30:    8(float) Constant 0
-     34(FxaaTex):             TypeStruct 6 9 8(float)
-              37:             TypePointer UniformConstant 6
-38(g_tInputTexture_sampler):     37(ptr) Variable UniformConstant
-              40:             TypePointer UniformConstant 9
-41(g_tInputTexture):     40(ptr) Variable UniformConstant
-              43:    8(float) Constant 1056964608
-              67:             TypePointer Output 12(fvec4)
-68(@entryPointOutput):     67(ptr) Variable Output
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+      9(FxaaTex):             TypeStruct 6 8 7(float)
+              11:             TypeVector 7(float) 4
+              28:             TypeSampledImage 8
+              36:             TypeVector 7(float) 2
+              38:    7(float) Constant 0
+              43:             TypePointer UniformConstant 6
+44(g_tInputTexture_sampler):     43(ptr) Variable UniformConstant
+              46:             TypePointer UniformConstant 8
+47(g_tInputTexture):     46(ptr) Variable UniformConstant
+              49:    7(float) Constant 1056964608
+              56:             TypePointer Output 11(fvec4)
+57(@entryPointOutput):     56(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              79:           6 Load 38(g_tInputTexture_sampler)
-              80:           9 Load 41(g_tInputTexture)
-              95:          24 SampledImage 80 79
-              98:   28(fvec2) CompositeConstruct 43 43
-              99:   12(fvec4) ImageSampleExplicitLod 95 98 Lod 30
-                              Store 68(@entryPointOutput) 99
+              63:           6 Load 44(g_tInputTexture_sampler)
+              64:           8 Load 47(g_tInputTexture)
+              73:          28 SampledImage 64 63
+              78:   36(fvec2) CompositeConstruct 49 49
+              79:   11(fvec4) ImageSampleExplicitLod 73 78 Lod 38
+                              Store 57(@entryPointOutput) 79
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.flattenSubset.frag.out b/Test/baseLegalResults/hlsl.flattenSubset.frag.out
index 20aedec26f4b446b54b560c7d700673b5627988a..1c5f9b6fd304b338cefd6bec88f5d6f0c1ba945a 100755
--- a/Test/baseLegalResults/hlsl.flattenSubset.frag.out
+++ b/Test/baseLegalResults/hlsl.flattenSubset.frag.out
@@ -2,47 +2,67 @@ hlsl.flattenSubset.frag
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 85
+// Id's are bound by 66
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 54 57
+                              EntryPoint Fragment 4  "main" 47 50
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
-                              Name 17  "samp"
-                              Name 41  "tex"
-                              Name 54  "vpos"
-                              Name 57  "@entryPointOutput"
-                              Decorate 17(samp) DescriptorSet 0
-                              Decorate 41(tex) DescriptorSet 0
-                              Decorate 54(vpos) Location 0
-                              Decorate 57(@entryPointOutput) Location 0
+                              Name 15  "S0"
+                              MemberName 15(S0) 0  "x"
+                              MemberName 15(S0) 1  "y"
+                              MemberName 15(S0) 2  "ss"
+                              Name 16  "S1"
+                              MemberName 16(S1) 0  "b"
+                              MemberName 16(S1) 1  "samplerState"
+                              MemberName 16(S1) 2  "s0"
+                              MemberName 16(S1) 3  "a"
+                              Name 21  "samp"
+                              Name 25  "S2"
+                              MemberName 25(S2) 0  "a1"
+                              MemberName 25(S2) 1  "a2"
+                              MemberName 25(S2) 2  "a3"
+                              MemberName 25(S2) 3  "a4"
+                              MemberName 25(S2) 4  "a5"
+                              MemberName 25(S2) 5  "resources"
+                              Name 33  "tex"
+                              Name 47  "vpos"
+                              Name 50  "@entryPointOutput"
+                              Decorate 21(samp) DescriptorSet 0
+                              Decorate 33(tex) DescriptorSet 0
+                              Decorate 47(vpos) Location 0
+                              Decorate 50(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
               13:             TypeSampler
-              16:             TypePointer UniformConstant 13
-        17(samp):     16(ptr) Variable UniformConstant
-              39:             TypeImage 6(float) 2D sampled format:Unknown
-              40:             TypePointer UniformConstant 39
-         41(tex):     40(ptr) Variable UniformConstant
-              44:             TypeSampledImage 39
-              46:             TypeVector 6(float) 2
-              47:    6(float) Constant 1056964608
-              48:   46(fvec2) ConstantComposite 47 47
-              53:             TypePointer Input 7(fvec4)
-        54(vpos):     53(ptr) Variable Input
-              56:             TypePointer Output 7(fvec4)
-57(@entryPointOutput):     56(ptr) Variable Output
+              14:             TypeInt 32 1
+          15(S0):             TypeStruct 14(int) 14(int) 13
+          16(S1):             TypeStruct 6(float) 13 15(S0) 14(int)
+              20:             TypePointer UniformConstant 13
+        21(samp):     20(ptr) Variable UniformConstant
+          25(S2):             TypeStruct 14(int) 14(int) 14(int) 14(int) 14(int) 16(S1)
+              31:             TypeImage 6(float) 2D sampled format:Unknown
+              32:             TypePointer UniformConstant 31
+         33(tex):     32(ptr) Variable UniformConstant
+              37:             TypeSampledImage 31
+              39:             TypeVector 6(float) 2
+              40:    6(float) Constant 1056964608
+              41:   39(fvec2) ConstantComposite 40 40
+              46:             TypePointer Input 7(fvec4)
+        47(vpos):     46(ptr) Variable Input
+              49:             TypePointer Output 7(fvec4)
+50(@entryPointOutput):     49(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              74:          13 Load 17(samp)
-              81:          39 Load 41(tex)
-              83:          44 SampledImage 81 74
-              84:    7(fvec4) ImageSampleImplicitLod 83 48
-                              Store 57(@entryPointOutput) 84
+              57:          13 Load 21(samp)
+              61:          31 Load 33(tex)
+              64:          37 SampledImage 61 57
+              65:    7(fvec4) ImageSampleImplicitLod 64 41
+                              Store 50(@entryPointOutput) 65
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.flattenSubset2.frag.out b/Test/baseLegalResults/hlsl.flattenSubset2.frag.out
index 724ae7bf9b5eefc3232eceb59ed6a5c8a820dee7..fe116c1e4d3b76dec0cb77ada5fa822589d8c175 100755
--- a/Test/baseLegalResults/hlsl.flattenSubset2.frag.out
+++ b/Test/baseLegalResults/hlsl.flattenSubset2.frag.out
@@ -2,36 +2,48 @@ hlsl.flattenSubset2.frag
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 44
+// Id's are bound by 53
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 40 43
+                              EntryPoint Fragment 4  "main" 49 52
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
-                              Name 31  "someTex"
-                              Name 40  "vpos"
-                              Name 43  "@entryPointOutput"
-                              Decorate 31(someTex) DescriptorSet 0
-                              Decorate 40(vpos) Location 0
-                              Decorate 43(@entryPointOutput) Location 0
+                              Name 14  "Nested"
+                              MemberName 14(Nested) 0  "y"
+                              MemberName 14(Nested) 1  "texNested"
+                              Name 15  "A"
+                              MemberName 15(A) 0  "n"
+                              MemberName 15(A) 1  "x"
+                              Name 25  "B"
+                              MemberName 25(B) 0  "n"
+                              MemberName 25(B) 1  "tex"
+                              Name 36  "someTex"
+                              Name 49  "vpos"
+                              Name 52  "@entryPointOutput"
+                              Decorate 36(someTex) DescriptorSet 0
+                              Decorate 49(vpos) Location 0
+                              Decorate 52(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
-              17:             TypeImage 6(float) 2D sampled format:Unknown
-              30:             TypePointer UniformConstant 17
-     31(someTex):     30(ptr) Variable UniformConstant
-              34:    6(float) Constant 0
-              35:    7(fvec4) ConstantComposite 34 34 34 34
-              39:             TypePointer Input 7(fvec4)
-        40(vpos):     39(ptr) Variable Input
-              42:             TypePointer Output 7(fvec4)
-43(@entryPointOutput):     42(ptr) Variable Output
+              13:             TypeImage 6(float) 2D sampled format:Unknown
+      14(Nested):             TypeStruct 6(float) 13
+           15(A):             TypeStruct 14(Nested) 6(float)
+           25(B):             TypeStruct 14(Nested) 13
+              35:             TypePointer UniformConstant 13
+     36(someTex):     35(ptr) Variable UniformConstant
+              43:    6(float) Constant 0
+              44:    7(fvec4) ConstantComposite 43 43 43 43
+              48:             TypePointer Input 7(fvec4)
+        49(vpos):     48(ptr) Variable Input
+              51:             TypePointer Output 7(fvec4)
+52(@entryPointOutput):     51(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-                              Store 43(@entryPointOutput) 35
+                              Store 52(@entryPointOutput) 44
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out b/Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
index ed3102e181002fb9eece80c95b8539a35476e9e1..97886212dbd3d6d41481179217ab4610c1bec541 100755
--- a/Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
+++ b/Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
@@ -2,90 +2,108 @@ hlsl.partialFlattenLocal.vert
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 148
+// Id's are bound by 132
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 90 93
+                              EntryPoint Vertex 4  "main" 83 86
                               Source HLSL 500
                               Name 4  "main"
-                              Name 17  "tex"
-                              Name 90  "pos"
-                              Name 93  "@entryPointOutput"
-                              Decorate 17(tex) DescriptorSet 0
-                              Decorate 90(pos) Location 0
-                              Decorate 93(@entryPointOutput) BuiltIn Position
+                              Name 22  "Packed"
+                              MemberName 22(Packed) 0  "tex"
+                              MemberName 22(Packed) 1  "pos"
+                              MemberName 22(Packed) 2  "uv"
+                              MemberName 22(Packed) 3  "x"
+                              MemberName 22(Packed) 4  "n"
+                              Name 27  "tex"
+                              Name 83  "pos"
+                              Name 86  "@entryPointOutput"
+                              Decorate 27(tex) DescriptorSet 0
+                              Decorate 83(pos) Location 0
+                              Decorate 86(@entryPointOutput) BuiltIn Position
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
               13:             TypeImage 6(float) 2D sampled format:Unknown
-              16:             TypePointer UniformConstant 13
-         17(tex):     16(ptr) Variable UniformConstant
-              19:             TypeVector 6(float) 3
-              20:             TypeInt 32 0
-              21:     20(int) Constant 3
-              22:             TypeArray 19(fvec3) 21
-              23:             TypePointer Function 22
-              25:             TypeInt 32 1
-              26:     25(int) Constant 0
-              27:    6(float) Constant 0
-              28:   19(fvec3) ConstantComposite 27 27 27
-              29:             TypePointer Function 19(fvec3)
-              31:             TypeVector 6(float) 2
-              32:     20(int) Constant 2
-              33:             TypeArray 31(fvec2) 32
-              34:             TypePointer Function 33
-              36:    6(float) Constant 1065353216
-              37:   31(fvec2) ConstantComposite 27 36
-              38:             TypePointer Function 31(fvec2)
-              52:     25(int) Constant 1
-              53:             TypeBool
-              89:             TypePointer Input 7(fvec4)
-         90(pos):     89(ptr) Variable Input
-              92:             TypePointer Output 7(fvec4)
-93(@entryPointOutput):     92(ptr) Variable Output
+              14:             TypeVector 6(float) 3
+              15:             TypeInt 32 0
+              16:     15(int) Constant 3
+              17:             TypeArray 14(fvec3) 16
+              18:             TypeVector 6(float) 2
+              19:     15(int) Constant 2
+              20:             TypeArray 18(fvec2) 19
+              21:             TypeInt 32 1
+      22(Packed):             TypeStruct 13 17 20 6(float) 21(int)
+              23:             TypePointer Function 22(Packed)
+              25:     21(int) Constant 0
+              26:             TypePointer UniformConstant 13
+         27(tex):     26(ptr) Variable UniformConstant
+              29:             TypePointer Function 13
+              31:     21(int) Constant 1
+              32:    6(float) Constant 0
+              33:   14(fvec3) ConstantComposite 32 32 32
+              34:             TypePointer Function 14(fvec3)
+              36:     21(int) Constant 2
+              37:    6(float) Constant 1065353216
+              38:   18(fvec2) ConstantComposite 32 37
+              39:             TypePointer Function 18(fvec2)
+              41:     21(int) Constant 3
+              42:             TypePointer Function 6(float)
+              44:     21(int) Constant 4
+              45:             TypePointer Function 21(int)
+              54:             TypeBool
+              82:             TypePointer Input 7(fvec4)
+         83(pos):     82(ptr) Variable Input
+              85:             TypePointer Output 7(fvec4)
+86(@entryPointOutput):     85(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              98:     23(ptr) Variable Function
-              99:     34(ptr) Variable Function
-              91:    7(fvec4) Load 90(pos)
-             110:     29(ptr) AccessChain 98 26
-                              Store 110 28
-             111:     38(ptr) AccessChain 99 26
-                              Store 111 37
-                              Branch 112
-             112:             Label
-             147:     25(int) Phi 26 5 131 114
-                              LoopMerge 113 114 None
-                              Branch 115
-             115:             Label
-             117:    53(bool) SLessThan 147 52
-                              BranchConditional 117 118 113
-             118:               Label
-             121:     38(ptr)   AccessChain 99 147
-             122:   31(fvec2)   Load 121
-             123:     29(ptr)   AccessChain 98 147
-             124:   19(fvec3)   Load 123
-             125:   31(fvec2)   VectorShuffle 124 124 0 1
-             126:   31(fvec2)   FAdd 125 122
-             127:     29(ptr)   AccessChain 98 147
-             128:   19(fvec3)   Load 127
-             129:   19(fvec3)   VectorShuffle 128 126 3 4 2
-                                Store 127 129
-                                Branch 114
-             114:               Label
-             131:     25(int)   IAdd 147 52
-                                Branch 112
-             113:             Label
-             133:          22 Load 98
-             146:   19(fvec3) CompositeExtract 133 0
-             140:    6(float) CompositeExtract 146 0
-             141:    6(float) CompositeExtract 146 1
-             142:    6(float) CompositeExtract 146 2
-             143:    7(fvec4) CompositeConstruct 140 141 142 27
-             144:    7(fvec4) FAdd 91 143
-                              Store 93(@entryPointOutput) 144
+              90:     23(ptr) Variable Function
+              84:    7(fvec4) Load 83(pos)
+              94:          13 Load 27(tex)
+              95:     29(ptr) AccessChain 90 25
+                              Store 95 94
+              96:     34(ptr) AccessChain 90 31 25
+                              Store 96 33
+              97:     39(ptr) AccessChain 90 36 25
+                              Store 97 38
+              98:     42(ptr) AccessChain 90 41
+                              Store 98 37
+              99:     45(ptr) AccessChain 90 44
+                              Store 99 41
+                              Branch 100
+             100:             Label
+             131:     21(int) Phi 25 5 119 102
+                              LoopMerge 101 102 None
+                              Branch 103
+             103:             Label
+             105:    54(bool) SLessThan 131 31
+                              BranchConditional 105 106 101
+             106:               Label
+             109:     39(ptr)   AccessChain 90 36 131
+             110:   18(fvec2)   Load 109
+             111:     34(ptr)   AccessChain 90 31 131
+             112:   14(fvec3)   Load 111
+             113:   18(fvec2)   VectorShuffle 112 112 0 1
+             114:   18(fvec2)   FAdd 113 110
+             115:     34(ptr)   AccessChain 90 31 131
+             116:   14(fvec3)   Load 115
+             117:   14(fvec3)   VectorShuffle 116 114 3 4 2
+                                Store 115 117
+                                Branch 102
+             102:               Label
+             119:     21(int)   IAdd 131 31
+                                Branch 100
+             101:             Label
+             120:  22(Packed) Load 90
+             130:   14(fvec3) CompositeExtract 120 1 0
+             124:    6(float) CompositeExtract 130 0
+             125:    6(float) CompositeExtract 130 1
+             126:    6(float) CompositeExtract 130 2
+             127:    7(fvec4) CompositeConstruct 124 125 126 32
+             128:    7(fvec4) FAdd 84 127
+                              Store 86(@entryPointOutput) 128
                               Return
                               FunctionEnd
diff --git a/Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out b/Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
index d57566b349ee46ec36e1f31addb4aa344c90052b..65fb83ebd524b4be5066f62defc3295328262714 100755
--- a/Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
+++ b/Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
@@ -2,37 +2,43 @@ hlsl.partialFlattenMixed.vert
 WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 31
+// Id's are bound by 36
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 27 30
+                              EntryPoint Vertex 4  "main" 32 35
                               Source HLSL 500
                               Name 4  "main"
-                              Name 20  "tex"
-                              Name 27  "pos"
-                              Name 30  "@entryPointOutput"
-                              Decorate 20(tex) DescriptorSet 0
-                              Decorate 27(pos) Location 0
-                              Decorate 30(@entryPointOutput) BuiltIn Position
+                              Name 18  "Packed"
+                              MemberName 18(Packed) 0  "a"
+                              MemberName 18(Packed) 1  "membTex"
+                              MemberName 18(Packed) 2  "b"
+                              Name 23  "tex"
+                              Name 32  "pos"
+                              Name 35  "@entryPointOutput"
+                              Decorate 23(tex) DescriptorSet 0
+                              Decorate 32(pos) Location 0
+                              Decorate 35(@entryPointOutput) BuiltIn Position
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
-              13:             TypeImage 6(float) 2D sampled format:Unknown
-              14:             TypeInt 32 0
-              15:     14(int) Constant 2
-              16:             TypeArray 13 15
-              19:             TypePointer UniformConstant 16
-         20(tex):     19(ptr) Variable UniformConstant
-              26:             TypePointer Input 7(fvec4)
-         27(pos):     26(ptr) Variable Input
-              29:             TypePointer Output 7(fvec4)
-30(@entryPointOutput):     29(ptr) Variable Output
+              13:             TypeInt 32 1
+              14:             TypeImage 6(float) 2D sampled format:Unknown
+              15:             TypeInt 32 0
+              16:     15(int) Constant 2
+              17:             TypeArray 14 16
+      18(Packed):             TypeStruct 13(int) 17 13(int)
+              22:             TypePointer UniformConstant 17
+         23(tex):     22(ptr) Variable UniformConstant
+              31:             TypePointer Input 7(fvec4)
+         32(pos):     31(ptr) Variable Input
+              34:             TypePointer Output 7(fvec4)
+35(@entryPointOutput):     34(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              28:    7(fvec4) Load 27(pos)
-                              Store 30(@entryPointOutput) 28
+              33:    7(fvec4) Load 32(pos)
+                              Store 35(@entryPointOutput) 33
                               Return
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.aliasOpaque.frag.out b/Test/baseResults/hlsl.aliasOpaque.frag.out
index 694d4044fb6f9b51afde7e8666bfcb4aac03eb92..9463cb746d23f2c5aa519aae688294b31eba1344 100755
--- a/Test/baseResults/hlsl.aliasOpaque.frag.out
+++ b/Test/baseResults/hlsl.aliasOpaque.frag.out
@@ -5,17 +5,24 @@ gl_FragCoord origin is upper left
 0:? Sequence
 0:12  Function Definition: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
 0:12    Function Parameters: 
-0:?       's.ss' ( in sampler)
-0:?       's.a' ( in float)
-0:?       's.tex' ( in texture2D)
+0:12      's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
 0:?     Sequence
 0:13      Branch: Return with expression
 0:13        vector-scale ( temp 4-component vector of float)
-0:?           's.a' ( in float)
+0:13          a: direct index for structure ( temp float)
+0:13            's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13            Constant:
+0:13              1 (const int)
 0:13          texture ( temp 4-component vector of float)
 0:13            Construct combined texture-sampler ( temp sampler2D)
-0:?               's.tex' ( in texture2D)
-0:?               's.ss' ( in sampler)
+0:13              tex: direct index for structure ( temp texture2D)
+0:13                's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13                Constant:
+0:13                  2 (const int)
+0:13              ss: direct index for structure ( temp sampler)
+0:13                's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13                Constant:
+0:13                  0 (const int)
 0:?             Constant:
 0:?               0.200000
 0:?               0.300000
@@ -23,23 +30,33 @@ gl_FragCoord origin is upper left
 0:17    Function Parameters: 
 0:?     Sequence
 0:19      move second child to first child ( temp sampler)
-0:?         'os.ss' ( temp sampler)
+0:19        ss: direct index for structure ( temp sampler)
+0:19          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:19          Constant:
+0:19            0 (const int)
 0:19        'gss2' ( uniform sampler)
 0:20      move second child to first child ( temp sampler)
-0:?         'os.ss' ( temp sampler)
+0:20        ss: direct index for structure ( temp sampler)
+0:20          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:20          Constant:
+0:20            0 (const int)
 0:20        'gss' ( uniform sampler)
 0:21      move second child to first child ( temp texture2D)
-0:?         'os.tex' ( temp texture2D)
+0:21        tex: direct index for structure ( temp texture2D)
+0:21          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:21          Constant:
+0:21            2 (const int)
 0:21        'gtex' ( uniform texture2D)
 0:22      move second child to first child ( temp float)
-0:?         'os.a' ( temp float)
+0:22        a: direct index for structure ( temp float)
+0:22          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:22          Constant:
+0:22            1 (const int)
 0:22        Constant:
 0:22          3.000000
 0:28      Branch: Return with expression
 0:28        Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
-0:?           'os.ss' ( temp sampler)
-0:?           'os.a' ( temp float)
-0:?           'os.tex' ( temp texture2D)
+0:28          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
 0:17  Function Definition: main( ( temp void)
 0:17    Function Parameters: 
 0:?     Sequence
@@ -61,17 +78,24 @@ gl_FragCoord origin is upper left
 0:? Sequence
 0:12  Function Definition: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
 0:12    Function Parameters: 
-0:?       's.ss' ( in sampler)
-0:?       's.a' ( in float)
-0:?       's.tex' ( in texture2D)
+0:12      's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
 0:?     Sequence
 0:13      Branch: Return with expression
 0:13        vector-scale ( temp 4-component vector of float)
-0:?           's.a' ( in float)
+0:13          a: direct index for structure ( temp float)
+0:13            's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13            Constant:
+0:13              1 (const int)
 0:13          texture ( temp 4-component vector of float)
 0:13            Construct combined texture-sampler ( temp sampler2D)
-0:?               's.tex' ( in texture2D)
-0:?               's.ss' ( in sampler)
+0:13              tex: direct index for structure ( temp texture2D)
+0:13                's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13                Constant:
+0:13                  2 (const int)
+0:13              ss: direct index for structure ( temp sampler)
+0:13                's' ( in structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:13                Constant:
+0:13                  0 (const int)
 0:?             Constant:
 0:?               0.200000
 0:?               0.300000
@@ -79,23 +103,33 @@ gl_FragCoord origin is upper left
 0:17    Function Parameters: 
 0:?     Sequence
 0:19      move second child to first child ( temp sampler)
-0:?         'os.ss' ( temp sampler)
+0:19        ss: direct index for structure ( temp sampler)
+0:19          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:19          Constant:
+0:19            0 (const int)
 0:19        'gss2' ( uniform sampler)
 0:20      move second child to first child ( temp sampler)
-0:?         'os.ss' ( temp sampler)
+0:20        ss: direct index for structure ( temp sampler)
+0:20          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:20          Constant:
+0:20            0 (const int)
 0:20        'gss' ( uniform sampler)
 0:21      move second child to first child ( temp texture2D)
-0:?         'os.tex' ( temp texture2D)
+0:21        tex: direct index for structure ( temp texture2D)
+0:21          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:21          Constant:
+0:21            2 (const int)
 0:21        'gtex' ( uniform texture2D)
 0:22      move second child to first child ( temp float)
-0:?         'os.a' ( temp float)
+0:22        a: direct index for structure ( temp float)
+0:22          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
+0:22          Constant:
+0:22            1 (const int)
 0:22        Constant:
 0:22          3.000000
 0:28      Branch: Return with expression
 0:28        Function Call: osCall(struct-OS-p1-f1-t211; ( temp 4-component vector of float)
-0:?           'os.ss' ( temp sampler)
-0:?           'os.a' ( temp float)
-0:?           'os.tex' ( temp texture2D)
+0:28          'os' ( temp structure{ temp sampler ss,  temp float a,  temp texture2D tex})
 0:17  Function Definition: main( ( temp void)
 0:17    Function Parameters: 
 0:?     Sequence
@@ -110,98 +144,99 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 59
+// Id's are bound by 64
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 57
+                              EntryPoint Fragment 4  "main" 62
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
-                              Name 17  "osCall(struct-OS-p1-f1-t211;"
-                              Name 14  "s.ss"
-                              Name 15  "s.a"
-                              Name 16  "s.tex"
-                              Name 20  "@main("
-                              Name 35  "os.ss"
-                              Name 37  "gss2"
-                              Name 39  "gss"
-                              Name 41  "os.tex"
-                              Name 43  "gtex"
-                              Name 45  "os.a"
-                              Name 47  "param"
-                              Name 49  "param"
-                              Name 51  "param"
-                              Name 57  "@entryPointOutput"
-                              Decorate 37(gss2) DescriptorSet 0
-                              Decorate 39(gss) DescriptorSet 0
-                              Decorate 43(gtex) DescriptorSet 0
-                              Decorate 57(@entryPointOutput) Location 0
+                              Name 9  "OS"
+                              MemberName 9(OS) 0  "ss"
+                              MemberName 9(OS) 1  "a"
+                              MemberName 9(OS) 2  "tex"
+                              Name 14  "osCall(struct-OS-p1-f1-t211;"
+                              Name 13  "s"
+                              Name 17  "@main("
+                              Name 42  "os"
+                              Name 44  "gss2"
+                              Name 47  "gss"
+                              Name 51  "gtex"
+                              Name 56  "param"
+                              Name 62  "@entryPointOutput"
+                              Decorate 44(gss2) DescriptorSet 0
+                              Decorate 47(gss) DescriptorSet 0
+                              Decorate 51(gtex) DescriptorSet 0
+                              Decorate 62(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               7:             TypePointer Function 6
-               8:             TypeFloat 32
-               9:             TypePointer Function 8(float)
-              10:             TypeImage 8(float) 2D sampled format:Unknown
-              11:             TypePointer Function 10
-              12:             TypeVector 8(float) 4
-              13:             TypeFunction 12(fvec4) 7(ptr) 9(ptr) 11(ptr)
-              19:             TypeFunction 12(fvec4)
-              25:             TypeSampledImage 10
-              27:             TypeVector 8(float) 2
-              28:    8(float) Constant 1045220557
-              29:    8(float) Constant 1050253722
-              30:   27(fvec2) ConstantComposite 28 29
-              36:             TypePointer UniformConstant 6
-        37(gss2):     36(ptr) Variable UniformConstant
-         39(gss):     36(ptr) Variable UniformConstant
-              42:             TypePointer UniformConstant 10
-        43(gtex):     42(ptr) Variable UniformConstant
-              46:    8(float) Constant 1077936128
-              56:             TypePointer Output 12(fvec4)
-57(@entryPointOutput):     56(ptr) Variable Output
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+           9(OS):             TypeStruct 6 7(float) 8
+              10:             TypePointer Function 9(OS)
+              11:             TypeVector 7(float) 4
+              12:             TypeFunction 11(fvec4) 10(ptr)
+              16:             TypeFunction 11(fvec4)
+              19:             TypeInt 32 1
+              20:     19(int) Constant 1
+              21:             TypePointer Function 7(float)
+              24:     19(int) Constant 2
+              25:             TypePointer Function 8
+              28:     19(int) Constant 0
+              29:             TypePointer Function 6
+              32:             TypeSampledImage 8
+              34:             TypeVector 7(float) 2
+              35:    7(float) Constant 1045220557
+              36:    7(float) Constant 1050253722
+              37:   34(fvec2) ConstantComposite 35 36
+              43:             TypePointer UniformConstant 6
+        44(gss2):     43(ptr) Variable UniformConstant
+         47(gss):     43(ptr) Variable UniformConstant
+              50:             TypePointer UniformConstant 8
+        51(gtex):     50(ptr) Variable UniformConstant
+              54:    7(float) Constant 1077936128
+              61:             TypePointer Output 11(fvec4)
+62(@entryPointOutput):     61(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              58:   12(fvec4) FunctionCall 20(@main()
-                              Store 57(@entryPointOutput) 58
+              63:   11(fvec4) FunctionCall 17(@main()
+                              Store 62(@entryPointOutput) 63
                               Return
                               FunctionEnd
-17(osCall(struct-OS-p1-f1-t211;):   12(fvec4) Function None 13
-        14(s.ss):      7(ptr) FunctionParameter
-         15(s.a):      9(ptr) FunctionParameter
-       16(s.tex):     11(ptr) FunctionParameter
-              18:             Label
-              22:    8(float) Load 15(s.a)
-              23:          10 Load 16(s.tex)
-              24:           6 Load 14(s.ss)
-              26:          25 SampledImage 23 24
-              31:   12(fvec4) ImageSampleImplicitLod 26 30
-              32:   12(fvec4) VectorTimesScalar 31 22
-                              ReturnValue 32
+14(osCall(struct-OS-p1-f1-t211;):   11(fvec4) Function None 12
+           13(s):     10(ptr) FunctionParameter
+              15:             Label
+              22:     21(ptr) AccessChain 13(s) 20
+              23:    7(float) Load 22
+              26:     25(ptr) AccessChain 13(s) 24
+              27:           8 Load 26
+              30:     29(ptr) AccessChain 13(s) 28
+              31:           6 Load 30
+              33:          32 SampledImage 27 31
+              38:   11(fvec4) ImageSampleImplicitLod 33 37
+              39:   11(fvec4) VectorTimesScalar 38 23
+                              ReturnValue 39
                               FunctionEnd
-      20(@main():   12(fvec4) Function None 19
-              21:             Label
-       35(os.ss):      7(ptr) Variable Function
-      41(os.tex):     11(ptr) Variable Function
-        45(os.a):      9(ptr) Variable Function
-       47(param):      7(ptr) Variable Function
-       49(param):      9(ptr) Variable Function
-       51(param):     11(ptr) Variable Function
-              38:           6 Load 37(gss2)
-                              Store 35(os.ss) 38
-              40:           6 Load 39(gss)
-                              Store 35(os.ss) 40
-              44:          10 Load 43(gtex)
-                              Store 41(os.tex) 44
-                              Store 45(os.a) 46
-              48:           6 Load 35(os.ss)
-                              Store 47(param) 48
-              50:    8(float) Load 45(os.a)
-                              Store 49(param) 50
-              52:          10 Load 41(os.tex)
-                              Store 51(param) 52
-              53:   12(fvec4) FunctionCall 17(osCall(struct-OS-p1-f1-t211;) 47(param) 49(param) 51(param)
-                              ReturnValue 53
+      17(@main():   11(fvec4) Function None 16
+              18:             Label
+          42(os):     10(ptr) Variable Function
+       56(param):     10(ptr) Variable Function
+              45:           6 Load 44(gss2)
+              46:     29(ptr) AccessChain 42(os) 28
+                              Store 46 45
+              48:           6 Load 47(gss)
+              49:     29(ptr) AccessChain 42(os) 28
+                              Store 49 48
+              52:           8 Load 51(gtex)
+              53:     25(ptr) AccessChain 42(os) 24
+                              Store 53 52
+              55:     21(ptr) AccessChain 42(os) 20
+                              Store 55 54
+              57:       9(OS) Load 42(os)
+                              Store 56(param) 57
+              58:   11(fvec4) FunctionCall 14(osCall(struct-OS-p1-f1-t211;) 56(param)
+                              ReturnValue 58
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.flattenOpaque.frag.out b/Test/baseResults/hlsl.flattenOpaque.frag.out
index 8eafba8e252db5a9a04d391779801e22c1c68061..1c653bd558a34b894fa662698861cb33dafe2371 100755
--- a/Test/baseResults/hlsl.flattenOpaque.frag.out
+++ b/Test/baseResults/hlsl.flattenOpaque.frag.out
@@ -1,54 +1,71 @@
 hlsl.flattenOpaque.frag
+WARNING: AST will form illegal SPIR-V; need to transform to legalize
 Shader version: 500
 gl_FragCoord origin is upper left
 0:? Sequence
 0:15  Function Definition: osCall1(struct-os-p11; ( temp 4-component vector of float)
 0:15    Function Parameters: 
-0:?       's.s2D' ( in sampler)
+0:15      's' ( in structure{ temp sampler s2D})
 0:?     Sequence
 0:16      Branch: Return with expression
 0:16        texture ( temp 4-component vector of float)
 0:16          Construct combined texture-sampler ( temp sampler2D)
 0:16            'tex' ( uniform texture2D)
-0:?             's.s2D' ( in sampler)
+0:16            s2D: direct index for structure ( temp sampler)
+0:16              's' ( in structure{ temp sampler s2D})
+0:16              Constant:
+0:16                0 (const int)
 0:?           Constant:
 0:?             0.200000
 0:?             0.300000
 0:20  Function Definition: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
 0:20    Function Parameters: 
-0:?       's.s2D' ( in sampler)
+0:20      's' ( in structure{ temp sampler s2D})
 0:20      'f2' ( in 2-component vector of float)
 0:?     Sequence
 0:21      Branch: Return with expression
 0:21        texture ( temp 4-component vector of float)
 0:21          Construct combined texture-sampler ( temp sampler2D)
 0:21            'tex' ( uniform texture2D)
-0:?             's.s2D' ( in sampler)
+0:21            s2D: direct index for structure ( temp sampler)
+0:21              's' ( in structure{ temp sampler s2D})
+0:21              Constant:
+0:21                0 (const int)
 0:21          'f2' ( in 2-component vector of float)
 0:25  Function Definition: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
 0:25    Function Parameters: 
-0:?       's.s2D' ( in sampler)
-0:?       's.tex' ( in texture2D)
+0:25      's' ( in structure{ temp sampler s2D,  temp texture2D tex})
 0:?     Sequence
 0:26      Branch: Return with expression
 0:26        texture ( temp 4-component vector of float)
 0:26          Construct combined texture-sampler ( temp sampler2D)
-0:?             's.tex' ( in texture2D)
-0:?             's.s2D' ( in sampler)
+0:26            tex: direct index for structure ( temp texture2D)
+0:26              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:26              Constant:
+0:26                1 (const int)
+0:26            s2D: direct index for structure ( temp sampler)
+0:26              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:26              Constant:
+0:26                0 (const int)
 0:?           Constant:
 0:?             0.200000
 0:?             0.300000
 0:30  Function Definition: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
 0:30    Function Parameters: 
-0:?       's.s2D' ( in sampler)
-0:?       's.tex' ( in texture2D)
+0:30      's' ( in structure{ temp sampler s2D,  temp texture2D tex})
 0:30      'f2' ( in 2-component vector of float)
 0:?     Sequence
 0:31      Branch: Return with expression
 0:31        texture ( temp 4-component vector of float)
 0:31          Construct combined texture-sampler ( temp sampler2D)
-0:?             's.tex' ( in texture2D)
-0:?             's.s2D' ( in sampler)
+0:31            tex: direct index for structure ( temp texture2D)
+0:31              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:31              Constant:
+0:31                1 (const int)
+0:31            s2D: direct index for structure ( temp sampler)
+0:31              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:31              Constant:
+0:31                0 (const int)
 0:31          'f2' ( in 2-component vector of float)
 0:35  Function Definition: @main( ( temp 4-component vector of float)
 0:35    Function Parameters: 
@@ -58,18 +75,60 @@ gl_FragCoord origin is upper left
 0:37          add ( temp 4-component vector of float)
 0:36            add ( temp 4-component vector of float)
 0:36              Function Call: osCall1(struct-os-p11; ( temp 4-component vector of float)
-0:?                 's.s2D' ( uniform sampler)
+0:36                Comma ( temp structure{ temp sampler s2D})
+0:36                  Sequence
+0:36                    move second child to first child ( temp sampler)
+0:36                      s2D: direct index for structure ( temp sampler)
+0:36                        'aggShadow' ( temp structure{ temp sampler s2D})
+0:36                        Constant:
+0:36                          0 (const int)
+0:?                       's.s2D' ( uniform sampler)
+0:36                  'aggShadow' ( temp structure{ temp sampler s2D})
 0:37              Function Call: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
-0:?                 's.s2D' ( uniform sampler)
+0:37                Comma ( temp structure{ temp sampler s2D})
+0:37                  Sequence
+0:37                    move second child to first child ( temp sampler)
+0:37                      s2D: direct index for structure ( temp sampler)
+0:37                        'aggShadow' ( temp structure{ temp sampler s2D})
+0:37                        Constant:
+0:37                          0 (const int)
+0:?                       's.s2D' ( uniform sampler)
+0:37                  'aggShadow' ( temp structure{ temp sampler s2D})
 0:?                 Constant:
 0:?                   0.200000
 0:?                   0.300000
 0:38            Function Call: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
-0:?               's2.s2D' ( uniform sampler)
-0:?               's2.tex' ( uniform texture2D)
+0:38              Comma ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                Sequence
+0:38                  move second child to first child ( temp sampler)
+0:38                    s2D: direct index for structure ( temp sampler)
+0:38                      'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                      Constant:
+0:38                        0 (const int)
+0:?                     's2.s2D' ( uniform sampler)
+0:38                  move second child to first child ( temp texture2D)
+0:38                    tex: direct index for structure ( temp texture2D)
+0:38                      'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                      Constant:
+0:38                        1 (const int)
+0:?                     's2.tex' ( uniform texture2D)
+0:38                'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
 0:39          Function Call: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
-0:?             's2.s2D' ( uniform sampler)
-0:?             's2.tex' ( uniform texture2D)
+0:39            Comma ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39              Sequence
+0:39                move second child to first child ( temp sampler)
+0:39                  s2D: direct index for structure ( temp sampler)
+0:39                    'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39                    Constant:
+0:39                      0 (const int)
+0:?                   's2.s2D' ( uniform sampler)
+0:39                move second child to first child ( temp texture2D)
+0:39                  tex: direct index for structure ( temp texture2D)
+0:39                    'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39                    Constant:
+0:39                      1 (const int)
+0:?                   's2.tex' ( uniform texture2D)
+0:39              'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
 0:?             Constant:
 0:?               0.200000
 0:?               0.300000
@@ -95,51 +154,67 @@ gl_FragCoord origin is upper left
 0:? Sequence
 0:15  Function Definition: osCall1(struct-os-p11; ( temp 4-component vector of float)
 0:15    Function Parameters: 
-0:?       's.s2D' ( in sampler)
+0:15      's' ( in structure{ temp sampler s2D})
 0:?     Sequence
 0:16      Branch: Return with expression
 0:16        texture ( temp 4-component vector of float)
 0:16          Construct combined texture-sampler ( temp sampler2D)
 0:16            'tex' ( uniform texture2D)
-0:?             's.s2D' ( in sampler)
+0:16            s2D: direct index for structure ( temp sampler)
+0:16              's' ( in structure{ temp sampler s2D})
+0:16              Constant:
+0:16                0 (const int)
 0:?           Constant:
 0:?             0.200000
 0:?             0.300000
 0:20  Function Definition: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
 0:20    Function Parameters: 
-0:?       's.s2D' ( in sampler)
+0:20      's' ( in structure{ temp sampler s2D})
 0:20      'f2' ( in 2-component vector of float)
 0:?     Sequence
 0:21      Branch: Return with expression
 0:21        texture ( temp 4-component vector of float)
 0:21          Construct combined texture-sampler ( temp sampler2D)
 0:21            'tex' ( uniform texture2D)
-0:?             's.s2D' ( in sampler)
+0:21            s2D: direct index for structure ( temp sampler)
+0:21              's' ( in structure{ temp sampler s2D})
+0:21              Constant:
+0:21                0 (const int)
 0:21          'f2' ( in 2-component vector of float)
 0:25  Function Definition: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
 0:25    Function Parameters: 
-0:?       's.s2D' ( in sampler)
-0:?       's.tex' ( in texture2D)
+0:25      's' ( in structure{ temp sampler s2D,  temp texture2D tex})
 0:?     Sequence
 0:26      Branch: Return with expression
 0:26        texture ( temp 4-component vector of float)
 0:26          Construct combined texture-sampler ( temp sampler2D)
-0:?             's.tex' ( in texture2D)
-0:?             's.s2D' ( in sampler)
+0:26            tex: direct index for structure ( temp texture2D)
+0:26              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:26              Constant:
+0:26                1 (const int)
+0:26            s2D: direct index for structure ( temp sampler)
+0:26              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:26              Constant:
+0:26                0 (const int)
 0:?           Constant:
 0:?             0.200000
 0:?             0.300000
 0:30  Function Definition: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
 0:30    Function Parameters: 
-0:?       's.s2D' ( in sampler)
-0:?       's.tex' ( in texture2D)
+0:30      's' ( in structure{ temp sampler s2D,  temp texture2D tex})
 0:30      'f2' ( in 2-component vector of float)
 0:?     Sequence
 0:31      Branch: Return with expression
 0:31        texture ( temp 4-component vector of float)
 0:31          Construct combined texture-sampler ( temp sampler2D)
-0:?             's.tex' ( in texture2D)
-0:?             's.s2D' ( in sampler)
+0:31            tex: direct index for structure ( temp texture2D)
+0:31              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:31              Constant:
+0:31                1 (const int)
+0:31            s2D: direct index for structure ( temp sampler)
+0:31              's' ( in structure{ temp sampler s2D,  temp texture2D tex})
+0:31              Constant:
+0:31                0 (const int)
 0:31          'f2' ( in 2-component vector of float)
 0:35  Function Definition: @main( ( temp 4-component vector of float)
 0:35    Function Parameters: 
@@ -149,18 +224,60 @@ gl_FragCoord origin is upper left
 0:37          add ( temp 4-component vector of float)
 0:36            add ( temp 4-component vector of float)
 0:36              Function Call: osCall1(struct-os-p11; ( temp 4-component vector of float)
-0:?                 's.s2D' ( uniform sampler)
+0:36                Comma ( temp structure{ temp sampler s2D})
+0:36                  Sequence
+0:36                    move second child to first child ( temp sampler)
+0:36                      s2D: direct index for structure ( temp sampler)
+0:36                        'aggShadow' ( temp structure{ temp sampler s2D})
+0:36                        Constant:
+0:36                          0 (const int)
+0:?                       's.s2D' ( uniform sampler)
+0:36                  'aggShadow' ( temp structure{ temp sampler s2D})
 0:37              Function Call: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
-0:?                 's.s2D' ( uniform sampler)
+0:37                Comma ( temp structure{ temp sampler s2D})
+0:37                  Sequence
+0:37                    move second child to first child ( temp sampler)
+0:37                      s2D: direct index for structure ( temp sampler)
+0:37                        'aggShadow' ( temp structure{ temp sampler s2D})
+0:37                        Constant:
+0:37                          0 (const int)
+0:?                       's.s2D' ( uniform sampler)
+0:37                  'aggShadow' ( temp structure{ temp sampler s2D})
 0:?                 Constant:
 0:?                   0.200000
 0:?                   0.300000
 0:38            Function Call: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
-0:?               's2.s2D' ( uniform sampler)
-0:?               's2.tex' ( uniform texture2D)
+0:38              Comma ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                Sequence
+0:38                  move second child to first child ( temp sampler)
+0:38                    s2D: direct index for structure ( temp sampler)
+0:38                      'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                      Constant:
+0:38                        0 (const int)
+0:?                     's2.s2D' ( uniform sampler)
+0:38                  move second child to first child ( temp texture2D)
+0:38                    tex: direct index for structure ( temp texture2D)
+0:38                      'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:38                      Constant:
+0:38                        1 (const int)
+0:?                     's2.tex' ( uniform texture2D)
+0:38                'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
 0:39          Function Call: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
-0:?             's2.s2D' ( uniform sampler)
-0:?             's2.tex' ( uniform texture2D)
+0:39            Comma ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39              Sequence
+0:39                move second child to first child ( temp sampler)
+0:39                  s2D: direct index for structure ( temp sampler)
+0:39                    'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39                    Constant:
+0:39                      0 (const int)
+0:?                   's2.s2D' ( uniform sampler)
+0:39                move second child to first child ( temp texture2D)
+0:39                  tex: direct index for structure ( temp texture2D)
+0:39                    'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
+0:39                    Constant:
+0:39                      1 (const int)
+0:?                   's2.tex' ( uniform texture2D)
+0:39              'aggShadow' ( temp structure{ temp sampler s2D,  temp texture2D tex})
 0:?             Constant:
 0:?               0.200000
 0:?               0.300000
@@ -179,151 +296,183 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 99
+// Id's are bound by 122
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 97
+                              EntryPoint Fragment 4  "main" 120
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
-                              Name 12  "osCall1(struct-os-p11;"
-                              Name 11  "s.s2D"
-                              Name 19  "osCall2(struct-os-p11;vf2;"
-                              Name 17  "s.s2D"
-                              Name 18  "f2"
-                              Name 26  "os2Call1(struct-os2-p1-t211;"
-                              Name 24  "s.s2D"
-                              Name 25  "s.tex"
+                              Name 7  "os"
+                              MemberName 7(os) 0  "s2D"
+                              Name 13  "osCall1(struct-os-p11;"
+                              Name 12  "s"
+                              Name 20  "osCall2(struct-os-p11;vf2;"
+                              Name 18  "s"
+                              Name 19  "f2"
+                              Name 23  "os2"
+                              MemberName 23(os2) 0  "s2D"
+                              MemberName 23(os2) 1  "tex"
+                              Name 27  "os2Call1(struct-os2-p1-t211;"
+                              Name 26  "s"
                               Name 32  "os2Call2(struct-os2-p1-t211;vf2;"
-                              Name 29  "s.s2D"
-                              Name 30  "s.tex"
+                              Name 30  "s"
                               Name 31  "f2"
                               Name 35  "@main("
                               Name 38  "tex"
-                              Name 70  "s.s2D"
-                              Name 71  "param"
-                              Name 74  "param"
-                              Name 76  "param"
-                              Name 79  "s2.s2D"
-                              Name 80  "s2.tex"
-                              Name 81  "param"
-                              Name 83  "param"
-                              Name 87  "param"
-                              Name 89  "param"
+                              Name 80  "aggShadow"
+                              Name 82  "s.s2D"
+                              Name 85  "param"
+                              Name 88  "aggShadow"
                               Name 91  "param"
-                              Name 97  "@entryPointOutput"
+                              Name 93  "param"
+                              Name 96  "aggShadow"
+                              Name 97  "s2.s2D"
+                              Name 100  "s2.tex"
+                              Name 103  "param"
+                              Name 107  "aggShadow"
+                              Name 112  "param"
+                              Name 114  "param"
+                              Name 120  "@entryPointOutput"
                               Decorate 38(tex) DescriptorSet 0
-                              Decorate 70(s.s2D) DescriptorSet 0
-                              Decorate 79(s2.s2D) DescriptorSet 0
-                              Decorate 80(s2.tex) DescriptorSet 0
-                              Decorate 97(@entryPointOutput) Location 0
+                              Decorate 82(s.s2D) DescriptorSet 0
+                              Decorate 97(s2.s2D) DescriptorSet 0
+                              Decorate 100(s2.tex) DescriptorSet 0
+                              Decorate 120(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               7:             TypePointer Function 6
-               8:             TypeFloat 32
-               9:             TypeVector 8(float) 4
-              10:             TypeFunction 9(fvec4) 7(ptr)
-              14:             TypeVector 8(float) 2
-              15:             TypePointer Function 14(fvec2)
-              16:             TypeFunction 9(fvec4) 7(ptr) 15(ptr)
-              21:             TypeImage 8(float) 2D sampled format:Unknown
-              22:             TypePointer Function 21
-              23:             TypeFunction 9(fvec4) 7(ptr) 22(ptr)
-              28:             TypeFunction 9(fvec4) 7(ptr) 22(ptr) 15(ptr)
-              34:             TypeFunction 9(fvec4)
-              37:             TypePointer UniformConstant 21
+           7(os):             TypeStruct 6
+               8:             TypePointer Function 7(os)
+               9:             TypeFloat 32
+              10:             TypeVector 9(float) 4
+              11:             TypeFunction 10(fvec4) 8(ptr)
+              15:             TypeVector 9(float) 2
+              16:             TypePointer Function 15(fvec2)
+              17:             TypeFunction 10(fvec4) 8(ptr) 16(ptr)
+              22:             TypeImage 9(float) 2D sampled format:Unknown
+         23(os2):             TypeStruct 6 22
+              24:             TypePointer Function 23(os2)
+              25:             TypeFunction 10(fvec4) 24(ptr)
+              29:             TypeFunction 10(fvec4) 24(ptr) 16(ptr)
+              34:             TypeFunction 10(fvec4)
+              37:             TypePointer UniformConstant 22
          38(tex):     37(ptr) Variable UniformConstant
-              41:             TypeSampledImage 21
-              43:    8(float) Constant 1045220557
-              44:    8(float) Constant 1050253722
-              45:   14(fvec2) ConstantComposite 43 44
-              69:             TypePointer UniformConstant 6
-       70(s.s2D):     69(ptr) Variable UniformConstant
-      79(s2.s2D):     69(ptr) Variable UniformConstant
-      80(s2.tex):     37(ptr) Variable UniformConstant
-              96:             TypePointer Output 9(fvec4)
-97(@entryPointOutput):     96(ptr) Variable Output
+              40:             TypeInt 32 1
+              41:     40(int) Constant 0
+              42:             TypePointer Function 6
+              45:             TypeSampledImage 22
+              47:    9(float) Constant 1045220557
+              48:    9(float) Constant 1050253722
+              49:   15(fvec2) ConstantComposite 47 48
+              61:     40(int) Constant 1
+              62:             TypePointer Function 22
+              81:             TypePointer UniformConstant 6
+       82(s.s2D):     81(ptr) Variable UniformConstant
+      97(s2.s2D):     81(ptr) Variable UniformConstant
+     100(s2.tex):     37(ptr) Variable UniformConstant
+             119:             TypePointer Output 10(fvec4)
+120(@entryPointOutput):    119(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              98:    9(fvec4) FunctionCall 35(@main()
-                              Store 97(@entryPointOutput) 98
+             121:   10(fvec4) FunctionCall 35(@main()
+                              Store 120(@entryPointOutput) 121
                               Return
                               FunctionEnd
-12(osCall1(struct-os-p11;):    9(fvec4) Function None 10
-       11(s.s2D):      7(ptr) FunctionParameter
-              13:             Label
-              39:          21 Load 38(tex)
-              40:           6 Load 11(s.s2D)
-              42:          41 SampledImage 39 40
-              46:    9(fvec4) ImageSampleImplicitLod 42 45
-                              ReturnValue 46
+13(osCall1(struct-os-p11;):   10(fvec4) Function None 11
+           12(s):      8(ptr) FunctionParameter
+              14:             Label
+              39:          22 Load 38(tex)
+              43:     42(ptr) AccessChain 12(s) 41
+              44:           6 Load 43
+              46:          45 SampledImage 39 44
+              50:   10(fvec4) ImageSampleImplicitLod 46 49
+                              ReturnValue 50
                               FunctionEnd
-19(osCall2(struct-os-p11;vf2;):    9(fvec4) Function None 16
-       17(s.s2D):      7(ptr) FunctionParameter
-          18(f2):     15(ptr) FunctionParameter
-              20:             Label
-              49:          21 Load 38(tex)
-              50:           6 Load 17(s.s2D)
-              51:          41 SampledImage 49 50
-              52:   14(fvec2) Load 18(f2)
-              53:    9(fvec4) ImageSampleImplicitLod 51 52
-                              ReturnValue 53
+20(osCall2(struct-os-p11;vf2;):   10(fvec4) Function None 17
+           18(s):      8(ptr) FunctionParameter
+          19(f2):     16(ptr) FunctionParameter
+              21:             Label
+              53:          22 Load 38(tex)
+              54:     42(ptr) AccessChain 18(s) 41
+              55:           6 Load 54
+              56:          45 SampledImage 53 55
+              57:   15(fvec2) Load 19(f2)
+              58:   10(fvec4) ImageSampleImplicitLod 56 57
+                              ReturnValue 58
                               FunctionEnd
-26(os2Call1(struct-os2-p1-t211;):    9(fvec4) Function None 23
-       24(s.s2D):      7(ptr) FunctionParameter
-       25(s.tex):     22(ptr) FunctionParameter
-              27:             Label
-              56:          21 Load 25(s.tex)
-              57:           6 Load 24(s.s2D)
-              58:          41 SampledImage 56 57
-              59:    9(fvec4) ImageSampleImplicitLod 58 45
-                              ReturnValue 59
+27(os2Call1(struct-os2-p1-t211;):   10(fvec4) Function None 25
+           26(s):     24(ptr) FunctionParameter
+              28:             Label
+              63:     62(ptr) AccessChain 26(s) 61
+              64:          22 Load 63
+              65:     42(ptr) AccessChain 26(s) 41
+              66:           6 Load 65
+              67:          45 SampledImage 64 66
+              68:   10(fvec4) ImageSampleImplicitLod 67 49
+                              ReturnValue 68
                               FunctionEnd
-32(os2Call2(struct-os2-p1-t211;vf2;):    9(fvec4) Function None 28
-       29(s.s2D):      7(ptr) FunctionParameter
-       30(s.tex):     22(ptr) FunctionParameter
-          31(f2):     15(ptr) FunctionParameter
+32(os2Call2(struct-os2-p1-t211;vf2;):   10(fvec4) Function None 29
+           30(s):     24(ptr) FunctionParameter
+          31(f2):     16(ptr) FunctionParameter
               33:             Label
-              62:          21 Load 30(s.tex)
-              63:           6 Load 29(s.s2D)
-              64:          41 SampledImage 62 63
-              65:   14(fvec2) Load 31(f2)
-              66:    9(fvec4) ImageSampleImplicitLod 64 65
-                              ReturnValue 66
+              71:     62(ptr) AccessChain 30(s) 61
+              72:          22 Load 71
+              73:     42(ptr) AccessChain 30(s) 41
+              74:           6 Load 73
+              75:          45 SampledImage 72 74
+              76:   15(fvec2) Load 31(f2)
+              77:   10(fvec4) ImageSampleImplicitLod 75 76
+                              ReturnValue 77
                               FunctionEnd
-      35(@main():    9(fvec4) Function None 34
+      35(@main():   10(fvec4) Function None 34
               36:             Label
-       71(param):      7(ptr) Variable Function
-       74(param):      7(ptr) Variable Function
-       76(param):     15(ptr) Variable Function
-       81(param):      7(ptr) Variable Function
-       83(param):     22(ptr) Variable Function
-       87(param):      7(ptr) Variable Function
-       89(param):     22(ptr) Variable Function
-       91(param):     15(ptr) Variable Function
-              72:           6 Load 70(s.s2D)
-                              Store 71(param) 72
-              73:    9(fvec4) FunctionCall 12(osCall1(struct-os-p11;) 71(param)
-              75:           6 Load 70(s.s2D)
-                              Store 74(param) 75
-                              Store 76(param) 45
-              77:    9(fvec4) FunctionCall 19(osCall2(struct-os-p11;vf2;) 74(param) 76(param)
-              78:    9(fvec4) FAdd 73 77
-              82:           6 Load 79(s2.s2D)
-                              Store 81(param) 82
-              84:          21 Load 80(s2.tex)
-                              Store 83(param) 84
-              85:    9(fvec4) FunctionCall 26(os2Call1(struct-os2-p1-t211;) 81(param) 83(param)
-              86:    9(fvec4) FAdd 78 85
-              88:           6 Load 79(s2.s2D)
-                              Store 87(param) 88
-              90:          21 Load 80(s2.tex)
-                              Store 89(param) 90
-                              Store 91(param) 45
-              92:    9(fvec4) FunctionCall 32(os2Call2(struct-os2-p1-t211;vf2;) 87(param) 89(param) 91(param)
-              93:    9(fvec4) FAdd 86 92
-                              ReturnValue 93
+   80(aggShadow):      8(ptr) Variable Function
+       85(param):      8(ptr) Variable Function
+   88(aggShadow):      8(ptr) Variable Function
+       91(param):      8(ptr) Variable Function
+       93(param):     16(ptr) Variable Function
+   96(aggShadow):     24(ptr) Variable Function
+      103(param):     24(ptr) Variable Function
+  107(aggShadow):     24(ptr) Variable Function
+      112(param):     24(ptr) Variable Function
+      114(param):     16(ptr) Variable Function
+              83:           6 Load 82(s.s2D)
+              84:     42(ptr) AccessChain 80(aggShadow) 41
+                              Store 84 83
+              86:       7(os) Load 80(aggShadow)
+                              Store 85(param) 86
+              87:   10(fvec4) FunctionCall 13(osCall1(struct-os-p11;) 85(param)
+              89:           6 Load 82(s.s2D)
+              90:     42(ptr) AccessChain 88(aggShadow) 41
+                              Store 90 89
+              92:       7(os) Load 88(aggShadow)
+                              Store 91(param) 92
+                              Store 93(param) 49
+              94:   10(fvec4) FunctionCall 20(osCall2(struct-os-p11;vf2;) 91(param) 93(param)
+              95:   10(fvec4) FAdd 87 94
+              98:           6 Load 97(s2.s2D)
+              99:     42(ptr) AccessChain 96(aggShadow) 41
+                              Store 99 98
+             101:          22 Load 100(s2.tex)
+             102:     62(ptr) AccessChain 96(aggShadow) 61
+                              Store 102 101
+             104:     23(os2) Load 96(aggShadow)
+                              Store 103(param) 104
+             105:   10(fvec4) FunctionCall 27(os2Call1(struct-os2-p1-t211;) 103(param)
+             106:   10(fvec4) FAdd 95 105
+             108:           6 Load 97(s2.s2D)
+             109:     42(ptr) AccessChain 107(aggShadow) 41
+                              Store 109 108
+             110:          22 Load 100(s2.tex)
+             111:     62(ptr) AccessChain 107(aggShadow) 61
+                              Store 111 110
+             113:     23(os2) Load 107(aggShadow)
+                              Store 112(param) 113
+                              Store 114(param) 49
+             115:   10(fvec4) FunctionCall 32(os2Call2(struct-os2-p1-t211;vf2;) 112(param) 114(param)
+             116:   10(fvec4) FAdd 106 115
+                              ReturnValue 116
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.flattenOpaqueInit.vert.out b/Test/baseResults/hlsl.flattenOpaqueInit.vert.out
index b5fac95d18ce5db865d02a5360e01eae8c253a1d..a97cfd60ac8f6c7870c1101fc5f26a81d6ab60d8 100755
--- a/Test/baseResults/hlsl.flattenOpaqueInit.vert.out
+++ b/Test/baseResults/hlsl.flattenOpaqueInit.vert.out
@@ -4,14 +4,19 @@ Shader version: 500
 0:? Sequence
 0:5  Function Definition: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
 0:5    Function Parameters: 
-0:?       'tex.smpl' ( in sampler)
-0:?       'tex.tex' ( in texture2D)
+0:5      'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
 0:?     Sequence
 0:6      Branch: Return with expression
 0:6        texture ( temp 4-component vector of float)
 0:6          Construct combined texture-sampler ( temp sampler2D)
-0:?             'tex.tex' ( in texture2D)
-0:?             'tex.smpl' ( in sampler)
+0:6            tex: direct index for structure ( temp texture2D)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
+0:6              Constant:
+0:6                1 (const int)
+0:6            smpl: direct index for structure ( temp sampler)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
+0:6              Constant:
+0:6                0 (const int)
 0:?           Constant:
 0:?             0.300000
 0:?             0.400000
@@ -19,10 +24,16 @@ Shader version: 500
 0:10    Function Parameters: 
 0:?     Sequence
 0:12      move second child to first child ( temp sampler)
-0:?         't.smpl' ( temp sampler)
+0:12        smpl: direct index for structure ( temp sampler)
+0:12          't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:12          Constant:
+0:12            0 (const int)
 0:12        'g_tInputTexture_sampler' ( uniform sampler)
 0:13      move second child to first child ( temp texture2D)
-0:?         't.tex' ( temp texture2D)
+0:13        tex: direct index for structure ( temp texture2D)
+0:13          't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:13          Constant:
+0:13            1 (const int)
 0:13        'g_tInputTexture' ( uniform texture2D)
 0:14      Branch: Return with expression
 0:14        't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
@@ -30,67 +41,34 @@ Shader version: 500
 0:18    Function Parameters: 
 0:?     Sequence
 0:19      Sequence
-0:19        Sequence
-0:19          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19            Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              'g_tInputTexture_sampler' ( uniform sampler)
-0:19              'g_tInputTexture' ( uniform texture2D)
-0:19          move second child to first child ( temp sampler)
-0:?             'tex1.smpl' ( temp sampler)
-0:19            smpl: direct index for structure ( temp sampler)
-0:19              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              Constant:
-0:19                0 (const int)
-0:19          move second child to first child ( temp texture2D)
-0:?             'tex1.tex' ( temp texture2D)
-0:19            tex: direct index for structure ( temp texture2D)
-0:19              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              Constant:
-0:19                1 (const int)
+0:19        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19          'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19          Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19            'g_tInputTexture_sampler' ( uniform sampler)
+0:19            'g_tInputTexture' ( uniform texture2D)
 0:20      Sequence
 0:20        move second child to first child ( temp 4-component vector of float)
 0:20          'res' ( temp 4-component vector of float)
 0:20          Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?             'tex1.smpl' ( temp sampler)
-0:?             'tex1.tex' ( temp texture2D)
+0:20            'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:21      Sequence
-0:21        Sequence
-0:21          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21            Function Call: fillOpaque( ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21          move second child to first child ( temp sampler)
-0:?             'tex2.smpl' ( temp sampler)
-0:21            smpl: direct index for structure ( temp sampler)
-0:21              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21              Constant:
-0:21                0 (const int)
-0:21          move second child to first child ( temp texture2D)
-0:?             'tex2.tex' ( temp texture2D)
-0:21            tex: direct index for structure ( temp texture2D)
-0:21              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21              Constant:
-0:21                1 (const int)
+0:21        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:21          'tex2' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:21          Function Call: fillOpaque( ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:22      add second child into first child ( temp 4-component vector of float)
 0:22        'res' ( temp 4-component vector of float)
 0:22        Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?           'tex2.smpl' ( temp sampler)
-0:?           'tex2.tex' ( temp texture2D)
+0:22          'tex2' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:23      Sequence
-0:23        Sequence
-0:23          move second child to first child ( temp sampler)
-0:?             'tex3.smpl' ( temp sampler)
-0:?             'tex1.smpl' ( temp sampler)
-0:23          move second child to first child ( temp texture2D)
-0:?             'tex3.tex' ( temp texture2D)
-0:?             'tex1.tex' ( temp texture2D)
+0:23        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:23          'tex3' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:23          'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:24      add second child into first child ( temp 4-component vector of float)
 0:24        'res' ( temp 4-component vector of float)
 0:24        Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?           'tex3.smpl' ( temp sampler)
-0:?           'tex3.tex' ( temp texture2D)
-0:25      Branch: Return with expression
-0:25        'res' ( temp 4-component vector of float)
+0:24          'tex3' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:26      Branch: Return with expression
+0:26        'res' ( temp 4-component vector of float)
 0:18  Function Definition: main( ( temp void)
 0:18    Function Parameters: 
 0:?     Sequence
@@ -110,14 +88,19 @@ Shader version: 500
 0:? Sequence
 0:5  Function Definition: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
 0:5    Function Parameters: 
-0:?       'tex.smpl' ( in sampler)
-0:?       'tex.tex' ( in texture2D)
+0:5      'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
 0:?     Sequence
 0:6      Branch: Return with expression
 0:6        texture ( temp 4-component vector of float)
 0:6          Construct combined texture-sampler ( temp sampler2D)
-0:?             'tex.tex' ( in texture2D)
-0:?             'tex.smpl' ( in sampler)
+0:6            tex: direct index for structure ( temp texture2D)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
+0:6              Constant:
+0:6                1 (const int)
+0:6            smpl: direct index for structure ( temp sampler)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex})
+0:6              Constant:
+0:6                0 (const int)
 0:?           Constant:
 0:?             0.300000
 0:?             0.400000
@@ -125,10 +108,16 @@ Shader version: 500
 0:10    Function Parameters: 
 0:?     Sequence
 0:12      move second child to first child ( temp sampler)
-0:?         't.smpl' ( temp sampler)
+0:12        smpl: direct index for structure ( temp sampler)
+0:12          't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:12          Constant:
+0:12            0 (const int)
 0:12        'g_tInputTexture_sampler' ( uniform sampler)
 0:13      move second child to first child ( temp texture2D)
-0:?         't.tex' ( temp texture2D)
+0:13        tex: direct index for structure ( temp texture2D)
+0:13          't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:13          Constant:
+0:13            1 (const int)
 0:13        'g_tInputTexture' ( uniform texture2D)
 0:14      Branch: Return with expression
 0:14        't' ( temp structure{ temp sampler smpl,  temp texture2D tex})
@@ -136,67 +125,34 @@ Shader version: 500
 0:18    Function Parameters: 
 0:?     Sequence
 0:19      Sequence
-0:19        Sequence
-0:19          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19            Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              'g_tInputTexture_sampler' ( uniform sampler)
-0:19              'g_tInputTexture' ( uniform texture2D)
-0:19          move second child to first child ( temp sampler)
-0:?             'tex1.smpl' ( temp sampler)
-0:19            smpl: direct index for structure ( temp sampler)
-0:19              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              Constant:
-0:19                0 (const int)
-0:19          move second child to first child ( temp texture2D)
-0:?             'tex1.tex' ( temp texture2D)
-0:19            tex: direct index for structure ( temp texture2D)
-0:19              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:19              Constant:
-0:19                1 (const int)
+0:19        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19          'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19          Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:19            'g_tInputTexture_sampler' ( uniform sampler)
+0:19            'g_tInputTexture' ( uniform texture2D)
 0:20      Sequence
 0:20        move second child to first child ( temp 4-component vector of float)
 0:20          'res' ( temp 4-component vector of float)
 0:20          Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?             'tex1.smpl' ( temp sampler)
-0:?             'tex1.tex' ( temp texture2D)
+0:20            'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:21      Sequence
-0:21        Sequence
-0:21          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21            Function Call: fillOpaque( ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21          move second child to first child ( temp sampler)
-0:?             'tex2.smpl' ( temp sampler)
-0:21            smpl: direct index for structure ( temp sampler)
-0:21              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21              Constant:
-0:21                0 (const int)
-0:21          move second child to first child ( temp texture2D)
-0:?             'tex2.tex' ( temp texture2D)
-0:21            tex: direct index for structure ( temp texture2D)
-0:21              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex})
-0:21              Constant:
-0:21                1 (const int)
+0:21        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:21          'tex2' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:21          Function Call: fillOpaque( ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:22      add second child into first child ( temp 4-component vector of float)
 0:22        'res' ( temp 4-component vector of float)
 0:22        Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?           'tex2.smpl' ( temp sampler)
-0:?           'tex2.tex' ( temp texture2D)
+0:22          'tex2' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:23      Sequence
-0:23        Sequence
-0:23          move second child to first child ( temp sampler)
-0:?             'tex3.smpl' ( temp sampler)
-0:?             'tex1.smpl' ( temp sampler)
-0:23          move second child to first child ( temp texture2D)
-0:?             'tex3.tex' ( temp texture2D)
-0:?             'tex1.tex' ( temp texture2D)
+0:23        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:23          'tex3' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:23          'tex1' ( temp structure{ temp sampler smpl,  temp texture2D tex})
 0:24      add second child into first child ( temp 4-component vector of float)
 0:24        'res' ( temp 4-component vector of float)
 0:24        Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float)
-0:?           'tex3.smpl' ( temp sampler)
-0:?           'tex3.tex' ( temp texture2D)
-0:25      Branch: Return with expression
-0:25        'res' ( temp 4-component vector of float)
+0:24          'tex3' ( temp structure{ temp sampler smpl,  temp texture2D tex})
+0:26      Branch: Return with expression
+0:26        'res' ( temp 4-component vector of float)
 0:18  Function Definition: main( ( temp void)
 0:18    Function Parameters: 
 0:?     Sequence
@@ -210,164 +166,126 @@ Shader version: 500
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 101
+// Id's are bound by 82
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 99
+                              EntryPoint Vertex 4  "main" 80
                               Source HLSL 500
                               Name 4  "main"
-                              Name 15  "lookUp(struct-FxaaTex-p1-t211;"
-                              Name 13  "tex.smpl"
-                              Name 14  "tex.tex"
-                              Name 17  "FxaaTex"
-                              MemberName 17(FxaaTex) 0  "smpl"
-                              MemberName 17(FxaaTex) 1  "tex"
-                              Name 19  "fillOpaque("
-                              Name 22  "@main("
-                              Name 36  "t.smpl"
-                              Name 38  "g_tInputTexture_sampler"
-                              Name 40  "t.tex"
-                              Name 42  "g_tInputTexture"
-                              Name 45  "t"
-                              Name 49  "flattenTemp"
-                              Name 53  "tex1.smpl"
-                              Name 58  "tex1.tex"
-                              Name 63  "res"
+                              Name 9  "FxaaTex"
+                              MemberName 9(FxaaTex) 0  "smpl"
+                              MemberName 9(FxaaTex) 1  "tex"
+                              Name 14  "lookUp(struct-FxaaTex-p1-t211;"
+                              Name 13  "tex"
+                              Name 17  "fillOpaque("
+                              Name 20  "@main("
+                              Name 41  "t"
+                              Name 43  "g_tInputTexture_sampler"
+                              Name 47  "g_tInputTexture"
+                              Name 53  "tex1"
+                              Name 58  "res"
+                              Name 59  "param"
+                              Name 62  "tex2"
                               Name 64  "param"
-                              Name 66  "param"
-                              Name 69  "flattenTemp"
-                              Name 71  "tex2.smpl"
-                              Name 74  "tex2.tex"
-                              Name 77  "param"
-                              Name 79  "param"
-                              Name 84  "tex3.smpl"
-                              Name 86  "tex3.tex"
-                              Name 88  "param"
-                              Name 90  "param"
-                              Name 99  "@entryPointOutput"
-                              Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
-                              Decorate 42(g_tInputTexture) DescriptorSet 0
-                              Decorate 99(@entryPointOutput) Location 0
+                              Name 69  "tex3"
+                              Name 71  "param"
+                              Name 80  "@entryPointOutput"
+                              Decorate 43(g_tInputTexture_sampler) DescriptorSet 0
+                              Decorate 47(g_tInputTexture) DescriptorSet 0
+                              Decorate 80(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               7:             TypePointer Function 6
-               8:             TypeFloat 32
-               9:             TypeImage 8(float) 2D sampled format:Unknown
-              10:             TypePointer Function 9
-              11:             TypeVector 8(float) 4
-              12:             TypeFunction 11(fvec4) 7(ptr) 10(ptr)
-     17(FxaaTex):             TypeStruct 6 9
-              18:             TypeFunction 17(FxaaTex)
-              21:             TypeFunction 11(fvec4)
-              26:             TypeSampledImage 9
-              28:             TypeVector 8(float) 2
-              29:    8(float) Constant 1050253722
-              30:    8(float) Constant 1053609165
-              31:   28(fvec2) ConstantComposite 29 30
-              32:    8(float) Constant 0
-              37:             TypePointer UniformConstant 6
-38(g_tInputTexture_sampler):     37(ptr) Variable UniformConstant
-              41:             TypePointer UniformConstant 9
-42(g_tInputTexture):     41(ptr) Variable UniformConstant
-              44:             TypePointer Function 17(FxaaTex)
-              54:             TypeInt 32 1
-              55:     54(int) Constant 0
-              59:     54(int) Constant 1
-              62:             TypePointer Function 11(fvec4)
-              98:             TypePointer Output 11(fvec4)
-99(@entryPointOutput):     98(ptr) Variable Output
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+      9(FxaaTex):             TypeStruct 6 8
+              10:             TypePointer Function 9(FxaaTex)
+              11:             TypeVector 7(float) 4
+              12:             TypeFunction 11(fvec4) 10(ptr)
+              16:             TypeFunction 9(FxaaTex)
+              19:             TypeFunction 11(fvec4)
+              22:             TypeInt 32 1
+              23:     22(int) Constant 1
+              24:             TypePointer Function 8
+              27:     22(int) Constant 0
+              28:             TypePointer Function 6
+              31:             TypeSampledImage 8
+              33:             TypeVector 7(float) 2
+              34:    7(float) Constant 1050253722
+              35:    7(float) Constant 1053609165
+              36:   33(fvec2) ConstantComposite 34 35
+              37:    7(float) Constant 0
+              42:             TypePointer UniformConstant 6
+43(g_tInputTexture_sampler):     42(ptr) Variable UniformConstant
+              46:             TypePointer UniformConstant 8
+47(g_tInputTexture):     46(ptr) Variable UniformConstant
+              57:             TypePointer Function 11(fvec4)
+              79:             TypePointer Output 11(fvec4)
+80(@entryPointOutput):     79(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-             100:   11(fvec4) FunctionCall 22(@main()
-                              Store 99(@entryPointOutput) 100
+              81:   11(fvec4) FunctionCall 20(@main()
+                              Store 80(@entryPointOutput) 81
                               Return
                               FunctionEnd
-15(lookUp(struct-FxaaTex-p1-t211;):   11(fvec4) Function None 12
-    13(tex.smpl):      7(ptr) FunctionParameter
-     14(tex.tex):     10(ptr) FunctionParameter
-              16:             Label
-              24:           9 Load 14(tex.tex)
-              25:           6 Load 13(tex.smpl)
-              27:          26 SampledImage 24 25
-              33:   11(fvec4) ImageSampleExplicitLod 27 31 Lod 32
-                              ReturnValue 33
+14(lookUp(struct-FxaaTex-p1-t211;):   11(fvec4) Function None 12
+         13(tex):     10(ptr) FunctionParameter
+              15:             Label
+              25:     24(ptr) AccessChain 13(tex) 23
+              26:           8 Load 25
+              29:     28(ptr) AccessChain 13(tex) 27
+              30:           6 Load 29
+              32:          31 SampledImage 26 30
+              38:   11(fvec4) ImageSampleExplicitLod 32 36 Lod 37
+                              ReturnValue 38
                               FunctionEnd
- 19(fillOpaque(): 17(FxaaTex) Function None 18
-              20:             Label
-      36(t.smpl):      7(ptr) Variable Function
-       40(t.tex):     10(ptr) Variable Function
-           45(t):     44(ptr) Variable Function
-              39:           6 Load 38(g_tInputTexture_sampler)
-                              Store 36(t.smpl) 39
-              43:           9 Load 42(g_tInputTexture)
-                              Store 40(t.tex) 43
-              46: 17(FxaaTex) Load 45(t)
-                              ReturnValue 46
+ 17(fillOpaque():  9(FxaaTex) Function None 16
+              18:             Label
+           41(t):     10(ptr) Variable Function
+              44:           6 Load 43(g_tInputTexture_sampler)
+              45:     28(ptr) AccessChain 41(t) 27
+                              Store 45 44
+              48:           8 Load 47(g_tInputTexture)
+              49:     24(ptr) AccessChain 41(t) 23
+                              Store 49 48
+              50:  9(FxaaTex) Load 41(t)
+                              ReturnValue 50
                               FunctionEnd
-      22(@main():   11(fvec4) Function None 21
-              23:             Label
- 49(flattenTemp):     44(ptr) Variable Function
-   53(tex1.smpl):      7(ptr) Variable Function
-    58(tex1.tex):     10(ptr) Variable Function
-         63(res):     62(ptr) Variable Function
-       64(param):      7(ptr) Variable Function
-       66(param):     10(ptr) Variable Function
- 69(flattenTemp):     44(ptr) Variable Function
-   71(tex2.smpl):      7(ptr) Variable Function
-    74(tex2.tex):     10(ptr) Variable Function
-       77(param):      7(ptr) Variable Function
-       79(param):     10(ptr) Variable Function
-   84(tex3.smpl):      7(ptr) Variable Function
-    86(tex3.tex):     10(ptr) Variable Function
-       88(param):      7(ptr) Variable Function
-       90(param):     10(ptr) Variable Function
-              50:           6 Load 38(g_tInputTexture_sampler)
-              51:           9 Load 42(g_tInputTexture)
-              52: 17(FxaaTex) CompositeConstruct 50 51
-                              Store 49(flattenTemp) 52
-              56:      7(ptr) AccessChain 49(flattenTemp) 55
-              57:           6 Load 56
-                              Store 53(tex1.smpl) 57
-              60:     10(ptr) AccessChain 49(flattenTemp) 59
-              61:           9 Load 60
-                              Store 58(tex1.tex) 61
-              65:           6 Load 53(tex1.smpl)
+      20(@main():   11(fvec4) Function None 19
+              21:             Label
+        53(tex1):     10(ptr) Variable Function
+         58(res):     57(ptr) Variable Function
+       59(param):     10(ptr) Variable Function
+        62(tex2):     10(ptr) Variable Function
+       64(param):     10(ptr) Variable Function
+        69(tex3):     10(ptr) Variable Function
+       71(param):     10(ptr) Variable Function
+              54:           6 Load 43(g_tInputTexture_sampler)
+              55:           8 Load 47(g_tInputTexture)
+              56:  9(FxaaTex) CompositeConstruct 54 55
+                              Store 53(tex1) 56
+              60:  9(FxaaTex) Load 53(tex1)
+                              Store 59(param) 60
+              61:   11(fvec4) FunctionCall 14(lookUp(struct-FxaaTex-p1-t211;) 59(param)
+                              Store 58(res) 61
+              63:  9(FxaaTex) FunctionCall 17(fillOpaque()
+                              Store 62(tex2) 63
+              65:  9(FxaaTex) Load 62(tex2)
                               Store 64(param) 65
-              67:           9 Load 58(tex1.tex)
-                              Store 66(param) 67
-              68:   11(fvec4) FunctionCall 15(lookUp(struct-FxaaTex-p1-t211;) 64(param) 66(param)
-                              Store 63(res) 68
-              70: 17(FxaaTex) FunctionCall 19(fillOpaque()
-                              Store 69(flattenTemp) 70
-              72:      7(ptr) AccessChain 69(flattenTemp) 55
-              73:           6 Load 72
-                              Store 71(tex2.smpl) 73
-              75:     10(ptr) AccessChain 69(flattenTemp) 59
-              76:           9 Load 75
-                              Store 74(tex2.tex) 76
-              78:           6 Load 71(tex2.smpl)
-                              Store 77(param) 78
-              80:           9 Load 74(tex2.tex)
-                              Store 79(param) 80
-              81:   11(fvec4) FunctionCall 15(lookUp(struct-FxaaTex-p1-t211;) 77(param) 79(param)
-              82:   11(fvec4) Load 63(res)
-              83:   11(fvec4) FAdd 82 81
-                              Store 63(res) 83
-              85:           6 Load 53(tex1.smpl)
-                              Store 84(tex3.smpl) 85
-              87:           9 Load 58(tex1.tex)
-                              Store 86(tex3.tex) 87
-              89:           6 Load 84(tex3.smpl)
-                              Store 88(param) 89
-              91:           9 Load 86(tex3.tex)
-                              Store 90(param) 91
-              92:   11(fvec4) FunctionCall 15(lookUp(struct-FxaaTex-p1-t211;) 88(param) 90(param)
-              93:   11(fvec4) Load 63(res)
-              94:   11(fvec4) FAdd 93 92
-                              Store 63(res) 94
-              95:   11(fvec4) Load 63(res)
-                              ReturnValue 95
+              66:   11(fvec4) FunctionCall 14(lookUp(struct-FxaaTex-p1-t211;) 64(param)
+              67:   11(fvec4) Load 58(res)
+              68:   11(fvec4) FAdd 67 66
+                              Store 58(res) 68
+              70:  9(FxaaTex) Load 53(tex1)
+                              Store 69(tex3) 70
+              72:  9(FxaaTex) Load 69(tex3)
+                              Store 71(param) 72
+              73:   11(fvec4) FunctionCall 14(lookUp(struct-FxaaTex-p1-t211;) 71(param)
+              74:   11(fvec4) Load 58(res)
+              75:   11(fvec4) FAdd 74 73
+                              Store 58(res) 75
+              76:   11(fvec4) Load 58(res)
+                              ReturnValue 76
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out b/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out
index 2de34838fd406b4618259d429886f8be3ef3ecba..1e96f20760f3d036dda840d63d0a128d178fdce9 100755
--- a/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out
+++ b/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out
@@ -4,53 +4,42 @@ Shader version: 500
 0:? Sequence
 0:5  Function Definition: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float)
 0:5    Function Parameters: 
-0:?       'tex.smpl' ( in sampler)
-0:?       'tex.tex' ( in texture2D)
-0:?       'tex.f' ( in float)
+0:5      'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
 0:?     Sequence
 0:6      Branch: Return with expression
 0:6        texture ( temp 4-component vector of float)
 0:6          Construct combined texture-sampler ( temp sampler2D)
-0:?             'tex.tex' ( in texture2D)
-0:?             'tex.smpl' ( in sampler)
+0:6            tex: direct index for structure ( temp texture2D)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                1 (const int)
+0:6            smpl: direct index for structure ( temp sampler)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                0 (const int)
 0:?           Construct vec2 ( temp 2-component vector of float)
-0:?             'tex.f' ( in float)
-0:?             'tex.f' ( in float)
+0:6            f: direct index for structure ( temp float)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                2 (const int)
+0:6            f: direct index for structure ( temp float)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                2 (const int)
 0:10  Function Definition: @main( ( temp 4-component vector of float)
 0:10    Function Parameters: 
 0:?     Sequence
 0:11      Sequence
-0:11        Sequence
-0:11          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11            Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              'g_tInputTexture_sampler' ( uniform sampler)
-0:11              'g_tInputTexture' ( uniform texture2D)
-0:11              Constant:
-0:11                0.500000
-0:11          move second child to first child ( temp sampler)
-0:?             'tex.smpl' ( temp sampler)
-0:11            smpl: direct index for structure ( temp sampler)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                0 (const int)
-0:11          move second child to first child ( temp texture2D)
-0:?             'tex.tex' ( temp texture2D)
-0:11            tex: direct index for structure ( temp texture2D)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                1 (const int)
-0:11          move second child to first child ( temp float)
-0:?             'tex.f' ( temp float)
-0:11            f: direct index for structure ( temp float)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                2 (const int)
+0:11        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11          'tex' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11          Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11            'g_tInputTexture_sampler' ( uniform sampler)
+0:11            'g_tInputTexture' ( uniform texture2D)
+0:11            Constant:
+0:11              0.500000
 0:12      Branch: Return with expression
 0:12        Function Call: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float)
-0:?           'tex.smpl' ( temp sampler)
-0:?           'tex.tex' ( temp texture2D)
-0:?           'tex.f' ( temp float)
+0:12          'tex' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
 0:10  Function Definition: main( ( temp void)
 0:10    Function Parameters: 
 0:?     Sequence
@@ -70,53 +59,42 @@ Shader version: 500
 0:? Sequence
 0:5  Function Definition: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float)
 0:5    Function Parameters: 
-0:?       'tex.smpl' ( in sampler)
-0:?       'tex.tex' ( in texture2D)
-0:?       'tex.f' ( in float)
+0:5      'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
 0:?     Sequence
 0:6      Branch: Return with expression
 0:6        texture ( temp 4-component vector of float)
 0:6          Construct combined texture-sampler ( temp sampler2D)
-0:?             'tex.tex' ( in texture2D)
-0:?             'tex.smpl' ( in sampler)
+0:6            tex: direct index for structure ( temp texture2D)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                1 (const int)
+0:6            smpl: direct index for structure ( temp sampler)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                0 (const int)
 0:?           Construct vec2 ( temp 2-component vector of float)
-0:?             'tex.f' ( in float)
-0:?             'tex.f' ( in float)
+0:6            f: direct index for structure ( temp float)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                2 (const int)
+0:6            f: direct index for structure ( temp float)
+0:6              'tex' ( in structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:6              Constant:
+0:6                2 (const int)
 0:10  Function Definition: @main( ( temp 4-component vector of float)
 0:10    Function Parameters: 
 0:?     Sequence
 0:11      Sequence
-0:11        Sequence
-0:11          move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11            'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11            Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              'g_tInputTexture_sampler' ( uniform sampler)
-0:11              'g_tInputTexture' ( uniform texture2D)
-0:11              Constant:
-0:11                0.500000
-0:11          move second child to first child ( temp sampler)
-0:?             'tex.smpl' ( temp sampler)
-0:11            smpl: direct index for structure ( temp sampler)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                0 (const int)
-0:11          move second child to first child ( temp texture2D)
-0:?             'tex.tex' ( temp texture2D)
-0:11            tex: direct index for structure ( temp texture2D)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                1 (const int)
-0:11          move second child to first child ( temp float)
-0:?             'tex.f' ( temp float)
-0:11            f: direct index for structure ( temp float)
-0:11              'flattenTemp' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
-0:11              Constant:
-0:11                2 (const int)
+0:11        move second child to first child ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11          'tex' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11          Construct structure ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
+0:11            'g_tInputTexture_sampler' ( uniform sampler)
+0:11            'g_tInputTexture' ( uniform texture2D)
+0:11            Constant:
+0:11              0.500000
 0:12      Branch: Return with expression
 0:12        Function Call: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float)
-0:?           'tex.smpl' ( temp sampler)
-0:?           'tex.tex' ( temp texture2D)
-0:?           'tex.f' ( temp float)
+0:12          'tex' ( temp structure{ temp sampler smpl,  temp texture2D tex,  temp float f})
 0:10  Function Definition: main( ( temp void)
 0:10    Function Parameters: 
 0:?     Sequence
@@ -130,111 +108,88 @@ Shader version: 500
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 70
+// Id's are bound by 59
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 68
+                              EntryPoint Vertex 4  "main" 57
                               Source HLSL 500
                               Name 4  "main"
-                              Name 17  "lookUp(struct-FxaaTex-p1-t21-f11;"
-                              Name 14  "tex.smpl"
-                              Name 15  "tex.tex"
-                              Name 16  "tex.f"
-                              Name 20  "@main("
-                              Name 34  "FxaaTex"
-                              MemberName 34(FxaaTex) 0  "smpl"
-                              MemberName 34(FxaaTex) 1  "tex"
-                              MemberName 34(FxaaTex) 2  "f"
-                              Name 36  "flattenTemp"
-                              Name 38  "g_tInputTexture_sampler"
-                              Name 41  "g_tInputTexture"
-                              Name 45  "tex.smpl"
-                              Name 50  "tex.tex"
-                              Name 54  "tex.f"
-                              Name 58  "param"
-                              Name 60  "param"
-                              Name 62  "param"
-                              Name 68  "@entryPointOutput"
-                              Decorate 38(g_tInputTexture_sampler) DescriptorSet 0
-                              Decorate 41(g_tInputTexture) DescriptorSet 0
-                              Decorate 68(@entryPointOutput) Location 0
+                              Name 9  "FxaaTex"
+                              MemberName 9(FxaaTex) 0  "smpl"
+                              MemberName 9(FxaaTex) 1  "tex"
+                              MemberName 9(FxaaTex) 2  "f"
+                              Name 14  "lookUp(struct-FxaaTex-p1-t21-f11;"
+                              Name 13  "tex"
+                              Name 17  "@main("
+                              Name 42  "tex"
+                              Name 44  "g_tInputTexture_sampler"
+                              Name 47  "g_tInputTexture"
+                              Name 51  "param"
+                              Name 57  "@entryPointOutput"
+                              Decorate 44(g_tInputTexture_sampler) DescriptorSet 0
+                              Decorate 47(g_tInputTexture) DescriptorSet 0
+                              Decorate 57(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeSampler
-               7:             TypePointer Function 6
-               8:             TypeFloat 32
-               9:             TypeImage 8(float) 2D sampled format:Unknown
-              10:             TypePointer Function 9
-              11:             TypePointer Function 8(float)
-              12:             TypeVector 8(float) 4
-              13:             TypeFunction 12(fvec4) 7(ptr) 10(ptr) 11(ptr)
-              19:             TypeFunction 12(fvec4)
-              24:             TypeSampledImage 9
-              28:             TypeVector 8(float) 2
-              30:    8(float) Constant 0
-     34(FxaaTex):             TypeStruct 6 9 8(float)
-              35:             TypePointer Function 34(FxaaTex)
-              37:             TypePointer UniformConstant 6
-38(g_tInputTexture_sampler):     37(ptr) Variable UniformConstant
-              40:             TypePointer UniformConstant 9
-41(g_tInputTexture):     40(ptr) Variable UniformConstant
-              43:    8(float) Constant 1056964608
-              46:             TypeInt 32 1
-              47:     46(int) Constant 0
-              51:     46(int) Constant 1
-              55:     46(int) Constant 2
-              67:             TypePointer Output 12(fvec4)
-68(@entryPointOutput):     67(ptr) Variable Output
+               7:             TypeFloat 32
+               8:             TypeImage 7(float) 2D sampled format:Unknown
+      9(FxaaTex):             TypeStruct 6 8 7(float)
+              10:             TypePointer Function 9(FxaaTex)
+              11:             TypeVector 7(float) 4
+              12:             TypeFunction 11(fvec4) 10(ptr)
+              16:             TypeFunction 11(fvec4)
+              19:             TypeInt 32 1
+              20:     19(int) Constant 1
+              21:             TypePointer Function 8
+              24:     19(int) Constant 0
+              25:             TypePointer Function 6
+              28:             TypeSampledImage 8
+              30:     19(int) Constant 2
+              31:             TypePointer Function 7(float)
+              36:             TypeVector 7(float) 2
+              38:    7(float) Constant 0
+              43:             TypePointer UniformConstant 6
+44(g_tInputTexture_sampler):     43(ptr) Variable UniformConstant
+              46:             TypePointer UniformConstant 8
+47(g_tInputTexture):     46(ptr) Variable UniformConstant
+              49:    7(float) Constant 1056964608
+              56:             TypePointer Output 11(fvec4)
+57(@entryPointOutput):     56(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              69:   12(fvec4) FunctionCall 20(@main()
-                              Store 68(@entryPointOutput) 69
+              58:   11(fvec4) FunctionCall 17(@main()
+                              Store 57(@entryPointOutput) 58
                               Return
                               FunctionEnd
-17(lookUp(struct-FxaaTex-p1-t21-f11;):   12(fvec4) Function None 13
-    14(tex.smpl):      7(ptr) FunctionParameter
-     15(tex.tex):     10(ptr) FunctionParameter
-       16(tex.f):     11(ptr) FunctionParameter
-              18:             Label
-              22:           9 Load 15(tex.tex)
-              23:           6 Load 14(tex.smpl)
-              25:          24 SampledImage 22 23
-              26:    8(float) Load 16(tex.f)
-              27:    8(float) Load 16(tex.f)
-              29:   28(fvec2) CompositeConstruct 26 27
-              31:   12(fvec4) ImageSampleExplicitLod 25 29 Lod 30
-                              ReturnValue 31
+14(lookUp(struct-FxaaTex-p1-t21-f11;):   11(fvec4) Function None 12
+         13(tex):     10(ptr) FunctionParameter
+              15:             Label
+              22:     21(ptr) AccessChain 13(tex) 20
+              23:           8 Load 22
+              26:     25(ptr) AccessChain 13(tex) 24
+              27:           6 Load 26
+              29:          28 SampledImage 23 27
+              32:     31(ptr) AccessChain 13(tex) 30
+              33:    7(float) Load 32
+              34:     31(ptr) AccessChain 13(tex) 30
+              35:    7(float) Load 34
+              37:   36(fvec2) CompositeConstruct 33 35
+              39:   11(fvec4) ImageSampleExplicitLod 29 37 Lod 38
+                              ReturnValue 39
                               FunctionEnd
-      20(@main():   12(fvec4) Function None 19
-              21:             Label
- 36(flattenTemp):     35(ptr) Variable Function
-    45(tex.smpl):      7(ptr) Variable Function
-     50(tex.tex):     10(ptr) Variable Function
-       54(tex.f):     11(ptr) Variable Function
-       58(param):      7(ptr) Variable Function
-       60(param):     10(ptr) Variable Function
-       62(param):     11(ptr) Variable Function
-              39:           6 Load 38(g_tInputTexture_sampler)
-              42:           9 Load 41(g_tInputTexture)
-              44: 34(FxaaTex) CompositeConstruct 39 42 43
-                              Store 36(flattenTemp) 44
-              48:      7(ptr) AccessChain 36(flattenTemp) 47
-              49:           6 Load 48
-                              Store 45(tex.smpl) 49
-              52:     10(ptr) AccessChain 36(flattenTemp) 51
-              53:           9 Load 52
-                              Store 50(tex.tex) 53
-              56:     11(ptr) AccessChain 36(flattenTemp) 55
-              57:    8(float) Load 56
-                              Store 54(tex.f) 57
-              59:           6 Load 45(tex.smpl)
-                              Store 58(param) 59
-              61:           9 Load 50(tex.tex)
-                              Store 60(param) 61
-              63:    8(float) Load 54(tex.f)
-                              Store 62(param) 63
-              64:   12(fvec4) FunctionCall 17(lookUp(struct-FxaaTex-p1-t21-f11;) 58(param) 60(param) 62(param)
-                              ReturnValue 64
+      17(@main():   11(fvec4) Function None 16
+              18:             Label
+         42(tex):     10(ptr) Variable Function
+       51(param):     10(ptr) Variable Function
+              45:           6 Load 44(g_tInputTexture_sampler)
+              48:           8 Load 47(g_tInputTexture)
+              50:  9(FxaaTex) CompositeConstruct 45 48 49
+                              Store 42(tex) 50
+              52:  9(FxaaTex) Load 42(tex)
+                              Store 51(param) 52
+              53:   11(fvec4) FunctionCall 14(lookUp(struct-FxaaTex-p1-t21-f11;) 51(param)
+                              ReturnValue 53
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.flattenSubset.frag.out b/Test/baseResults/hlsl.flattenSubset.frag.out
index f6d867fc34aac070be3b03c156a3da4454b700d9..f40a6d698bcf6caa4fe3c106302fdcc9498b48d0 100755
--- a/Test/baseResults/hlsl.flattenSubset.frag.out
+++ b/Test/baseResults/hlsl.flattenSubset.frag.out
@@ -8,32 +8,34 @@ gl_FragCoord origin is upper left
 0:30      'vpos' ( in 4-component vector of float)
 0:?     Sequence
 0:33      move second child to first child ( temp sampler)
-0:?         's1.s0.ss' ( temp sampler)
+0:33        ss: direct index for structure ( temp sampler)
+0:33          s0: direct index for structure ( temp structure{ temp int x,  temp int y,  temp sampler ss})
+0:33            's1' ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:33            Constant:
+0:33              2 (const int)
+0:33          Constant:
+0:33            2 (const int)
 0:33        'samp' ( uniform sampler)
-0:34      Sequence
-0:34        move second child to first child ( temp float)
-0:?           's2.resources.b' ( temp float)
-0:?           's1.b' ( temp float)
-0:34        move second child to first child ( temp sampler)
-0:?           's2.resources.samplerState' ( temp sampler)
-0:?           's1.samplerState' ( temp sampler)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.s0.x' ( temp int)
-0:?           's1.s0.x' ( temp int)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.s0.y' ( temp int)
-0:?           's1.s0.y' ( temp int)
-0:34        move second child to first child ( temp sampler)
-0:?           's2.resources.s0.ss' ( temp sampler)
-0:?           's1.s0.ss' ( temp sampler)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.a' ( temp int)
-0:?           's1.a' ( temp int)
+0:34      move second child to first child ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:34        resources: direct index for structure ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:34          's2' ( temp structure{ temp int a1,  temp int a2,  temp int a3,  temp int a4,  temp int a5,  temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a} resources})
+0:34          Constant:
+0:34            5 (const int)
+0:34        's1' ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
 0:35      Branch: Return with expression
 0:35        texture ( temp 4-component vector of float)
 0:35          Construct combined texture-sampler ( temp sampler2D)
 0:35            'tex' ( uniform texture2D)
-0:?             's2.resources.s0.ss' ( temp sampler)
+0:35            ss: direct index for structure ( temp sampler)
+0:35              s0: direct index for structure ( temp structure{ temp int x,  temp int y,  temp sampler ss})
+0:35                resources: direct index for structure ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:35                  's2' ( temp structure{ temp int a1,  temp int a2,  temp int a3,  temp int a4,  temp int a5,  temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a} resources})
+0:35                  Constant:
+0:35                    5 (const int)
+0:35                Constant:
+0:35                  2 (const int)
+0:35              Constant:
+0:35                2 (const int)
 0:35          Constant:
 0:35            0.500000
 0:35            0.500000
@@ -65,32 +67,34 @@ gl_FragCoord origin is upper left
 0:30      'vpos' ( in 4-component vector of float)
 0:?     Sequence
 0:33      move second child to first child ( temp sampler)
-0:?         's1.s0.ss' ( temp sampler)
+0:33        ss: direct index for structure ( temp sampler)
+0:33          s0: direct index for structure ( temp structure{ temp int x,  temp int y,  temp sampler ss})
+0:33            's1' ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:33            Constant:
+0:33              2 (const int)
+0:33          Constant:
+0:33            2 (const int)
 0:33        'samp' ( uniform sampler)
-0:34      Sequence
-0:34        move second child to first child ( temp float)
-0:?           's2.resources.b' ( temp float)
-0:?           's1.b' ( temp float)
-0:34        move second child to first child ( temp sampler)
-0:?           's2.resources.samplerState' ( temp sampler)
-0:?           's1.samplerState' ( temp sampler)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.s0.x' ( temp int)
-0:?           's1.s0.x' ( temp int)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.s0.y' ( temp int)
-0:?           's1.s0.y' ( temp int)
-0:34        move second child to first child ( temp sampler)
-0:?           's2.resources.s0.ss' ( temp sampler)
-0:?           's1.s0.ss' ( temp sampler)
-0:34        move second child to first child ( temp int)
-0:?           's2.resources.a' ( temp int)
-0:?           's1.a' ( temp int)
+0:34      move second child to first child ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:34        resources: direct index for structure ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:34          's2' ( temp structure{ temp int a1,  temp int a2,  temp int a3,  temp int a4,  temp int a5,  temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a} resources})
+0:34          Constant:
+0:34            5 (const int)
+0:34        's1' ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
 0:35      Branch: Return with expression
 0:35        texture ( temp 4-component vector of float)
 0:35          Construct combined texture-sampler ( temp sampler2D)
 0:35            'tex' ( uniform texture2D)
-0:?             's2.resources.s0.ss' ( temp sampler)
+0:35            ss: direct index for structure ( temp sampler)
+0:35              s0: direct index for structure ( temp structure{ temp int x,  temp int y,  temp sampler ss})
+0:35                resources: direct index for structure ( temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a})
+0:35                  's2' ( temp structure{ temp int a1,  temp int a2,  temp int a3,  temp int a4,  temp int a5,  temp structure{ temp float b,  temp sampler samplerState,  temp structure{ temp int x,  temp int y,  temp sampler ss} s0,  temp int a} resources})
+0:35                  Constant:
+0:35                    5 (const int)
+0:35                Constant:
+0:35                  2 (const int)
+0:35              Constant:
+0:35                2 (const int)
 0:35          Constant:
 0:35            0.500000
 0:35            0.500000
@@ -112,39 +116,45 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 61
+// Id's are bound by 54
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 54 57
+                              EntryPoint Fragment 4  "main" 47 50
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
                               Name 11  "@main(vf4;"
                               Name 10  "vpos"
-                              Name 15  "s1.s0.ss"
-                              Name 17  "samp"
-                              Name 20  "s2.resources.b"
-                              Name 21  "s1.b"
-                              Name 23  "s2.resources.samplerState"
-                              Name 24  "s1.samplerState"
-                              Name 28  "s2.resources.s0.x"
-                              Name 29  "s1.s0.x"
-                              Name 31  "s2.resources.s0.y"
-                              Name 32  "s1.s0.y"
-                              Name 34  "s2.resources.s0.ss"
-                              Name 36  "s2.resources.a"
-                              Name 37  "s1.a"
-                              Name 41  "tex"
-                              Name 52  "vpos"
-                              Name 54  "vpos"
-                              Name 57  "@entryPointOutput"
-                              Name 58  "param"
-                              Decorate 17(samp) DescriptorSet 0
-                              Decorate 41(tex) DescriptorSet 0
-                              Decorate 54(vpos) Location 0
-                              Decorate 57(@entryPointOutput) Location 0
+                              Name 15  "S0"
+                              MemberName 15(S0) 0  "x"
+                              MemberName 15(S0) 1  "y"
+                              MemberName 15(S0) 2  "ss"
+                              Name 16  "S1"
+                              MemberName 16(S1) 0  "b"
+                              MemberName 16(S1) 1  "samplerState"
+                              MemberName 16(S1) 2  "s0"
+                              MemberName 16(S1) 3  "a"
+                              Name 18  "s1"
+                              Name 21  "samp"
+                              Name 25  "S2"
+                              MemberName 25(S2) 0  "a1"
+                              MemberName 25(S2) 1  "a2"
+                              MemberName 25(S2) 2  "a3"
+                              MemberName 25(S2) 3  "a4"
+                              MemberName 25(S2) 4  "a5"
+                              MemberName 25(S2) 5  "resources"
+                              Name 27  "s2"
+                              Name 33  "tex"
+                              Name 45  "vpos"
+                              Name 47  "vpos"
+                              Name 50  "@entryPointOutput"
+                              Name 51  "param"
+                              Decorate 21(samp) DescriptorSet 0
+                              Decorate 33(tex) DescriptorSet 0
+                              Decorate 47(vpos) Location 0
+                              Decorate 50(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -152,67 +162,55 @@ gl_FragCoord origin is upper left
                8:             TypePointer Function 7(fvec4)
                9:             TypeFunction 7(fvec4) 8(ptr)
               13:             TypeSampler
-              14:             TypePointer Function 13
-              16:             TypePointer UniformConstant 13
-        17(samp):     16(ptr) Variable UniformConstant
-              19:             TypePointer Function 6(float)
-              26:             TypeInt 32 1
-              27:             TypePointer Function 26(int)
-              39:             TypeImage 6(float) 2D sampled format:Unknown
-              40:             TypePointer UniformConstant 39
-         41(tex):     40(ptr) Variable UniformConstant
-              44:             TypeSampledImage 39
-              46:             TypeVector 6(float) 2
-              47:    6(float) Constant 1056964608
-              48:   46(fvec2) ConstantComposite 47 47
-              53:             TypePointer Input 7(fvec4)
-        54(vpos):     53(ptr) Variable Input
-              56:             TypePointer Output 7(fvec4)
-57(@entryPointOutput):     56(ptr) Variable Output
+              14:             TypeInt 32 1
+          15(S0):             TypeStruct 14(int) 14(int) 13
+          16(S1):             TypeStruct 6(float) 13 15(S0) 14(int)
+              17:             TypePointer Function 16(S1)
+              19:     14(int) Constant 2
+              20:             TypePointer UniformConstant 13
+        21(samp):     20(ptr) Variable UniformConstant
+              23:             TypePointer Function 13
+          25(S2):             TypeStruct 14(int) 14(int) 14(int) 14(int) 14(int) 16(S1)
+              26:             TypePointer Function 25(S2)
+              28:     14(int) Constant 5
+              31:             TypeImage 6(float) 2D sampled format:Unknown
+              32:             TypePointer UniformConstant 31
+         33(tex):     32(ptr) Variable UniformConstant
+              37:             TypeSampledImage 31
+              39:             TypeVector 6(float) 2
+              40:    6(float) Constant 1056964608
+              41:   39(fvec2) ConstantComposite 40 40
+              46:             TypePointer Input 7(fvec4)
+        47(vpos):     46(ptr) Variable Input
+              49:             TypePointer Output 7(fvec4)
+50(@entryPointOutput):     49(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-        52(vpos):      8(ptr) Variable Function
-       58(param):      8(ptr) Variable Function
-              55:    7(fvec4) Load 54(vpos)
-                              Store 52(vpos) 55
-              59:    7(fvec4) Load 52(vpos)
-                              Store 58(param) 59
-              60:    7(fvec4) FunctionCall 11(@main(vf4;) 58(param)
-                              Store 57(@entryPointOutput) 60
+        45(vpos):      8(ptr) Variable Function
+       51(param):      8(ptr) Variable Function
+              48:    7(fvec4) Load 47(vpos)
+                              Store 45(vpos) 48
+              52:    7(fvec4) Load 45(vpos)
+                              Store 51(param) 52
+              53:    7(fvec4) FunctionCall 11(@main(vf4;) 51(param)
+                              Store 50(@entryPointOutput) 53
                               Return
                               FunctionEnd
   11(@main(vf4;):    7(fvec4) Function None 9
         10(vpos):      8(ptr) FunctionParameter
               12:             Label
-    15(s1.s0.ss):     14(ptr) Variable Function
-20(s2.resources.b):     19(ptr) Variable Function
-        21(s1.b):     19(ptr) Variable Function
-23(s2.resources.samplerState):     14(ptr) Variable Function
-24(s1.samplerState):     14(ptr) Variable Function
-28(s2.resources.s0.x):     27(ptr) Variable Function
-     29(s1.s0.x):     27(ptr) Variable Function
-31(s2.resources.s0.y):     27(ptr) Variable Function
-     32(s1.s0.y):     27(ptr) Variable Function
-34(s2.resources.s0.ss):     14(ptr) Variable Function
-36(s2.resources.a):     27(ptr) Variable Function
-        37(s1.a):     27(ptr) Variable Function
-              18:          13 Load 17(samp)
-                              Store 15(s1.s0.ss) 18
-              22:    6(float) Load 21(s1.b)
-                              Store 20(s2.resources.b) 22
-              25:          13 Load 24(s1.samplerState)
-                              Store 23(s2.resources.samplerState) 25
-              30:     26(int) Load 29(s1.s0.x)
-                              Store 28(s2.resources.s0.x) 30
-              33:     26(int) Load 32(s1.s0.y)
-                              Store 31(s2.resources.s0.y) 33
-              35:          13 Load 15(s1.s0.ss)
-                              Store 34(s2.resources.s0.ss) 35
-              38:     26(int) Load 37(s1.a)
-                              Store 36(s2.resources.a) 38
-              42:          39 Load 41(tex)
-              43:          13 Load 34(s2.resources.s0.ss)
-              45:          44 SampledImage 42 43
-              49:    7(fvec4) ImageSampleImplicitLod 45 48
-                              ReturnValue 49
+          18(s1):     17(ptr) Variable Function
+          27(s2):     26(ptr) Variable Function
+              22:          13 Load 21(samp)
+              24:     23(ptr) AccessChain 18(s1) 19 19
+                              Store 24 22
+              29:      16(S1) Load 18(s1)
+              30:     17(ptr) AccessChain 27(s2) 28
+                              Store 30 29
+              34:          31 Load 33(tex)
+              35:     23(ptr) AccessChain 27(s2) 28 19 19
+              36:          13 Load 35
+              38:          37 SampledImage 34 36
+              42:    7(fvec4) ImageSampleImplicitLod 38 41
+                              ReturnValue 42
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.flattenSubset2.frag.out b/Test/baseResults/hlsl.flattenSubset2.frag.out
index 4983834d6e438db3271a5fa67994ac4b36d26801..bddeae4925e738b3a05581dc6591cb0087fdcad6 100755
--- a/Test/baseResults/hlsl.flattenSubset2.frag.out
+++ b/Test/baseResults/hlsl.flattenSubset2.frag.out
@@ -7,33 +7,48 @@ gl_FragCoord origin is upper left
 0:8    Function Parameters: 
 0:8      'vpos' ( in 4-component vector of float)
 0:?     Sequence
-0:13      Sequence
-0:13        move second child to first child ( temp float)
-0:?           'a1.n.y' ( temp float)
-0:?           'a2.n.y' ( temp float)
-0:13        move second child to first child ( temp texture2D)
-0:?           'a1.n.texNested' ( temp texture2D)
-0:?           'a2.n.texNested' ( temp texture2D)
-0:14      Sequence
-0:14        move second child to first child ( temp float)
-0:?           'b.n.y' ( temp float)
-0:?           'a1.n.y' ( temp float)
-0:14        move second child to first child ( temp texture2D)
-0:?           'b.n.texNested' ( temp texture2D)
-0:?           'a1.n.texNested' ( temp texture2D)
+0:13      move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:13        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:13          'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:13          Constant:
+0:13            0 (const int)
+0:13        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:13          'a2' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:13          Constant:
+0:13            0 (const int)
+0:14      move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:14        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:14          'b' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp texture2D tex})
+0:14          Constant:
+0:14            0 (const int)
+0:14        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:14          'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:14          Constant:
+0:14            0 (const int)
 0:17      Sequence
-0:17        Sequence
-0:17          move second child to first child ( temp float)
-0:?             'n.y' ( temp float)
-0:?             'b.n.y' ( temp float)
-0:17          move second child to first child ( temp texture2D)
-0:?             'n.texNested' ( temp texture2D)
-0:?             'b.n.texNested' ( temp texture2D)
+0:17        move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:17          'n' ( temp structure{ temp float y,  temp texture2D texNested})
+0:17          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:17            'b' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp texture2D tex})
+0:17            Constant:
+0:17              0 (const int)
 0:20      move second child to first child ( temp texture2D)
-0:?         'a2.n.texNested' ( temp texture2D)
+0:20        texNested: direct index for structure ( temp texture2D)
+0:20          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:20            'a2' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:20            Constant:
+0:20              0 (const int)
+0:20          Constant:
+0:20            1 (const int)
 0:20        'someTex' ( uniform texture2D)
 0:21      move second child to first child ( temp float)
-0:?         'a1.n.y' ( temp float)
+0:21        y: direct index for structure ( temp float)
+0:21          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:21            'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:21            Constant:
+0:21              0 (const int)
+0:21          Constant:
+0:21            0 (const int)
 0:21        Constant:
 0:21          1.000000
 0:23      Branch: Return with expression
@@ -68,33 +83,48 @@ gl_FragCoord origin is upper left
 0:8    Function Parameters: 
 0:8      'vpos' ( in 4-component vector of float)
 0:?     Sequence
-0:13      Sequence
-0:13        move second child to first child ( temp float)
-0:?           'a1.n.y' ( temp float)
-0:?           'a2.n.y' ( temp float)
-0:13        move second child to first child ( temp texture2D)
-0:?           'a1.n.texNested' ( temp texture2D)
-0:?           'a2.n.texNested' ( temp texture2D)
-0:14      Sequence
-0:14        move second child to first child ( temp float)
-0:?           'b.n.y' ( temp float)
-0:?           'a1.n.y' ( temp float)
-0:14        move second child to first child ( temp texture2D)
-0:?           'b.n.texNested' ( temp texture2D)
-0:?           'a1.n.texNested' ( temp texture2D)
+0:13      move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:13        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:13          'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:13          Constant:
+0:13            0 (const int)
+0:13        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:13          'a2' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:13          Constant:
+0:13            0 (const int)
+0:14      move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:14        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:14          'b' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp texture2D tex})
+0:14          Constant:
+0:14            0 (const int)
+0:14        n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:14          'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:14          Constant:
+0:14            0 (const int)
 0:17      Sequence
-0:17        Sequence
-0:17          move second child to first child ( temp float)
-0:?             'n.y' ( temp float)
-0:?             'b.n.y' ( temp float)
-0:17          move second child to first child ( temp texture2D)
-0:?             'n.texNested' ( temp texture2D)
-0:?             'b.n.texNested' ( temp texture2D)
+0:17        move second child to first child ( temp structure{ temp float y,  temp texture2D texNested})
+0:17          'n' ( temp structure{ temp float y,  temp texture2D texNested})
+0:17          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:17            'b' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp texture2D tex})
+0:17            Constant:
+0:17              0 (const int)
 0:20      move second child to first child ( temp texture2D)
-0:?         'a2.n.texNested' ( temp texture2D)
+0:20        texNested: direct index for structure ( temp texture2D)
+0:20          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:20            'a2' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:20            Constant:
+0:20              0 (const int)
+0:20          Constant:
+0:20            1 (const int)
 0:20        'someTex' ( uniform texture2D)
 0:21      move second child to first child ( temp float)
-0:?         'a1.n.y' ( temp float)
+0:21        y: direct index for structure ( temp float)
+0:21          n: direct index for structure ( temp structure{ temp float y,  temp texture2D texNested})
+0:21            'a1' ( temp structure{ temp structure{ temp float y,  temp texture2D texNested} n,  temp float x})
+0:21            Constant:
+0:21              0 (const int)
+0:21          Constant:
+0:21            0 (const int)
 0:21        Constant:
 0:21          1.000000
 0:23      Branch: Return with expression
@@ -120,88 +150,99 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 47
+// Id's are bound by 56
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 40 43
+                              EntryPoint Fragment 4  "main" 49 52
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
                               Name 11  "@main(vf4;"
                               Name 10  "vpos"
-                              Name 14  "a1.n.y"
-                              Name 15  "a2.n.y"
-                              Name 19  "a1.n.texNested"
-                              Name 20  "a2.n.texNested"
-                              Name 22  "b.n.y"
-                              Name 24  "b.n.texNested"
-                              Name 26  "n.y"
-                              Name 28  "n.texNested"
-                              Name 31  "someTex"
-                              Name 38  "vpos"
-                              Name 40  "vpos"
-                              Name 43  "@entryPointOutput"
-                              Name 44  "param"
-                              Decorate 31(someTex) DescriptorSet 0
-                              Decorate 40(vpos) Location 0
-                              Decorate 43(@entryPointOutput) Location 0
+                              Name 14  "Nested"
+                              MemberName 14(Nested) 0  "y"
+                              MemberName 14(Nested) 1  "texNested"
+                              Name 15  "A"
+                              MemberName 15(A) 0  "n"
+                              MemberName 15(A) 1  "x"
+                              Name 17  "a1"
+                              Name 20  "a2"
+                              Name 25  "B"
+                              MemberName 25(B) 0  "n"
+                              MemberName 25(B) 1  "tex"
+                              Name 27  "b"
+                              Name 31  "n"
+                              Name 36  "someTex"
+                              Name 47  "vpos"
+                              Name 49  "vpos"
+                              Name 52  "@entryPointOutput"
+                              Name 53  "param"
+                              Decorate 36(someTex) DescriptorSet 0
+                              Decorate 49(vpos) Location 0
+                              Decorate 52(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
                8:             TypePointer Function 7(fvec4)
                9:             TypeFunction 7(fvec4) 8(ptr)
-              13:             TypePointer Function 6(float)
-              17:             TypeImage 6(float) 2D sampled format:Unknown
-              18:             TypePointer Function 17
-              30:             TypePointer UniformConstant 17
-     31(someTex):     30(ptr) Variable UniformConstant
-              33:    6(float) Constant 1065353216
-              34:    6(float) Constant 0
-              35:    7(fvec4) ConstantComposite 34 34 34 34
-              39:             TypePointer Input 7(fvec4)
-        40(vpos):     39(ptr) Variable Input
-              42:             TypePointer Output 7(fvec4)
-43(@entryPointOutput):     42(ptr) Variable Output
+              13:             TypeImage 6(float) 2D sampled format:Unknown
+      14(Nested):             TypeStruct 6(float) 13
+           15(A):             TypeStruct 14(Nested) 6(float)
+              16:             TypePointer Function 15(A)
+              18:             TypeInt 32 1
+              19:     18(int) Constant 0
+              21:             TypePointer Function 14(Nested)
+           25(B):             TypeStruct 14(Nested) 13
+              26:             TypePointer Function 25(B)
+              34:     18(int) Constant 1
+              35:             TypePointer UniformConstant 13
+     36(someTex):     35(ptr) Variable UniformConstant
+              38:             TypePointer Function 13
+              40:    6(float) Constant 1065353216
+              41:             TypePointer Function 6(float)
+              43:    6(float) Constant 0
+              44:    7(fvec4) ConstantComposite 43 43 43 43
+              48:             TypePointer Input 7(fvec4)
+        49(vpos):     48(ptr) Variable Input
+              51:             TypePointer Output 7(fvec4)
+52(@entryPointOutput):     51(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-        38(vpos):      8(ptr) Variable Function
-       44(param):      8(ptr) Variable Function
-              41:    7(fvec4) Load 40(vpos)
-                              Store 38(vpos) 41
-              45:    7(fvec4) Load 38(vpos)
-                              Store 44(param) 45
-              46:    7(fvec4) FunctionCall 11(@main(vf4;) 44(param)
-                              Store 43(@entryPointOutput) 46
+        47(vpos):      8(ptr) Variable Function
+       53(param):      8(ptr) Variable Function
+              50:    7(fvec4) Load 49(vpos)
+                              Store 47(vpos) 50
+              54:    7(fvec4) Load 47(vpos)
+                              Store 53(param) 54
+              55:    7(fvec4) FunctionCall 11(@main(vf4;) 53(param)
+                              Store 52(@entryPointOutput) 55
                               Return
                               FunctionEnd
   11(@main(vf4;):    7(fvec4) Function None 9
         10(vpos):      8(ptr) FunctionParameter
               12:             Label
-      14(a1.n.y):     13(ptr) Variable Function
-      15(a2.n.y):     13(ptr) Variable Function
-19(a1.n.texNested):     18(ptr) Variable Function
-20(a2.n.texNested):     18(ptr) Variable Function
-       22(b.n.y):     13(ptr) Variable Function
-24(b.n.texNested):     18(ptr) Variable Function
-         26(n.y):     13(ptr) Variable Function
- 28(n.texNested):     18(ptr) Variable Function
-              16:    6(float) Load 15(a2.n.y)
-                              Store 14(a1.n.y) 16
-              21:          17 Load 20(a2.n.texNested)
-                              Store 19(a1.n.texNested) 21
-              23:    6(float) Load 14(a1.n.y)
-                              Store 22(b.n.y) 23
-              25:          17 Load 19(a1.n.texNested)
-                              Store 24(b.n.texNested) 25
-              27:    6(float) Load 22(b.n.y)
-                              Store 26(n.y) 27
-              29:          17 Load 24(b.n.texNested)
-                              Store 28(n.texNested) 29
-              32:          17 Load 31(someTex)
-                              Store 20(a2.n.texNested) 32
-                              Store 14(a1.n.y) 33
-                              ReturnValue 35
+          17(a1):     16(ptr) Variable Function
+          20(a2):     16(ptr) Variable Function
+           27(b):     26(ptr) Variable Function
+           31(n):     21(ptr) Variable Function
+              22:     21(ptr) AccessChain 20(a2) 19
+              23:  14(Nested) Load 22
+              24:     21(ptr) AccessChain 17(a1) 19
+                              Store 24 23
+              28:     21(ptr) AccessChain 17(a1) 19
+              29:  14(Nested) Load 28
+              30:     21(ptr) AccessChain 27(b) 19
+                              Store 30 29
+              32:     21(ptr) AccessChain 27(b) 19
+              33:  14(Nested) Load 32
+                              Store 31(n) 33
+              37:          13 Load 36(someTex)
+              39:     38(ptr) AccessChain 20(a2) 19 34
+                              Store 39 37
+              42:     41(ptr) AccessChain 17(a1) 19 19
+                              Store 42 40
+                              ReturnValue 44
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.partialFlattenLocal.vert.out b/Test/baseResults/hlsl.partialFlattenLocal.vert.out
index 7847c088c547ce145ede581554b75c33f9153ac1..236a6ca2112c5d6b89e6fe811a7e949d45ddd73f 100755
--- a/Test/baseResults/hlsl.partialFlattenLocal.vert.out
+++ b/Test/baseResults/hlsl.partialFlattenLocal.vert.out
@@ -7,11 +7,17 @@ Shader version: 500
 0:12      'pos' ( in 4-component vector of float)
 0:?     Sequence
 0:14      move second child to first child ( temp texture2D)
-0:?         'packed.tex' ( temp texture2D)
+0:14        tex: direct index for structure ( temp texture2D)
+0:14          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:14          Constant:
+0:14            0 (const int)
 0:14        'tex' ( uniform texture2D)
 0:15      move second child to first child ( temp 3-component vector of float)
 0:15        direct index ( temp 3-component vector of float)
-0:?           'packed.pos' ( temp 3-element array of 3-component vector of float)
+0:15          pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:15            'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:15            Constant:
+0:15              1 (const int)
 0:15          Constant:
 0:15            0 (const int)
 0:?         Constant:
@@ -20,18 +26,27 @@ Shader version: 500
 0:?           0.000000
 0:16      move second child to first child ( temp 2-component vector of float)
 0:16        direct index ( temp 2-component vector of float)
-0:?           'packed.uv' ( temp 2-element array of 2-component vector of float)
+0:16          uv: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:16            'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:16            Constant:
+0:16              2 (const int)
 0:16          Constant:
 0:16            0 (const int)
 0:?         Constant:
 0:?           0.000000
 0:?           1.000000
 0:17      move second child to first child ( temp float)
-0:?         'packed.x' ( temp float)
+0:17        x: direct index for structure ( temp float)
+0:17          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:17          Constant:
+0:17            3 (const int)
 0:17        Constant:
 0:17          1.000000
 0:18      move second child to first child ( temp int)
-0:?         'packed.n' ( temp int)
+0:18        n: direct index for structure ( temp int)
+0:18          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:18          Constant:
+0:18            4 (const int)
 0:18        Constant:
 0:18          3 (const int)
 0:20      Sequence
@@ -50,7 +65,10 @@ Shader version: 500
 0:21            add second child into first child ( temp 2-component vector of float)
 0:21              vector swizzle ( temp 2-component vector of float)
 0:21                indirect index ( temp 3-component vector of float)
-0:?                   'packed.pos' ( temp 3-element array of 3-component vector of float)
+0:21                  pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:21                    'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:21                    Constant:
+0:21                      1 (const int)
 0:21                  'i' ( temp int)
 0:21                Sequence
 0:21                  Constant:
@@ -58,34 +76,27 @@ Shader version: 500
 0:21                  Constant:
 0:21                    1 (const int)
 0:21              indirect index ( temp 2-component vector of float)
-0:?                 'packed.uv' ( temp 2-element array of 2-component vector of float)
+0:21                uv: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:21                  'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:21                  Constant:
+0:21                    2 (const int)
 0:21                'i' ( temp int)
 0:20          Loop Terminal Expression
 0:20          Pre-Increment ( temp int)
 0:20            'i' ( temp int)
 0:24      Sequence
-0:24        Sequence
-0:24          move second child to first child ( temp texture2D)
-0:?             'packed2.tex' ( temp texture2D)
-0:?             'packed.tex' ( temp texture2D)
-0:24          move second child to first child ( temp 3-element array of 3-component vector of float)
-0:?             'packed2.pos' ( temp 3-element array of 3-component vector of float)
-0:?             'packed.pos' ( temp 3-element array of 3-component vector of float)
-0:24          move second child to first child ( temp 2-element array of 2-component vector of float)
-0:?             'packed2.uv' ( temp 2-element array of 2-component vector of float)
-0:?             'packed.uv' ( temp 2-element array of 2-component vector of float)
-0:24          move second child to first child ( temp float)
-0:?             'packed2.x' ( temp float)
-0:?             'packed.x' ( temp float)
-0:24          move second child to first child ( temp int)
-0:?             'packed2.n' ( temp int)
-0:?             'packed.n' ( temp int)
+0:24        move second child to first child ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:24          'packed2' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:24          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
 0:26      Branch: Return with expression
 0:26        add ( temp 4-component vector of float)
 0:26          'pos' ( in 4-component vector of float)
 0:?           Construct vec4 ( temp 4-component vector of float)
 0:26            direct index ( temp 3-component vector of float)
-0:?               'packed2.pos' ( temp 3-element array of 3-component vector of float)
+0:26              pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:26                'packed2' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:26                Constant:
+0:26                  1 (const int)
 0:26              Constant:
 0:26                0 (const int)
 0:26            Constant:
@@ -116,11 +127,17 @@ Shader version: 500
 0:12      'pos' ( in 4-component vector of float)
 0:?     Sequence
 0:14      move second child to first child ( temp texture2D)
-0:?         'packed.tex' ( temp texture2D)
+0:14        tex: direct index for structure ( temp texture2D)
+0:14          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:14          Constant:
+0:14            0 (const int)
 0:14        'tex' ( uniform texture2D)
 0:15      move second child to first child ( temp 3-component vector of float)
 0:15        direct index ( temp 3-component vector of float)
-0:?           'packed.pos' ( temp 3-element array of 3-component vector of float)
+0:15          pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:15            'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:15            Constant:
+0:15              1 (const int)
 0:15          Constant:
 0:15            0 (const int)
 0:?         Constant:
@@ -129,18 +146,27 @@ Shader version: 500
 0:?           0.000000
 0:16      move second child to first child ( temp 2-component vector of float)
 0:16        direct index ( temp 2-component vector of float)
-0:?           'packed.uv' ( temp 2-element array of 2-component vector of float)
+0:16          uv: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:16            'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:16            Constant:
+0:16              2 (const int)
 0:16          Constant:
 0:16            0 (const int)
 0:?         Constant:
 0:?           0.000000
 0:?           1.000000
 0:17      move second child to first child ( temp float)
-0:?         'packed.x' ( temp float)
+0:17        x: direct index for structure ( temp float)
+0:17          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:17          Constant:
+0:17            3 (const int)
 0:17        Constant:
 0:17          1.000000
 0:18      move second child to first child ( temp int)
-0:?         'packed.n' ( temp int)
+0:18        n: direct index for structure ( temp int)
+0:18          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:18          Constant:
+0:18            4 (const int)
 0:18        Constant:
 0:18          3 (const int)
 0:20      Sequence
@@ -159,7 +185,10 @@ Shader version: 500
 0:21            add second child into first child ( temp 2-component vector of float)
 0:21              vector swizzle ( temp 2-component vector of float)
 0:21                indirect index ( temp 3-component vector of float)
-0:?                   'packed.pos' ( temp 3-element array of 3-component vector of float)
+0:21                  pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:21                    'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:21                    Constant:
+0:21                      1 (const int)
 0:21                  'i' ( temp int)
 0:21                Sequence
 0:21                  Constant:
@@ -167,34 +196,27 @@ Shader version: 500
 0:21                  Constant:
 0:21                    1 (const int)
 0:21              indirect index ( temp 2-component vector of float)
-0:?                 'packed.uv' ( temp 2-element array of 2-component vector of float)
+0:21                uv: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:21                  'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:21                  Constant:
+0:21                    2 (const int)
 0:21                'i' ( temp int)
 0:20          Loop Terminal Expression
 0:20          Pre-Increment ( temp int)
 0:20            'i' ( temp int)
 0:24      Sequence
-0:24        Sequence
-0:24          move second child to first child ( temp texture2D)
-0:?             'packed2.tex' ( temp texture2D)
-0:?             'packed.tex' ( temp texture2D)
-0:24          move second child to first child ( temp 3-element array of 3-component vector of float)
-0:?             'packed2.pos' ( temp 3-element array of 3-component vector of float)
-0:?             'packed.pos' ( temp 3-element array of 3-component vector of float)
-0:24          move second child to first child ( temp 2-element array of 2-component vector of float)
-0:?             'packed2.uv' ( temp 2-element array of 2-component vector of float)
-0:?             'packed.uv' ( temp 2-element array of 2-component vector of float)
-0:24          move second child to first child ( temp float)
-0:?             'packed2.x' ( temp float)
-0:?             'packed.x' ( temp float)
-0:24          move second child to first child ( temp int)
-0:?             'packed2.n' ( temp int)
-0:?             'packed.n' ( temp int)
+0:24        move second child to first child ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:24          'packed2' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:24          'packed' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
 0:26      Branch: Return with expression
 0:26        add ( temp 4-component vector of float)
 0:26          'pos' ( in 4-component vector of float)
 0:?           Construct vec4 ( temp 4-component vector of float)
 0:26            direct index ( temp 3-component vector of float)
-0:?               'packed2.pos' ( temp 3-element array of 3-component vector of float)
+0:26              pos: direct index for structure ( temp 3-element array of 3-component vector of float)
+0:26                'packed2' ( temp structure{ temp texture2D tex,  temp 3-element array of 3-component vector of float pos,  temp 2-element array of 2-component vector of float uv,  temp float x,  temp int n})
+0:26                Constant:
+0:26                  1 (const int)
 0:26              Constant:
 0:26                0 (const int)
 0:26            Constant:
@@ -216,35 +238,33 @@ Shader version: 500
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 97
+// Id's are bound by 90
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 90 93
+                              EntryPoint Vertex 4  "main" 83 86
                               Source HLSL 500
                               Name 4  "main"
                               Name 11  "@main(vf4;"
                               Name 10  "pos"
-                              Name 15  "packed.tex"
-                              Name 17  "tex"
-                              Name 24  "packed.pos"
-                              Name 35  "packed.uv"
-                              Name 41  "packed.x"
-                              Name 43  "packed.n"
-                              Name 45  "i"
-                              Name 68  "packed2.tex"
-                              Name 70  "packed2.pos"
-                              Name 72  "packed2.uv"
-                              Name 74  "packed2.x"
-                              Name 76  "packed2.n"
-                              Name 88  "pos"
-                              Name 90  "pos"
-                              Name 93  "@entryPointOutput"
-                              Name 94  "param"
-                              Decorate 17(tex) DescriptorSet 0
-                              Decorate 90(pos) Location 0
-                              Decorate 93(@entryPointOutput) BuiltIn Position
+                              Name 22  "Packed"
+                              MemberName 22(Packed) 0  "tex"
+                              MemberName 22(Packed) 1  "pos"
+                              MemberName 22(Packed) 2  "uv"
+                              MemberName 22(Packed) 3  "x"
+                              MemberName 22(Packed) 4  "n"
+                              Name 24  "packed"
+                              Name 27  "tex"
+                              Name 47  "i"
+                              Name 69  "packed2"
+                              Name 81  "pos"
+                              Name 83  "pos"
+                              Name 86  "@entryPointOutput"
+                              Name 87  "param"
+                              Decorate 27(tex) DescriptorSet 0
+                              Decorate 83(pos) Location 0
+                              Decorate 86(@entryPointOutput) BuiltIn Position
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -252,115 +272,104 @@ Shader version: 500
                8:             TypePointer Function 7(fvec4)
                9:             TypeFunction 7(fvec4) 8(ptr)
               13:             TypeImage 6(float) 2D sampled format:Unknown
-              14:             TypePointer Function 13
-              16:             TypePointer UniformConstant 13
-         17(tex):     16(ptr) Variable UniformConstant
-              19:             TypeVector 6(float) 3
-              20:             TypeInt 32 0
-              21:     20(int) Constant 3
-              22:             TypeArray 19(fvec3) 21
-              23:             TypePointer Function 22
-              25:             TypeInt 32 1
-              26:     25(int) Constant 0
-              27:    6(float) Constant 0
-              28:   19(fvec3) ConstantComposite 27 27 27
-              29:             TypePointer Function 19(fvec3)
-              31:             TypeVector 6(float) 2
-              32:     20(int) Constant 2
-              33:             TypeArray 31(fvec2) 32
-              34:             TypePointer Function 33
-              36:    6(float) Constant 1065353216
-              37:   31(fvec2) ConstantComposite 27 36
-              38:             TypePointer Function 31(fvec2)
-              40:             TypePointer Function 6(float)
-              42:             TypePointer Function 25(int)
-              44:     25(int) Constant 3
-              52:     25(int) Constant 1
-              53:             TypeBool
-              89:             TypePointer Input 7(fvec4)
-         90(pos):     89(ptr) Variable Input
-              92:             TypePointer Output 7(fvec4)
-93(@entryPointOutput):     92(ptr) Variable Output
+              14:             TypeVector 6(float) 3
+              15:             TypeInt 32 0
+              16:     15(int) Constant 3
+              17:             TypeArray 14(fvec3) 16
+              18:             TypeVector 6(float) 2
+              19:     15(int) Constant 2
+              20:             TypeArray 18(fvec2) 19
+              21:             TypeInt 32 1
+      22(Packed):             TypeStruct 13 17 20 6(float) 21(int)
+              23:             TypePointer Function 22(Packed)
+              25:     21(int) Constant 0
+              26:             TypePointer UniformConstant 13
+         27(tex):     26(ptr) Variable UniformConstant
+              29:             TypePointer Function 13
+              31:     21(int) Constant 1
+              32:    6(float) Constant 0
+              33:   14(fvec3) ConstantComposite 32 32 32
+              34:             TypePointer Function 14(fvec3)
+              36:     21(int) Constant 2
+              37:    6(float) Constant 1065353216
+              38:   18(fvec2) ConstantComposite 32 37
+              39:             TypePointer Function 18(fvec2)
+              41:     21(int) Constant 3
+              42:             TypePointer Function 6(float)
+              44:     21(int) Constant 4
+              45:             TypePointer Function 21(int)
+              54:             TypeBool
+              82:             TypePointer Input 7(fvec4)
+         83(pos):     82(ptr) Variable Input
+              85:             TypePointer Output 7(fvec4)
+86(@entryPointOutput):     85(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-         88(pos):      8(ptr) Variable Function
-       94(param):      8(ptr) Variable Function
-              91:    7(fvec4) Load 90(pos)
-                              Store 88(pos) 91
-              95:    7(fvec4) Load 88(pos)
-                              Store 94(param) 95
-              96:    7(fvec4) FunctionCall 11(@main(vf4;) 94(param)
-                              Store 93(@entryPointOutput) 96
+         81(pos):      8(ptr) Variable Function
+       87(param):      8(ptr) Variable Function
+              84:    7(fvec4) Load 83(pos)
+                              Store 81(pos) 84
+              88:    7(fvec4) Load 81(pos)
+                              Store 87(param) 88
+              89:    7(fvec4) FunctionCall 11(@main(vf4;) 87(param)
+                              Store 86(@entryPointOutput) 89
                               Return
                               FunctionEnd
   11(@main(vf4;):    7(fvec4) Function None 9
          10(pos):      8(ptr) FunctionParameter
               12:             Label
-  15(packed.tex):     14(ptr) Variable Function
-  24(packed.pos):     23(ptr) Variable Function
-   35(packed.uv):     34(ptr) Variable Function
-    41(packed.x):     40(ptr) Variable Function
-    43(packed.n):     42(ptr) Variable Function
-           45(i):     42(ptr) Variable Function
- 68(packed2.tex):     14(ptr) Variable Function
- 70(packed2.pos):     23(ptr) Variable Function
-  72(packed2.uv):     34(ptr) Variable Function
-   74(packed2.x):     40(ptr) Variable Function
-   76(packed2.n):     42(ptr) Variable Function
-              18:          13 Load 17(tex)
-                              Store 15(packed.tex) 18
-              30:     29(ptr) AccessChain 24(packed.pos) 26
+      24(packed):     23(ptr) Variable Function
+           47(i):     45(ptr) Variable Function
+     69(packed2):     23(ptr) Variable Function
+              28:          13 Load 27(tex)
+              30:     29(ptr) AccessChain 24(packed) 25
                               Store 30 28
-              39:     38(ptr) AccessChain 35(packed.uv) 26
-                              Store 39 37
-                              Store 41(packed.x) 36
-                              Store 43(packed.n) 44
-                              Store 45(i) 26
-                              Branch 46
-              46:             Label
-                              LoopMerge 48 49 None
-                              Branch 50
-              50:             Label
-              51:     25(int) Load 45(i)
-              54:    53(bool) SLessThan 51 52
-                              BranchConditional 54 47 48
-              47:               Label
-              55:     25(int)   Load 45(i)
-              56:     25(int)   Load 45(i)
-              57:     38(ptr)   AccessChain 35(packed.uv) 56
-              58:   31(fvec2)   Load 57
-              59:     29(ptr)   AccessChain 24(packed.pos) 55
-              60:   19(fvec3)   Load 59
-              61:   31(fvec2)   VectorShuffle 60 60 0 1
-              62:   31(fvec2)   FAdd 61 58
-              63:     29(ptr)   AccessChain 24(packed.pos) 55
-              64:   19(fvec3)   Load 63
-              65:   19(fvec3)   VectorShuffle 64 62 3 4 2
-                                Store 63 65
-                                Branch 49
-              49:               Label
-              66:     25(int)   Load 45(i)
-              67:     25(int)   IAdd 66 52
-                                Store 45(i) 67
-                                Branch 46
+              35:     34(ptr) AccessChain 24(packed) 31 25
+                              Store 35 33
+              40:     39(ptr) AccessChain 24(packed) 36 25
+                              Store 40 38
+              43:     42(ptr) AccessChain 24(packed) 41
+                              Store 43 37
+              46:     45(ptr) AccessChain 24(packed) 44
+                              Store 46 41
+                              Store 47(i) 25
+                              Branch 48
               48:             Label
-              69:          13 Load 15(packed.tex)
-                              Store 68(packed2.tex) 69
-              71:          22 Load 24(packed.pos)
-                              Store 70(packed2.pos) 71
-              73:          33 Load 35(packed.uv)
-                              Store 72(packed2.uv) 73
-              75:    6(float) Load 41(packed.x)
-                              Store 74(packed2.x) 75
-              77:     25(int) Load 43(packed.n)
-                              Store 76(packed2.n) 77
-              78:    7(fvec4) Load 10(pos)
-              79:     29(ptr) AccessChain 70(packed2.pos) 26
-              80:   19(fvec3) Load 79
-              81:    6(float) CompositeExtract 80 0
-              82:    6(float) CompositeExtract 80 1
-              83:    6(float) CompositeExtract 80 2
-              84:    7(fvec4) CompositeConstruct 81 82 83 27
-              85:    7(fvec4) FAdd 78 84
-                              ReturnValue 85
+                              LoopMerge 50 51 None
+                              Branch 52
+              52:             Label
+              53:     21(int) Load 47(i)
+              55:    54(bool) SLessThan 53 31
+                              BranchConditional 55 49 50
+              49:               Label
+              56:     21(int)   Load 47(i)
+              57:     21(int)   Load 47(i)
+              58:     39(ptr)   AccessChain 24(packed) 36 57
+              59:   18(fvec2)   Load 58
+              60:     34(ptr)   AccessChain 24(packed) 31 56
+              61:   14(fvec3)   Load 60
+              62:   18(fvec2)   VectorShuffle 61 61 0 1
+              63:   18(fvec2)   FAdd 62 59
+              64:     34(ptr)   AccessChain 24(packed) 31 56
+              65:   14(fvec3)   Load 64
+              66:   14(fvec3)   VectorShuffle 65 63 3 4 2
+                                Store 64 66
+                                Branch 51
+              51:               Label
+              67:     21(int)   Load 47(i)
+              68:     21(int)   IAdd 67 31
+                                Store 47(i) 68
+                                Branch 48
+              50:             Label
+              70:  22(Packed) Load 24(packed)
+                              Store 69(packed2) 70
+              71:    7(fvec4) Load 10(pos)
+              72:     34(ptr) AccessChain 69(packed2) 31 25
+              73:   14(fvec3) Load 72
+              74:    6(float) CompositeExtract 73 0
+              75:    6(float) CompositeExtract 73 1
+              76:    6(float) CompositeExtract 73 2
+              77:    7(fvec4) CompositeConstruct 74 75 76 32
+              78:    7(fvec4) FAdd 71 77
+                              ReturnValue 78
                               FunctionEnd
diff --git a/Test/baseResults/hlsl.partialFlattenMixed.vert.out b/Test/baseResults/hlsl.partialFlattenMixed.vert.out
index 50c8cb9bd0c4d1f77715f8d417c97852fca3a7ab..6fc97f4d00fa58ec53ab3976157c1ecd6eab243e 100755
--- a/Test/baseResults/hlsl.partialFlattenMixed.vert.out
+++ b/Test/baseResults/hlsl.partialFlattenMixed.vert.out
@@ -9,13 +9,19 @@ Shader version: 500
 0:13      Sequence
 0:13        move second child to first child ( temp texture2D)
 0:13          direct index ( temp texture2D)
-0:?             'packed.membTex' ( temp 2-element array of texture2D)
+0:13            membTex: direct index for structure ( temp 2-element array of texture2D)
+0:13              'packed' ( temp structure{ temp int a,  temp 2-element array of texture2D membTex,  temp int b})
+0:13              Constant:
+0:13                1 (const int)
 0:13            Constant:
 0:13              0 (const int)
 0:?           'tex[0]' ( uniform texture2D)
 0:13        move second child to first child ( temp texture2D)
 0:13          direct index ( temp texture2D)
-0:?             'packed.membTex' ( temp 2-element array of texture2D)
+0:13            membTex: direct index for structure ( temp 2-element array of texture2D)
+0:13              'packed' ( temp structure{ temp int a,  temp 2-element array of texture2D membTex,  temp int b})
+0:13              Constant:
+0:13                1 (const int)
 0:13            Constant:
 0:13              1 (const int)
 0:?           'tex[1]' ( uniform texture2D)
@@ -50,13 +56,19 @@ Shader version: 500
 0:13      Sequence
 0:13        move second child to first child ( temp texture2D)
 0:13          direct index ( temp texture2D)
-0:?             'packed.membTex' ( temp 2-element array of texture2D)
+0:13            membTex: direct index for structure ( temp 2-element array of texture2D)
+0:13              'packed' ( temp structure{ temp int a,  temp 2-element array of texture2D membTex,  temp int b})
+0:13              Constant:
+0:13                1 (const int)
 0:13            Constant:
 0:13              0 (const int)
 0:?           'tex[0]' ( uniform texture2D)
 0:13        move second child to first child ( temp texture2D)
 0:13          direct index ( temp texture2D)
-0:?             'packed.membTex' ( temp 2-element array of texture2D)
+0:13            membTex: direct index for structure ( temp 2-element array of texture2D)
+0:13              'packed' ( temp structure{ temp int a,  temp 2-element array of texture2D membTex,  temp int b})
+0:13              Constant:
+0:13                1 (const int)
 0:13            Constant:
 0:13              1 (const int)
 0:?           'tex[1]' ( uniform texture2D)
@@ -80,71 +92,76 @@ Shader version: 500
 
 // Module Version 10000
 // Generated by (magic number): 80002
-// Id's are bound by 42
+// Id's are bound by 43
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 35 38
+                              EntryPoint Vertex 4  "main" 36 39
                               Source HLSL 500
                               Name 4  "main"
                               Name 11  "@main(vf4;"
                               Name 10  "pos"
-                              Name 18  "packed.membTex"
-                              Name 22  "tex[0]"
-                              Name 27  "tex[1]"
-                              Name 33  "pos"
-                              Name 35  "pos"
-                              Name 38  "@entryPointOutput"
-                              Name 39  "param"
-                              Decorate 22(tex[0]) DescriptorSet 0
-                              Decorate 27(tex[1]) DescriptorSet 0
-                              Decorate 35(pos) Location 0
-                              Decorate 38(@entryPointOutput) BuiltIn Position
+                              Name 18  "Packed"
+                              MemberName 18(Packed) 0  "a"
+                              MemberName 18(Packed) 1  "membTex"
+                              MemberName 18(Packed) 2  "b"
+                              Name 20  "packed"
+                              Name 24  "tex[0]"
+                              Name 28  "tex[1]"
+                              Name 34  "pos"
+                              Name 36  "pos"
+                              Name 39  "@entryPointOutput"
+                              Name 40  "param"
+                              Decorate 24(tex[0]) DescriptorSet 0
+                              Decorate 28(tex[1]) DescriptorSet 0
+                              Decorate 36(pos) Location 0
+                              Decorate 39(@entryPointOutput) BuiltIn Position
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeVector 6(float) 4
                8:             TypePointer Function 7(fvec4)
                9:             TypeFunction 7(fvec4) 8(ptr)
-              13:             TypeImage 6(float) 2D sampled format:Unknown
-              14:             TypeInt 32 0
-              15:     14(int) Constant 2
-              16:             TypeArray 13 15
-              17:             TypePointer Function 16
-              19:             TypeInt 32 1
-              20:     19(int) Constant 0
-              21:             TypePointer UniformConstant 13
-      22(tex[0]):     21(ptr) Variable UniformConstant
-              24:             TypePointer Function 13
-              26:     19(int) Constant 1
-      27(tex[1]):     21(ptr) Variable UniformConstant
-              34:             TypePointer Input 7(fvec4)
-         35(pos):     34(ptr) Variable Input
-              37:             TypePointer Output 7(fvec4)
-38(@entryPointOutput):     37(ptr) Variable Output
+              13:             TypeInt 32 1
+              14:             TypeImage 6(float) 2D sampled format:Unknown
+              15:             TypeInt 32 0
+              16:     15(int) Constant 2
+              17:             TypeArray 14 16
+      18(Packed):             TypeStruct 13(int) 17 13(int)
+              19:             TypePointer Function 18(Packed)
+              21:     13(int) Constant 1
+              22:     13(int) Constant 0
+              23:             TypePointer UniformConstant 14
+      24(tex[0]):     23(ptr) Variable UniformConstant
+              26:             TypePointer Function 14
+      28(tex[1]):     23(ptr) Variable UniformConstant
+              35:             TypePointer Input 7(fvec4)
+         36(pos):     35(ptr) Variable Input
+              38:             TypePointer Output 7(fvec4)
+39(@entryPointOutput):     38(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-         33(pos):      8(ptr) Variable Function
-       39(param):      8(ptr) Variable Function
-              36:    7(fvec4) Load 35(pos)
-                              Store 33(pos) 36
-              40:    7(fvec4) Load 33(pos)
-                              Store 39(param) 40
-              41:    7(fvec4) FunctionCall 11(@main(vf4;) 39(param)
-                              Store 38(@entryPointOutput) 41
+         34(pos):      8(ptr) Variable Function
+       40(param):      8(ptr) Variable Function
+              37:    7(fvec4) Load 36(pos)
+                              Store 34(pos) 37
+              41:    7(fvec4) Load 34(pos)
+                              Store 40(param) 41
+              42:    7(fvec4) FunctionCall 11(@main(vf4;) 40(param)
+                              Store 39(@entryPointOutput) 42
                               Return
                               FunctionEnd
   11(@main(vf4;):    7(fvec4) Function None 9
          10(pos):      8(ptr) FunctionParameter
               12:             Label
-18(packed.membTex):     17(ptr) Variable Function
-              23:          13 Load 22(tex[0])
-              25:     24(ptr) AccessChain 18(packed.membTex) 20
-                              Store 25 23
-              28:          13 Load 27(tex[1])
-              29:     24(ptr) AccessChain 18(packed.membTex) 26
-                              Store 29 28
-              30:    7(fvec4) Load 10(pos)
-                              ReturnValue 30
+      20(packed):     19(ptr) Variable Function
+              25:          14 Load 24(tex[0])
+              27:     26(ptr) AccessChain 20(packed) 21 22
+                              Store 27 25
+              29:          14 Load 28(tex[1])
+              30:     26(ptr) AccessChain 20(packed) 21 21
+                              Store 30 29
+              31:    7(fvec4) Load 10(pos)
+                              ReturnValue 31
                               FunctionEnd
diff --git a/Test/hlsl.flattenOpaqueInit.vert b/Test/hlsl.flattenOpaqueInit.vert
index 4181802cf9d872bea962adb1be28da09f2c9ccea..9ed8bc7a2c1e18481662abb85ed7ca504a6435d2 100644
--- a/Test/hlsl.flattenOpaqueInit.vert
+++ b/Test/hlsl.flattenOpaqueInit.vert
@@ -22,5 +22,6 @@ float4 main() : SV_TARGET0
     res += lookUp(tex2);
     FxaaTex tex3 = tex1;
     res += lookUp(tex3);
+
     return res;
 }
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
index 7192747c41a8e3840b6aa22e3dd076b5987f3ba1..3088450c5b5440672b908af1df2ab55488cc8657 100755
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -1160,7 +1160,7 @@ bool HlslParseContext::shouldFlatten(const TType& type, TStorageQualifier qualif
         return (type.isArray() && intermediate.getFlattenUniformArrays() && topLevel) ||
                (type.isStruct() && type.containsOpaque());
     default:
-        return type.isStruct() && type.containsOpaque();
+        return false;
     };
 }