Merge remote-tracking branch 'aosp/upstream-master' into update-shaderc

Includes:
3a21c880 Merge pull request #1042 from LoopDawg/warning-fix-2
43f682f6 Merge pull request #1039 from amdrexu/bugfix
2baa7742 Linux build warning fix
2a305f65 Fix issues of GL_ARB_viewport_layer_array
75e057f9 Merge pull request #1037 from LoopDawg/clip-cull-geom
5e5b12e9 HLSL: add geometry stage support for clip/cull distance
a459fc81 Merge pull request #1031 from xxxbxxx/for-upstream-2
4e2f05da Build: Fix #1036: size_t warning.
eb71cdd5 HLSL: fix preprocessor concatenation behaviour.
ea0c1643 Merge pull request #1035 from LoopDawg/clip-cull-type-fix
d6f4d9b4 HLSL: fix type on clip/cull index result
82e95a3a SPV: Add auto location mapping of non-opaque non-block uniform variables.
8268a355 Build: Attempt better support for VS 2012.
74c5f711 Merge pull request #1014 from KhronosGroup/SPV_EXT_shader_viewport_index_layer
35343cb8 Merge pull request #1034 from KhronosGroup/module-processes
b41bff69 SPV: 1st pass implementation of SPV_EXT_shader_viewport_index_layer.
2a27116c SPV reflection: Add OpModuleProcessed for compile options.
1f312f90 Merge pull request #1028 from LoopDawg/clip-cull-input
e2cda3c2 HLSL: handle clip and cull distance input builtin type conversion

Test: checkbuild.py on Linux; unit tests on Windows
Change-Id: I747eb59a3c91e4e1e69a9d0ab6cab212a2e5bec6
diff --git a/SPIRV/GLSL.ext.KHR.h b/SPIRV/GLSL.ext.KHR.h
index 8a5db3e..2eb10ae 100644
--- a/SPIRV/GLSL.ext.KHR.h
+++ b/SPIRV/GLSL.ext.KHR.h
@@ -43,5 +43,6 @@
 static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
 static const char* const E_SPV_KHR_post_depth_coverage          = "SPV_KHR_post_depth_coverage";
 static const char* const E_SPV_EXT_shader_stencil_export        = "SPV_EXT_shader_stencil_export";
+static const char* const E_SPV_EXT_shader_viewport_index_layer  = "SPV_EXT_shader_viewport_index_layer";
 
 #endif  // #ifndef GLSLextKHR_H
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 6f3d2c8..b6c9705 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -455,15 +455,13 @@
     case glslang::EbvViewportIndex:
         if (!memberDeclaration) {
             builder.addCapability(spv::CapabilityMultiViewport);
-#ifdef NV_EXTENSIONS
             if (glslangIntermediate->getStage() == EShLangVertex ||
                 glslangIntermediate->getStage() == EShLangTessControl ||
                 glslangIntermediate->getStage() == EShLangTessEvaluation) {
 
-                builder.addExtension(spv::E_SPV_NV_viewport_array2);
-                builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV);
+                builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
+                builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
             }
-#endif
         }
         return spv::BuiltInViewportIndex;
 
@@ -482,15 +480,13 @@
     case glslang::EbvLayer:
         if (!memberDeclaration) {
             builder.addCapability(spv::CapabilityGeometry);
-#ifdef NV_EXTENSIONS
             if (glslangIntermediate->getStage() == EShLangVertex ||
                 glslangIntermediate->getStage() == EShLangTessControl ||
                 glslangIntermediate->getStage() == EShLangTessEvaluation) {
 
-                builder.addExtension(spv::E_SPV_NV_viewport_array2);
-                builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV);
+                builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
+                builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
             }
-#endif
         }
 
         return spv::BuiltInLayer;
@@ -881,11 +877,30 @@
     spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
 
     builder.clearAccessChain();
-    builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
+    builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()),
+                      glslangIntermediate->getVersion());
+
     if (options.generateDebugInfo) {
-        builder.setSourceFile(glslangIntermediate->getSourceFile());
-        builder.setSourceText(glslangIntermediate->getSourceText());
         builder.setEmitOpLines();
+        builder.setSourceFile(glslangIntermediate->getSourceFile());
+
+        // Set the source shader's text. If for SPV version 1.0, include
+        // a preamble in comments stating the OpModuleProcessed instructions.
+        // Otherwise, emit those as actual instructions.
+        std::string text;
+        const std::vector<std::string>& processes = glslangIntermediate->getProcesses();
+        for (int p = 0; p < (int)processes.size(); ++p) {
+            if (glslangIntermediate->getSpv().spv < 0x00010100) {
+                text.append("// OpModuleProcessed ");
+                text.append(processes[p]);
+                text.append("\n");
+            } else
+                builder.addModuleProcessed(processes[p]);
+        }
+        if (glslangIntermediate->getSpv().spv < 0x00010100 && (int)processes.size() > 0)
+            text.append("#line 1\n");
+        text.append(glslangIntermediate->getSourceText());
+        builder.setSourceText(text);
     }
     stdBuiltins = builder.import("GLSL.std.450");
     builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
@@ -5475,14 +5490,12 @@
     }
     else if (builtIn == spv::BuiltInLayer) {
         // SPV_NV_viewport_array2 extension
-        if (symbol->getQualifier().layoutViewportRelative)
-        {
+        if (symbol->getQualifier().layoutViewportRelative) {
             addDecoration(id, (spv::Decoration)spv::DecorationViewportRelativeNV);
             builder.addCapability(spv::CapabilityShaderViewportMaskNV);
             builder.addExtension(spv::E_SPV_NV_viewport_array2);
         }
-        if(symbol->getQualifier().layoutSecondaryViewportRelativeOffset != -2048)
-        {
+        if (symbol->getQualifier().layoutSecondaryViewportRelativeOffset != -2048) {
             addDecoration(id, (spv::Decoration)spv::DecorationSecondaryViewportRelativeNV, symbol->getQualifier().layoutSecondaryViewportRelativeOffset);
             builder.addCapability(spv::CapabilityShaderStereoViewNV);
             builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp
index 9246a81..289d59a 100644
--- a/SPIRV/SpvBuilder.cpp
+++ b/SPIRV/SpvBuilder.cpp
@@ -2430,6 +2430,7 @@
 
     // Debug instructions
     dumpInstructions(out, strings);
+    dumpModuleProcesses(out);
     dumpSourceInstructions(out);
     for (int e = 0; e < (int)sourceExtensions.size(); ++e) {
         Instruction sourceExtInst(0, 0, OpSourceExtension);
@@ -2637,4 +2638,15 @@
     }
 }
 
+void Builder::dumpModuleProcesses(std::vector<unsigned int>& out) const
+{
+    for (int i = 0; i < (int)moduleProcesses.size(); ++i) {
+        // TODO: switch this out for the 1.1 headers
+        const spv::Op OpModuleProcessed = (spv::Op)330;
+        Instruction moduleProcessed(OpModuleProcessed);
+        moduleProcessed.addStringOperand(moduleProcesses[i]);
+        moduleProcessed.dump(out);
+    }
+}
+
 }; // end spv namespace
diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h
index 3a94919..59b1da2 100755
--- a/SPIRV/SpvBuilder.h
+++ b/SPIRV/SpvBuilder.h
@@ -79,6 +79,7 @@
     }
     void setSourceText(const std::string& text) { sourceText = text; }
     void addSourceExtension(const char* ext) { sourceExtensions.push_back(ext); }
+    void addModuleProcessed(const std::string& p) { moduleProcesses.push_back(p.c_str()); }
     void setEmitOpLines() { emitOpLines = true; }
     void addExtension(const char* ext) { extensions.insert(ext); }
     Id import(const char*);
@@ -582,6 +583,7 @@
     void createSelectionMerge(Block* mergeBlock, unsigned int control);
     void dumpSourceInstructions(std::vector<unsigned int>&) const;
     void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
+    void dumpModuleProcesses(std::vector<unsigned int>&) const;
 
     SourceLanguage source;
     int sourceVersion;
@@ -591,6 +593,7 @@
     bool emitOpLines;
     std::set<std::string> extensions;
     std::vector<const char*> sourceExtensions;
+    std::vector<const char*> moduleProcesses;
     AddressingModel addressModel;
     MemoryModel memoryModel;
     std::set<spv::Capability> capabilities;
diff --git a/SPIRV/hex_float.h b/SPIRV/hex_float.h
index 31b9f9e..905b21a 100644
--- a/SPIRV/hex_float.h
+++ b/SPIRV/hex_float.h
@@ -23,7 +23,7 @@
 #include <limits>
 #include <sstream>
 
-#if defined(_MSC_VER) && _MSC_VER < 1700
+#if defined(_MSC_VER) && _MSC_VER < 1800
 namespace std {
 bool isnan(double f)
 {
diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h
index 087a53f..6880595 100755
--- a/SPIRV/spvIR.h
+++ b/SPIRV/spvIR.h
@@ -65,6 +65,14 @@
 const Id NoType = 0;
 
 const Decoration NoPrecision = DecorationMax;
+
+#ifdef __GNUC__
+#   define POTENTIALLY_UNUSED __attribute__((unused))
+#else
+#   define POTENTIALLY_UNUSED
+#endif
+
+POTENTIALLY_UNUSED
 const MemorySemanticsMask MemorySemanticsAllMemory =
                 (MemorySemanticsMask)(MemorySemanticsSequentiallyConsistentMask |
                                       MemorySemanticsUniformMemoryMask |
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 3301df4..53a33b8 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -152,6 +152,7 @@
 int VulkanClientVersion = 100;           // would map to, say, Vulkan 1.0
 int OpenGLClientVersion = 450;           // doesn't influence anything yet, but maps to OpenGL 4.50
 unsigned int TargetVersion = 0x00001000; // maps to, say, SPIR-V 1.0
+std::vector<std::string> Processes;      // what should be recorded by OpModuleProcessed, or equivalent
 
 std::array<unsigned int, EShLangCount> baseSamplerBinding;
 std::array<unsigned int, EShLangCount> baseTextureBinding;
@@ -175,6 +176,9 @@
         text.append("#define ");
         fixLine(def);
 
+        Processes.push_back("D");
+        Processes.back().append(def);
+
         // The first "=" needs to turn into a space
         const size_t equal = def.find_first_of("=");
         if (equal != def.npos)
@@ -189,6 +193,10 @@
     {
         text.append("#undef ");
         fixLine(undef);
+
+        Processes.push_back("U");
+        Processes.back().append(undef);
+
         text.append(undef);
         text.append("\n");
     }
@@ -421,6 +429,8 @@
                     } else if (lowerword == "no-storage-format" || // synonyms
                                lowerword == "nsf") {
                         Options |= EOptionNoStorageFormat;
+                    } else if (lowerword == "relaxed-errors") {
+                        Options |= EOptionRelaxedErrors;
                     } else if (lowerword == "resource-set-bindings" ||  // synonyms
                                lowerword == "resource-set-binding"  ||
                                lowerword == "rsb") {
@@ -459,6 +469,8 @@
                         sourceEntryPointName = argv[1];
                         bumpArg();
                         break;
+                    } else if (lowerword == "suppress-warnings") {
+                        Options |= EOptionSuppressWarnings;
                     } else if (lowerword == "target-env") {
                         if (argc > 1) {
                             if (strcmp(argv[1], "vulkan1.0") == 0) {
@@ -737,6 +749,7 @@
             shader->setSourceEntryPoint(sourceEntryPointName);
         if (UserPreamble.isSet())
             shader->setPreamble(UserPreamble.get());
+        shader->addProcesses(Processes);
 
         shader->setShiftSamplerBinding(baseSamplerBinding[compUnit.stage]);
         shader->setShiftTextureBinding(baseTextureBinding[compUnit.stage]);
@@ -1162,11 +1175,11 @@
            "  -m          memory leak mode\n"
            "  -o  <file>  save binary to <file>, requires a binary option (e.g., -V)\n"
            "  -q          dump reflection query database\n"
-           "  -r          relaxed semantic error-checking mode\n"
+           "  -r          synonym for --relaxed-errors\n"
            "  -s          silent mode\n"
            "  -t          multi-threaded mode\n"
            "  -v          print version strings\n"
-           "  -w          suppress warnings (except as required by #extension : warn)\n"
+           "  -w          synonym for --suppress-warnings\n"
            "  -x          save binary output as text-based 32-bit hexadecimal numbers\n"
            "  --auto-map-bindings                  automatically bind uniform variables\n"
            "                                       without explicit bindings.\n"
@@ -1185,6 +1198,7 @@
            "  --ku                                 synonym for --keep-uncalled\n"
            "  --no-storage-format                  use Unknown image format\n"
            "  --nsf                                synonym for --no-storage-format\n"
+           "  --relaxed-errors                     relaxed GLSL semantic error-checking mode\n"
            "  --resource-set-binding [stage] name set binding\n"
            "              Set descriptor set and binding for individual resources\n"
            "  --resource-set-binding [stage] set\n"
@@ -1206,11 +1220,13 @@
            "  --source-entrypoint name             the given shader source function is\n"
            "                                       renamed to be the entry point given in -e\n"
            "  --sep                                synonym for --source-entrypoint\n"
-           "  --target-env {vulkan1.0|opengl}      set the execution environment the generated\n"
-           "                                       code will execute in (as opposed to language\n"
-           "                                       semantics selected by --client)\n"
-           "                                       default is 'vulkan1.0' under '--client vulkan'\n"
-           "                                       default is 'opengl' under '--client opengl'\n"
+           "  --suppress-warnings                  suppress GLSL warnings\n"
+           "                                       (except as required by #extension : warn)\n"
+           "  --target-env {vulkan1.0|opengl}      set the execution environment code will\n"
+           "                                       execute in (as opposed to language\n"
+           "                                       semantics selected by --client) defaults:\n"
+           "                                        'vulkan1.0' under '--client vulkan<ver>'\n"
+           "                                        'opengl' under '--client opengl<ver>'\n"
            "  --variable-name <name>               Creates a C header file that contains a\n"
            "                                       uint32_t array named <name>\n"
            "                                       initialized with the shader binary code.\n"
diff --git a/Test/baseResults/glspv.frag.out b/Test/baseResults/glspv.frag.out
index 36afc83..5622d01 100755
--- a/Test/baseResults/glspv.frag.out
+++ b/Test/baseResults/glspv.frag.out
@@ -1,10 +1,9 @@
 glspv.frag
 ERROR: 0:4: '#error' : GL_SPIRV is set ( correct , not an error )  
 ERROR: 0:6: '#error' : GL_SPIR is 100  
-ERROR: 0:14: 'f' : non-opaque uniform variables need a layout(location=L) 
 ERROR: 0:19: 'input_attachment_index' : only allowed when using GLSL for Vulkan 
 ERROR: 0:19: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
-ERROR: 5 compilation errors.  No code generated.
+ERROR: 4 compilation errors.  No code generated.
 
 
 SPIR-V is not generated for failed compile or link
diff --git a/Test/baseResults/hlsl.clipdistance-1.frag.out b/Test/baseResults/hlsl.clipdistance-1.frag.out
new file mode 100644
index 0000000..b3cdb61
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-1.frag.out
@@ -0,0 +1,190 @@
+hlsl.clipdistance-1.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;f1;f1; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in float)
+0:4      'cull' ( in float)
+0:?     Sequence
+0:5      Branch: Return with expression
+0:5        add ( temp 4-component vector of float)
+0:5          add ( temp 4-component vector of float)
+0:5            'pos' ( in 4-component vector of float)
+0:5            'clip' ( in float)
+0:5          'cull' ( in float)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:?           'clip' ( temp float)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 1-element array of float ClipDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:?           'cull' ( temp float)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 1-element array of float CullDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;f1;f1; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp float)
+0:?           'cull' ( temp float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 1-element array of float ClipDistance)
+0:?     'cull' ( in 1-element array of float CullDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;f1;f1; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in float)
+0:4      'cull' ( in float)
+0:?     Sequence
+0:5      Branch: Return with expression
+0:5        add ( temp 4-component vector of float)
+0:5          add ( temp 4-component vector of float)
+0:5            'pos' ( in 4-component vector of float)
+0:5            'clip' ( in float)
+0:5          'cull' ( in float)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:?           'clip' ( temp float)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 1-element array of float ClipDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:?           'cull' ( temp float)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 1-element array of float CullDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;f1;f1; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp float)
+0:?           'cull' ( temp float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 1-element array of float ClipDistance)
+0:?     'cull' ( in 1-element array of float CullDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 53
+
+                              Capability Shader
+                              Capability ClipDistance
+                              Capability CullDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 27 34 41 45
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 14  "@main(vf4;f1;f1;"
+                              Name 11  "pos"
+                              Name 12  "clip"
+                              Name 13  "cull"
+                              Name 25  "pos"
+                              Name 27  "pos"
+                              Name 29  "clip"
+                              Name 34  "clip"
+                              Name 40  "cull"
+                              Name 41  "cull"
+                              Name 45  "@entryPointOutput"
+                              Name 46  "param"
+                              Name 48  "param"
+                              Name 50  "param"
+                              Decorate 27(pos) BuiltIn FragCoord
+                              Decorate 34(clip) BuiltIn ClipDistance
+                              Decorate 41(cull) BuiltIn CullDistance
+                              Decorate 45(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypePointer Function 7(fvec4)
+               9:             TypePointer Function 6(float)
+              10:             TypeFunction 7(fvec4) 8(ptr) 9(ptr) 9(ptr)
+              26:             TypePointer Input 7(fvec4)
+         27(pos):     26(ptr) Variable Input
+              30:             TypeInt 32 0
+              31:     30(int) Constant 1
+              32:             TypeArray 6(float) 31
+              33:             TypePointer Input 32
+        34(clip):     33(ptr) Variable Input
+              35:             TypeInt 32 1
+              36:     35(int) Constant 0
+              37:             TypePointer Input 6(float)
+        41(cull):     33(ptr) Variable Input
+              44:             TypePointer Output 7(fvec4)
+45(@entryPointOutput):     44(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+         25(pos):      8(ptr) Variable Function
+        29(clip):      9(ptr) Variable Function
+        40(cull):      9(ptr) Variable Function
+       46(param):      8(ptr) Variable Function
+       48(param):      9(ptr) Variable Function
+       50(param):      9(ptr) Variable Function
+              28:    7(fvec4) Load 27(pos)
+                              Store 25(pos) 28
+              38:     37(ptr) AccessChain 34(clip) 36
+              39:    6(float) Load 38
+                              Store 29(clip) 39
+              42:     37(ptr) AccessChain 41(cull) 36
+              43:    6(float) Load 42
+                              Store 40(cull) 43
+              47:    7(fvec4) Load 25(pos)
+                              Store 46(param) 47
+              49:    6(float) Load 29(clip)
+                              Store 48(param) 49
+              51:    6(float) Load 40(cull)
+                              Store 50(param) 51
+              52:    7(fvec4) FunctionCall 14(@main(vf4;f1;f1;) 46(param) 48(param) 50(param)
+                              Store 45(@entryPointOutput) 52
+                              Return
+                              FunctionEnd
+14(@main(vf4;f1;f1;):    7(fvec4) Function None 10
+         11(pos):      8(ptr) FunctionParameter
+        12(clip):      9(ptr) FunctionParameter
+        13(cull):      9(ptr) FunctionParameter
+              15:             Label
+              16:    7(fvec4) Load 11(pos)
+              17:    6(float) Load 12(clip)
+              18:    7(fvec4) CompositeConstruct 17 17 17 17
+              19:    7(fvec4) FAdd 16 18
+              20:    6(float) Load 13(cull)
+              21:    7(fvec4) CompositeConstruct 20 20 20 20
+              22:    7(fvec4) FAdd 19 21
+                              ReturnValue 22
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-1.geom.out b/Test/baseResults/hlsl.clipdistance-1.geom.out
new file mode 100644
index 0000000..bde7822
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-1.geom.out
@@ -0,0 +1,737 @@
+hlsl.clipdistance-1.geom
+Shader version: 500
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:11  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3]; ( temp void)
+0:11    Function Parameters: 
+0:11      'pos' ( in 3-element array of 4-component vector of float)
+0:11      'VertexID' ( in 3-element array of uint)
+0:11      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:11      'clip' ( in 3-element array of 4-component vector of float)
+0:?     Sequence
+0:14      move second child to first child ( temp 4-component vector of float)
+0:14        pos: direct index for structure ( temp 4-component vector of float)
+0:14          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:14          Constant:
+0:14            0 (const int)
+0:14        direct index ( temp 4-component vector of float)
+0:14          'pos' ( in 3-element array of 4-component vector of float)
+0:14          Constant:
+0:14            0 (const int)
+0:15      move second child to first child ( temp 2-component vector of float)
+0:15        clip: direct index for structure ( temp 2-component vector of float)
+0:15          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:15          Constant:
+0:15            1 (const int)
+0:15        vector swizzle ( temp 2-component vector of float)
+0:15          direct index ( temp 4-component vector of float)
+0:15            'clip' ( in 3-element array of 4-component vector of float)
+0:15            Constant:
+0:15              0 (const int)
+0:15          Sequence
+0:15            Constant:
+0:15              0 (const int)
+0:15            Constant:
+0:15              1 (const int)
+0:17      Sequence
+0:17        Sequence
+0:17          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:17            pos: direct index for structure ( temp 4-component vector of float)
+0:17              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17              Constant:
+0:17                0 (const int)
+0:?           Sequence
+0:17            move second child to first child ( temp float)
+0:17              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 2-element array of float ClipDistance)
+0:17                Constant:
+0:17                  0 (const int)
+0:17              direct index ( temp float)
+0:17                clip: direct index for structure ( temp 2-component vector of float)
+0:17                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17                  Constant:
+0:17                    1 (const int)
+0:17                Constant:
+0:17                  0 (const int)
+0:17            move second child to first child ( temp float)
+0:17              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 2-element array of float ClipDistance)
+0:17                Constant:
+0:17                  1 (const int)
+0:17              direct index ( temp float)
+0:17                clip: direct index for structure ( temp 2-component vector of float)
+0:17                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17                  Constant:
+0:17                    1 (const int)
+0:17                Constant:
+0:17                  1 (const int)
+0:17        EmitVertex ( temp void)
+0:11  Function Definition: main( ( temp void)
+0:11    Function Parameters: 
+0:?     Sequence
+0:11      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:11      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:?         'clip' ( temp 3-element array of 4-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip' ( out 2-element array of float ClipDistance)
+
+
+Linked geometry stage:
+
+
+Shader version: 500
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:11  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3]; ( temp void)
+0:11    Function Parameters: 
+0:11      'pos' ( in 3-element array of 4-component vector of float)
+0:11      'VertexID' ( in 3-element array of uint)
+0:11      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:11      'clip' ( in 3-element array of 4-component vector of float)
+0:?     Sequence
+0:14      move second child to first child ( temp 4-component vector of float)
+0:14        pos: direct index for structure ( temp 4-component vector of float)
+0:14          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:14          Constant:
+0:14            0 (const int)
+0:14        direct index ( temp 4-component vector of float)
+0:14          'pos' ( in 3-element array of 4-component vector of float)
+0:14          Constant:
+0:14            0 (const int)
+0:15      move second child to first child ( temp 2-component vector of float)
+0:15        clip: direct index for structure ( temp 2-component vector of float)
+0:15          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:15          Constant:
+0:15            1 (const int)
+0:15        vector swizzle ( temp 2-component vector of float)
+0:15          direct index ( temp 4-component vector of float)
+0:15            'clip' ( in 3-element array of 4-component vector of float)
+0:15            Constant:
+0:15              0 (const int)
+0:15          Sequence
+0:15            Constant:
+0:15              0 (const int)
+0:15            Constant:
+0:15              1 (const int)
+0:17      Sequence
+0:17        Sequence
+0:17          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:17            pos: direct index for structure ( temp 4-component vector of float)
+0:17              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17              Constant:
+0:17                0 (const int)
+0:?           Sequence
+0:17            move second child to first child ( temp float)
+0:17              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 2-element array of float ClipDistance)
+0:17                Constant:
+0:17                  0 (const int)
+0:17              direct index ( temp float)
+0:17                clip: direct index for structure ( temp 2-component vector of float)
+0:17                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17                  Constant:
+0:17                    1 (const int)
+0:17                Constant:
+0:17                  0 (const int)
+0:17            move second child to first child ( temp float)
+0:17              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 2-element array of float ClipDistance)
+0:17                Constant:
+0:17                  1 (const int)
+0:17              direct index ( temp float)
+0:17                clip: direct index for structure ( temp 2-component vector of float)
+0:17                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:17                  Constant:
+0:17                    1 (const int)
+0:17                Constant:
+0:17                  1 (const int)
+0:17        EmitVertex ( temp void)
+0:11  Function Definition: main( ( temp void)
+0:11    Function Parameters: 
+0:?     Sequence
+0:11      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:11      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip})
+0:?         'clip' ( temp 3-element array of 4-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip' ( out 2-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 118
+
+                              Capability Geometry
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Geometry 4  "main" 38 44 57 61 68
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 Invocations 1
+                              ExecutionMode 4 OutputLineStrip
+                              ExecutionMode 4 OutputVertices 3
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 15  "S"
+                              MemberName 15(S) 0  "pos"
+                              MemberName 15(S) 1  "clip"
+                              Name 22  "@main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3];"
+                              Name 18  "pos"
+                              Name 19  "VertexID"
+                              Name 20  "OutputStream"
+                              Name 21  "clip"
+                              Name 24  "s"
+                              Name 38  "OutputStream.pos"
+                              Name 44  "OutputStream.clip"
+                              Name 55  "pos"
+                              Name 57  "pos"
+                              Name 59  "VertexID"
+                              Name 61  "VertexID"
+                              Name 63  "clip"
+                              Name 68  "clip"
+                              Name 108  "OutputStream"
+                              Name 109  "param"
+                              Name 111  "param"
+                              Name 113  "param"
+                              Name 114  "param"
+                              Decorate 38(OutputStream.pos) BuiltIn Position
+                              Decorate 44(OutputStream.clip) BuiltIn ClipDistance
+                              Decorate 57(pos) BuiltIn Position
+                              Decorate 61(VertexID) Location 0
+                              Decorate 68(clip) BuiltIn ClipDistance
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeInt 32 0
+               9:      8(int) Constant 3
+              10:             TypeArray 7(fvec4) 9
+              11:             TypePointer Function 10
+              12:             TypeArray 8(int) 9
+              13:             TypePointer Function 12
+              14:             TypeVector 6(float) 2
+           15(S):             TypeStruct 7(fvec4) 14(fvec2)
+              16:             TypePointer Function 15(S)
+              17:             TypeFunction 2 11(ptr) 13(ptr) 16(ptr) 11(ptr)
+              25:             TypeInt 32 1
+              26:     25(int) Constant 0
+              27:             TypePointer Function 7(fvec4)
+              31:     25(int) Constant 1
+              35:             TypePointer Function 14(fvec2)
+              37:             TypePointer Output 7(fvec4)
+38(OutputStream.pos):     37(ptr) Variable Output
+              41:      8(int) Constant 2
+              42:             TypeArray 6(float) 41
+              43:             TypePointer Output 42
+44(OutputStream.clip):     43(ptr) Variable Output
+              45:      8(int) Constant 0
+              46:             TypePointer Function 6(float)
+              49:             TypePointer Output 6(float)
+              51:      8(int) Constant 1
+              56:             TypePointer Input 10
+         57(pos):     56(ptr) Variable Input
+              60:             TypePointer Input 12
+    61(VertexID):     60(ptr) Variable Input
+              64:      8(int) Constant 4
+              65:             TypeArray 6(float) 64
+              66:             TypeArray 65 9
+              67:             TypePointer Input 66
+        68(clip):     67(ptr) Variable Input
+              69:             TypePointer Input 6(float)
+              76:     25(int) Constant 2
+              80:     25(int) Constant 3
+         4(main):           2 Function None 3
+               5:             Label
+         55(pos):     11(ptr) Variable Function
+    59(VertexID):     13(ptr) Variable Function
+        63(clip):     11(ptr) Variable Function
+108(OutputStream):     16(ptr) Variable Function
+      109(param):     11(ptr) Variable Function
+      111(param):     13(ptr) Variable Function
+      113(param):     16(ptr) Variable Function
+      114(param):     11(ptr) Variable Function
+              58:          10 Load 57(pos)
+                              Store 55(pos) 58
+              62:          12 Load 61(VertexID)
+                              Store 59(VertexID) 62
+              70:     69(ptr) AccessChain 68(clip) 26 26
+              71:    6(float) Load 70
+              72:     46(ptr) AccessChain 63(clip) 26 45
+                              Store 72 71
+              73:     69(ptr) AccessChain 68(clip) 26 31
+              74:    6(float) Load 73
+              75:     46(ptr) AccessChain 63(clip) 26 51
+                              Store 75 74
+              77:     69(ptr) AccessChain 68(clip) 26 76
+              78:    6(float) Load 77
+              79:     46(ptr) AccessChain 63(clip) 26 41
+                              Store 79 78
+              81:     69(ptr) AccessChain 68(clip) 26 80
+              82:    6(float) Load 81
+              83:     46(ptr) AccessChain 63(clip) 26 9
+                              Store 83 82
+              84:     69(ptr) AccessChain 68(clip) 31 26
+              85:    6(float) Load 84
+              86:     46(ptr) AccessChain 63(clip) 31 45
+                              Store 86 85
+              87:     69(ptr) AccessChain 68(clip) 31 31
+              88:    6(float) Load 87
+              89:     46(ptr) AccessChain 63(clip) 31 51
+                              Store 89 88
+              90:     69(ptr) AccessChain 68(clip) 31 76
+              91:    6(float) Load 90
+              92:     46(ptr) AccessChain 63(clip) 31 41
+                              Store 92 91
+              93:     69(ptr) AccessChain 68(clip) 31 80
+              94:    6(float) Load 93
+              95:     46(ptr) AccessChain 63(clip) 31 9
+                              Store 95 94
+              96:     69(ptr) AccessChain 68(clip) 76 26
+              97:    6(float) Load 96
+              98:     46(ptr) AccessChain 63(clip) 76 45
+                              Store 98 97
+              99:     69(ptr) AccessChain 68(clip) 76 31
+             100:    6(float) Load 99
+             101:     46(ptr) AccessChain 63(clip) 76 51
+                              Store 101 100
+             102:     69(ptr) AccessChain 68(clip) 76 76
+             103:    6(float) Load 102
+             104:     46(ptr) AccessChain 63(clip) 76 41
+                              Store 104 103
+             105:     69(ptr) AccessChain 68(clip) 76 80
+             106:    6(float) Load 105
+             107:     46(ptr) AccessChain 63(clip) 76 9
+                              Store 107 106
+             110:          10 Load 55(pos)
+                              Store 109(param) 110
+             112:          12 Load 59(VertexID)
+                              Store 111(param) 112
+             115:          10 Load 63(clip)
+                              Store 114(param) 115
+             116:           2 FunctionCall 22(@main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3];) 109(param) 111(param) 113(param) 114(param)
+             117:       15(S) Load 113(param)
+                              Store 108(OutputStream) 117
+                              Return
+                              FunctionEnd
+22(@main(vf4[3];u1[3];struct-S-vf4-vf21;vf4[3];):           2 Function None 17
+         18(pos):     11(ptr) FunctionParameter
+    19(VertexID):     13(ptr) FunctionParameter
+20(OutputStream):     16(ptr) FunctionParameter
+        21(clip):     11(ptr) FunctionParameter
+              23:             Label
+           24(s):     16(ptr) Variable Function
+              28:     27(ptr) AccessChain 18(pos) 26
+              29:    7(fvec4) Load 28
+              30:     27(ptr) AccessChain 24(s) 26
+                              Store 30 29
+              32:     27(ptr) AccessChain 21(clip) 26
+              33:    7(fvec4) Load 32
+              34:   14(fvec2) VectorShuffle 33 33 0 1
+              36:     35(ptr) AccessChain 24(s) 31
+                              Store 36 34
+              39:     27(ptr) AccessChain 24(s) 26
+              40:    7(fvec4) Load 39
+                              Store 38(OutputStream.pos) 40
+              47:     46(ptr) AccessChain 24(s) 31 45
+              48:    6(float) Load 47
+              50:     49(ptr) AccessChain 44(OutputStream.clip) 26
+                              Store 50 48
+              52:     46(ptr) AccessChain 24(s) 31 51
+              53:    6(float) Load 52
+              54:     49(ptr) AccessChain 44(OutputStream.clip) 31
+                              Store 54 53
+                              EmitVertex
+                              Return
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-1.vert.out b/Test/baseResults/hlsl.clipdistance-1.vert.out
index 5a254ec..b11c1cf 100644
--- a/Test/baseResults/hlsl.clipdistance-1.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-1.vert.out
@@ -34,14 +34,14 @@
 0:?         'pos' ( temp 4-component vector of float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 1-element array of float ClipDistance)
 0:4            Constant:
 0:4              0 (const int)
 0:?           'clip' ( temp float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 1-element array of float CullDistance)
 0:4            Constant:
 0:4              0 (const int)
@@ -90,14 +90,14 @@
 0:?         'pos' ( temp 4-component vector of float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 1-element array of float ClipDistance)
 0:4            Constant:
 0:4              0 (const int)
 0:?           'clip' ( temp float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 1-element array of float CullDistance)
 0:4            Constant:
 0:4              0 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-2.frag.out b/Test/baseResults/hlsl.clipdistance-2.frag.out
new file mode 100644
index 0000000..f39295e
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-2.frag.out
@@ -0,0 +1,419 @@
+hlsl.clipdistance-2.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;vf2[2];vf2[2]; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in 2-element array of 2-component vector of float)
+0:4      'cull' ( in 2-element array of 2-component vector of float)
+0:?     Sequence
+0:6      Branch: Return with expression
+0:6        add ( temp 4-component vector of float)
+0:6          add ( temp 4-component vector of float)
+0:6            'pos' ( in 4-component vector of float)
+0:6            direct index ( temp float)
+0:6              direct index ( temp 2-component vector of float)
+0:6                'clip' ( in 2-element array of 2-component vector of float)
+0:6                Constant:
+0:6                  0 (const int)
+0:6              Constant:
+0:6                0 (const int)
+0:6          direct index ( temp float)
+0:6            direct index ( temp 2-component vector of float)
+0:6              'cull' ( in 2-element array of 2-component vector of float)
+0:6              Constant:
+0:6                0 (const int)
+0:6            Constant:
+0:6              0 (const int)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              1 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              2 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              3 (const int)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              1 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              2 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              3 (const int)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;vf2[2];vf2[2]; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp 2-element array of 2-component vector of float)
+0:?           'cull' ( temp 2-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 4-element array of float ClipDistance)
+0:?     'cull' ( in 4-element array of float CullDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;vf2[2];vf2[2]; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in 2-element array of 2-component vector of float)
+0:4      'cull' ( in 2-element array of 2-component vector of float)
+0:?     Sequence
+0:6      Branch: Return with expression
+0:6        add ( temp 4-component vector of float)
+0:6          add ( temp 4-component vector of float)
+0:6            'pos' ( in 4-component vector of float)
+0:6            direct index ( temp float)
+0:6              direct index ( temp 2-component vector of float)
+0:6                'clip' ( in 2-element array of 2-component vector of float)
+0:6                Constant:
+0:6                  0 (const int)
+0:6              Constant:
+0:6                0 (const int)
+0:6          direct index ( temp float)
+0:6            direct index ( temp 2-component vector of float)
+0:6              'cull' ( in 2-element array of 2-component vector of float)
+0:6              Constant:
+0:6                0 (const int)
+0:6            Constant:
+0:6              0 (const int)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              1 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              2 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'clip' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float ClipDistance)
+0:?             'clip' ( in 4-element array of float ClipDistance)
+0:4            Constant:
+0:4              3 (const int)
+0:?       Sequence
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              0 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                0 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              1 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              0 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              2 (const int)
+0:4        move second child to first child ( temp float)
+0:4          direct index ( temp float)
+0:4            direct index ( temp 2-component vector of float)
+0:?               'cull' ( temp 2-element array of 2-component vector of float)
+0:4              Constant:
+0:4                1 (const int)
+0:4            Constant:
+0:4              1 (const int)
+0:4          direct index ( in float CullDistance)
+0:?             'cull' ( in 4-element array of float CullDistance)
+0:4            Constant:
+0:4              3 (const int)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;vf2[2];vf2[2]; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp 2-element array of 2-component vector of float)
+0:?           'cull' ( temp 2-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 4-element array of float ClipDistance)
+0:?     'cull' ( in 4-element array of float CullDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 84
+
+                              Capability Shader
+                              Capability ClipDistance
+                              Capability CullDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 37 43 62 76
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 18  "@main(vf4;vf2[2];vf2[2];"
+                              Name 15  "pos"
+                              Name 16  "clip"
+                              Name 17  "cull"
+                              Name 35  "pos"
+                              Name 37  "pos"
+                              Name 39  "clip"
+                              Name 43  "clip"
+                              Name 61  "cull"
+                              Name 62  "cull"
+                              Name 76  "@entryPointOutput"
+                              Name 77  "param"
+                              Name 79  "param"
+                              Name 81  "param"
+                              Decorate 37(pos) BuiltIn FragCoord
+                              Decorate 43(clip) BuiltIn ClipDistance
+                              Decorate 62(cull) BuiltIn CullDistance
+                              Decorate 76(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypePointer Function 7(fvec4)
+               9:             TypeVector 6(float) 2
+              10:             TypeInt 32 0
+              11:     10(int) Constant 2
+              12:             TypeArray 9(fvec2) 11
+              13:             TypePointer Function 12
+              14:             TypeFunction 7(fvec4) 8(ptr) 13(ptr) 13(ptr)
+              21:             TypeInt 32 1
+              22:     21(int) Constant 0
+              23:     10(int) Constant 0
+              24:             TypePointer Function 6(float)
+              36:             TypePointer Input 7(fvec4)
+         37(pos):     36(ptr) Variable Input
+              40:     10(int) Constant 4
+              41:             TypeArray 6(float) 40
+              42:             TypePointer Input 41
+        43(clip):     42(ptr) Variable Input
+              44:             TypePointer Input 6(float)
+              48:     21(int) Constant 1
+              51:     10(int) Constant 1
+              53:     21(int) Constant 2
+              57:     21(int) Constant 3
+        62(cull):     42(ptr) Variable Input
+              75:             TypePointer Output 7(fvec4)
+76(@entryPointOutput):     75(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+         35(pos):      8(ptr) Variable Function
+        39(clip):     13(ptr) Variable Function
+        61(cull):     13(ptr) Variable Function
+       77(param):      8(ptr) Variable Function
+       79(param):     13(ptr) Variable Function
+       81(param):     13(ptr) Variable Function
+              38:    7(fvec4) Load 37(pos)
+                              Store 35(pos) 38
+              45:     44(ptr) AccessChain 43(clip) 22
+              46:    6(float) Load 45
+              47:     24(ptr) AccessChain 39(clip) 22 23
+                              Store 47 46
+              49:     44(ptr) AccessChain 43(clip) 48
+              50:    6(float) Load 49
+              52:     24(ptr) AccessChain 39(clip) 22 51
+                              Store 52 50
+              54:     44(ptr) AccessChain 43(clip) 53
+              55:    6(float) Load 54
+              56:     24(ptr) AccessChain 39(clip) 48 23
+                              Store 56 55
+              58:     44(ptr) AccessChain 43(clip) 57
+              59:    6(float) Load 58
+              60:     24(ptr) AccessChain 39(clip) 48 51
+                              Store 60 59
+              63:     44(ptr) AccessChain 62(cull) 22
+              64:    6(float) Load 63
+              65:     24(ptr) AccessChain 61(cull) 22 23
+                              Store 65 64
+              66:     44(ptr) AccessChain 62(cull) 48
+              67:    6(float) Load 66
+              68:     24(ptr) AccessChain 61(cull) 22 51
+                              Store 68 67
+              69:     44(ptr) AccessChain 62(cull) 53
+              70:    6(float) Load 69
+              71:     24(ptr) AccessChain 61(cull) 48 23
+                              Store 71 70
+              72:     44(ptr) AccessChain 62(cull) 57
+              73:    6(float) Load 72
+              74:     24(ptr) AccessChain 61(cull) 48 51
+                              Store 74 73
+              78:    7(fvec4) Load 35(pos)
+                              Store 77(param) 78
+              80:          12 Load 39(clip)
+                              Store 79(param) 80
+              82:          12 Load 61(cull)
+                              Store 81(param) 82
+              83:    7(fvec4) FunctionCall 18(@main(vf4;vf2[2];vf2[2];) 77(param) 79(param) 81(param)
+                              Store 76(@entryPointOutput) 83
+                              Return
+                              FunctionEnd
+18(@main(vf4;vf2[2];vf2[2];):    7(fvec4) Function None 14
+         15(pos):      8(ptr) FunctionParameter
+        16(clip):     13(ptr) FunctionParameter
+        17(cull):     13(ptr) FunctionParameter
+              19:             Label
+              20:    7(fvec4) Load 15(pos)
+              25:     24(ptr) AccessChain 16(clip) 22 23
+              26:    6(float) Load 25
+              27:    7(fvec4) CompositeConstruct 26 26 26 26
+              28:    7(fvec4) FAdd 20 27
+              29:     24(ptr) AccessChain 17(cull) 22 23
+              30:    6(float) Load 29
+              31:    7(fvec4) CompositeConstruct 30 30 30 30
+              32:    7(fvec4) FAdd 28 31
+                              ReturnValue 32
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-2.geom.out b/Test/baseResults/hlsl.clipdistance-2.geom.out
new file mode 100644
index 0000000..158cb2c
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-2.geom.out
@@ -0,0 +1,924 @@
+hlsl.clipdistance-2.geom
+Shader version: 500
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:11  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
+0:11    Function Parameters: 
+0:11      'pos' ( in 3-element array of 4-component vector of float)
+0:11      'VertexID' ( in 3-element array of uint)
+0:11      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:11      'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:?     Sequence
+0:14      move second child to first child ( temp 4-component vector of float)
+0:14        pos: direct index for structure ( temp 4-component vector of float)
+0:14          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:14          Constant:
+0:14            0 (const int)
+0:14        direct index ( temp 4-component vector of float)
+0:14          'pos' ( in 3-element array of 4-component vector of float)
+0:14          Constant:
+0:14            0 (const int)
+0:15      move second child to first child ( temp 2-component vector of float)
+0:15        direct index ( temp 2-component vector of float)
+0:15          clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:15            's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:15            Constant:
+0:15              1 (const int)
+0:15          Constant:
+0:15            0 (const int)
+0:15        direct index ( temp 2-component vector of float)
+0:15          direct index ( temp 2-element array of 2-component vector of float)
+0:15            'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:15            Constant:
+0:15              0 (const int)
+0:15          Constant:
+0:15            0 (const int)
+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:16          clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:16            's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:16            Constant:
+0:16              1 (const int)
+0:16          Constant:
+0:16            1 (const int)
+0:16        direct index ( temp 2-component vector of float)
+0:16          direct index ( temp 2-element array of 2-component vector of float)
+0:16            'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:16            Constant:
+0:16              0 (const int)
+0:16          Constant:
+0:16            1 (const int)
+0:18      Sequence
+0:18        Sequence
+0:18          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:18            pos: direct index for structure ( temp 4-component vector of float)
+0:18              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18              Constant:
+0:18                0 (const int)
+0:?           Sequence
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  0 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    0 (const int)
+0:18                Constant:
+0:18                  0 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  1 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    0 (const int)
+0:18                Constant:
+0:18                  1 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  2 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    1 (const int)
+0:18                Constant:
+0:18                  0 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  3 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    1 (const int)
+0:18                Constant:
+0:18                  1 (const int)
+0:18        EmitVertex ( temp void)
+0:11  Function Definition: main( ( temp void)
+0:11    Function Parameters: 
+0:?     Sequence
+0:11      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:11      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:?         'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip' ( out 4-element array of float ClipDistance)
+
+
+Linked geometry stage:
+
+
+Shader version: 500
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:11  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
+0:11    Function Parameters: 
+0:11      'pos' ( in 3-element array of 4-component vector of float)
+0:11      'VertexID' ( in 3-element array of uint)
+0:11      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:11      'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:?     Sequence
+0:14      move second child to first child ( temp 4-component vector of float)
+0:14        pos: direct index for structure ( temp 4-component vector of float)
+0:14          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:14          Constant:
+0:14            0 (const int)
+0:14        direct index ( temp 4-component vector of float)
+0:14          'pos' ( in 3-element array of 4-component vector of float)
+0:14          Constant:
+0:14            0 (const int)
+0:15      move second child to first child ( temp 2-component vector of float)
+0:15        direct index ( temp 2-component vector of float)
+0:15          clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:15            's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:15            Constant:
+0:15              1 (const int)
+0:15          Constant:
+0:15            0 (const int)
+0:15        direct index ( temp 2-component vector of float)
+0:15          direct index ( temp 2-element array of 2-component vector of float)
+0:15            'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:15            Constant:
+0:15              0 (const int)
+0:15          Constant:
+0:15            0 (const int)
+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:16          clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:16            's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:16            Constant:
+0:16              1 (const int)
+0:16          Constant:
+0:16            1 (const int)
+0:16        direct index ( temp 2-component vector of float)
+0:16          direct index ( temp 2-element array of 2-component vector of float)
+0:16            'clip' ( in 3-element array of 2-element array of 2-component vector of float)
+0:16            Constant:
+0:16              0 (const int)
+0:16          Constant:
+0:16            1 (const int)
+0:18      Sequence
+0:18        Sequence
+0:18          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:18            pos: direct index for structure ( temp 4-component vector of float)
+0:18              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18              Constant:
+0:18                0 (const int)
+0:?           Sequence
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  0 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    0 (const int)
+0:18                Constant:
+0:18                  0 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  1 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    0 (const int)
+0:18                Constant:
+0:18                  1 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  2 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    1 (const int)
+0:18                Constant:
+0:18                  0 (const int)
+0:18            move second child to first child ( temp float)
+0:18              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip' ( out 4-element array of float ClipDistance)
+0:18                Constant:
+0:18                  3 (const int)
+0:18              direct index ( temp float)
+0:18                direct index ( temp 2-component vector of float)
+0:18                  clip: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:18                    's' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:18                    Constant:
+0:18                      1 (const int)
+0:18                  Constant:
+0:18                    1 (const int)
+0:18                Constant:
+0:18                  1 (const int)
+0:18        EmitVertex ( temp void)
+0:11  Function Definition: main( ( temp void)
+0:11    Function Parameters: 
+0:?     Sequence
+0:11      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:11      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  0 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  1 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                0 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              0 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              2 (const int)
+0:11        move second child to first child ( temp float)
+0:11          direct index ( temp float)
+0:11            direct index ( temp 2-component vector of float)
+0:11              direct index ( temp 2-element array of 2-component vector of float)
+0:?                 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:11                Constant:
+0:11                  2 (const int)
+0:11              Constant:
+0:11                1 (const int)
+0:11            Constant:
+0:11              1 (const int)
+0:11          direct index ( in float ClipDistance)
+0:11            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:11              Constant:
+0:11                2 (const int)
+0:11            Constant:
+0:11              3 (const int)
+0:11      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-element array of 2-component vector of float clip})
+0:?         'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip' ( out 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 128
+
+                              Capability Geometry
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Geometry 4  "main" 44 50 71 75 80
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 Invocations 1
+                              ExecutionMode 4 OutputLineStrip
+                              ExecutionMode 4 OutputVertices 3
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 17  "S"
+                              MemberName 17(S) 0  "pos"
+                              MemberName 17(S) 1  "clip"
+                              Name 26  "@main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2];"
+                              Name 22  "pos"
+                              Name 23  "VertexID"
+                              Name 24  "OutputStream"
+                              Name 25  "clip"
+                              Name 28  "s"
+                              Name 44  "OutputStream.pos"
+                              Name 50  "OutputStream.clip"
+                              Name 69  "pos"
+                              Name 71  "pos"
+                              Name 73  "VertexID"
+                              Name 75  "VertexID"
+                              Name 77  "clip"
+                              Name 80  "clip"
+                              Name 118  "OutputStream"
+                              Name 119  "param"
+                              Name 121  "param"
+                              Name 123  "param"
+                              Name 124  "param"
+                              Decorate 44(OutputStream.pos) BuiltIn Position
+                              Decorate 50(OutputStream.clip) BuiltIn ClipDistance
+                              Decorate 71(pos) BuiltIn Position
+                              Decorate 75(VertexID) Location 0
+                              Decorate 80(clip) BuiltIn ClipDistance
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeInt 32 0
+               9:      8(int) Constant 3
+              10:             TypeArray 7(fvec4) 9
+              11:             TypePointer Function 10
+              12:             TypeArray 8(int) 9
+              13:             TypePointer Function 12
+              14:             TypeVector 6(float) 2
+              15:      8(int) Constant 2
+              16:             TypeArray 14(fvec2) 15
+           17(S):             TypeStruct 7(fvec4) 16
+              18:             TypePointer Function 17(S)
+              19:             TypeArray 16 9
+              20:             TypePointer Function 19
+              21:             TypeFunction 2 11(ptr) 13(ptr) 18(ptr) 20(ptr)
+              29:             TypeInt 32 1
+              30:     29(int) Constant 0
+              31:             TypePointer Function 7(fvec4)
+              35:     29(int) Constant 1
+              36:             TypePointer Function 14(fvec2)
+              43:             TypePointer Output 7(fvec4)
+44(OutputStream.pos):     43(ptr) Variable Output
+              47:      8(int) Constant 4
+              48:             TypeArray 6(float) 47
+              49:             TypePointer Output 48
+50(OutputStream.clip):     49(ptr) Variable Output
+              51:      8(int) Constant 0
+              52:             TypePointer Function 6(float)
+              55:             TypePointer Output 6(float)
+              57:      8(int) Constant 1
+              61:     29(int) Constant 2
+              65:     29(int) Constant 3
+              70:             TypePointer Input 10
+         71(pos):     70(ptr) Variable Input
+              74:             TypePointer Input 12
+    75(VertexID):     74(ptr) Variable Input
+              78:             TypeArray 48 9
+              79:             TypePointer Input 78
+        80(clip):     79(ptr) Variable Input
+              81:             TypePointer Input 6(float)
+         4(main):           2 Function None 3
+               5:             Label
+         69(pos):     11(ptr) Variable Function
+    73(VertexID):     13(ptr) Variable Function
+        77(clip):     20(ptr) Variable Function
+118(OutputStream):     18(ptr) Variable Function
+      119(param):     11(ptr) Variable Function
+      121(param):     13(ptr) Variable Function
+      123(param):     18(ptr) Variable Function
+      124(param):     20(ptr) Variable Function
+              72:          10 Load 71(pos)
+                              Store 69(pos) 72
+              76:          12 Load 75(VertexID)
+                              Store 73(VertexID) 76
+              82:     81(ptr) AccessChain 80(clip) 30 30
+              83:    6(float) Load 82
+              84:     52(ptr) AccessChain 77(clip) 30 30 51
+                              Store 84 83
+              85:     81(ptr) AccessChain 80(clip) 30 35
+              86:    6(float) Load 85
+              87:     52(ptr) AccessChain 77(clip) 30 30 57
+                              Store 87 86
+              88:     81(ptr) AccessChain 80(clip) 30 61
+              89:    6(float) Load 88
+              90:     52(ptr) AccessChain 77(clip) 30 35 51
+                              Store 90 89
+              91:     81(ptr) AccessChain 80(clip) 30 65
+              92:    6(float) Load 91
+              93:     52(ptr) AccessChain 77(clip) 30 35 57
+                              Store 93 92
+              94:     81(ptr) AccessChain 80(clip) 35 30
+              95:    6(float) Load 94
+              96:     52(ptr) AccessChain 77(clip) 35 30 51
+                              Store 96 95
+              97:     81(ptr) AccessChain 80(clip) 35 35
+              98:    6(float) Load 97
+              99:     52(ptr) AccessChain 77(clip) 35 30 57
+                              Store 99 98
+             100:     81(ptr) AccessChain 80(clip) 35 61
+             101:    6(float) Load 100
+             102:     52(ptr) AccessChain 77(clip) 35 35 51
+                              Store 102 101
+             103:     81(ptr) AccessChain 80(clip) 35 65
+             104:    6(float) Load 103
+             105:     52(ptr) AccessChain 77(clip) 35 35 57
+                              Store 105 104
+             106:     81(ptr) AccessChain 80(clip) 61 30
+             107:    6(float) Load 106
+             108:     52(ptr) AccessChain 77(clip) 61 30 51
+                              Store 108 107
+             109:     81(ptr) AccessChain 80(clip) 61 35
+             110:    6(float) Load 109
+             111:     52(ptr) AccessChain 77(clip) 61 30 57
+                              Store 111 110
+             112:     81(ptr) AccessChain 80(clip) 61 61
+             113:    6(float) Load 112
+             114:     52(ptr) AccessChain 77(clip) 61 35 51
+                              Store 114 113
+             115:     81(ptr) AccessChain 80(clip) 61 65
+             116:    6(float) Load 115
+             117:     52(ptr) AccessChain 77(clip) 61 35 57
+                              Store 117 116
+             120:          10 Load 69(pos)
+                              Store 119(param) 120
+             122:          12 Load 73(VertexID)
+                              Store 121(param) 122
+             125:          19 Load 77(clip)
+                              Store 124(param) 125
+             126:           2 FunctionCall 26(@main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2];) 119(param) 121(param) 123(param) 124(param)
+             127:       17(S) Load 123(param)
+                              Store 118(OutputStream) 127
+                              Return
+                              FunctionEnd
+26(@main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2];):           2 Function None 21
+         22(pos):     11(ptr) FunctionParameter
+    23(VertexID):     13(ptr) FunctionParameter
+24(OutputStream):     18(ptr) FunctionParameter
+        25(clip):     20(ptr) FunctionParameter
+              27:             Label
+           28(s):     18(ptr) Variable Function
+              32:     31(ptr) AccessChain 22(pos) 30
+              33:    7(fvec4) Load 32
+              34:     31(ptr) AccessChain 28(s) 30
+                              Store 34 33
+              37:     36(ptr) AccessChain 25(clip) 30 30
+              38:   14(fvec2) Load 37
+              39:     36(ptr) AccessChain 28(s) 35 30
+                              Store 39 38
+              40:     36(ptr) AccessChain 25(clip) 30 35
+              41:   14(fvec2) Load 40
+              42:     36(ptr) AccessChain 28(s) 35 35
+                              Store 42 41
+              45:     31(ptr) AccessChain 28(s) 30
+              46:    7(fvec4) Load 45
+                              Store 44(OutputStream.pos) 46
+              53:     52(ptr) AccessChain 28(s) 35 30 51
+              54:    6(float) Load 53
+              56:     55(ptr) AccessChain 50(OutputStream.clip) 30
+                              Store 56 54
+              58:     52(ptr) AccessChain 28(s) 35 30 57
+              59:    6(float) Load 58
+              60:     55(ptr) AccessChain 50(OutputStream.clip) 35
+                              Store 60 59
+              62:     52(ptr) AccessChain 28(s) 35 35 51
+              63:    6(float) Load 62
+              64:     55(ptr) AccessChain 50(OutputStream.clip) 61
+                              Store 64 63
+              66:     52(ptr) AccessChain 28(s) 35 35 57
+              67:    6(float) Load 66
+              68:     55(ptr) AccessChain 50(OutputStream.clip) 65
+                              Store 68 67
+                              EmitVertex
+                              Return
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-2.vert.out b/Test/baseResults/hlsl.clipdistance-2.vert.out
index cb6d887..bdab064 100644
--- a/Test/baseResults/hlsl.clipdistance-2.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-2.vert.out
@@ -106,7 +106,7 @@
 0:?         'pos' ( temp 4-component vector of float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              0 (const int)
@@ -118,7 +118,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              1 (const int)
@@ -130,7 +130,7 @@
 0:4            Constant:
 0:4              1 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              2 (const int)
@@ -142,7 +142,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              3 (const int)
@@ -155,7 +155,7 @@
 0:4              1 (const int)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              0 (const int)
@@ -167,7 +167,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              1 (const int)
@@ -179,7 +179,7 @@
 0:4            Constant:
 0:4              1 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              2 (const int)
@@ -191,7 +191,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              3 (const int)
@@ -318,7 +318,7 @@
 0:?         'pos' ( temp 4-component vector of float)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              0 (const int)
@@ -330,7 +330,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              1 (const int)
@@ -342,7 +342,7 @@
 0:4            Constant:
 0:4              1 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              2 (const int)
@@ -354,7 +354,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float ClipDistance)
 0:?             'clip' ( out 4-element array of float ClipDistance)
 0:4            Constant:
 0:4              3 (const int)
@@ -367,7 +367,7 @@
 0:4              1 (const int)
 0:?       Sequence
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              0 (const int)
@@ -379,7 +379,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              1 (const int)
@@ -391,7 +391,7 @@
 0:4            Constant:
 0:4              1 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              2 (const int)
@@ -403,7 +403,7 @@
 0:4            Constant:
 0:4              0 (const int)
 0:4        move second child to first child ( temp float)
-0:4          direct index ( temp float)
+0:4          direct index ( out float CullDistance)
 0:?             'cull' ( out 4-element array of float CullDistance)
 0:4            Constant:
 0:4              3 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-3.frag.out b/Test/baseResults/hlsl.clipdistance-3.frag.out
new file mode 100644
index 0000000..8515cd7
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-3.frag.out
@@ -0,0 +1,190 @@
+hlsl.clipdistance-3.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in 2-element array of float)
+0:4      'cull' ( in 2-element array of float)
+0:?     Sequence
+0:5      Branch: Return with expression
+0:5        add ( temp 4-component vector of float)
+0:5          add ( temp 4-component vector of float)
+0:5            'pos' ( in 4-component vector of float)
+0:5            direct index ( temp float)
+0:5              'clip' ( in 2-element array of float)
+0:5              Constant:
+0:5                0 (const int)
+0:5          direct index ( temp float)
+0:5            'cull' ( in 2-element array of float)
+0:5            Constant:
+0:5              0 (const int)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp 2-element array of float)
+0:?           'clip' ( temp 2-element array of float)
+0:?           'clip' ( in 2-element array of float ClipDistance)
+0:?       Sequence
+0:4        move second child to first child ( temp 2-element array of float)
+0:?           'cull' ( temp 2-element array of float)
+0:?           'cull' ( in 2-element array of float CullDistance)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp 2-element array of float)
+0:?           'cull' ( temp 2-element array of float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 2-element array of float ClipDistance)
+0:?     'cull' ( in 2-element array of float CullDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4  Function Definition: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
+0:4    Function Parameters: 
+0:4      'pos' ( in 4-component vector of float)
+0:4      'clip' ( in 2-element array of float)
+0:4      'cull' ( in 2-element array of float)
+0:?     Sequence
+0:5      Branch: Return with expression
+0:5        add ( temp 4-component vector of float)
+0:5          add ( temp 4-component vector of float)
+0:5            'pos' ( in 4-component vector of float)
+0:5            direct index ( temp float)
+0:5              'clip' ( in 2-element array of float)
+0:5              Constant:
+0:5                0 (const int)
+0:5          direct index ( temp float)
+0:5            'cull' ( in 2-element array of float)
+0:5            Constant:
+0:5              0 (const int)
+0:4  Function Definition: main( ( temp void)
+0:4    Function Parameters: 
+0:?     Sequence
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         'pos' ( temp 4-component vector of float)
+0:?         'pos' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:4        move second child to first child ( temp 2-element array of float)
+0:?           'clip' ( temp 2-element array of float)
+0:?           'clip' ( in 2-element array of float ClipDistance)
+0:?       Sequence
+0:4        move second child to first child ( temp 2-element array of float)
+0:?           'cull' ( temp 2-element array of float)
+0:?           'cull' ( in 2-element array of float CullDistance)
+0:4      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:4        Function Call: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
+0:?           'pos' ( temp 4-component vector of float)
+0:?           'clip' ( temp 2-element array of float)
+0:?           'cull' ( temp 2-element array of float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'pos' ( in 4-component vector of float FragCoord)
+0:?     'clip' ( in 2-element array of float ClipDistance)
+0:?     'cull' ( in 2-element array of float CullDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 53
+
+                              Capability Shader
+                              Capability ClipDistance
+                              Capability CullDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 35 39 42 45
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 17  "@main(vf4;f1[2];f1[2];"
+                              Name 14  "pos"
+                              Name 15  "clip"
+                              Name 16  "cull"
+                              Name 33  "pos"
+                              Name 35  "pos"
+                              Name 37  "clip"
+                              Name 39  "clip"
+                              Name 41  "cull"
+                              Name 42  "cull"
+                              Name 45  "@entryPointOutput"
+                              Name 46  "param"
+                              Name 48  "param"
+                              Name 50  "param"
+                              Decorate 35(pos) BuiltIn FragCoord
+                              Decorate 39(clip) BuiltIn ClipDistance
+                              Decorate 42(cull) BuiltIn CullDistance
+                              Decorate 45(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypePointer Function 7(fvec4)
+               9:             TypeInt 32 0
+              10:      9(int) Constant 2
+              11:             TypeArray 6(float) 10
+              12:             TypePointer Function 11
+              13:             TypeFunction 7(fvec4) 8(ptr) 12(ptr) 12(ptr)
+              20:             TypeInt 32 1
+              21:     20(int) Constant 0
+              22:             TypePointer Function 6(float)
+              34:             TypePointer Input 7(fvec4)
+         35(pos):     34(ptr) Variable Input
+              38:             TypePointer Input 11
+        39(clip):     38(ptr) Variable Input
+        42(cull):     38(ptr) Variable Input
+              44:             TypePointer Output 7(fvec4)
+45(@entryPointOutput):     44(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+         33(pos):      8(ptr) Variable Function
+        37(clip):     12(ptr) Variable Function
+        41(cull):     12(ptr) Variable Function
+       46(param):      8(ptr) Variable Function
+       48(param):     12(ptr) Variable Function
+       50(param):     12(ptr) Variable Function
+              36:    7(fvec4) Load 35(pos)
+                              Store 33(pos) 36
+              40:          11 Load 39(clip)
+                              Store 37(clip) 40
+              43:          11 Load 42(cull)
+                              Store 41(cull) 43
+              47:    7(fvec4) Load 33(pos)
+                              Store 46(param) 47
+              49:          11 Load 37(clip)
+                              Store 48(param) 49
+              51:          11 Load 41(cull)
+                              Store 50(param) 51
+              52:    7(fvec4) FunctionCall 17(@main(vf4;f1[2];f1[2];) 46(param) 48(param) 50(param)
+                              Store 45(@entryPointOutput) 52
+                              Return
+                              FunctionEnd
+17(@main(vf4;f1[2];f1[2];):    7(fvec4) Function None 13
+         14(pos):      8(ptr) FunctionParameter
+        15(clip):     12(ptr) FunctionParameter
+        16(cull):     12(ptr) FunctionParameter
+              18:             Label
+              19:    7(fvec4) Load 14(pos)
+              23:     22(ptr) AccessChain 15(clip) 21
+              24:    6(float) Load 23
+              25:    7(fvec4) CompositeConstruct 24 24 24 24
+              26:    7(fvec4) FAdd 19 25
+              27:     22(ptr) AccessChain 16(cull) 21
+              28:    6(float) Load 27
+              29:    7(fvec4) CompositeConstruct 28 28 28 28
+              30:    7(fvec4) FAdd 26 29
+                              ReturnValue 30
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-3.geom.out b/Test/baseResults/hlsl.clipdistance-3.geom.out
new file mode 100644
index 0000000..d48c73a
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-3.geom.out
@@ -0,0 +1,830 @@
+hlsl.clipdistance-3.geom
+Shader version: 500
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:12  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3]; ( temp void)
+0:12    Function Parameters: 
+0:12      'pos' ( in 3-element array of 4-component vector of float)
+0:12      'VertexID' ( in 3-element array of uint)
+0:12      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:12      'clip' ( in 3-element array of 4-component vector of float)
+0:?     Sequence
+0:15      move second child to first child ( temp 4-component vector of float)
+0:15        pos: direct index for structure ( temp 4-component vector of float)
+0:15          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:15          Constant:
+0:15            0 (const int)
+0:15        direct index ( temp 4-component vector of float)
+0:15          'pos' ( in 3-element array of 4-component vector of float)
+0:15          Constant:
+0:15            0 (const int)
+0:16      move second child to first child ( temp 2-component vector of float)
+0:16        clip0: direct index for structure ( temp 2-component vector of float)
+0:16          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:16          Constant:
+0:16            1 (const int)
+0:16        vector swizzle ( temp 2-component vector of float)
+0:16          direct index ( temp 4-component vector of float)
+0:16            'clip' ( in 3-element array of 4-component vector of float)
+0:16            Constant:
+0:16              0 (const int)
+0:16          Sequence
+0:16            Constant:
+0:16              0 (const int)
+0:16            Constant:
+0:16              1 (const int)
+0:17      move second child to first child ( temp 2-component vector of float)
+0:17        clip1: direct index for structure ( temp 2-component vector of float)
+0:17          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:17          Constant:
+0:17            2 (const int)
+0:17        vector swizzle ( temp 2-component vector of float)
+0:17          direct index ( temp 4-component vector of float)
+0:17            'clip' ( in 3-element array of 4-component vector of float)
+0:17            Constant:
+0:17              0 (const int)
+0:17          Sequence
+0:17            Constant:
+0:17              2 (const int)
+0:17            Constant:
+0:17              3 (const int)
+0:19      Sequence
+0:19        Sequence
+0:19          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:19            pos: direct index for structure ( temp 4-component vector of float)
+0:19              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19              Constant:
+0:19                0 (const int)
+0:?           Sequence
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  0 (const int)
+0:19              direct index ( temp float)
+0:19                clip0: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    1 (const int)
+0:19                Constant:
+0:19                  0 (const int)
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  1 (const int)
+0:19              direct index ( temp float)
+0:19                clip0: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    1 (const int)
+0:19                Constant:
+0:19                  1 (const int)
+0:?           Sequence
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  2 (const int)
+0:19              direct index ( temp float)
+0:19                clip1: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    2 (const int)
+0:19                Constant:
+0:19                  0 (const int)
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  3 (const int)
+0:19              direct index ( temp float)
+0:19                clip1: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    2 (const int)
+0:19                Constant:
+0:19                  1 (const int)
+0:19        EmitVertex ( temp void)
+0:12  Function Definition: main( ( temp void)
+0:12    Function Parameters: 
+0:?     Sequence
+0:12      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:12      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:?         'clip' ( temp 3-element array of 4-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+
+
+Linked geometry stage:
+
+
+Shader version: 500
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:12  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3]; ( temp void)
+0:12    Function Parameters: 
+0:12      'pos' ( in 3-element array of 4-component vector of float)
+0:12      'VertexID' ( in 3-element array of uint)
+0:12      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:12      'clip' ( in 3-element array of 4-component vector of float)
+0:?     Sequence
+0:15      move second child to first child ( temp 4-component vector of float)
+0:15        pos: direct index for structure ( temp 4-component vector of float)
+0:15          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:15          Constant:
+0:15            0 (const int)
+0:15        direct index ( temp 4-component vector of float)
+0:15          'pos' ( in 3-element array of 4-component vector of float)
+0:15          Constant:
+0:15            0 (const int)
+0:16      move second child to first child ( temp 2-component vector of float)
+0:16        clip0: direct index for structure ( temp 2-component vector of float)
+0:16          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:16          Constant:
+0:16            1 (const int)
+0:16        vector swizzle ( temp 2-component vector of float)
+0:16          direct index ( temp 4-component vector of float)
+0:16            'clip' ( in 3-element array of 4-component vector of float)
+0:16            Constant:
+0:16              0 (const int)
+0:16          Sequence
+0:16            Constant:
+0:16              0 (const int)
+0:16            Constant:
+0:16              1 (const int)
+0:17      move second child to first child ( temp 2-component vector of float)
+0:17        clip1: direct index for structure ( temp 2-component vector of float)
+0:17          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:17          Constant:
+0:17            2 (const int)
+0:17        vector swizzle ( temp 2-component vector of float)
+0:17          direct index ( temp 4-component vector of float)
+0:17            'clip' ( in 3-element array of 4-component vector of float)
+0:17            Constant:
+0:17              0 (const int)
+0:17          Sequence
+0:17            Constant:
+0:17              2 (const int)
+0:17            Constant:
+0:17              3 (const int)
+0:19      Sequence
+0:19        Sequence
+0:19          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:19            pos: direct index for structure ( temp 4-component vector of float)
+0:19              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19              Constant:
+0:19                0 (const int)
+0:?           Sequence
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  0 (const int)
+0:19              direct index ( temp float)
+0:19                clip0: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    1 (const int)
+0:19                Constant:
+0:19                  0 (const int)
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  1 (const int)
+0:19              direct index ( temp float)
+0:19                clip0: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    1 (const int)
+0:19                Constant:
+0:19                  1 (const int)
+0:?           Sequence
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  2 (const int)
+0:19              direct index ( temp float)
+0:19                clip1: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    2 (const int)
+0:19                Constant:
+0:19                  0 (const int)
+0:19            move second child to first child ( temp float)
+0:19              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:19                Constant:
+0:19                  3 (const int)
+0:19              direct index ( temp float)
+0:19                clip1: direct index for structure ( temp 2-component vector of float)
+0:19                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:19                  Constant:
+0:19                    2 (const int)
+0:19                Constant:
+0:19                  1 (const int)
+0:19        EmitVertex ( temp void)
+0:12  Function Definition: main( ( temp void)
+0:12    Function Parameters: 
+0:?     Sequence
+0:12      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:12      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                0 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                1 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              0 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              1 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              2 (const int)
+0:12        move second child to first child ( temp float)
+0:12          direct index ( temp float)
+0:12            direct index ( temp 4-component vector of float)
+0:?               'clip' ( temp 3-element array of 4-component vector of float)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12          direct index ( in float ClipDistance)
+0:12            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:12              Constant:
+0:12                2 (const int)
+0:12            Constant:
+0:12              3 (const int)
+0:12      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:?         'clip' ( temp 3-element array of 4-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 127
+
+                              Capability Geometry
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Geometry 4  "main" 43 49 69 73 78
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 Invocations 1
+                              ExecutionMode 4 OutputLineStrip
+                              ExecutionMode 4 OutputVertices 3
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 15  "S"
+                              MemberName 15(S) 0  "pos"
+                              MemberName 15(S) 1  "clip0"
+                              MemberName 15(S) 2  "clip1"
+                              Name 22  "@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3];"
+                              Name 18  "pos"
+                              Name 19  "VertexID"
+                              Name 20  "OutputStream"
+                              Name 21  "clip"
+                              Name 24  "s"
+                              Name 43  "OutputStream.pos"
+                              Name 49  "OutputStream.clip1"
+                              Name 67  "pos"
+                              Name 69  "pos"
+                              Name 71  "VertexID"
+                              Name 73  "VertexID"
+                              Name 75  "clip"
+                              Name 78  "clip"
+                              Name 117  "OutputStream"
+                              Name 118  "param"
+                              Name 120  "param"
+                              Name 122  "param"
+                              Name 123  "param"
+                              Decorate 43(OutputStream.pos) BuiltIn Position
+                              Decorate 49(OutputStream.clip1) BuiltIn ClipDistance
+                              Decorate 69(pos) BuiltIn Position
+                              Decorate 73(VertexID) Location 0
+                              Decorate 78(clip) BuiltIn ClipDistance
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeInt 32 0
+               9:      8(int) Constant 3
+              10:             TypeArray 7(fvec4) 9
+              11:             TypePointer Function 10
+              12:             TypeArray 8(int) 9
+              13:             TypePointer Function 12
+              14:             TypeVector 6(float) 2
+           15(S):             TypeStruct 7(fvec4) 14(fvec2) 14(fvec2)
+              16:             TypePointer Function 15(S)
+              17:             TypeFunction 2 11(ptr) 13(ptr) 16(ptr) 11(ptr)
+              25:             TypeInt 32 1
+              26:     25(int) Constant 0
+              27:             TypePointer Function 7(fvec4)
+              31:     25(int) Constant 1
+              35:             TypePointer Function 14(fvec2)
+              37:     25(int) Constant 2
+              42:             TypePointer Output 7(fvec4)
+43(OutputStream.pos):     42(ptr) Variable Output
+              46:      8(int) Constant 4
+              47:             TypeArray 6(float) 46
+              48:             TypePointer Output 47
+49(OutputStream.clip1):     48(ptr) Variable Output
+              50:      8(int) Constant 0
+              51:             TypePointer Function 6(float)
+              54:             TypePointer Output 6(float)
+              56:      8(int) Constant 1
+              63:     25(int) Constant 3
+              68:             TypePointer Input 10
+         69(pos):     68(ptr) Variable Input
+              72:             TypePointer Input 12
+    73(VertexID):     72(ptr) Variable Input
+              76:             TypeArray 47 9
+              77:             TypePointer Input 76
+        78(clip):     77(ptr) Variable Input
+              79:             TypePointer Input 6(float)
+              88:      8(int) Constant 2
+         4(main):           2 Function None 3
+               5:             Label
+         67(pos):     11(ptr) Variable Function
+    71(VertexID):     13(ptr) Variable Function
+        75(clip):     11(ptr) Variable Function
+117(OutputStream):     16(ptr) Variable Function
+      118(param):     11(ptr) Variable Function
+      120(param):     13(ptr) Variable Function
+      122(param):     16(ptr) Variable Function
+      123(param):     11(ptr) Variable Function
+              70:          10 Load 69(pos)
+                              Store 67(pos) 70
+              74:          12 Load 73(VertexID)
+                              Store 71(VertexID) 74
+              80:     79(ptr) AccessChain 78(clip) 26 26
+              81:    6(float) Load 80
+              82:     51(ptr) AccessChain 75(clip) 26 50
+                              Store 82 81
+              83:     79(ptr) AccessChain 78(clip) 26 31
+              84:    6(float) Load 83
+              85:     51(ptr) AccessChain 75(clip) 26 56
+                              Store 85 84
+              86:     79(ptr) AccessChain 78(clip) 26 37
+              87:    6(float) Load 86
+              89:     51(ptr) AccessChain 75(clip) 26 88
+                              Store 89 87
+              90:     79(ptr) AccessChain 78(clip) 26 63
+              91:    6(float) Load 90
+              92:     51(ptr) AccessChain 75(clip) 26 9
+                              Store 92 91
+              93:     79(ptr) AccessChain 78(clip) 31 26
+              94:    6(float) Load 93
+              95:     51(ptr) AccessChain 75(clip) 31 50
+                              Store 95 94
+              96:     79(ptr) AccessChain 78(clip) 31 31
+              97:    6(float) Load 96
+              98:     51(ptr) AccessChain 75(clip) 31 56
+                              Store 98 97
+              99:     79(ptr) AccessChain 78(clip) 31 37
+             100:    6(float) Load 99
+             101:     51(ptr) AccessChain 75(clip) 31 88
+                              Store 101 100
+             102:     79(ptr) AccessChain 78(clip) 31 63
+             103:    6(float) Load 102
+             104:     51(ptr) AccessChain 75(clip) 31 9
+                              Store 104 103
+             105:     79(ptr) AccessChain 78(clip) 37 26
+             106:    6(float) Load 105
+             107:     51(ptr) AccessChain 75(clip) 37 50
+                              Store 107 106
+             108:     79(ptr) AccessChain 78(clip) 37 31
+             109:    6(float) Load 108
+             110:     51(ptr) AccessChain 75(clip) 37 56
+                              Store 110 109
+             111:     79(ptr) AccessChain 78(clip) 37 37
+             112:    6(float) Load 111
+             113:     51(ptr) AccessChain 75(clip) 37 88
+                              Store 113 112
+             114:     79(ptr) AccessChain 78(clip) 37 63
+             115:    6(float) Load 114
+             116:     51(ptr) AccessChain 75(clip) 37 9
+                              Store 116 115
+             119:          10 Load 67(pos)
+                              Store 118(param) 119
+             121:          12 Load 71(VertexID)
+                              Store 120(param) 121
+             124:          10 Load 75(clip)
+                              Store 123(param) 124
+             125:           2 FunctionCall 22(@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3];) 118(param) 120(param) 122(param) 123(param)
+             126:       15(S) Load 122(param)
+                              Store 117(OutputStream) 126
+                              Return
+                              FunctionEnd
+22(@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf4[3];):           2 Function None 17
+         18(pos):     11(ptr) FunctionParameter
+    19(VertexID):     13(ptr) FunctionParameter
+20(OutputStream):     16(ptr) FunctionParameter
+        21(clip):     11(ptr) FunctionParameter
+              23:             Label
+           24(s):     16(ptr) Variable Function
+              28:     27(ptr) AccessChain 18(pos) 26
+              29:    7(fvec4) Load 28
+              30:     27(ptr) AccessChain 24(s) 26
+                              Store 30 29
+              32:     27(ptr) AccessChain 21(clip) 26
+              33:    7(fvec4) Load 32
+              34:   14(fvec2) VectorShuffle 33 33 0 1
+              36:     35(ptr) AccessChain 24(s) 31
+                              Store 36 34
+              38:     27(ptr) AccessChain 21(clip) 26
+              39:    7(fvec4) Load 38
+              40:   14(fvec2) VectorShuffle 39 39 2 3
+              41:     35(ptr) AccessChain 24(s) 37
+                              Store 41 40
+              44:     27(ptr) AccessChain 24(s) 26
+              45:    7(fvec4) Load 44
+                              Store 43(OutputStream.pos) 45
+              52:     51(ptr) AccessChain 24(s) 31 50
+              53:    6(float) Load 52
+              55:     54(ptr) AccessChain 49(OutputStream.clip1) 26
+                              Store 55 53
+              57:     51(ptr) AccessChain 24(s) 31 56
+              58:    6(float) Load 57
+              59:     54(ptr) AccessChain 49(OutputStream.clip1) 31
+                              Store 59 58
+              60:     51(ptr) AccessChain 24(s) 37 50
+              61:    6(float) Load 60
+              62:     54(ptr) AccessChain 49(OutputStream.clip1) 37
+                              Store 62 61
+              64:     51(ptr) AccessChain 24(s) 37 56
+              65:    6(float) Load 64
+              66:     54(ptr) AccessChain 49(OutputStream.clip1) 63
+                              Store 66 65
+                              EmitVertex
+                              Return
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-4.frag.out b/Test/baseResults/hlsl.clipdistance-4.frag.out
new file mode 100644
index 0000000..b5fa6c5
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-4.frag.out
@@ -0,0 +1,262 @@
+hlsl.clipdistance-4.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7  Function Definition: @main(struct-VS_OUTPUT-vf4-vf41; ( temp 4-component vector of float)
+0:7    Function Parameters: 
+0:7      'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:?     Sequence
+0:8      Branch: Return with expression
+0:8        add ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:8            'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:8            Constant:
+0:8              0 (const int)
+0:8          ClipRect: direct index for structure ( temp 4-component vector of float)
+0:8            'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:8            Constant:
+0:8              1 (const int)
+0:7  Function Definition: main( ( temp void)
+0:7    Function Parameters: 
+0:?     Sequence
+0:7      Sequence
+0:7        move second child to first child ( temp 4-component vector of float)
+0:7          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7            Constant:
+0:7              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                0 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                1 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                2 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                2 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                3 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                3 (const int)
+0:7      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:7        Function Call: @main(struct-VS_OUTPUT-vf4-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.ClipRect' ( in 4-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7  Function Definition: @main(struct-VS_OUTPUT-vf4-vf41; ( temp 4-component vector of float)
+0:7    Function Parameters: 
+0:7      'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:?     Sequence
+0:8      Branch: Return with expression
+0:8        add ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:8            'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:8            Constant:
+0:8              0 (const int)
+0:8          ClipRect: direct index for structure ( temp 4-component vector of float)
+0:8            'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:8            Constant:
+0:8              1 (const int)
+0:7  Function Definition: main( ( temp void)
+0:7    Function Parameters: 
+0:?     Sequence
+0:7      Sequence
+0:7        move second child to first child ( temp 4-component vector of float)
+0:7          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7            Constant:
+0:7              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                0 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                1 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                2 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                2 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              ClipRect: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                3 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                3 (const int)
+0:7      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:7        Function Call: @main(struct-VS_OUTPUT-vf4-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float ClipRect})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.ClipRect' ( in 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 57
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 24 32 54
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 8  "VS_OUTPUT"
+                              MemberName 8(VS_OUTPUT) 0  "Position"
+                              MemberName 8(VS_OUTPUT) 1  "ClipRect"
+                              Name 11  "@main(struct-VS_OUTPUT-vf4-vf41;"
+                              Name 10  "v"
+                              Name 22  "v"
+                              Name 24  "v.Position"
+                              Name 32  "v.ClipRect"
+                              Name 54  "@entryPointOutput"
+                              Decorate 24(v.Position) BuiltIn FragCoord
+                              Decorate 32(v.ClipRect) BuiltIn ClipDistance
+                              Decorate 54(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+    8(VS_OUTPUT):             TypeStruct 7(fvec4) 7(fvec4)
+               9:             TypeFunction 7(fvec4) 8(VS_OUTPUT)
+              13:             TypeInt 32 1
+              14:     13(int) Constant 0
+              16:     13(int) Constant 1
+              21:             TypePointer Function 8(VS_OUTPUT)
+              23:             TypePointer Input 7(fvec4)
+  24(v.Position):     23(ptr) Variable Input
+              26:             TypePointer Function 7(fvec4)
+              28:             TypeInt 32 0
+              29:     28(int) Constant 4
+              30:             TypeArray 6(float) 29
+              31:             TypePointer Input 30
+  32(v.ClipRect):     31(ptr) Variable Input
+              33:             TypePointer Input 6(float)
+              36:     28(int) Constant 0
+              37:             TypePointer Function 6(float)
+              41:     28(int) Constant 1
+              43:     13(int) Constant 2
+              46:     28(int) Constant 2
+              48:     13(int) Constant 3
+              51:     28(int) Constant 3
+              53:             TypePointer Output 7(fvec4)
+54(@entryPointOutput):     53(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           22(v):     21(ptr) Variable Function
+              25:    7(fvec4) Load 24(v.Position)
+              27:     26(ptr) AccessChain 22(v) 14
+                              Store 27 25
+              34:     33(ptr) AccessChain 32(v.ClipRect) 14
+              35:    6(float) Load 34
+              38:     37(ptr) AccessChain 22(v) 16 36
+                              Store 38 35
+              39:     33(ptr) AccessChain 32(v.ClipRect) 16
+              40:    6(float) Load 39
+              42:     37(ptr) AccessChain 22(v) 16 41
+                              Store 42 40
+              44:     33(ptr) AccessChain 32(v.ClipRect) 43
+              45:    6(float) Load 44
+              47:     37(ptr) AccessChain 22(v) 16 46
+                              Store 47 45
+              49:     33(ptr) AccessChain 32(v.ClipRect) 48
+              50:    6(float) Load 49
+              52:     37(ptr) AccessChain 22(v) 16 51
+                              Store 52 50
+              55:8(VS_OUTPUT) Load 22(v)
+              56:    7(fvec4) FunctionCall 11(@main(struct-VS_OUTPUT-vf4-vf41;) 55
+                              Store 54(@entryPointOutput) 56
+                              Return
+                              FunctionEnd
+11(@main(struct-VS_OUTPUT-vf4-vf41;):    7(fvec4) Function None 9
+           10(v):8(VS_OUTPUT) FunctionParameter
+              12:             Label
+              15:    7(fvec4) CompositeExtract 10(v) 0
+              17:    7(fvec4) CompositeExtract 10(v) 1
+              18:    7(fvec4) FAdd 15 17
+                              ReturnValue 18
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-4.geom.out b/Test/baseResults/hlsl.clipdistance-4.geom.out
new file mode 100644
index 0000000..82d0c0a
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-4.geom.out
@@ -0,0 +1,819 @@
+hlsl.clipdistance-4.geom
+Shader version: 500
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:13  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3]; ( temp void)
+0:13    Function Parameters: 
+0:13      'pos' ( in 3-element array of 4-component vector of float)
+0:13      'VertexID' ( in 3-element array of uint)
+0:13      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:13      'clip0' ( in 3-element array of 2-component vector of float)
+0:13      'clip1' ( in 3-element array of 2-component vector of float)
+0:?     Sequence
+0:16      move second child to first child ( temp 4-component vector of float)
+0:16        pos: direct index for structure ( temp 4-component vector of float)
+0:16          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:16          Constant:
+0:16            0 (const int)
+0:16        direct index ( temp 4-component vector of float)
+0:16          'pos' ( in 3-element array of 4-component vector of float)
+0:16          Constant:
+0:16            0 (const int)
+0:17      move second child to first child ( temp 2-component vector of float)
+0:17        clip0: direct index for structure ( temp 2-component vector of float)
+0:17          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:17          Constant:
+0:17            1 (const int)
+0:17        direct index ( temp 2-component vector of float)
+0:17          'clip0' ( in 3-element array of 2-component vector of float)
+0:17          Constant:
+0:17            0 (const int)
+0:18      move second child to first child ( temp 2-component vector of float)
+0:18        clip1: direct index for structure ( temp 2-component vector of float)
+0:18          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:18          Constant:
+0:18            2 (const int)
+0:18        direct index ( temp 2-component vector of float)
+0:18          'clip1' ( in 3-element array of 2-component vector of float)
+0:18          Constant:
+0:18            0 (const int)
+0:20      Sequence
+0:20        Sequence
+0:20          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:20            pos: direct index for structure ( temp 4-component vector of float)
+0:20              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20              Constant:
+0:20                0 (const int)
+0:?           Sequence
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  0 (const int)
+0:20              direct index ( temp float)
+0:20                clip0: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    1 (const int)
+0:20                Constant:
+0:20                  0 (const int)
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  1 (const int)
+0:20              direct index ( temp float)
+0:20                clip0: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    1 (const int)
+0:20                Constant:
+0:20                  1 (const int)
+0:?           Sequence
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  2 (const int)
+0:20              direct index ( temp float)
+0:20                clip1: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    2 (const int)
+0:20                Constant:
+0:20                  0 (const int)
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  3 (const int)
+0:20              direct index ( temp float)
+0:20                clip1: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    2 (const int)
+0:20                Constant:
+0:20                  1 (const int)
+0:20        EmitVertex ( temp void)
+0:13  Function Definition: main( ( temp void)
+0:13    Function Parameters: 
+0:?     Sequence
+0:13      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:13      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:?       Sequence
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:?         'clip0' ( temp 3-element array of 2-component vector of float)
+0:?         'clip1' ( temp 3-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+
+
+Linked geometry stage:
+
+
+Shader version: 500
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = line_strip
+0:? Sequence
+0:13  Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3]; ( temp void)
+0:13    Function Parameters: 
+0:13      'pos' ( in 3-element array of 4-component vector of float)
+0:13      'VertexID' ( in 3-element array of uint)
+0:13      'OutputStream' ( out structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:13      'clip0' ( in 3-element array of 2-component vector of float)
+0:13      'clip1' ( in 3-element array of 2-component vector of float)
+0:?     Sequence
+0:16      move second child to first child ( temp 4-component vector of float)
+0:16        pos: direct index for structure ( temp 4-component vector of float)
+0:16          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:16          Constant:
+0:16            0 (const int)
+0:16        direct index ( temp 4-component vector of float)
+0:16          'pos' ( in 3-element array of 4-component vector of float)
+0:16          Constant:
+0:16            0 (const int)
+0:17      move second child to first child ( temp 2-component vector of float)
+0:17        clip0: direct index for structure ( temp 2-component vector of float)
+0:17          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:17          Constant:
+0:17            1 (const int)
+0:17        direct index ( temp 2-component vector of float)
+0:17          'clip0' ( in 3-element array of 2-component vector of float)
+0:17          Constant:
+0:17            0 (const int)
+0:18      move second child to first child ( temp 2-component vector of float)
+0:18        clip1: direct index for structure ( temp 2-component vector of float)
+0:18          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:18          Constant:
+0:18            2 (const int)
+0:18        direct index ( temp 2-component vector of float)
+0:18          'clip1' ( in 3-element array of 2-component vector of float)
+0:18          Constant:
+0:18            0 (const int)
+0:20      Sequence
+0:20        Sequence
+0:20          move second child to first child ( temp 4-component vector of float)
+0:?             'OutputStream.pos' ( out 4-component vector of float Position)
+0:20            pos: direct index for structure ( temp 4-component vector of float)
+0:20              's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20              Constant:
+0:20                0 (const int)
+0:?           Sequence
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  0 (const int)
+0:20              direct index ( temp float)
+0:20                clip0: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    1 (const int)
+0:20                Constant:
+0:20                  0 (const int)
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  1 (const int)
+0:20              direct index ( temp float)
+0:20                clip0: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    1 (const int)
+0:20                Constant:
+0:20                  1 (const int)
+0:?           Sequence
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  2 (const int)
+0:20              direct index ( temp float)
+0:20                clip1: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    2 (const int)
+0:20                Constant:
+0:20                  0 (const int)
+0:20            move second child to first child ( temp float)
+0:20              direct index ( out float ClipDistance)
+0:?                 'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+0:20                Constant:
+0:20                  3 (const int)
+0:20              direct index ( temp float)
+0:20                clip1: direct index for structure ( temp 2-component vector of float)
+0:20                  's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:20                  Constant:
+0:20                    2 (const int)
+0:20                Constant:
+0:20                  1 (const int)
+0:20        EmitVertex ( temp void)
+0:13  Function Definition: main( ( temp void)
+0:13    Function Parameters: 
+0:?     Sequence
+0:13      move second child to first child ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'pos' ( in 3-element array of 4-component vector of float Position)
+0:13      move second child to first child ( temp 3-element array of uint)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'VertexID' (layout( location=0) in 3-element array of uint)
+0:?       Sequence
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip0' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:?       Sequence
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                0 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                1 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              0 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              2 (const int)
+0:13        move second child to first child ( temp float)
+0:13          direct index ( temp float)
+0:13            direct index ( temp 2-component vector of float)
+0:?               'clip1' ( temp 3-element array of 2-component vector of float)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              1 (const int)
+0:13          direct index ( in float ClipDistance)
+0:13            direct index ( in 4-element array of float ClipDistance)
+0:?               'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:13              Constant:
+0:13                2 (const int)
+0:13            Constant:
+0:13              3 (const int)
+0:13      Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3]; ( temp void)
+0:?         'pos' ( temp 3-element array of 4-component vector of float)
+0:?         'VertexID' ( temp 3-element array of uint)
+0:?         'OutputStream' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float clip0,  temp 2-component vector of float clip1})
+0:?         'clip0' ( temp 3-element array of 2-component vector of float)
+0:?         'clip1' ( temp 3-element array of 2-component vector of float)
+0:?   Linker Objects
+0:?     'pos' ( in 3-element array of 4-component vector of float Position)
+0:?     'VertexID' (layout( location=0) in 3-element array of uint)
+0:?     'OutputStream.pos' ( out 4-component vector of float Position)
+0:?     'clip0' ( in 3-element array of 4-element array of float ClipDistance)
+0:?     'OutputStream.clip1' ( out 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 130
+
+                              Capability Geometry
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Geometry 4  "main" 44 50 70 74 79
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 Invocations 1
+                              ExecutionMode 4 OutputLineStrip
+                              ExecutionMode 4 OutputVertices 3
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 15  "S"
+                              MemberName 15(S) 0  "pos"
+                              MemberName 15(S) 1  "clip0"
+                              MemberName 15(S) 2  "clip1"
+                              Name 25  "@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3];"
+                              Name 20  "pos"
+                              Name 21  "VertexID"
+                              Name 22  "OutputStream"
+                              Name 23  "clip0"
+                              Name 24  "clip1"
+                              Name 27  "s"
+                              Name 44  "OutputStream.pos"
+                              Name 50  "OutputStream.clip1"
+                              Name 68  "pos"
+                              Name 70  "pos"
+                              Name 72  "VertexID"
+                              Name 74  "VertexID"
+                              Name 76  "clip0"
+                              Name 79  "clip0"
+                              Name 99  "clip1"
+                              Name 118  "OutputStream"
+                              Name 119  "param"
+                              Name 121  "param"
+                              Name 123  "param"
+                              Name 124  "param"
+                              Name 126  "param"
+                              Decorate 44(OutputStream.pos) BuiltIn Position
+                              Decorate 50(OutputStream.clip1) BuiltIn ClipDistance
+                              Decorate 70(pos) BuiltIn Position
+                              Decorate 74(VertexID) Location 0
+                              Decorate 79(clip0) BuiltIn ClipDistance
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeInt 32 0
+               9:      8(int) Constant 3
+              10:             TypeArray 7(fvec4) 9
+              11:             TypePointer Function 10
+              12:             TypeArray 8(int) 9
+              13:             TypePointer Function 12
+              14:             TypeVector 6(float) 2
+           15(S):             TypeStruct 7(fvec4) 14(fvec2) 14(fvec2)
+              16:             TypePointer Function 15(S)
+              17:             TypeArray 14(fvec2) 9
+              18:             TypePointer Function 17
+              19:             TypeFunction 2 11(ptr) 13(ptr) 16(ptr) 18(ptr) 18(ptr)
+              28:             TypeInt 32 1
+              29:     28(int) Constant 0
+              30:             TypePointer Function 7(fvec4)
+              34:     28(int) Constant 1
+              35:             TypePointer Function 14(fvec2)
+              39:     28(int) Constant 2
+              43:             TypePointer Output 7(fvec4)
+44(OutputStream.pos):     43(ptr) Variable Output
+              47:      8(int) Constant 4
+              48:             TypeArray 6(float) 47
+              49:             TypePointer Output 48
+50(OutputStream.clip1):     49(ptr) Variable Output
+              51:      8(int) Constant 0
+              52:             TypePointer Function 6(float)
+              55:             TypePointer Output 6(float)
+              57:      8(int) Constant 1
+              64:     28(int) Constant 3
+              69:             TypePointer Input 10
+         70(pos):     69(ptr) Variable Input
+              73:             TypePointer Input 12
+    74(VertexID):     73(ptr) Variable Input
+              77:             TypeArray 48 9
+              78:             TypePointer Input 77
+       79(clip0):     78(ptr) Variable Input
+              80:             TypePointer Input 6(float)
+         4(main):           2 Function None 3
+               5:             Label
+         68(pos):     11(ptr) Variable Function
+    72(VertexID):     13(ptr) Variable Function
+       76(clip0):     18(ptr) Variable Function
+       99(clip1):     18(ptr) Variable Function
+118(OutputStream):     16(ptr) Variable Function
+      119(param):     11(ptr) Variable Function
+      121(param):     13(ptr) Variable Function
+      123(param):     16(ptr) Variable Function
+      124(param):     18(ptr) Variable Function
+      126(param):     18(ptr) Variable Function
+              71:          10 Load 70(pos)
+                              Store 68(pos) 71
+              75:          12 Load 74(VertexID)
+                              Store 72(VertexID) 75
+              81:     80(ptr) AccessChain 79(clip0) 29 29
+              82:    6(float) Load 81
+              83:     52(ptr) AccessChain 76(clip0) 29 51
+                              Store 83 82
+              84:     80(ptr) AccessChain 79(clip0) 29 34
+              85:    6(float) Load 84
+              86:     52(ptr) AccessChain 76(clip0) 29 57
+                              Store 86 85
+              87:     80(ptr) AccessChain 79(clip0) 29 39
+              88:    6(float) Load 87
+              89:     52(ptr) AccessChain 76(clip0) 34 51
+                              Store 89 88
+              90:     80(ptr) AccessChain 79(clip0) 29 64
+              91:    6(float) Load 90
+              92:     52(ptr) AccessChain 76(clip0) 34 57
+                              Store 92 91
+              93:     80(ptr) AccessChain 79(clip0) 34 29
+              94:    6(float) Load 93
+              95:     52(ptr) AccessChain 76(clip0) 39 51
+                              Store 95 94
+              96:     80(ptr) AccessChain 79(clip0) 34 34
+              97:    6(float) Load 96
+              98:     52(ptr) AccessChain 76(clip0) 39 57
+                              Store 98 97
+             100:     80(ptr) AccessChain 79(clip0) 29 39
+             101:    6(float) Load 100
+             102:     52(ptr) AccessChain 99(clip1) 29 51
+                              Store 102 101
+             103:     80(ptr) AccessChain 79(clip0) 29 64
+             104:    6(float) Load 103
+             105:     52(ptr) AccessChain 99(clip1) 29 57
+                              Store 105 104
+             106:     80(ptr) AccessChain 79(clip0) 34 39
+             107:    6(float) Load 106
+             108:     52(ptr) AccessChain 99(clip1) 34 51
+                              Store 108 107
+             109:     80(ptr) AccessChain 79(clip0) 34 64
+             110:    6(float) Load 109
+             111:     52(ptr) AccessChain 99(clip1) 34 57
+                              Store 111 110
+             112:     80(ptr) AccessChain 79(clip0) 39 39
+             113:    6(float) Load 112
+             114:     52(ptr) AccessChain 99(clip1) 39 51
+                              Store 114 113
+             115:     80(ptr) AccessChain 79(clip0) 39 64
+             116:    6(float) Load 115
+             117:     52(ptr) AccessChain 99(clip1) 39 57
+                              Store 117 116
+             120:          10 Load 68(pos)
+                              Store 119(param) 120
+             122:          12 Load 72(VertexID)
+                              Store 121(param) 122
+             125:          17 Load 76(clip0)
+                              Store 124(param) 125
+             127:          17 Load 99(clip1)
+                              Store 126(param) 127
+             128:           2 FunctionCall 25(@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3];) 119(param) 121(param) 123(param) 124(param) 126(param)
+             129:       15(S) Load 123(param)
+                              Store 118(OutputStream) 129
+                              Return
+                              FunctionEnd
+25(@main(vf4[3];u1[3];struct-S-vf4-vf2-vf21;vf2[3];vf2[3];):           2 Function None 19
+         20(pos):     11(ptr) FunctionParameter
+    21(VertexID):     13(ptr) FunctionParameter
+22(OutputStream):     16(ptr) FunctionParameter
+       23(clip0):     18(ptr) FunctionParameter
+       24(clip1):     18(ptr) FunctionParameter
+              26:             Label
+           27(s):     16(ptr) Variable Function
+              31:     30(ptr) AccessChain 20(pos) 29
+              32:    7(fvec4) Load 31
+              33:     30(ptr) AccessChain 27(s) 29
+                              Store 33 32
+              36:     35(ptr) AccessChain 23(clip0) 29
+              37:   14(fvec2) Load 36
+              38:     35(ptr) AccessChain 27(s) 34
+                              Store 38 37
+              40:     35(ptr) AccessChain 24(clip1) 29
+              41:   14(fvec2) Load 40
+              42:     35(ptr) AccessChain 27(s) 39
+                              Store 42 41
+              45:     30(ptr) AccessChain 27(s) 29
+              46:    7(fvec4) Load 45
+                              Store 44(OutputStream.pos) 46
+              53:     52(ptr) AccessChain 27(s) 34 51
+              54:    6(float) Load 53
+              56:     55(ptr) AccessChain 50(OutputStream.clip1) 29
+                              Store 56 54
+              58:     52(ptr) AccessChain 27(s) 34 57
+              59:    6(float) Load 58
+              60:     55(ptr) AccessChain 50(OutputStream.clip1) 34
+                              Store 60 59
+              61:     52(ptr) AccessChain 27(s) 39 51
+              62:    6(float) Load 61
+              63:     55(ptr) AccessChain 50(OutputStream.clip1) 39
+                              Store 63 62
+              65:     52(ptr) AccessChain 27(s) 39 57
+              66:    6(float) Load 65
+              67:     55(ptr) AccessChain 50(OutputStream.clip1) 64
+                              Store 67 66
+                              EmitVertex
+                              Return
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-4.vert.out b/Test/baseResults/hlsl.clipdistance-4.vert.out
index 617f05b..ac99334 100644
--- a/Test/baseResults/hlsl.clipdistance-4.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-4.vert.out
@@ -80,7 +80,7 @@
 0:11              0 (const int)
 0:?         Sequence
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                0 (const int)
@@ -92,7 +92,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                1 (const int)
@@ -104,7 +104,7 @@
 0:11              Constant:
 0:11                1 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                2 (const int)
@@ -116,7 +116,7 @@
 0:11              Constant:
 0:11                2 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                3 (const int)
@@ -217,7 +217,7 @@
 0:11              0 (const int)
 0:?         Sequence
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                0 (const int)
@@ -229,7 +229,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                1 (const int)
@@ -241,7 +241,7 @@
 0:11              Constant:
 0:11                1 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                2 (const int)
@@ -253,7 +253,7 @@
 0:11              Constant:
 0:11                2 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                3 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-5.frag.out b/Test/baseResults/hlsl.clipdistance-5.frag.out
new file mode 100644
index 0000000..7c1bac5
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-5.frag.out
@@ -0,0 +1,325 @@
+hlsl.clipdistance-5.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7  Function Definition: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
+0:7    Function Parameters: 
+0:7      'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:?     Sequence
+0:8      Branch: Return with expression
+0:8        add ( temp 4-component vector of float)
+0:8          add ( temp 4-component vector of float)
+0:8            Position: direct index for structure ( temp 4-component vector of float)
+0:8              'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( temp float)
+0:8              direct index ( temp 2-component vector of float)
+0:8                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:8                  'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8                  Constant:
+0:8                    1 (const int)
+0:8                Constant:
+0:8                  0 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8          direct index ( temp float)
+0:8            direct index ( temp 2-component vector of float)
+0:8              ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:8                'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            Constant:
+0:8              0 (const int)
+0:7  Function Definition: main( ( temp void)
+0:7    Function Parameters: 
+0:?     Sequence
+0:7      Sequence
+0:7        move second child to first child ( temp 4-component vector of float)
+0:7          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7            Constant:
+0:7              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  0 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                0 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  0 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                1 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                2 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                3 (const int)
+0:7      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:7        Function Call: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.ClipRect' ( in 4-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7  Function Definition: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
+0:7    Function Parameters: 
+0:7      'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:?     Sequence
+0:8      Branch: Return with expression
+0:8        add ( temp 4-component vector of float)
+0:8          add ( temp 4-component vector of float)
+0:8            Position: direct index for structure ( temp 4-component vector of float)
+0:8              'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( temp float)
+0:8              direct index ( temp 2-component vector of float)
+0:8                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:8                  'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8                  Constant:
+0:8                    1 (const int)
+0:8                Constant:
+0:8                  0 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8          direct index ( temp float)
+0:8            direct index ( temp 2-component vector of float)
+0:8              ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:8                'v' ( const (read only) structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            Constant:
+0:8              0 (const int)
+0:7  Function Definition: main( ( temp void)
+0:7    Function Parameters: 
+0:?     Sequence
+0:7      Sequence
+0:7        move second child to first child ( temp 4-component vector of float)
+0:7          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7            Constant:
+0:7              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  0 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                0 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  0 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                1 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                0 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                2 (const int)
+0:7          move second child to first child ( temp float)
+0:7            direct index ( temp float)
+0:7              direct index ( temp 2-component vector of float)
+0:7                ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
+0:?                   'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:7                  Constant:
+0:7                    1 (const int)
+0:7                Constant:
+0:7                  1 (const int)
+0:7              Constant:
+0:7                1 (const int)
+0:7            direct index ( in float ClipDistance)
+0:?               'v.ClipRect' ( in 4-element array of float ClipDistance)
+0:7              Constant:
+0:7                3 (const int)
+0:7      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:7        Function Call: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 2-element array of 2-component vector of float ClipRect})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.ClipRect' ( in 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 62
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 33 40 59
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 12  "VS_OUTPUT"
+                              MemberName 12(VS_OUTPUT) 0  "Position"
+                              MemberName 12(VS_OUTPUT) 1  "ClipRect"
+                              Name 15  "@main(struct-VS_OUTPUT-vf4-vf2[2]1;"
+                              Name 14  "v"
+                              Name 31  "v"
+                              Name 33  "v.Position"
+                              Name 40  "v.ClipRect"
+                              Name 59  "@entryPointOutput"
+                              Decorate 33(v.Position) BuiltIn FragCoord
+                              Decorate 40(v.ClipRect) BuiltIn ClipDistance
+                              Decorate 59(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeVector 6(float) 2
+               9:             TypeInt 32 0
+              10:      9(int) Constant 2
+              11:             TypeArray 8(fvec2) 10
+   12(VS_OUTPUT):             TypeStruct 7(fvec4) 11
+              13:             TypeFunction 7(fvec4) 12(VS_OUTPUT)
+              17:             TypeInt 32 1
+              18:     17(int) Constant 0
+              20:     17(int) Constant 1
+              21:      9(int) Constant 0
+              30:             TypePointer Function 12(VS_OUTPUT)
+              32:             TypePointer Input 7(fvec4)
+  33(v.Position):     32(ptr) Variable Input
+              35:             TypePointer Function 7(fvec4)
+              37:      9(int) Constant 4
+              38:             TypeArray 6(float) 37
+              39:             TypePointer Input 38
+  40(v.ClipRect):     39(ptr) Variable Input
+              41:             TypePointer Input 6(float)
+              44:             TypePointer Function 6(float)
+              48:      9(int) Constant 1
+              50:     17(int) Constant 2
+              54:     17(int) Constant 3
+              58:             TypePointer Output 7(fvec4)
+59(@entryPointOutput):     58(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           31(v):     30(ptr) Variable Function
+              34:    7(fvec4) Load 33(v.Position)
+              36:     35(ptr) AccessChain 31(v) 18
+                              Store 36 34
+              42:     41(ptr) AccessChain 40(v.ClipRect) 18
+              43:    6(float) Load 42
+              45:     44(ptr) AccessChain 31(v) 20 18 21
+                              Store 45 43
+              46:     41(ptr) AccessChain 40(v.ClipRect) 20
+              47:    6(float) Load 46
+              49:     44(ptr) AccessChain 31(v) 20 18 48
+                              Store 49 47
+              51:     41(ptr) AccessChain 40(v.ClipRect) 50
+              52:    6(float) Load 51
+              53:     44(ptr) AccessChain 31(v) 20 20 21
+                              Store 53 52
+              55:     41(ptr) AccessChain 40(v.ClipRect) 54
+              56:    6(float) Load 55
+              57:     44(ptr) AccessChain 31(v) 20 20 48
+                              Store 57 56
+              60:12(VS_OUTPUT) Load 31(v)
+              61:    7(fvec4) FunctionCall 15(@main(struct-VS_OUTPUT-vf4-vf2[2]1;) 60
+                              Store 59(@entryPointOutput) 61
+                              Return
+                              FunctionEnd
+15(@main(struct-VS_OUTPUT-vf4-vf2[2]1;):    7(fvec4) Function None 13
+           14(v):12(VS_OUTPUT) FunctionParameter
+              16:             Label
+              19:    7(fvec4) CompositeExtract 14(v) 0
+              22:    6(float) CompositeExtract 14(v) 1 0 0
+              23:    7(fvec4) CompositeConstruct 22 22 22 22
+              24:    7(fvec4) FAdd 19 23
+              25:    6(float) CompositeExtract 14(v) 1 1 0
+              26:    7(fvec4) CompositeConstruct 25 25 25 25
+              27:    7(fvec4) FAdd 24 26
+                              ReturnValue 27
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-5.vert.out b/Test/baseResults/hlsl.clipdistance-5.vert.out
index 35a966b..7a50973 100644
--- a/Test/baseResults/hlsl.clipdistance-5.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-5.vert.out
@@ -92,7 +92,7 @@
 0:11              0 (const int)
 0:?         Sequence
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                0 (const int)
@@ -107,7 +107,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                1 (const int)
@@ -122,7 +122,7 @@
 0:11              Constant:
 0:11                1 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                2 (const int)
@@ -137,7 +137,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                3 (const int)
@@ -253,7 +253,7 @@
 0:11              0 (const int)
 0:?         Sequence
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                0 (const int)
@@ -268,7 +268,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                1 (const int)
@@ -283,7 +283,7 @@
 0:11              Constant:
 0:11                1 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                2 (const int)
@@ -298,7 +298,7 @@
 0:11              Constant:
 0:11                0 (const int)
 0:11          move second child to first child ( temp float)
-0:11            direct index ( temp float)
+0:11            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.ClipRect' ( out 4-element array of float ClipDistance)
 0:11              Constant:
 0:11                3 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-6.frag.out b/Test/baseResults/hlsl.clipdistance-6.frag.out
new file mode 100644
index 0000000..c249b0e
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-6.frag.out
@@ -0,0 +1,399 @@
+hlsl.clipdistance-6.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf4-vf41; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            clip0: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                1 (const int)
+0:9          clip1: direct index for structure ( temp 4-component vector of float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                4 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                5 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                6 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                7 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf4-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 8-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf4-vf41; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            clip0: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                1 (const int)
+0:9          clip1: direct index for structure ( temp 4-component vector of float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                4 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                5 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                6 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                7 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf4-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 4-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 8-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 79
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 31 38 75
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 8  "VS_OUTPUT"
+                              MemberName 8(VS_OUTPUT) 0  "Position"
+                              MemberName 8(VS_OUTPUT) 1  "clip0"
+                              MemberName 8(VS_OUTPUT) 2  "clip1"
+                              Name 12  "@main(struct-VS_OUTPUT-vf4-vf4-vf41;"
+                              Name 11  "v"
+                              Name 29  "v"
+                              Name 31  "v.Position"
+                              Name 38  "v.clip1"
+                              Name 75  "@entryPointOutput"
+                              Name 76  "param"
+                              Decorate 31(v.Position) BuiltIn FragCoord
+                              Decorate 38(v.clip1) BuiltIn ClipDistance
+                              Decorate 75(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+    8(VS_OUTPUT):             TypeStruct 7(fvec4) 7(fvec4) 7(fvec4)
+               9:             TypePointer Function 8(VS_OUTPUT)
+              10:             TypeFunction 7(fvec4) 9(ptr)
+              14:             TypeInt 32 1
+              15:     14(int) Constant 0
+              16:             TypePointer Function 7(fvec4)
+              19:     14(int) Constant 1
+              23:     14(int) Constant 2
+              30:             TypePointer Input 7(fvec4)
+  31(v.Position):     30(ptr) Variable Input
+              34:             TypeInt 32 0
+              35:     34(int) Constant 8
+              36:             TypeArray 6(float) 35
+              37:             TypePointer Input 36
+     38(v.clip1):     37(ptr) Variable Input
+              39:             TypePointer Input 6(float)
+              42:     34(int) Constant 0
+              43:             TypePointer Function 6(float)
+              47:     34(int) Constant 1
+              51:     34(int) Constant 2
+              53:     14(int) Constant 3
+              56:     34(int) Constant 3
+              58:     14(int) Constant 4
+              62:     14(int) Constant 5
+              66:     14(int) Constant 6
+              70:     14(int) Constant 7
+              74:             TypePointer Output 7(fvec4)
+75(@entryPointOutput):     74(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           29(v):      9(ptr) Variable Function
+       76(param):      9(ptr) Variable Function
+              32:    7(fvec4) Load 31(v.Position)
+              33:     16(ptr) AccessChain 29(v) 15
+                              Store 33 32
+              40:     39(ptr) AccessChain 38(v.clip1) 15
+              41:    6(float) Load 40
+              44:     43(ptr) AccessChain 29(v) 19 42
+                              Store 44 41
+              45:     39(ptr) AccessChain 38(v.clip1) 19
+              46:    6(float) Load 45
+              48:     43(ptr) AccessChain 29(v) 19 47
+                              Store 48 46
+              49:     39(ptr) AccessChain 38(v.clip1) 23
+              50:    6(float) Load 49
+              52:     43(ptr) AccessChain 29(v) 19 51
+                              Store 52 50
+              54:     39(ptr) AccessChain 38(v.clip1) 53
+              55:    6(float) Load 54
+              57:     43(ptr) AccessChain 29(v) 19 56
+                              Store 57 55
+              59:     39(ptr) AccessChain 38(v.clip1) 58
+              60:    6(float) Load 59
+              61:     43(ptr) AccessChain 29(v) 23 42
+                              Store 61 60
+              63:     39(ptr) AccessChain 38(v.clip1) 62
+              64:    6(float) Load 63
+              65:     43(ptr) AccessChain 29(v) 23 47
+                              Store 65 64
+              67:     39(ptr) AccessChain 38(v.clip1) 66
+              68:    6(float) Load 67
+              69:     43(ptr) AccessChain 29(v) 23 51
+                              Store 69 68
+              71:     39(ptr) AccessChain 38(v.clip1) 70
+              72:    6(float) Load 71
+              73:     43(ptr) AccessChain 29(v) 23 56
+                              Store 73 72
+              77:8(VS_OUTPUT) Load 29(v)
+                              Store 76(param) 77
+              78:    7(fvec4) FunctionCall 12(@main(struct-VS_OUTPUT-vf4-vf4-vf41;) 76(param)
+                              Store 75(@entryPointOutput) 78
+                              Return
+                              FunctionEnd
+12(@main(struct-VS_OUTPUT-vf4-vf4-vf41;):    7(fvec4) Function None 10
+           11(v):      9(ptr) FunctionParameter
+              13:             Label
+              17:     16(ptr) AccessChain 11(v) 15
+              18:    7(fvec4) Load 17
+              20:     16(ptr) AccessChain 11(v) 19
+              21:    7(fvec4) Load 20
+              22:    7(fvec4) FAdd 18 21
+              24:     16(ptr) AccessChain 11(v) 23
+              25:    7(fvec4) Load 24
+              26:    7(fvec4) FAdd 22 25
+                              ReturnValue 26
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-6.vert.out b/Test/baseResults/hlsl.clipdistance-6.vert.out
index 44ce6fd..6449482 100644
--- a/Test/baseResults/hlsl.clipdistance-6.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-6.vert.out
@@ -111,7 +111,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -123,7 +123,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -135,7 +135,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -147,7 +147,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                3 (const int)
@@ -160,7 +160,7 @@
 0:8                3 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                4 (const int)
@@ -172,7 +172,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                5 (const int)
@@ -184,7 +184,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                6 (const int)
@@ -196,7 +196,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                7 (const int)
@@ -327,7 +327,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -339,7 +339,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -351,7 +351,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -363,7 +363,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                3 (const int)
@@ -376,7 +376,7 @@
 0:8                3 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                4 (const int)
@@ -388,7 +388,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                5 (const int)
@@ -400,7 +400,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                6 (const int)
@@ -412,7 +412,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                7 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-7.frag.out b/Test/baseResults/hlsl.clipdistance-7.frag.out
new file mode 100644
index 0000000..e6e5c00
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-7.frag.out
@@ -0,0 +1,385 @@
+hlsl.clipdistance-7.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-vf41; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          direct index ( temp float)
+0:9            clip1: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                2 (const int)
+0:9            Constant:
+0:9              0 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                4 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                5 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                6 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                7 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 8-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-vf41; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          direct index ( temp float)
+0:9            clip1: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:9              Constant:
+0:9                2 (const int)
+0:9            Constant:
+0:9              0 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                4 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                5 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                6 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip1: direct index for structure ( temp 4-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:8                Constant:
+0:8                  2 (const int)
+0:8              Constant:
+0:8                3 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 8-element array of float ClipDistance)
+0:8              Constant:
+0:8                7 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-vf41; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp 4-component vector of float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 8-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 78
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 37 43 74
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 9  "VS_OUTPUT"
+                              MemberName 9(VS_OUTPUT) 0  "Position"
+                              MemberName 9(VS_OUTPUT) 1  "clip0"
+                              MemberName 9(VS_OUTPUT) 2  "clip1"
+                              Name 13  "@main(struct-VS_OUTPUT-vf4-vf3-vf41;"
+                              Name 12  "v"
+                              Name 35  "v"
+                              Name 37  "v.Position"
+                              Name 43  "v.clip1"
+                              Name 74  "@entryPointOutput"
+                              Name 75  "param"
+                              Decorate 37(v.Position) BuiltIn FragCoord
+                              Decorate 43(v.clip1) BuiltIn ClipDistance
+                              Decorate 74(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeVector 6(float) 3
+    9(VS_OUTPUT):             TypeStruct 7(fvec4) 8(fvec3) 7(fvec4)
+              10:             TypePointer Function 9(VS_OUTPUT)
+              11:             TypeFunction 7(fvec4) 10(ptr)
+              15:             TypeInt 32 1
+              16:     15(int) Constant 0
+              17:             TypePointer Function 7(fvec4)
+              20:     15(int) Constant 1
+              21:             TypeInt 32 0
+              22:     21(int) Constant 0
+              23:             TypePointer Function 6(float)
+              28:     15(int) Constant 2
+              36:             TypePointer Input 7(fvec4)
+  37(v.Position):     36(ptr) Variable Input
+              40:     21(int) Constant 8
+              41:             TypeArray 6(float) 40
+              42:             TypePointer Input 41
+     43(v.clip1):     42(ptr) Variable Input
+              44:             TypePointer Input 6(float)
+              50:     21(int) Constant 1
+              54:     21(int) Constant 2
+              56:     15(int) Constant 4
+              60:     15(int) Constant 5
+              64:     15(int) Constant 6
+              68:     15(int) Constant 7
+              71:     21(int) Constant 3
+              73:             TypePointer Output 7(fvec4)
+74(@entryPointOutput):     73(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           35(v):     10(ptr) Variable Function
+       75(param):     10(ptr) Variable Function
+              38:    7(fvec4) Load 37(v.Position)
+              39:     17(ptr) AccessChain 35(v) 16
+                              Store 39 38
+              45:     44(ptr) AccessChain 43(v.clip1) 16
+              46:    6(float) Load 45
+              47:     23(ptr) AccessChain 35(v) 20 22
+                              Store 47 46
+              48:     44(ptr) AccessChain 43(v.clip1) 20
+              49:    6(float) Load 48
+              51:     23(ptr) AccessChain 35(v) 20 50
+                              Store 51 49
+              52:     44(ptr) AccessChain 43(v.clip1) 28
+              53:    6(float) Load 52
+              55:     23(ptr) AccessChain 35(v) 20 54
+                              Store 55 53
+              57:     44(ptr) AccessChain 43(v.clip1) 56
+              58:    6(float) Load 57
+              59:     23(ptr) AccessChain 35(v) 28 22
+                              Store 59 58
+              61:     44(ptr) AccessChain 43(v.clip1) 60
+              62:    6(float) Load 61
+              63:     23(ptr) AccessChain 35(v) 28 50
+                              Store 63 62
+              65:     44(ptr) AccessChain 43(v.clip1) 64
+              66:    6(float) Load 65
+              67:     23(ptr) AccessChain 35(v) 28 54
+                              Store 67 66
+              69:     44(ptr) AccessChain 43(v.clip1) 68
+              70:    6(float) Load 69
+              72:     23(ptr) AccessChain 35(v) 28 71
+                              Store 72 70
+              76:9(VS_OUTPUT) Load 35(v)
+                              Store 75(param) 76
+              77:    7(fvec4) FunctionCall 13(@main(struct-VS_OUTPUT-vf4-vf3-vf41;) 75(param)
+                              Store 74(@entryPointOutput) 77
+                              Return
+                              FunctionEnd
+13(@main(struct-VS_OUTPUT-vf4-vf3-vf41;):    7(fvec4) Function None 11
+           12(v):     10(ptr) FunctionParameter
+              14:             Label
+              18:     17(ptr) AccessChain 12(v) 16
+              19:    7(fvec4) Load 18
+              24:     23(ptr) AccessChain 12(v) 20 22
+              25:    6(float) Load 24
+              26:    7(fvec4) CompositeConstruct 25 25 25 25
+              27:    7(fvec4) FAdd 19 26
+              29:     23(ptr) AccessChain 12(v) 28 22
+              30:    6(float) Load 29
+              31:    7(fvec4) CompositeConstruct 30 30 30 30
+              32:    7(fvec4) FAdd 27 31
+                              ReturnValue 32
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-7.vert.out b/Test/baseResults/hlsl.clipdistance-7.vert.out
index 49e6aee..5a93c2c 100644
--- a/Test/baseResults/hlsl.clipdistance-7.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-7.vert.out
@@ -101,7 +101,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -113,7 +113,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -125,7 +125,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -138,7 +138,7 @@
 0:8                2 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                4 (const int)
@@ -150,7 +150,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                5 (const int)
@@ -162,7 +162,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                6 (const int)
@@ -174,7 +174,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                7 (const int)
@@ -295,7 +295,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -307,7 +307,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -319,7 +319,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -332,7 +332,7 @@
 0:8                2 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                4 (const int)
@@ -344,7 +344,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                5 (const int)
@@ -356,7 +356,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                6 (const int)
@@ -368,7 +368,7 @@
 0:8              Constant:
 0:8                2 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 8-element array of float ClipDistance)
 0:8              Constant:
 0:8                7 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-8.frag.out b/Test/baseResults/hlsl.clipdistance-8.frag.out
new file mode 100644
index 0000000..6777efa
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-8.frag.out
@@ -0,0 +1,285 @@
+hlsl.clipdistance-8.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          clip1: direct index for structure ( temp float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            clip1: direct index for structure ( temp float)
+0:?               'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 4-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          clip1: direct index for structure ( temp float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            clip1: direct index for structure ( temp float)
+0:?               'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( in float ClipDistance)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 65
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 37 43 61
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 9  "VS_OUTPUT"
+                              MemberName 9(VS_OUTPUT) 0  "Position"
+                              MemberName 9(VS_OUTPUT) 1  "clip0"
+                              MemberName 9(VS_OUTPUT) 2  "clip1"
+                              Name 13  "@main(struct-VS_OUTPUT-vf4-vf3-f11;"
+                              Name 12  "v"
+                              Name 35  "v"
+                              Name 37  "v.Position"
+                              Name 43  "v.clip1"
+                              Name 61  "@entryPointOutput"
+                              Name 62  "param"
+                              Decorate 37(v.Position) BuiltIn FragCoord
+                              Decorate 43(v.clip1) BuiltIn ClipDistance
+                              Decorate 61(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeVector 6(float) 3
+    9(VS_OUTPUT):             TypeStruct 7(fvec4) 8(fvec3) 6(float)
+              10:             TypePointer Function 9(VS_OUTPUT)
+              11:             TypeFunction 7(fvec4) 10(ptr)
+              15:             TypeInt 32 1
+              16:     15(int) Constant 0
+              17:             TypePointer Function 7(fvec4)
+              20:     15(int) Constant 1
+              21:             TypeInt 32 0
+              22:     21(int) Constant 0
+              23:             TypePointer Function 6(float)
+              28:     15(int) Constant 2
+              36:             TypePointer Input 7(fvec4)
+  37(v.Position):     36(ptr) Variable Input
+              40:     21(int) Constant 4
+              41:             TypeArray 6(float) 40
+              42:             TypePointer Input 41
+     43(v.clip1):     42(ptr) Variable Input
+              44:             TypePointer Input 6(float)
+              50:     21(int) Constant 1
+              54:     21(int) Constant 2
+              56:     15(int) Constant 3
+              60:             TypePointer Output 7(fvec4)
+61(@entryPointOutput):     60(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           35(v):     10(ptr) Variable Function
+       62(param):     10(ptr) Variable Function
+              38:    7(fvec4) Load 37(v.Position)
+              39:     17(ptr) AccessChain 35(v) 16
+                              Store 39 38
+              45:     44(ptr) AccessChain 43(v.clip1) 16
+              46:    6(float) Load 45
+              47:     23(ptr) AccessChain 35(v) 20 22
+                              Store 47 46
+              48:     44(ptr) AccessChain 43(v.clip1) 20
+              49:    6(float) Load 48
+              51:     23(ptr) AccessChain 35(v) 20 50
+                              Store 51 49
+              52:     44(ptr) AccessChain 43(v.clip1) 28
+              53:    6(float) Load 52
+              55:     23(ptr) AccessChain 35(v) 20 54
+                              Store 55 53
+              57:     44(ptr) AccessChain 43(v.clip1) 56
+              58:    6(float) Load 57
+              59:     23(ptr) AccessChain 35(v) 28
+                              Store 59 58
+              63:9(VS_OUTPUT) Load 35(v)
+                              Store 62(param) 63
+              64:    7(fvec4) FunctionCall 13(@main(struct-VS_OUTPUT-vf4-vf3-f11;) 62(param)
+                              Store 61(@entryPointOutput) 64
+                              Return
+                              FunctionEnd
+13(@main(struct-VS_OUTPUT-vf4-vf3-f11;):    7(fvec4) Function None 11
+           12(v):     10(ptr) FunctionParameter
+              14:             Label
+              18:     17(ptr) AccessChain 12(v) 16
+              19:    7(fvec4) Load 18
+              24:     23(ptr) AccessChain 12(v) 20 22
+              25:    6(float) Load 24
+              26:    7(fvec4) CompositeConstruct 25 25 25 25
+              27:    7(fvec4) FAdd 19 26
+              29:     23(ptr) AccessChain 12(v) 28
+              30:    6(float) Load 29
+              31:    7(fvec4) CompositeConstruct 30 30 30 30
+              32:    7(fvec4) FAdd 27 31
+                              ReturnValue 32
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-8.vert.out b/Test/baseResults/hlsl.clipdistance-8.vert.out
index 80a2909..1705f2b 100644
--- a/Test/baseResults/hlsl.clipdistance-8.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-8.vert.out
@@ -68,7 +68,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -80,7 +80,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -92,7 +92,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -105,7 +105,7 @@
 0:8                2 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                3 (const int)
@@ -190,7 +190,7 @@
 0:8              0 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                0 (const int)
@@ -202,7 +202,7 @@
 0:8              Constant:
 0:8                0 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                1 (const int)
@@ -214,7 +214,7 @@
 0:8              Constant:
 0:8                1 (const int)
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                2 (const int)
@@ -227,7 +227,7 @@
 0:8                2 (const int)
 0:?         Sequence
 0:8          move second child to first child ( temp float)
-0:8            direct index ( temp float)
+0:8            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 4-element array of float ClipDistance)
 0:8              Constant:
 0:8                3 (const int)
diff --git a/Test/baseResults/hlsl.clipdistance-9.frag.out b/Test/baseResults/hlsl.clipdistance-9.frag.out
new file mode 100644
index 0000000..b5c0926
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-9.frag.out
@@ -0,0 +1,250 @@
+hlsl.clipdistance-9.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:6  Function Definition: @main(vf4;vf3;f1; ( temp 4-component vector of float)
+0:6    Function Parameters: 
+0:6      'Position' ( in 4-component vector of float)
+0:6      'clip0' ( in 3-component vector of float)
+0:6      'clip1' ( in float)
+0:?     Sequence
+0:7      Branch: Return with expression
+0:7        add ( temp 4-component vector of float)
+0:7          add ( temp 4-component vector of float)
+0:7            'Position' ( in 4-component vector of float)
+0:7            direct index ( temp float)
+0:7              'clip0' ( in 3-component vector of float)
+0:7              Constant:
+0:7                0 (const int)
+0:7          'clip1' ( in float)
+0:6  Function Definition: main( ( temp void)
+0:6    Function Parameters: 
+0:?     Sequence
+0:6      move second child to first child ( temp 4-component vector of float)
+0:?         'Position' ( temp 4-component vector of float)
+0:?         'Position' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              0 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              0 (const int)
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              1 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              1 (const int)
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              2 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              2 (const int)
+0:?       Sequence
+0:6        move second child to first child ( temp float)
+0:?           'clip1' ( temp float)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              3 (const int)
+0:6      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:6        Function Call: @main(vf4;vf3;f1; ( temp 4-component vector of float)
+0:?           'Position' ( temp 4-component vector of float)
+0:?           'clip0' ( temp 3-component vector of float)
+0:?           'clip1' ( temp float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'Position' ( in 4-component vector of float FragCoord)
+0:?     'clip0' ( in 4-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:6  Function Definition: @main(vf4;vf3;f1; ( temp 4-component vector of float)
+0:6    Function Parameters: 
+0:6      'Position' ( in 4-component vector of float)
+0:6      'clip0' ( in 3-component vector of float)
+0:6      'clip1' ( in float)
+0:?     Sequence
+0:7      Branch: Return with expression
+0:7        add ( temp 4-component vector of float)
+0:7          add ( temp 4-component vector of float)
+0:7            'Position' ( in 4-component vector of float)
+0:7            direct index ( temp float)
+0:7              'clip0' ( in 3-component vector of float)
+0:7              Constant:
+0:7                0 (const int)
+0:7          'clip1' ( in float)
+0:6  Function Definition: main( ( temp void)
+0:6    Function Parameters: 
+0:?     Sequence
+0:6      move second child to first child ( temp 4-component vector of float)
+0:?         'Position' ( temp 4-component vector of float)
+0:?         'Position' ( in 4-component vector of float FragCoord)
+0:?       Sequence
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              0 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              0 (const int)
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              1 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              1 (const int)
+0:6        move second child to first child ( temp float)
+0:6          direct index ( temp float)
+0:?             'clip0' ( temp 3-component vector of float)
+0:6            Constant:
+0:6              2 (const int)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              2 (const int)
+0:?       Sequence
+0:6        move second child to first child ( temp float)
+0:?           'clip1' ( temp float)
+0:6          direct index ( in float ClipDistance)
+0:?             'clip0' ( in 4-element array of float ClipDistance)
+0:6            Constant:
+0:6              3 (const int)
+0:6      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:6        Function Call: @main(vf4;vf3;f1; ( temp 4-component vector of float)
+0:?           'Position' ( temp 4-component vector of float)
+0:?           'clip0' ( temp 3-component vector of float)
+0:?           'clip1' ( temp float)
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'Position' ( in 4-component vector of float FragCoord)
+0:?     'clip0' ( in 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 68
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 32 38 60
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 16  "@main(vf4;vf3;f1;"
+                              Name 13  "Position"
+                              Name 14  "clip0"
+                              Name 15  "clip1"
+                              Name 30  "Position"
+                              Name 32  "Position"
+                              Name 34  "clip0"
+                              Name 38  "clip0"
+                              Name 55  "clip1"
+                              Name 60  "@entryPointOutput"
+                              Name 61  "param"
+                              Name 63  "param"
+                              Name 65  "param"
+                              Decorate 32(Position) BuiltIn FragCoord
+                              Decorate 38(clip0) BuiltIn ClipDistance
+                              Decorate 60(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypePointer Function 7(fvec4)
+               9:             TypeVector 6(float) 3
+              10:             TypePointer Function 9(fvec3)
+              11:             TypePointer Function 6(float)
+              12:             TypeFunction 7(fvec4) 8(ptr) 10(ptr) 11(ptr)
+              19:             TypeInt 32 0
+              20:     19(int) Constant 0
+              31:             TypePointer Input 7(fvec4)
+    32(Position):     31(ptr) Variable Input
+              35:     19(int) Constant 4
+              36:             TypeArray 6(float) 35
+              37:             TypePointer Input 36
+       38(clip0):     37(ptr) Variable Input
+              39:             TypeInt 32 1
+              40:     39(int) Constant 0
+              41:             TypePointer Input 6(float)
+              45:     39(int) Constant 1
+              48:     19(int) Constant 1
+              50:     39(int) Constant 2
+              53:     19(int) Constant 2
+              56:     39(int) Constant 3
+              59:             TypePointer Output 7(fvec4)
+60(@entryPointOutput):     59(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+    30(Position):      8(ptr) Variable Function
+       34(clip0):     10(ptr) Variable Function
+       55(clip1):     11(ptr) Variable Function
+       61(param):      8(ptr) Variable Function
+       63(param):     10(ptr) Variable Function
+       65(param):     11(ptr) Variable Function
+              33:    7(fvec4) Load 32(Position)
+                              Store 30(Position) 33
+              42:     41(ptr) AccessChain 38(clip0) 40
+              43:    6(float) Load 42
+              44:     11(ptr) AccessChain 34(clip0) 20
+                              Store 44 43
+              46:     41(ptr) AccessChain 38(clip0) 45
+              47:    6(float) Load 46
+              49:     11(ptr) AccessChain 34(clip0) 48
+                              Store 49 47
+              51:     41(ptr) AccessChain 38(clip0) 50
+              52:    6(float) Load 51
+              54:     11(ptr) AccessChain 34(clip0) 53
+                              Store 54 52
+              57:     41(ptr) AccessChain 38(clip0) 56
+              58:    6(float) Load 57
+                              Store 55(clip1) 58
+              62:    7(fvec4) Load 30(Position)
+                              Store 61(param) 62
+              64:    9(fvec3) Load 34(clip0)
+                              Store 63(param) 64
+              66:    6(float) Load 55(clip1)
+                              Store 65(param) 66
+              67:    7(fvec4) FunctionCall 16(@main(vf4;vf3;f1;) 61(param) 63(param) 65(param)
+                              Store 60(@entryPointOutput) 67
+                              Return
+                              FunctionEnd
+16(@main(vf4;vf3;f1;):    7(fvec4) Function None 12
+    13(Position):      8(ptr) FunctionParameter
+       14(clip0):     10(ptr) FunctionParameter
+       15(clip1):     11(ptr) FunctionParameter
+              17:             Label
+              18:    7(fvec4) Load 13(Position)
+              21:     11(ptr) AccessChain 14(clip0) 20
+              22:    6(float) Load 21
+              23:    7(fvec4) CompositeConstruct 22 22 22 22
+              24:    7(fvec4) FAdd 18 23
+              25:    6(float) Load 15(clip1)
+              26:    7(fvec4) CompositeConstruct 25 25 25 25
+              27:    7(fvec4) FAdd 24 26
+                              ReturnValue 27
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.clipdistance-9.vert.out b/Test/baseResults/hlsl.clipdistance-9.vert.out
index 8e5b3dd..f984be0 100644
--- a/Test/baseResults/hlsl.clipdistance-9.vert.out
+++ b/Test/baseResults/hlsl.clipdistance-9.vert.out
@@ -57,7 +57,7 @@
 0:7              0 (const int)
 0:?       Sequence
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              0 (const int)
@@ -66,7 +66,7 @@
 0:7            Constant:
 0:7              0 (const int)
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              1 (const int)
@@ -75,7 +75,7 @@
 0:7            Constant:
 0:7              1 (const int)
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              2 (const int)
@@ -85,7 +85,7 @@
 0:7              2 (const int)
 0:?       Sequence
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              3 (const int)
@@ -156,7 +156,7 @@
 0:7              0 (const int)
 0:?       Sequence
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              0 (const int)
@@ -165,7 +165,7 @@
 0:7            Constant:
 0:7              0 (const int)
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              1 (const int)
@@ -174,7 +174,7 @@
 0:7            Constant:
 0:7              1 (const int)
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              2 (const int)
@@ -184,7 +184,7 @@
 0:7              2 (const int)
 0:?       Sequence
 0:7        move second child to first child ( temp float)
-0:7          direct index ( temp float)
+0:7          direct index ( out float ClipDistance)
 0:?             'clip0' ( out 4-element array of float ClipDistance)
 0:7            Constant:
 0:7              3 (const int)
diff --git a/Test/baseResults/hlsl.preprocessor.frag.out b/Test/baseResults/hlsl.preprocessor.frag.out
new file mode 100644
index 0000000..1db7c24
--- /dev/null
+++ b/Test/baseResults/hlsl.preprocessor.frag.out
@@ -0,0 +1,163 @@
+hlsl.preprocessor.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:9  Function Definition: @main(vf4; ( temp 4-component vector of float)
+0:9    Function Parameters: 
+0:9      'input' ( in 4-component vector of float)
+0:?     Sequence
+0:10      Sequence
+0:10        move second child to first child ( temp 4-component vector of float)
+0:10          'tex' ( temp 4-component vector of float)
+0:10          texture ( temp 4-component vector of float)
+0:10            Construct combined texture-sampler ( temp sampler2D)
+0:10              'test_texture' ( uniform texture2D)
+0:10              'test_texture_ss' ( uniform sampler)
+0:10            vector swizzle ( temp 2-component vector of float)
+0:10              vector swizzle ( temp 2-component vector of float)
+0:10                'input' ( in 4-component vector of float)
+0:10                Sequence
+0:10                  Constant:
+0:10                    0 (const int)
+0:10                  Constant:
+0:10                    1 (const int)
+0:10              Sequence
+0:10                Constant:
+0:10                  0 (const int)
+0:10                Constant:
+0:10                  1 (const int)
+0:11      Branch: Return with expression
+0:11        'tex' ( temp 4-component vector of float)
+0:9  Function Definition: main( ( temp void)
+0:9    Function Parameters: 
+0:?     Sequence
+0:9      move second child to first child ( temp 4-component vector of float)
+0:?         'input' ( temp 4-component vector of float)
+0:?         'input' (layout( location=0) in 4-component vector of float)
+0:9      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:9        Function Call: @main(vf4; ( temp 4-component vector of float)
+0:?           'input' ( temp 4-component vector of float)
+0:?   Linker Objects
+0:?     'test_texture' ( uniform texture2D)
+0:?     'test_texture_ss' ( uniform sampler)
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'input' (layout( location=0) in 4-component vector of float)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:9  Function Definition: @main(vf4; ( temp 4-component vector of float)
+0:9    Function Parameters: 
+0:9      'input' ( in 4-component vector of float)
+0:?     Sequence
+0:10      Sequence
+0:10        move second child to first child ( temp 4-component vector of float)
+0:10          'tex' ( temp 4-component vector of float)
+0:10          texture ( temp 4-component vector of float)
+0:10            Construct combined texture-sampler ( temp sampler2D)
+0:10              'test_texture' ( uniform texture2D)
+0:10              'test_texture_ss' ( uniform sampler)
+0:10            vector swizzle ( temp 2-component vector of float)
+0:10              vector swizzle ( temp 2-component vector of float)
+0:10                'input' ( in 4-component vector of float)
+0:10                Sequence
+0:10                  Constant:
+0:10                    0 (const int)
+0:10                  Constant:
+0:10                    1 (const int)
+0:10              Sequence
+0:10                Constant:
+0:10                  0 (const int)
+0:10                Constant:
+0:10                  1 (const int)
+0:11      Branch: Return with expression
+0:11        'tex' ( temp 4-component vector of float)
+0:9  Function Definition: main( ( temp void)
+0:9    Function Parameters: 
+0:?     Sequence
+0:9      move second child to first child ( temp 4-component vector of float)
+0:?         'input' ( temp 4-component vector of float)
+0:?         'input' (layout( location=0) in 4-component vector of float)
+0:9      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:9        Function Call: @main(vf4; ( temp 4-component vector of float)
+0:?           'input' ( temp 4-component vector of float)
+0:?   Linker Objects
+0:?     'test_texture' ( uniform texture2D)
+0:?     'test_texture_ss' ( uniform sampler)
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'input' (layout( location=0) in 4-component vector of float)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 40
+
+                              Capability Shader
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 33 36
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 11  "@main(vf4;"
+                              Name 10  "input"
+                              Name 13  "tex"
+                              Name 16  "test_texture"
+                              Name 20  "test_texture_ss"
+                              Name 31  "input"
+                              Name 33  "input"
+                              Name 36  "@entryPointOutput"
+                              Name 37  "param"
+                              Decorate 16(test_texture) DescriptorSet 0
+                              Decorate 20(test_texture_ss) DescriptorSet 0
+                              Decorate 33(input) Location 0
+                              Decorate 36(@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)
+              14:             TypeImage 6(float) 2D sampled format:Unknown
+              15:             TypePointer UniformConstant 14
+16(test_texture):     15(ptr) Variable UniformConstant
+              18:             TypeSampler
+              19:             TypePointer UniformConstant 18
+20(test_texture_ss):     19(ptr) Variable UniformConstant
+              22:             TypeSampledImage 14
+              24:             TypeVector 6(float) 2
+              32:             TypePointer Input 7(fvec4)
+       33(input):     32(ptr) Variable Input
+              35:             TypePointer Output 7(fvec4)
+36(@entryPointOutput):     35(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+       31(input):      8(ptr) Variable Function
+       37(param):      8(ptr) Variable Function
+              34:    7(fvec4) Load 33(input)
+                              Store 31(input) 34
+              38:    7(fvec4) Load 31(input)
+                              Store 37(param) 38
+              39:    7(fvec4) FunctionCall 11(@main(vf4;) 37(param)
+                              Store 36(@entryPointOutput) 39
+                              Return
+                              FunctionEnd
+  11(@main(vf4;):    7(fvec4) Function None 9
+       10(input):      8(ptr) FunctionParameter
+              12:             Label
+         13(tex):      8(ptr) Variable Function
+              17:          14 Load 16(test_texture)
+              21:          18 Load 20(test_texture_ss)
+              23:          22 SampledImage 17 21
+              25:    7(fvec4) Load 10(input)
+              26:   24(fvec2) VectorShuffle 25 25 0 1
+              27:    7(fvec4) ImageSampleImplicitLod 23 26
+                              Store 13(tex) 27
+              28:    7(fvec4) Load 13(tex)
+                              ReturnValue 28
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.semantic-1.vert.out b/Test/baseResults/hlsl.semantic-1.vert.out
new file mode 100644
index 0000000..9678570
--- /dev/null
+++ b/Test/baseResults/hlsl.semantic-1.vert.out
@@ -0,0 +1,374 @@
+hlsl.semantic-1.vert
+Shader version: 500
+0:? Sequence
+0:16  Function Definition: @main(vf4; ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16    Function Parameters: 
+0:16      'v' ( in 4-component vector of float)
+0:?     Sequence
+0:18      move second child to first child ( temp 4-component vector of float)
+0:18        pos: direct index for structure ( temp 4-component vector of float)
+0:18          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:18          Constant:
+0:18            0 (const int)
+0:18        'v' ( in 4-component vector of float)
+0:19      move second child to first child ( temp 2-component vector of float)
+0:19        UV0: direct index for structure ( temp 2-component vector of float)
+0:19          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:19          Constant:
+0:19            1 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:19          direct index ( temp float)
+0:19            'v' ( in 4-component vector of float)
+0:19            Constant:
+0:19              0 (const int)
+0:19          direct index ( temp float)
+0:19            'v' ( in 4-component vector of float)
+0:19            Constant:
+0:19              0 (const int)
+0:20      move second child to first child ( temp 2-component vector of float)
+0:20        UV1: direct index for structure ( temp 2-component vector of float)
+0:20          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:20          Constant:
+0:20            2 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:20          direct index ( temp float)
+0:20            'v' ( in 4-component vector of float)
+0:20            Constant:
+0:20              1 (const int)
+0:20          direct index ( temp float)
+0:20            'v' ( in 4-component vector of float)
+0:20            Constant:
+0:20              1 (const int)
+0:21      move second child to first child ( temp 2-component vector of float)
+0:21        UV2: direct index for structure ( temp 2-component vector of float)
+0:21          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:21          Constant:
+0:21            3 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:21          direct index ( temp float)
+0:21            'v' ( in 4-component vector of float)
+0:21            Constant:
+0:21              2 (const int)
+0:21          direct index ( temp float)
+0:21            'v' ( in 4-component vector of float)
+0:21            Constant:
+0:21              2 (const int)
+0:22      move second child to first child ( temp 2-component vector of float)
+0:22        UV3: direct index for structure ( temp 2-component vector of float)
+0:22          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:22          Constant:
+0:22            4 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:22          direct index ( temp float)
+0:22            'v' ( in 4-component vector of float)
+0:22            Constant:
+0:22              3 (const int)
+0:22          direct index ( temp float)
+0:22            'v' ( in 4-component vector of float)
+0:22            Constant:
+0:22              3 (const int)
+0:23      Branch: Return with expression
+0:23        's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16  Function Definition: main( ( temp void)
+0:16    Function Parameters: 
+0:?     Sequence
+0:16      move second child to first child ( temp 4-component vector of float)
+0:?         'v' ( temp 4-component vector of float)
+0:?         'v' (layout( location=0) in 4-component vector of float)
+0:16      Sequence
+0:16        move second child to first child ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16          'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16          Function Call: @main(vf4; ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:?             'v' ( temp 4-component vector of float)
+0:16        move second child to first child ( temp 4-component vector of float)
+0:?           '@entryPointOutput.pos' (layout( location=0) out 4-component vector of float)
+0:16          pos: direct index for structure ( temp 4-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              0 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV0' (layout( location=1) out 2-component vector of float)
+0:16          UV0: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              1 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV1' (layout( location=2) out 2-component vector of float)
+0:16          UV1: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              2 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV2' (layout( location=3) out 2-component vector of float)
+0:16          UV2: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              3 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV3' (layout( location=4) out 2-component vector of float)
+0:16          UV3: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              4 (const int)
+0:?   Linker Objects
+0:?     '@entryPointOutput.pos' (layout( location=0) out 4-component vector of float)
+0:?     '@entryPointOutput.UV0' (layout( location=1) out 2-component vector of float)
+0:?     '@entryPointOutput.UV1' (layout( location=2) out 2-component vector of float)
+0:?     '@entryPointOutput.UV2' (layout( location=3) out 2-component vector of float)
+0:?     '@entryPointOutput.UV3' (layout( location=4) out 2-component vector of float)
+0:?     'v' (layout( location=0) in 4-component vector of float)
+
+
+Linked vertex stage:
+
+
+Shader version: 500
+0:? Sequence
+0:16  Function Definition: @main(vf4; ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16    Function Parameters: 
+0:16      'v' ( in 4-component vector of float)
+0:?     Sequence
+0:18      move second child to first child ( temp 4-component vector of float)
+0:18        pos: direct index for structure ( temp 4-component vector of float)
+0:18          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:18          Constant:
+0:18            0 (const int)
+0:18        'v' ( in 4-component vector of float)
+0:19      move second child to first child ( temp 2-component vector of float)
+0:19        UV0: direct index for structure ( temp 2-component vector of float)
+0:19          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:19          Constant:
+0:19            1 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:19          direct index ( temp float)
+0:19            'v' ( in 4-component vector of float)
+0:19            Constant:
+0:19              0 (const int)
+0:19          direct index ( temp float)
+0:19            'v' ( in 4-component vector of float)
+0:19            Constant:
+0:19              0 (const int)
+0:20      move second child to first child ( temp 2-component vector of float)
+0:20        UV1: direct index for structure ( temp 2-component vector of float)
+0:20          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:20          Constant:
+0:20            2 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:20          direct index ( temp float)
+0:20            'v' ( in 4-component vector of float)
+0:20            Constant:
+0:20              1 (const int)
+0:20          direct index ( temp float)
+0:20            'v' ( in 4-component vector of float)
+0:20            Constant:
+0:20              1 (const int)
+0:21      move second child to first child ( temp 2-component vector of float)
+0:21        UV2: direct index for structure ( temp 2-component vector of float)
+0:21          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:21          Constant:
+0:21            3 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:21          direct index ( temp float)
+0:21            'v' ( in 4-component vector of float)
+0:21            Constant:
+0:21              2 (const int)
+0:21          direct index ( temp float)
+0:21            'v' ( in 4-component vector of float)
+0:21            Constant:
+0:21              2 (const int)
+0:22      move second child to first child ( temp 2-component vector of float)
+0:22        UV3: direct index for structure ( temp 2-component vector of float)
+0:22          's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:22          Constant:
+0:22            4 (const int)
+0:?         Construct vec2 ( temp 2-component vector of float)
+0:22          direct index ( temp float)
+0:22            'v' ( in 4-component vector of float)
+0:22            Constant:
+0:22              3 (const int)
+0:22          direct index ( temp float)
+0:22            'v' ( in 4-component vector of float)
+0:22            Constant:
+0:22              3 (const int)
+0:23      Branch: Return with expression
+0:23        's' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16  Function Definition: main( ( temp void)
+0:16    Function Parameters: 
+0:?     Sequence
+0:16      move second child to first child ( temp 4-component vector of float)
+0:?         'v' ( temp 4-component vector of float)
+0:?         'v' (layout( location=0) in 4-component vector of float)
+0:16      Sequence
+0:16        move second child to first child ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16          'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16          Function Call: @main(vf4; ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:?             'v' ( temp 4-component vector of float)
+0:16        move second child to first child ( temp 4-component vector of float)
+0:?           '@entryPointOutput.pos' (layout( location=0) out 4-component vector of float)
+0:16          pos: direct index for structure ( temp 4-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              0 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV0' (layout( location=1) out 2-component vector of float)
+0:16          UV0: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              1 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV1' (layout( location=2) out 2-component vector of float)
+0:16          UV1: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              2 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV2' (layout( location=3) out 2-component vector of float)
+0:16          UV2: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              3 (const int)
+0:16        move second child to first child ( temp 2-component vector of float)
+0:?           '@entryPointOutput.UV3' (layout( location=4) out 2-component vector of float)
+0:16          UV3: direct index for structure ( temp 2-component vector of float)
+0:16            'flattenTemp' ( temp structure{ temp 4-component vector of float pos,  temp 2-component vector of float UV0,  temp 2-component vector of float UV1,  temp 2-component vector of float UV2,  temp 2-component vector of float UV3})
+0:16            Constant:
+0:16              4 (const int)
+0:?   Linker Objects
+0:?     '@entryPointOutput.pos' (layout( location=0) out 4-component vector of float)
+0:?     '@entryPointOutput.UV0' (layout( location=1) out 2-component vector of float)
+0:?     '@entryPointOutput.UV1' (layout( location=2) out 2-component vector of float)
+0:?     '@entryPointOutput.UV2' (layout( location=3) out 2-component vector of float)
+0:?     '@entryPointOutput.UV3' (layout( location=4) out 2-component vector of float)
+0:?     'v' (layout( location=0) in 4-component vector of float)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 84
+
+                              Capability Shader
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Vertex 4  "main" 61 68 72 75 78 81
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 10  "S"
+                              MemberName 10(S) 0  "pos"
+                              MemberName 10(S) 1  "UV0"
+                              MemberName 10(S) 2  "UV1"
+                              MemberName 10(S) 3  "UV2"
+                              MemberName 10(S) 4  "UV3"
+                              Name 13  "@main(vf4;"
+                              Name 12  "v"
+                              Name 16  "s"
+                              Name 59  "v"
+                              Name 61  "v"
+                              Name 63  "flattenTemp"
+                              Name 64  "param"
+                              Name 68  "@entryPointOutput.pos"
+                              Name 72  "@entryPointOutput.UV0"
+                              Name 75  "@entryPointOutput.UV1"
+                              Name 78  "@entryPointOutput.UV2"
+                              Name 81  "@entryPointOutput.UV3"
+                              Decorate 61(v) Location 0
+                              Decorate 68(@entryPointOutput.pos) Location 0
+                              Decorate 72(@entryPointOutput.UV0) Location 1
+                              Decorate 75(@entryPointOutput.UV1) Location 2
+                              Decorate 78(@entryPointOutput.UV2) Location 3
+                              Decorate 81(@entryPointOutput.UV3) Location 4
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypePointer Function 7(fvec4)
+               9:             TypeVector 6(float) 2
+           10(S):             TypeStruct 7(fvec4) 9(fvec2) 9(fvec2) 9(fvec2) 9(fvec2)
+              11:             TypeFunction 10(S) 8(ptr)
+              15:             TypePointer Function 10(S)
+              17:             TypeInt 32 1
+              18:     17(int) Constant 0
+              21:     17(int) Constant 1
+              22:             TypeInt 32 0
+              23:     22(int) Constant 0
+              24:             TypePointer Function 6(float)
+              30:             TypePointer Function 9(fvec2)
+              32:     17(int) Constant 2
+              33:     22(int) Constant 1
+              40:     17(int) Constant 3
+              41:     22(int) Constant 2
+              48:     17(int) Constant 4
+              49:     22(int) Constant 3
+              60:             TypePointer Input 7(fvec4)
+           61(v):     60(ptr) Variable Input
+              67:             TypePointer Output 7(fvec4)
+68(@entryPointOutput.pos):     67(ptr) Variable Output
+              71:             TypePointer Output 9(fvec2)
+72(@entryPointOutput.UV0):     71(ptr) Variable Output
+75(@entryPointOutput.UV1):     71(ptr) Variable Output
+78(@entryPointOutput.UV2):     71(ptr) Variable Output
+81(@entryPointOutput.UV3):     71(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           59(v):      8(ptr) Variable Function
+ 63(flattenTemp):     15(ptr) Variable Function
+       64(param):      8(ptr) Variable Function
+              62:    7(fvec4) Load 61(v)
+                              Store 59(v) 62
+              65:    7(fvec4) Load 59(v)
+                              Store 64(param) 65
+              66:       10(S) FunctionCall 13(@main(vf4;) 64(param)
+                              Store 63(flattenTemp) 66
+              69:      8(ptr) AccessChain 63(flattenTemp) 18
+              70:    7(fvec4) Load 69
+                              Store 68(@entryPointOutput.pos) 70
+              73:     30(ptr) AccessChain 63(flattenTemp) 21
+              74:    9(fvec2) Load 73
+                              Store 72(@entryPointOutput.UV0) 74
+              76:     30(ptr) AccessChain 63(flattenTemp) 32
+              77:    9(fvec2) Load 76
+                              Store 75(@entryPointOutput.UV1) 77
+              79:     30(ptr) AccessChain 63(flattenTemp) 40
+              80:    9(fvec2) Load 79
+                              Store 78(@entryPointOutput.UV2) 80
+              82:     30(ptr) AccessChain 63(flattenTemp) 48
+              83:    9(fvec2) Load 82
+                              Store 81(@entryPointOutput.UV3) 83
+                              Return
+                              FunctionEnd
+  13(@main(vf4;):       10(S) Function None 11
+           12(v):      8(ptr) FunctionParameter
+              14:             Label
+           16(s):     15(ptr) Variable Function
+              19:    7(fvec4) Load 12(v)
+              20:      8(ptr) AccessChain 16(s) 18
+                              Store 20 19
+              25:     24(ptr) AccessChain 12(v) 23
+              26:    6(float) Load 25
+              27:     24(ptr) AccessChain 12(v) 23
+              28:    6(float) Load 27
+              29:    9(fvec2) CompositeConstruct 26 28
+              31:     30(ptr) AccessChain 16(s) 21
+                              Store 31 29
+              34:     24(ptr) AccessChain 12(v) 33
+              35:    6(float) Load 34
+              36:     24(ptr) AccessChain 12(v) 33
+              37:    6(float) Load 36
+              38:    9(fvec2) CompositeConstruct 35 37
+              39:     30(ptr) AccessChain 16(s) 32
+                              Store 39 38
+              42:     24(ptr) AccessChain 12(v) 41
+              43:    6(float) Load 42
+              44:     24(ptr) AccessChain 12(v) 41
+              45:    6(float) Load 44
+              46:    9(fvec2) CompositeConstruct 43 45
+              47:     30(ptr) AccessChain 16(s) 40
+                              Store 47 46
+              50:     24(ptr) AccessChain 12(v) 49
+              51:    6(float) Load 50
+              52:     24(ptr) AccessChain 12(v) 49
+              53:    6(float) Load 52
+              54:    9(fvec2) CompositeConstruct 51 53
+              55:     30(ptr) AccessChain 16(s) 48
+                              Store 55 54
+              56:       10(S) Load 16(s)
+                              ReturnValue 56
+                              FunctionEnd
diff --git a/Test/baseResults/hlsl.semantic.geom.out b/Test/baseResults/hlsl.semantic.geom.out
index f7b82b6..74f7a26 100755
--- a/Test/baseResults/hlsl.semantic.geom.out
+++ b/Test/baseResults/hlsl.semantic.geom.out
@@ -20,7 +20,7 @@
 0:15                0 (const int)
 0:?           Sequence
 0:15            move second child to first child ( temp float)
-0:15              direct index ( temp float)
+0:15              direct index ( out float ClipDistance)
 0:?                 'OutputStream.clip0' ( out 1-element array of float ClipDistance)
 0:15                Constant:
 0:15                  0 (const int)
@@ -30,7 +30,7 @@
 0:15                  1 (const int)
 0:?           Sequence
 0:15            move second child to first child ( temp float)
-0:15              direct index ( temp float)
+0:15              direct index ( out float CullDistance)
 0:?                 'OutputStream.cull0' ( out 1-element array of float CullDistance)
 0:15                Constant:
 0:15                  0 (const int)
@@ -100,7 +100,7 @@
 0:15                0 (const int)
 0:?           Sequence
 0:15            move second child to first child ( temp float)
-0:15              direct index ( temp float)
+0:15              direct index ( out float ClipDistance)
 0:?                 'OutputStream.clip0' ( out 1-element array of float ClipDistance)
 0:15                Constant:
 0:15                  0 (const int)
@@ -110,7 +110,7 @@
 0:15                  1 (const int)
 0:?           Sequence
 0:15            move second child to first child ( temp float)
-0:15              direct index ( temp float)
+0:15              direct index ( out float CullDistance)
 0:?                 'OutputStream.cull0' ( out 1-element array of float CullDistance)
 0:15                Constant:
 0:15                  0 (const int)
diff --git a/Test/baseResults/hlsl.semantic.vert.out b/Test/baseResults/hlsl.semantic.vert.out
index a3aa340..50a653d 100755
--- a/Test/baseResults/hlsl.semantic.vert.out
+++ b/Test/baseResults/hlsl.semantic.vert.out
@@ -28,13 +28,13 @@
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:10            Constant:
 0:10              2 (const int)
-0:?           'ins.cull0' (layout( location=2) in float)
+0:?           'ins.cull0' (layout( location=0) in float)
 0:10        move second child to first child ( temp float)
 0:10          cull1: direct index for structure ( temp float)
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:10            Constant:
 0:10              3 (const int)
-0:?           'ins.cull1' (layout( location=3) in float)
+0:?           'ins.cull1' (layout( location=1) in float)
 0:10        move second child to first child ( temp int)
 0:10          ii: direct index for structure ( temp int)
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
@@ -48,7 +48,7 @@
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:10              Constant:
 0:10                0 (const int)
@@ -58,7 +58,7 @@
 0:10                0 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:10              Constant:
 0:10                1 (const int)
@@ -68,7 +68,7 @@
 0:10                1 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float CullDistance)
 0:?               '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 0:10              Constant:
 0:10                0 (const int)
@@ -78,7 +78,7 @@
 0:10                2 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float CullDistance)
 0:?               '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 0:10              Constant:
 0:10                1 (const int)
@@ -97,8 +97,8 @@
 0:?     'ins.ii' ( in int InstanceIndex)
 0:?     'ins.clip0' (layout( location=0) in float)
 0:?     'ins.clip1' (layout( location=1) in float)
-0:?     'ins.cull0' (layout( location=2) in float)
-0:?     'ins.cull1' (layout( location=3) in float)
+0:?     'ins.cull0' (layout( location=0) in float)
+0:?     'ins.cull1' (layout( location=1) in float)
 0:?     '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:?     '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 
@@ -135,13 +135,13 @@
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:10            Constant:
 0:10              2 (const int)
-0:?           'ins.cull0' (layout( location=2) in float)
+0:?           'ins.cull0' (layout( location=0) in float)
 0:10        move second child to first child ( temp float)
 0:10          cull1: direct index for structure ( temp float)
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:10            Constant:
 0:10              3 (const int)
-0:?           'ins.cull1' (layout( location=3) in float)
+0:?           'ins.cull1' (layout( location=1) in float)
 0:10        move second child to first child ( temp int)
 0:10          ii: direct index for structure ( temp int)
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
@@ -155,7 +155,7 @@
 0:?             'ins' ( temp structure{ temp float clip0,  temp float clip1,  temp float cull0,  temp float cull1,  temp int ii})
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:10              Constant:
 0:10                0 (const int)
@@ -165,7 +165,7 @@
 0:10                0 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float ClipDistance)
 0:?               '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:10              Constant:
 0:10                1 (const int)
@@ -175,7 +175,7 @@
 0:10                1 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float CullDistance)
 0:?               '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 0:10              Constant:
 0:10                0 (const int)
@@ -185,7 +185,7 @@
 0:10                2 (const int)
 0:?         Sequence
 0:10          move second child to first child ( temp float)
-0:10            direct index ( temp float)
+0:10            direct index ( out float CullDistance)
 0:?               '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 0:10              Constant:
 0:10                1 (const int)
@@ -204,8 +204,8 @@
 0:?     'ins.ii' ( in int InstanceIndex)
 0:?     'ins.clip0' (layout( location=0) in float)
 0:?     'ins.clip1' (layout( location=1) in float)
-0:?     'ins.cull0' (layout( location=2) in float)
-0:?     'ins.cull1' (layout( location=3) in float)
+0:?     'ins.cull0' (layout( location=0) in float)
+0:?     'ins.cull1' (layout( location=1) in float)
 0:?     '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
 0:?     '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
 
@@ -243,8 +243,8 @@
                               Name 67  "@entryPointOutput.ii"
                               Decorate 21(ins.clip0) Location 0
                               Decorate 26(ins.clip1) Location 1
-                              Decorate 30(ins.cull0) Location 2
-                              Decorate 34(ins.cull1) Location 3
+                              Decorate 30(ins.cull0) Location 0
+                              Decorate 34(ins.cull1) Location 1
                               Decorate 39(ins.ii) BuiltIn InstanceIndex
                               Decorate 51(@entryPointOutput.clip1) BuiltIn ClipDistance
                               Decorate 59(@entryPointOutput.cull1) BuiltIn CullDistance
diff --git a/Test/baseResults/spv.debugInfo.frag.out b/Test/baseResults/spv.debugInfo.frag.out
index f501528..2e0d1b3 100644
--- a/Test/baseResults/spv.debugInfo.frag.out
+++ b/Test/baseResults/spv.debugInfo.frag.out
@@ -7,9 +7,19 @@
                2:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 5  "main" 24 52
-                              ExecutionMode 5 OriginUpperLeft
+                              ExecutionMode 5 OriginLowerLeft
                1:             String  "spv.debugInfo.frag"
-                              Source GLSL 450 1  "#version 450
+                              Source GLSL 450 1  "// OpModuleProcessed no-storage-format
+// OpModuleProcessed resource-set-binding 3
+// OpModuleProcessed auto-map-locations
+// OpModuleProcessed client opengl100
+// OpModuleProcessed target-env opengl
+// OpModuleProcessed relaxed-errors
+// OpModuleProcessed suppress-warnings
+// OpModuleProcessed hlsl-offsets
+// OpModuleProcessed entry-point main
+#line 1
+#version 450
 
 struct S {
     int a;
@@ -84,8 +94,8 @@
                               MemberDecorate 53(S) 0 Offset 0
                               MemberDecorate 54(ubuf) 0 Offset 0
                               Decorate 54(ubuf) Block
-                              Decorate 56 DescriptorSet 0
-                              Decorate 69(s2d) DescriptorSet 0
+                              Decorate 56 DescriptorSet 3
+                              Decorate 69(s2d) DescriptorSet 3
                3:             TypeVoid
                4:             TypeFunction 3
                7:             TypeInt 32 1
diff --git a/Test/baseResults/spv.hlslDebugInfo.frag.out b/Test/baseResults/spv.hlslDebugInfo.frag.out
new file mode 100644
index 0000000..571e594
--- /dev/null
+++ b/Test/baseResults/spv.hlslDebugInfo.frag.out
@@ -0,0 +1,58 @@
+spv.hlslDebugInfo.vert
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 19
+
+                              Capability Shader
+               2:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Vertex 5  "newMain" 17
+               1:             String  "spv.hlslDebugInfo.vert"
+                              Source HLSL 500 1  "// OpModuleProcessed entry-point newMain
+// OpModuleProcessed shift-sampler-binding 2
+// OpModuleProcessed shift-texture-binding 4
+// OpModuleProcessed shift-image-binding 1
+// OpModuleProcessed shift-UBO-binding 6
+// OpModuleProcessed shift-ssbo-binding 3
+// OpModuleProcessed shift-uav-binding 5
+// OpModuleProcessed flatten-uniform-arrays
+// OpModuleProcessed no-storage-format
+// OpModuleProcessed resource-set-binding t0 0 0
+// OpModuleProcessed hlsl-iomap
+// OpModuleProcessed auto-map-bindings
+// OpModuleProcessed auto-map-locations
+// OpModuleProcessed client vulkan100
+// OpModuleProcessed target-env vulkan1.0
+// OpModuleProcessed source-entrypoint origMain
+// OpModuleProcessed hlsl-offsets
+#line 1
+float4 origMain() : SV_Position
+{
+    return (float4)0;
+}
+"
+                              Name 5  "newMain"
+                              Name 10  "@newMain("
+                              Name 17  "@entryPointOutput"
+                              Decorate 17(@entryPointOutput) BuiltIn Position
+               3:             TypeVoid
+               4:             TypeFunction 3
+               7:             TypeFloat 32
+               8:             TypeVector 7(float) 4
+               9:             TypeFunction 8(fvec4)
+              12:    7(float) Constant 0
+              13:    8(fvec4) ConstantComposite 12 12 12 12
+              16:             TypePointer Output 8(fvec4)
+17(@entryPointOutput):     16(ptr) Variable Output
+      5(newMain):           3 Function None 4
+               6:             Label
+                              Line 1 2 0
+              18:    8(fvec4) FunctionCall 10(@newMain()
+                              Store 17(@entryPointOutput) 18
+                              Return
+                              FunctionEnd
+   10(@newMain():    8(fvec4) Function None 9
+              11:             Label
+                              Line 1 3 0
+                              ReturnValue 13
+                              FunctionEnd
diff --git a/Test/baseResults/spv.looseUniformNoLoc.vert.out b/Test/baseResults/spv.looseUniformNoLoc.vert.out
new file mode 100644
index 0000000..55d1639
--- /dev/null
+++ b/Test/baseResults/spv.looseUniformNoLoc.vert.out
@@ -0,0 +1,8 @@
+spv.looseUniformNoLoc.vert
+ERROR: spv.looseUniformNoLoc.vert:9: 'uv' : non-opaque uniform variables need a layout(location=L) 
+ERROR: 1 compilation errors.  No code generated.
+
+
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
+
+SPIR-V is not generated for failed compile or link
diff --git a/Test/baseResults/spv.noBuiltInLoc.vert.out b/Test/baseResults/spv.noBuiltInLoc.vert.out
index 3d980bf..d6cbeaa 100644
--- a/Test/baseResults/spv.noBuiltInLoc.vert.out
+++ b/Test/baseResults/spv.noBuiltInLoc.vert.out
@@ -1,12 +1,12 @@
 spv.noBuiltInLoc.vert
 // Module Version 10000
 // Generated by (magic number): 80001
-// Id's are bound by 23
+// Id's are bound by 33
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 9 11 18
+                              EntryPoint Vertex 4  "main" 9 11 18 31 32
                               Source GLSL 450
                               Name 4  "main"
                               Name 9  "bar"
@@ -17,6 +17,11 @@
                               MemberName 16(gl_PerVertex) 2  "gl_ClipDistance"
                               MemberName 16(gl_PerVertex) 3  "gl_CullDistance"
                               Name 18  ""
+                              Name 24  "uv1"
+                              Name 26  "uv2"
+                              Name 29  "uv3"
+                              Name 31  "gl_VertexID"
+                              Name 32  "gl_InstanceID"
                               Decorate 9(bar) Location 0
                               Decorate 11(foo) Location 0
                               MemberDecorate 16(gl_PerVertex) 0 BuiltIn Position
@@ -24,6 +29,14 @@
                               MemberDecorate 16(gl_PerVertex) 2 BuiltIn ClipDistance
                               MemberDecorate 16(gl_PerVertex) 3 BuiltIn CullDistance
                               Decorate 16(gl_PerVertex) Block
+                              Decorate 24(uv1) Location 0
+                              Decorate 24(uv1) DescriptorSet 0
+                              Decorate 26(uv2) Location 1
+                              Decorate 26(uv2) DescriptorSet 0
+                              Decorate 29(uv3) Location 2
+                              Decorate 29(uv3) DescriptorSet 0
+                              Decorate 31(gl_VertexID) BuiltIn VertexId
+                              Decorate 32(gl_InstanceID) BuiltIn InstanceId
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -40,6 +53,16 @@
               18:     17(ptr) Variable Output
               19:             TypeInt 32 1
               20:     19(int) Constant 0
+              23:             TypePointer UniformConstant 7(fvec4)
+         24(uv1):     23(ptr) Variable UniformConstant
+              25:             TypePointer UniformConstant 6(float)
+         26(uv2):     25(ptr) Variable UniformConstant
+              27:             TypeVector 6(float) 3
+              28:             TypePointer UniformConstant 27(fvec3)
+         29(uv3):     28(ptr) Variable UniformConstant
+              30:             TypePointer Input 19(int)
+ 31(gl_VertexID):     30(ptr) Variable Input
+32(gl_InstanceID):     30(ptr) Variable Input
          4(main):           2 Function None 3
                5:             Label
               12:    7(fvec4) Load 11(foo)
diff --git a/Test/baseResults/spv.stereoViewRendering.vert.out b/Test/baseResults/spv.stereoViewRendering.vert.out
index 2452c31..fbbdf17 100644
--- a/Test/baseResults/spv.stereoViewRendering.vert.out
+++ b/Test/baseResults/spv.stereoViewRendering.vert.out
@@ -8,6 +8,7 @@
                               Capability ShaderViewportIndexLayerNV
                               Capability ShaderViewportMaskNV
                               Capability ShaderStereoViewNV
+                              Extension  "SPV_EXT_shader_viewport_index_layer"
                               Extension  "SPV_NV_stereo_view_rendering"
                               Extension  "SPV_NV_viewport_array2"
                1:             ExtInstImport  "GLSL.std.450"
diff --git a/Test/baseResults/spv.viewportArray2.tesc.out b/Test/baseResults/spv.viewportArray2.tesc.out
index 814f013..a8c7dc6 100644
--- a/Test/baseResults/spv.viewportArray2.tesc.out
+++ b/Test/baseResults/spv.viewportArray2.tesc.out
@@ -7,6 +7,7 @@
                               Capability MultiViewport
                               Capability ShaderViewportIndexLayerNV
                               Capability ShaderViewportMaskNV
+                              Extension  "SPV_EXT_shader_viewport_index_layer"
                               Extension  "SPV_NV_viewport_array2"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
diff --git a/Test/baseResults/spv.viewportArray2.vert.out b/Test/baseResults/spv.viewportArray2.vert.out
index 3b3e847..cc52905 100644
--- a/Test/baseResults/spv.viewportArray2.vert.out
+++ b/Test/baseResults/spv.viewportArray2.vert.out
@@ -8,6 +8,7 @@
                               Capability MultiViewport
                               Capability ShaderViewportIndexLayerNV
                               Capability ShaderViewportMaskNV
+                              Extension  "SPV_EXT_shader_viewport_index_layer"
                               Extension  "SPV_NV_viewport_array2"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
diff --git a/Test/hlsl.clipdistance-1.frag b/Test/hlsl.clipdistance-1.frag
new file mode 100644
index 0000000..10813b3
--- /dev/null
+++ b/Test/hlsl.clipdistance-1.frag
@@ -0,0 +1,6 @@
+float4 main(in float4 pos : SV_Position, 
+            in float clip : SV_ClipDistance,
+            in float cull : SV_CullDistance) : SV_Target0
+{
+    return pos + clip + cull;
+}
diff --git a/Test/hlsl.clipdistance-1.geom b/Test/hlsl.clipdistance-1.geom
new file mode 100644
index 0000000..76c34b3
--- /dev/null
+++ b/Test/hlsl.clipdistance-1.geom
@@ -0,0 +1,19 @@
+struct S {
+    float4 pos     : SV_Position;
+    float2 clip    : SV_ClipDistance0;
+};
+
+[maxvertexcount(3)]
+void main(triangle in float4 pos[3] : SV_Position, 
+          triangle in uint VertexID[3] : VertexID,
+          inout LineStream<S> OutputStream,
+          triangle in float4 clip[3] : SV_ClipDistance)   // externally: an array 3 of array 4 (not vec4!) of float.
+{
+    S s;
+
+    s.pos = pos[0];
+    s.clip = clip[0].xy;
+
+    OutputStream.Append(s);
+}
+
diff --git a/Test/hlsl.clipdistance-2.frag b/Test/hlsl.clipdistance-2.frag
new file mode 100644
index 0000000..b6f88d5
--- /dev/null
+++ b/Test/hlsl.clipdistance-2.frag
@@ -0,0 +1,7 @@
+float4 main(in float4 pos : SV_Position,
+            in float2 clip[2] : SV_ClipDistance,               // array of vector float
+            in float2 cull[2] : SV_CullDistance)  : SV_Target0 // array of vector float
+{
+
+    return pos + clip[0][0] + cull[0][0];
+}
diff --git a/Test/hlsl.clipdistance-2.geom b/Test/hlsl.clipdistance-2.geom
new file mode 100644
index 0000000..90f047f
--- /dev/null
+++ b/Test/hlsl.clipdistance-2.geom
@@ -0,0 +1,19 @@
+struct S {
+    float4 pos     : SV_Position;
+    float2 clip[2] : SV_ClipDistance0;
+};
+
+[maxvertexcount(3)]
+void main(triangle in float4 pos[3] : SV_Position, 
+          triangle in uint VertexID[3] : VertexID,
+          inout LineStream<S> OutputStream,
+          triangle in float2 clip[3][2] : SV_ClipDistance) // externally: an array 3 of array 4 of float.
+{
+    S s;
+
+    s.pos = pos[0];
+    s.clip[0] = clip[0][0];
+    s.clip[1] = clip[0][1];
+
+    OutputStream.Append(s);
+}
diff --git a/Test/hlsl.clipdistance-3.frag b/Test/hlsl.clipdistance-3.frag
new file mode 100644
index 0000000..e2b6b86
--- /dev/null
+++ b/Test/hlsl.clipdistance-3.frag
@@ -0,0 +1,6 @@
+float4 main(in float4 pos : SV_Position,
+            in float clip[2] : SV_ClipDistance,              // array of scalar float
+            in float cull[2] : SV_CullDistance) : SV_Target0 // array of scalar float
+{
+    return pos + clip[0] + cull[0];
+}
diff --git a/Test/hlsl.clipdistance-3.geom b/Test/hlsl.clipdistance-3.geom
new file mode 100644
index 0000000..2aa4cd4
--- /dev/null
+++ b/Test/hlsl.clipdistance-3.geom
@@ -0,0 +1,20 @@
+struct S {
+    float4 pos     : SV_Position;
+    float2 clip0   : SV_ClipDistance0;  // clip0 and clip1 form an array of float[4] externally.
+    float2 clip1   : SV_ClipDistance1;
+};
+
+[maxvertexcount(3)]
+void main(triangle in float4 pos[3] : SV_Position, 
+          triangle in uint VertexID[3] : VertexID,
+          inout LineStream<S> OutputStream,
+          triangle in float4 clip[3] : SV_ClipDistance)   // externally: an array 3 of array 4 (not vec4!) of float.
+{
+    S s;
+
+    s.pos = pos[0];
+    s.clip0 = clip[0].xy;
+    s.clip1 = clip[0].zw;
+
+    OutputStream.Append(s);
+}
diff --git a/Test/hlsl.clipdistance-4.frag b/Test/hlsl.clipdistance-4.frag
new file mode 100644
index 0000000..6144160
--- /dev/null
+++ b/Test/hlsl.clipdistance-4.frag
@@ -0,0 +1,9 @@
+struct VS_OUTPUT        {
+    float4 Position             : SV_Position;
+    float4 ClipRect             : SV_ClipDistance0;  // vector in split struct
+};
+
+float4 main(const VS_OUTPUT v) : SV_Target0
+{
+    return v.Position + v.ClipRect;
+}
diff --git a/Test/hlsl.clipdistance-4.geom b/Test/hlsl.clipdistance-4.geom
new file mode 100644
index 0000000..ff296a8
--- /dev/null
+++ b/Test/hlsl.clipdistance-4.geom
@@ -0,0 +1,21 @@
+struct S {
+    float4 pos     : SV_Position;
+    float2 clip0   : SV_ClipDistance0;  // clip0 and clip1 form an array of float[4] externally.
+    float2 clip1   : SV_ClipDistance1;
+};
+
+[maxvertexcount(3)]
+void main(triangle in float4 pos[3] : SV_Position, 
+          triangle in uint VertexID[3] : VertexID,
+          inout LineStream<S> OutputStream,
+          triangle in float2 clip0[3] : SV_ClipDistance0,  // test input arrayed semantic vars
+          triangle in float2 clip1[3] : SV_ClipDistance1)
+{
+    S s;
+
+    s.pos = pos[0];
+    s.clip0 = clip0[0];
+    s.clip1 = clip1[0];
+
+    OutputStream.Append(s);
+}
diff --git a/Test/hlsl.clipdistance-5.frag b/Test/hlsl.clipdistance-5.frag
new file mode 100644
index 0000000..4722999
--- /dev/null
+++ b/Test/hlsl.clipdistance-5.frag
@@ -0,0 +1,9 @@
+struct VS_OUTPUT        {
+    float4 Position             : SV_Position;
+    float2 ClipRect[2]          : SV_ClipDistance0;  // array of float2 in split struct
+};
+
+float4 main(const VS_OUTPUT v) : SV_Target0
+{
+    return v.Position + v.ClipRect[0].x + v.ClipRect[1].x;
+}
diff --git a/Test/hlsl.clipdistance-6.frag b/Test/hlsl.clipdistance-6.frag
new file mode 100644
index 0000000..646197b
--- /dev/null
+++ b/Test/hlsl.clipdistance-6.frag
@@ -0,0 +1,10 @@
+struct VS_OUTPUT        {
+    float4 Position             : SV_Position;
+    float4 clip0                : SV_ClipDistance0;  // multiple semantic IDs, two vec4s (no extra packing)
+    float4 clip1                : SV_ClipDistance1;  // ...
+};
+
+float4 main(VS_OUTPUT v) : SV_Target0
+{
+    return v.Position + v.clip0 + v.clip1;
+}
diff --git a/Test/hlsl.clipdistance-7.frag b/Test/hlsl.clipdistance-7.frag
new file mode 100644
index 0000000..1a26df8
--- /dev/null
+++ b/Test/hlsl.clipdistance-7.frag
@@ -0,0 +1,10 @@
+struct VS_OUTPUT        {
+    float4 Position             : SV_Position;
+    float3 clip0                : SV_ClipDistance0;  // multiple semantic IDs, vec3+vec4 (skip)
+    float4 clip1                : SV_ClipDistance1;  // ...
+};
+
+float4 main(VS_OUTPUT v) : SV_Target0
+{
+    return v.Position + v.clip0.x + v.clip1.x;
+}
diff --git a/Test/hlsl.clipdistance-8.frag b/Test/hlsl.clipdistance-8.frag
new file mode 100644
index 0000000..2edf194
--- /dev/null
+++ b/Test/hlsl.clipdistance-8.frag
@@ -0,0 +1,10 @@
+struct VS_OUTPUT        {
+    float4 Position             : SV_Position;
+    float3 clip0                : SV_ClipDistance0;  // multiple semantic IDs, vec3+float (pack)
+    float  clip1                : SV_ClipDistance1;  // ...
+};
+
+float4 main(VS_OUTPUT v) : SV_Target0
+{
+    return v.Position + v.clip0.x + v.clip1;
+}
diff --git a/Test/hlsl.clipdistance-9.frag b/Test/hlsl.clipdistance-9.frag
new file mode 100644
index 0000000..cbe940a
--- /dev/null
+++ b/Test/hlsl.clipdistance-9.frag
@@ -0,0 +1,8 @@
+
+// Test packing 0 and 1 semantics into single array[4], from in fn params.
+float4 main(in float4 Position : SV_Position,
+            in float3 clip0 : SV_ClipDistance0,
+            in float clip1 : SV_ClipDistance1) : SV_Target0
+{
+    return Position + clip0.x + clip1;
+}
diff --git a/Test/hlsl.preprocessor.frag b/Test/hlsl.preprocessor.frag
new file mode 100644
index 0000000..dba341e
--- /dev/null
+++ b/Test/hlsl.preprocessor.frag
@@ -0,0 +1,13 @@
+#define DEFINE_TEXTURE(name) Texture2D name; SamplerState name##_ss;
+#define SAMPLE_TEXTURE(name, uv) name.Sample(name##_ss, (uv).xy)
+
+#define test_texture2 test_texture
+
+DEFINE_TEXTURE(test_texture)
+
+float4 main(float4 input : TEXCOORD0) : SV_TARGET
+{
+    float4 tex = SAMPLE_TEXTURE(test_texture2, input.xy);
+    return tex;
+}
+
diff --git a/Test/hlsl.semantic-1.vert b/Test/hlsl.semantic-1.vert
new file mode 100644
index 0000000..ec92428
--- /dev/null
+++ b/Test/hlsl.semantic-1.vert
@@ -0,0 +1,24 @@
+#define DLAYER 3
+
+#define DMACRO1 TEXCOORD1
+#define DMACRO(num) TEXCOORD##num
+
+struct S {
+	float4 pos	: POSITION;
+	float2 UV0    	: TEXCOORD0;
+	float2 UV1	: DMACRO1;
+	float2 UV2	: DMACRO(2);
+	float2 UV3	: DMACRO(DLAYER);
+};
+
+
+S main(float4 v : POSITION)
+{
+    S s;
+    s.pos = v;
+    s.UV0 = float2(v.x,v.x);
+    s.UV1 = float2(v.y,v.y);
+    s.UV2 = float2(v.z,v.z);
+    s.UV3 = float2(v.w,v.w);
+    return s;
+}
diff --git a/Test/runtests b/Test/runtests
index c5a9337..f0da75f 100755
--- a/Test/runtests
+++ b/Test/runtests
@@ -109,15 +109,21 @@
 echo Testing SPV no location
 $EXE -V -C spv.noLocation.vert > $TARGETDIR/spv.noLocation.vert.out
 diff -b $BASEDIR/spv.noLocation.vert.out $TARGETDIR/spv.noLocation.vert.out || HASERROR=1
-$EXE -H --aml spv.noBuiltInLoc.vert > $TARGETDIR/spv.noBuiltInLoc.vert.out
+$EXE -G -H --aml spv.noBuiltInLoc.vert > $TARGETDIR/spv.noBuiltInLoc.vert.out
 diff -b $BASEDIR/spv.noBuiltInLoc.vert.out $TARGETDIR/spv.noBuiltInLoc.vert.out || HASERROR=1
+$EXE -G spv.looseUniformNoLoc.vert > $TARGETDIR/spv.looseUniformNoLoc.vert.out
+diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc.vert.out || HASERROR=1
 
 #
 # Testing debug information
 #
 echo Testing SPV Debug Information
-$EXE -g -H spv.debugInfo.frag > $TARGETDIR/spv.debugInfo.frag.out
+$EXE -g --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf \
+     -G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.frag.out
 diff -b $BASEDIR/spv.debugInfo.frag.out $TARGETDIR/spv.debugInfo.frag.out || HASERROR=1
+$EXE -g -D -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \
+     --sep origMain -H spv.hlslDebugInfo.vert --rsb vert t0 0 0 > $TARGETDIR/spv.hlslDebugInfo.frag.out
+diff -b $BASEDIR/spv.hlslDebugInfo.frag.out $TARGETDIR/spv.hlslDebugInfo.frag.out || HASERROR=1
 
 #
 # Testing Includer
diff --git a/Test/spv.hlslDebugInfo.vert b/Test/spv.hlslDebugInfo.vert
new file mode 100644
index 0000000..b2bc187
--- /dev/null
+++ b/Test/spv.hlslDebugInfo.vert
@@ -0,0 +1,4 @@
+float4 origMain() : SV_Position

+{

+    return (float4)0;

+}

diff --git a/Test/spv.looseUniformNoLoc.vert b/Test/spv.looseUniformNoLoc.vert
new file mode 100644
index 0000000..e887359
--- /dev/null
+++ b/Test/spv.looseUniformNoLoc.vert
@@ -0,0 +1,15 @@
+#version 450 core

+

+layout(location = 0)

+in  vec4 foo;

+

+layout(location = 0)

+out vec4 bar;

+

+uniform vec4 uv;

+

+void main()

+{

+    bar = foo;

+    gl_Position = foo;

+}
\ No newline at end of file
diff --git a/Test/spv.noBuiltInLoc.vert b/Test/spv.noBuiltInLoc.vert
index e754892..5fbe252 100644
--- a/Test/spv.noBuiltInLoc.vert
+++ b/Test/spv.noBuiltInLoc.vert
@@ -6,6 +6,10 @@
 layout(location = 0)

 out vec4 bar;

 

+uniform vec4 uv1;

+uniform float uv2;

+uniform vec3 uv3;

+

 void main()

 {

     bar = foo;

diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h
index 0f2c908..0820154 100644
--- a/glslang/Include/Common.h
+++ b/glslang/Include/Common.h
@@ -63,7 +63,7 @@
 }
 #endif
 
-#if defined(_MSC_VER) && _MSC_VER < 1700
+#if defined(_MSC_VER) && _MSC_VER < 1800
 inline long long int strtoll (const char* str, char** endptr, int base)
 {
   return _strtoi64(str, endptr, base);
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index 6e6660e..e71ec5e 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -3425,6 +3425,12 @@
                 "in int gl_DrawIDARB;"
                 );
         }
+        if (version >= 450) {
+            stageBuiltins[EShLangVertex].append(
+                "out int gl_ViewportIndex;"
+                "out int gl_Layer;"
+                );
+        }
         if (version >= 460) {
             stageBuiltins[EShLangVertex].append(
                 "in int gl_BaseVertex;"
@@ -3436,8 +3442,6 @@
 #ifdef NV_EXTENSIONS
         if (version >= 450)
             stageBuiltins[EShLangVertex].append(
-                "out int gl_ViewportIndex;"
-                "out int gl_Layer;"
                 "out int gl_ViewportMask[];"             // GL_NV_viewport_array2
                 "out int gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
                 "out vec4 gl_SecondaryPositionNV;"       // GL_NV_stereo_view_rendering
@@ -3730,11 +3734,15 @@
             "};"
             "\n");
 
+        if (version >= 450)
+            stageBuiltins[EShLangTessEvaluation].append(
+                "out int gl_ViewportIndex;"
+                "out int gl_Layer;"
+                );
+
 #ifdef NV_EXTENSIONS
         if (version >= 450)
             stageBuiltins[EShLangTessEvaluation].append(
-                "out int  gl_ViewportIndex;"
-                "out int  gl_Layer;"
                 "out int  gl_ViewportMask[];"             // GL_NV_viewport_array2
                 "out vec4 gl_SecondaryPositionNV;"        // GL_NV_stereo_view_rendering
                 "out int  gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
@@ -5467,6 +5475,14 @@
             symbolTable.setVariableExtensions("gl_Layer",         Num_viewportEXTs, viewportEXTs);
             symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
         }
+#else
+        if (language == EShLangVertex || language == EShLangTessEvaluation) {
+            symbolTable.setVariableExtensions("gl_Layer",         1, &E_GL_ARB_shader_viewport_layer_array);
+            symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_shader_viewport_layer_array);
+        }
+#endif
+
+#ifdef NV_EXTENSIONS
         symbolTable.setVariableExtensions("gl_ViewportMask",            1, &E_GL_NV_viewport_array2);
         symbolTable.setVariableExtensions("gl_SecondaryPositionNV",     1, &E_GL_NV_stereo_view_rendering);
         symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 7902db8..6decfea 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -2493,8 +2493,8 @@
         // Vulkan doesn't allow transparent uniforms outside of blocks
         if (spvVersion.vulkan > 0)
             vulkanRemoved(loc, "non-opaque uniforms outside a block");
-        // OpenGL wants locations on these
-        if (spvVersion.openGl > 0 && !type.getQualifier().hasLocation())
+        // OpenGL wants locations on these (unless they are getting automapped)
+        if (spvVersion.openGl > 0 && !type.getQualifier().hasLocation() && !intermediate.getAutoMapLocations())
             error(loc, "non-opaque uniform variables need a layout(location=L)", identifier.c_str(), "");
     }
 }
diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h
index 73f2470..d04607a 100644
--- a/glslang/MachineIndependent/ParseHelper.h
+++ b/glslang/MachineIndependent/ParseHelper.h
@@ -76,6 +76,7 @@
                       EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
                       TInfoSink& infoSink, bool forwardCompatible, EShMessages messages)
           : TParseVersions(interm, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
+            scopeMangler("::"),
             symbolTable(symbolTable),
             statementNestingLevel(0), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
             postEntryPointReturn(false),
@@ -143,7 +144,7 @@
     virtual bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*);
     virtual void rValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*);
 
-    const char* const scopeMangler = "::";
+    const char* const scopeMangler;
 
     // Basic parsing state, easily accessible to the grammar
 
diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp
index d2964e4..2a904f4 100644
--- a/glslang/MachineIndependent/ShaderLang.cpp
+++ b/glslang/MachineIndependent/ShaderLang.cpp
@@ -675,6 +675,22 @@
     }
 }
 
+// Most processes are recorded when set in the intermediate representation,
+// These are the few that are not.
+void RecordProcesses(TIntermediate& intermediate, EShMessages messages, const std::string& sourceEntryPointName)
+{
+    if ((messages & EShMsgRelaxedErrors) != 0)
+        intermediate.addProcess("relaxed-errors");
+    if ((messages & EShMsgSuppressWarnings) != 0)
+        intermediate.addProcess("suppress-warnings");
+    if ((messages & EShMsgKeepUncalled) != 0)
+        intermediate.addProcess("keep-uncalled");
+    if (sourceEntryPointName.size() > 0) {
+        intermediate.addProcess("source-entrypoint");
+        intermediate.addProcessArgument(sourceEntryPointName);
+    }
+}
+
 // This is the common setup and cleanup code for PreprocessDeferred and
 // CompileDeferred.
 // It takes any callable with a signature of
@@ -798,6 +814,7 @@
     intermediate.setVersion(version);
     intermediate.setProfile(profile);
     intermediate.setSpv(spvVersion);
+    RecordProcesses(intermediate, messages, sourceEntryPointName);
     if (spvVersion.vulkan >= 100)
         intermediate.setOriginUpperLeft();
     if ((messages & EShMsgHlslOffsets) || source == EShSourceHlsl)
@@ -1641,6 +1658,11 @@
     sourceEntryPointName = name;
 }
 
+void TShader::addProcesses(const std::vector<std::string>& p)
+{
+    intermediate->addProcesses(p);
+}
+
 // Set binding base for sampler types
 void TShader::setShiftSamplerBinding(unsigned int base) { intermediate->setShiftSamplerBinding(base); }
 // Set binding base for texture types (SRV)
@@ -1658,7 +1680,7 @@
 // Enables binding automapping using TIoMapper
 void TShader::setAutoMapBindings(bool map)              { intermediate->setAutoMapBindings(map); }
 // Fragile: currently within one stage: simple auto-assignment of location
-void TShader::setAutoMapLocations(bool map)              { intermediate->setAutoMapLocations(map); }
+void TShader::setAutoMapLocations(bool map)             { intermediate->setAutoMapLocations(map); }
 // See comment above TDefaultHlslIoMapper in iomapper.cpp:
 void TShader::setHlslIoMapping(bool hlslIoMap)          { intermediate->setHlslIoMapping(hlslIoMap); }
 void TShader::setFlattenUniformArrays(bool flatten)     { intermediate->setFlattenUniformArrays(flatten); }
diff --git a/glslang/MachineIndependent/iomapper.cpp b/glslang/MachineIndependent/iomapper.cpp
index fc85e97..1758d00 100644
--- a/glslang/MachineIndependent/iomapper.cpp
+++ b/glslang/MachineIndependent/iomapper.cpp
@@ -253,10 +253,14 @@
         ent.newBinding = -1;
         ent.newSet = -1;
         ent.newIndex = -1;
-        const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
+        const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(),
+                                                             ent.live);
         if (isValid) {
-            ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
+            ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(),
+                                                            ent.live);
             ent.newSet = resolver.resolveSet(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
+            ent.newLocation = resolver.resolveUniformLocation(stage, ent.symbol->getName().c_str(),
+                                                                     ent.symbol->getType(), ent.live);
 
             if (ent.newBinding != -1) {
                 if (ent.newBinding >= int(TQualifier::layoutBindingEnd)) {
@@ -356,6 +360,7 @@
     std::vector<std::string> baseResourceSetBinding;
     bool doAutoBindingMapping;
     bool doAutoLocationMapping;
+    int nextUniformLocation;
     typedef std::vector<int> TSlotSet;
     typedef std::unordered_map<int, TSlotSet> TSlotSetMap;
     TSlotSetMap slots;
@@ -411,7 +416,27 @@
 
         return 0;
     }
+    int resolveUniformLocation(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override
+    {
+        // kick out of not doing this
+        if (!doAutoLocationMapping)
+            return -1;
 
+        // no locations added if already present, a built-in variable, a block, or an opaque
+        if (type.getQualifier().hasLocation() || type.isBuiltIn() ||
+            type.getBasicType() == EbtBlock || type.containsOpaque())
+            return -1;
+
+        // no locations on blocks of built-in variables
+        if (type.isStruct()) {
+            if (type.getStruct()->size() < 1)
+                return -1;
+            if ((*type.getStruct())[0].type->isBuiltIn())
+                return -1;
+        }
+
+        return nextUniformLocation++;
+    }
     bool validateInOut(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override
     {
         return true;
@@ -700,6 +725,7 @@
         resolverBase->baseResourceSetBinding = intermediate.getResourceSetBinding();
         resolverBase->doAutoBindingMapping = intermediate.getAutoMapBindings();
         resolverBase->doAutoLocationMapping = intermediate.getAutoMapLocations();
+        resolverBase->nextUniformLocation = 0;
 
         resolver = resolverBase;
     }
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index c1daf1b..9f6e3da 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -150,6 +150,54 @@
     bool containsDouble;
 };
 
+// Track a set of strings describing how the module was processed.
+// Using the form:
+//   process arg0 arg1 arg2 ...
+//   process arg0 arg1 arg2 ...
+// where everything is textual, and there can be zero or more arguments
+class TProcesses {
+public:
+    TProcesses() {}
+    ~TProcesses() {}
+
+    void addProcess(const char* process)
+    {
+        processes.push_back(process);
+    }
+    void addProcess(const std::string& process)
+    {
+        processes.push_back(process);
+    }
+    void addArgument(int arg)
+    {
+        processes.back().append(" ");
+        std::string argString = std::to_string(arg);
+        processes.back().append(argString);
+    }
+    void addArgument(const char* arg)
+    {
+        processes.back().append(" ");
+        processes.back().append(arg);
+    }
+    void addArgument(const std::string& arg)
+    {
+        processes.back().append(" ");
+        processes.back().append(arg);
+    }
+    void addIfNonZero(const char* process, int value)
+    {
+        if (value != 0) {
+            addProcess(process);
+            addArgument(value);
+        }
+    }
+
+    const std::vector<std::string>& getProcesses() const { return processes; }
+
+private:
+    std::vector<std::string> processes;
+};
+
 class TSymbolTable;
 class TSymbol;
 class TVariable;
@@ -160,11 +208,14 @@
 class TIntermediate {
 public:
     explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
+        implicitThisName("@this"),
         language(l), source(EShSourceNone), profile(p), version(v), treeRoot(0),
         numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
-        invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
+        invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet),
+        inputPrimitive(ElgNone), outputPrimitive(ElgNone),
         pixelCenterInteger(false), originUpperLeft(false),
-        vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), postDepthCoverage(false), depthLayout(EldNone), depthReplacing(false),
+        vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false),
+        postDepthCoverage(false), depthLayout(EldNone), depthReplacing(false),
         blendEquations(0), xfbMode(false), multiStream(false),
 #ifdef NV_EXTENSIONS
         layoutOverrideCoverage(false),
@@ -201,46 +252,135 @@
 
     void setSource(EShSource s) { source = s; }
     EShSource getSource() const { return source; }
-    void setEntryPointName(const char* ep) { entryPointName = ep; }
+    void setEntryPointName(const char* ep)
+    {
+        entryPointName = ep;
+        processes.addProcess("entry-point");
+        processes.addArgument(entryPointName);
+    }
     void setEntryPointMangledName(const char* ep) { entryPointMangledName = ep; }
     const std::string& getEntryPointName() const { return entryPointName; }
     const std::string& getEntryPointMangledName() const { return entryPointMangledName; }
 
-    void setShiftSamplerBinding(unsigned int shift) { shiftSamplerBinding = shift; }
+    void setShiftSamplerBinding(unsigned int shift)
+    {
+        shiftSamplerBinding = shift;
+        processes.addIfNonZero("shift-sampler-binding", shift);
+    }
     unsigned int getShiftSamplerBinding() const { return shiftSamplerBinding; }
-    void setShiftTextureBinding(unsigned int shift) { shiftTextureBinding = shift; }
+    void setShiftTextureBinding(unsigned int shift)
+    {
+        shiftTextureBinding = shift;
+        processes.addIfNonZero("shift-texture-binding", shift);
+    }
     unsigned int getShiftTextureBinding() const { return shiftTextureBinding; }
-    void setShiftImageBinding(unsigned int shift) { shiftImageBinding = shift; }
+    void setShiftImageBinding(unsigned int shift)
+    {
+        shiftImageBinding = shift;
+        processes.addIfNonZero("shift-image-binding", shift);
+    }
     unsigned int getShiftImageBinding() const { return shiftImageBinding; }
-    void setShiftUboBinding(unsigned int shift)     { shiftUboBinding = shift; }
-    unsigned int getShiftUboBinding()     const { return shiftUboBinding; }
-    void setShiftSsboBinding(unsigned int shift)     { shiftSsboBinding = shift; }
-    unsigned int getShiftSsboBinding()  const { return shiftSsboBinding; }
-    void setShiftUavBinding(unsigned int shift) { shiftUavBinding = shift; }
-    unsigned int getShiftUavBinding()  const { return shiftUavBinding; }
-    void setResourceSetBinding(const std::vector<std::string>& shift) { resourceSetBinding = shift; }
+    void setShiftUboBinding(unsigned int shift)
+    {
+        shiftUboBinding = shift;
+        processes.addIfNonZero("shift-UBO-binding", shift);
+    }
+    unsigned int getShiftUboBinding() const { return shiftUboBinding; }
+    void setShiftSsboBinding(unsigned int shift)
+    {
+        shiftSsboBinding = shift;
+        processes.addIfNonZero("shift-ssbo-binding", shift);
+    }
+    unsigned int getShiftSsboBinding() const { return shiftSsboBinding; }
+    void setShiftUavBinding(unsigned int shift)
+    {
+        shiftUavBinding = shift;
+        processes.addIfNonZero("shift-uav-binding", shift);
+    }
+    unsigned int getShiftUavBinding() const { return shiftUavBinding; }
+    void setResourceSetBinding(const std::vector<std::string>& shift)
+    {
+        resourceSetBinding = shift;
+        if (shift.size() > 0) {
+            processes.addProcess("resource-set-binding");
+            for (int s = 0; s < (int)shift.size(); ++s)
+                processes.addArgument(shift[s]);
+        }
+    }
     const std::vector<std::string>& getResourceSetBinding() const { return resourceSetBinding; }
-    void setAutoMapBindings(bool map)           { autoMapBindings = map; }
-    bool getAutoMapBindings()             const { return autoMapBindings; }
-    void setAutoMapLocations(bool map)          { autoMapLocations = map; }
-    bool getAutoMapLocations()            const { return autoMapLocations; }
-    void setFlattenUniformArrays(bool flatten)  { flattenUniformArrays = flatten; }
-    bool getFlattenUniformArrays()        const { return flattenUniformArrays; }
-    void setNoStorageFormat(bool b)             { useUnknownFormat = b; }
-    bool getNoStorageFormat()             const { return useUnknownFormat; }
-    void setHlslOffsets()         { hlslOffsets = true; }
+    void setAutoMapBindings(bool map)
+    {
+        autoMapBindings = map;
+        if (autoMapBindings)
+            processes.addProcess("auto-map-bindings");
+    }
+    bool getAutoMapBindings() const { return autoMapBindings; }
+    void setAutoMapLocations(bool map)
+    {
+        autoMapLocations = map;
+        if (autoMapLocations)
+            processes.addProcess("auto-map-locations");
+    }
+    bool getAutoMapLocations() const { return autoMapLocations; }
+    void setFlattenUniformArrays(bool flatten)
+    {
+        flattenUniformArrays = flatten;
+        if (flattenUniformArrays)
+            processes.addProcess("flatten-uniform-arrays");
+    }
+    bool getFlattenUniformArrays() const { return flattenUniformArrays; }
+    void setNoStorageFormat(bool b)
+    {
+        useUnknownFormat = b;
+        if (useUnknownFormat)
+            processes.addProcess("no-storage-format");
+    }
+    bool getNoStorageFormat() const { return useUnknownFormat; }
+    void setHlslOffsets()
+    {
+        hlslOffsets = true;
+        if (hlslOffsets)
+            processes.addProcess("hlsl-offsets");
+    }
     bool usingHlslOFfsets() const { return hlslOffsets; }
-    void setUseStorageBuffer() { useStorageBuffer = true; }
+    void setUseStorageBuffer()
+    {
+        useStorageBuffer = true;
+        processes.addProcess("use-storage-buffer");
+    }
     bool usingStorageBuffer() const { return useStorageBuffer; }
-    void setHlslIoMapping(bool b) { hlslIoMapping = b; }
-    bool usingHlslIoMapping()     { return hlslIoMapping; }
+    void setHlslIoMapping(bool b)
+    {
+        hlslIoMapping = b;
+        if (hlslIoMapping)
+            processes.addProcess("hlsl-iomap");
+    }
+    bool usingHlslIoMapping() { return hlslIoMapping; }
+
     void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { textureSamplerTransformMode = mode; }
 
     void setVersion(int v) { version = v; }
     int getVersion() const { return version; }
     void setProfile(EProfile p) { profile = p; }
     EProfile getProfile() const { return profile; }
-    void setSpv(const SpvVersion& s) { spvVersion = s; }
+    void setSpv(const SpvVersion& s)
+    {
+        spvVersion = s;
+
+        // client processes
+        if (spvVersion.vulkan > 0)
+            processes.addProcess("client vulkan100");
+        if (spvVersion.openGl > 0)
+            processes.addProcess("client opengl100");
+
+        // target-environment processes
+        if (spvVersion.vulkan == 100)
+            processes.addProcess("target-env vulkan1.0");
+        else if (spvVersion.vulkan > 0)
+            processes.addProcess("target-env vulkanUnknown");
+        if (spvVersion.openGl > 0)
+            processes.addProcess("target-env opengl");
+    }
     const SpvVersion& getSpv() const { return spvVersion; }
     EShLanguage getStage() const { return language; }
     void addRequestedExtension(const char* extension) { requestedExtensions.insert(extension); }
@@ -462,8 +602,15 @@
     const std::string& getSourceFile() const { return sourceFile; }
     void addSourceText(const char* text) { sourceText = sourceText + text; }
     const std::string& getSourceText() const { return sourceText; }
+    void addProcesses(const std::vector<std::string>& p) {
+        for (int i = 0; i < (int)p.size(); ++i)
+            processes.addProcess(p[i]);
+    }
+    void addProcess(const std::string& process) { processes.addProcess(process); }
+    void addProcessArgument(const std::string& arg) { processes.addArgument(arg); }
+    const std::vector<std::string>& getProcesses() const { return processes.getProcesses(); }
 
-    const char* const implicitThisName = "@this";
+    const char* const implicitThisName;
 
 protected:
     TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
@@ -558,6 +705,9 @@
     std::string sourceFile;
     std::string sourceText;
 
+    // for OpModuleProcessed, or equivalent
+    TProcesses processes;
+
 private:
     void operator=(TIntermediate&); // prevent assignments
 };
diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp
index 9242350..ecda34c 100644
--- a/glslang/MachineIndependent/preprocessor/Pp.cpp
+++ b/glslang/MachineIndependent/preprocessor/Pp.cpp
@@ -1068,6 +1068,10 @@
         pasting = true;
     }
 
+    // HLSL does expand macros before concatenation
+    if (pasting && pp->parseContext.isReadingHLSL())
+        pasting = false;
+
     // TODO: preprocessor:  properly handle whitespace (or lack of it) between tokens when expanding
     if (token == PpAtomIdentifier) {
         int i;
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
index 12672ee..b36e384 100644
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -346,6 +346,7 @@
     void setPreamble(const char* s) { preamble = s; }
     void setEntryPoint(const char* entryPoint);
     void setSourceEntryPoint(const char* sourceEntryPointName);
+    void addProcesses(const std::vector<std::string>&);
     void setShiftSamplerBinding(unsigned int base);
     void setShiftTextureBinding(unsigned int base);
     void setShiftImageBinding(unsigned int base);
@@ -532,9 +533,10 @@
 
 // Allows to customize the binding layout after linking.
 // All used uniform variables will invoke at least validateBinding.
-// If validateBinding returned true then the other resolveBinding
-// and resolveSet are invoked to resolve the binding and descriptor
-// set index respectively.
+// If validateBinding returned true then the other resolveBinding,
+// resolveSet, and resolveLocation are invoked to resolve the binding
+// and descriptor set index respectively.
+//
 // Invocations happen in a particular order:
 // 1) all shader inputs
 // 2) all shader outputs
@@ -566,6 +568,9 @@
   // Should return a value >= 0 if the current set should be overridden.
   // Return -1 if the current set (including no set) should be kept.
   virtual int resolveSet(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
+  // Should return a value >= 0 if the current location should be overridden.
+  // Return -1 if the current location (including no location) should be kept.
+  virtual int resolveUniformLocation(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
   // Should return true if the resulting/current setup would be okay.
   // Basic idea is to do aliasing checks and reject invalid semantic names.
   virtual bool validateInOut(EShLanguage stage, const char* name, const TType& type, bool is_live) = 0;
diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp
index 27452ab..4079d83 100644
--- a/gtests/Hlsl.FromFile.cpp
+++ b/gtests/Hlsl.FromFile.cpp
@@ -97,14 +97,27 @@
         {"hlsl.cast.frag", "PixelShaderFunction"},
         {"hlsl.charLit.vert", "main"},
         {"hlsl.clip.frag", "main"},
+        {"hlsl.clipdistance-1.frag", "main"},
+        {"hlsl.clipdistance-1.geom", "main"},
         {"hlsl.clipdistance-1.vert", "main"},
+        {"hlsl.clipdistance-2.frag", "main"},
+        {"hlsl.clipdistance-2.geom", "main"},
         {"hlsl.clipdistance-2.vert", "main"},
+        {"hlsl.clipdistance-3.frag", "main"},
+        {"hlsl.clipdistance-3.geom", "main"},
         {"hlsl.clipdistance-3.vert", "main"},
+        {"hlsl.clipdistance-4.frag", "main"},
+        {"hlsl.clipdistance-4.geom", "main"},
         {"hlsl.clipdistance-4.vert", "main"},
+        {"hlsl.clipdistance-5.frag", "main"},
         {"hlsl.clipdistance-5.vert", "main"},
+        {"hlsl.clipdistance-6.frag", "main"},
         {"hlsl.clipdistance-6.vert", "main"},
+        {"hlsl.clipdistance-7.frag", "main"},
         {"hlsl.clipdistance-7.vert", "main"},
+        {"hlsl.clipdistance-8.frag", "main"},
         {"hlsl.clipdistance-8.vert", "main"},
+        {"hlsl.clipdistance-9.frag", "main"},
         {"hlsl.clipdistance-9.vert", "main"},
         {"hlsl.comparison.vec.frag", "main"},
         {"hlsl.conditional.frag", "PixelShaderFunction"},
@@ -300,11 +313,13 @@
         {"hlsl.matType.bool.frag", "main"},
         {"hlsl.matType.int.frag", "main"},
         {"hlsl.max.frag", "PixelShaderFunction"},
+        {"hlsl.preprocessor.frag", "main"},
         {"hlsl.precedence.frag", "PixelShaderFunction"},
         {"hlsl.precedence2.frag", "PixelShaderFunction"},
         {"hlsl.scalar2matrix.frag", "main"},
         {"hlsl.semantic.geom", "main"},
         {"hlsl.semantic.vert", "main"},
+        {"hlsl.semantic-1.vert", "main"},
         {"hlsl.scope.frag", "PixelShaderFunction"},
         {"hlsl.sin.frag", "PixelShaderFunction"},
         {"hlsl.struct.frag", "PixelShaderFunction"},
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
index 9b54bbd..346a117 100755
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -66,6 +66,8 @@
     entryPointFunction(nullptr),
     entryPointFunctionBody(nullptr),
     gsStreamOutput(nullptr),
+    clipDistanceInput(nullptr),
+    cullDistanceInput(nullptr),
     clipDistanceOutput(nullptr),
     cullDistanceOutput(nullptr)
 {
@@ -80,8 +82,10 @@
     globalInputDefaults.clear();
     globalOutputDefaults.clear();
 
-    clipSemanticNSize.fill(0);
-    cullSemanticNSize.fill(0);
+    clipSemanticNSizeIn.fill(0);
+    cullSemanticNSizeIn.fill(0);
+    clipSemanticNSizeOut.fill(0);
+    cullSemanticNSizeOut.fill(0);
 
     // "Shaders in the transform
     // feedback capturing mode have an initial global default of
@@ -1152,14 +1156,18 @@
     if (arraySizes != nullptr && !memberType.isArray())
         ioVar->getWritableType().newArraySizes(*arraySizes);
 
-    fixBuiltInIoType(ioVar->getWritableType());
-
     splitBuiltIns[tInterstageIoData(memberType.getQualifier().builtIn, outerQualifier.storage)] = ioVar;
     if (!isClipOrCullDistance(ioVar->getType()))
         trackLinkage(*ioVar);
 
     // Merge qualifier from the user structure
     mergeQualifiers(ioVar->getWritableType().getQualifier(), outerQualifier);
+
+    // Fix the builtin type if needed (e.g, some types require fixed array sizes, no matter how the
+    // shader declared them).  This is done after mergeQualifiers(), in case fixBuiltInIoType looks
+    // at the qualifier to determine e.g, in or out qualifications.
+    fixBuiltInIoType(ioVar->getWritableType());
+
     // But, not location, we're losing that
     ioVar->getWritableType().getQualifier().layoutLocation = TQualifier::layoutLocationEnd;
 }
@@ -1483,10 +1491,18 @@
         }
     default:
         if (isClipOrCullDistance(type)) {
+            const int loc = type.getQualifier().layoutLocation;
+
             if (type.getQualifier().builtIn == EbvClipDistance) {
-                clipSemanticNSize[type.getQualifier().layoutLocation] = type.getVectorSize();
+                if (type.getQualifier().storage == EvqVaryingIn)
+                    clipSemanticNSizeIn[loc] = type.getVectorSize();
+                else
+                    clipSemanticNSizeOut[loc] = type.getVectorSize();
             } else {
-                cullSemanticNSize[type.getQualifier().layoutLocation] = type.getVectorSize();
+                if (type.getQualifier().storage == EvqVaryingIn)
+                    cullSemanticNSizeIn[loc] = type.getVectorSize();
+                else
+                    cullSemanticNSizeOut[loc] = type.getVectorSize();
             }
         }
 
@@ -2271,26 +2287,39 @@
 TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc, TOperator op, int semanticId,
                                                            TIntermTyped* left, TIntermTyped* right)
 {
+    switch (language) {
+    case EShLangFragment:
+    case EShLangVertex:
+    case EShLangGeometry:
+        break;
+    default:
+        error(loc, "unimplemented: clip/cull not currently implemented for this stage", "", "");
+        return nullptr;
+    }
+
     TVariable** clipCullVar = nullptr;
 
-    const TBuiltInVariable builtInType = left->getQualifier().builtIn;
+    // Figure out if we are assigning to, or from, clip or cull distance.
+    const bool isOutput = isClipOrCullDistance(left->getType());
 
-    // array sizes, or 1 if it's not an array:
-    const int rhsArraySize = (right->getType().isArray() ? right->getType().getOuterArraySize() : 1);
-    // vector sizes:
-    const int rhsVectorSize = right->getType().getVectorSize();
+    // This is the rvalue or lvalue holding the clip or cull distance.
+    TIntermTyped* clipCullNode = isOutput ? left : right;
+    // This is the value going into or out of the clip or cull distance.
+    TIntermTyped* internalNode = isOutput ? right : left;
 
-    decltype(clipSemanticNSize)* semanticNSize = nullptr;
+    const TBuiltInVariable builtInType = clipCullNode->getQualifier().builtIn;
+
+    decltype(clipSemanticNSizeIn)* semanticNSize = nullptr;
 
     // Refer to either the clip or the cull distance, depending on semantic.
     switch (builtInType) {
     case EbvClipDistance:
-        clipCullVar = &clipDistanceOutput;
-        semanticNSize = &clipSemanticNSize;
+        clipCullVar = isOutput ? &clipDistanceOutput : &clipDistanceInput;
+        semanticNSize = isOutput ? &clipSemanticNSizeOut : &clipSemanticNSizeIn;
         break;
     case EbvCullDistance:
-        clipCullVar = &cullDistanceOutput;
-        semanticNSize = &cullSemanticNSize;
+        clipCullVar = isOutput ? &cullDistanceOutput : &cullDistanceInput;
+        semanticNSize = isOutput ? &cullSemanticNSizeOut : &cullSemanticNSizeIn;
         break;
 
     // called invalidly: we expected a clip or a cull distance.
@@ -2316,31 +2345,52 @@
         vecItems += (*semanticNSize)[x];
         arrayLoc += (*semanticNSize)[x];
     }
-        
+ 
+
+    // It can have up to 2 array dimensions (in the case of geometry shader inputs)
+    const TArraySizes* const internalArraySizes = internalNode->getType().getArraySizes();
+    const int internalArrayDims = internalNode->getType().isArray() ? internalArraySizes->getNumDims() : 0;
+    // vector sizes:
+    const int internalVectorSize = internalNode->getType().getVectorSize();
+    // array sizes, or 1 if it's not an array:
+    const int internalInnerArraySize = (internalArrayDims > 0 ? internalArraySizes->getDimSize(internalArrayDims-1) : 1);
+    const int internalOuterArraySize = (internalArrayDims > 1 ? internalArraySizes->getDimSize(0) : 1);
+
+    // The created type may be an array of arrays, e.g, for geometry shader inputs.
+    const bool isImplicitlyArrayed = (language == EShLangGeometry && !isOutput);
 
     // If we haven't created the output already, create it now.
     if (*clipCullVar == nullptr) {
-        // ClipDistance and CullDistance are handled specially in the entry point output 
-        // copy algorithm, because they may need to be unpacked from components of vectors
-        // (or a scalar) into a float array.  Here, we make the array the right size and type,
+        // ClipDistance and CullDistance are handled specially in the entry point input/output copy
+        // algorithm, because they may need to be unpacked from components of vectors (or a scalar)
+        // into a float array, or vice versa.  Here, we make the array the right size and type,
         // which depends on the incoming data, which has several potential dimensions:
-        //    Semantic ID
-        //    vector size
-        //    array size
+        //    * Semantic ID
+        //    * vector size 
+        //    * array size
         // Of those, semantic ID and array size cannot appear simultaneously.
+        //
+        // Also to note: for implicitly arrayed forms (e.g, geometry shader inputs), we need to create two
+        // array dimensions.  The shader's declaration may have one or two array dimensions.  One is always
+        // the geometry's dimension.
 
-        const int requiredArraySize = arrayLoc * rhsArraySize;
+        const bool useInnerSize = internalArrayDims > 1 || !isImplicitlyArrayed;
 
-        TType clipCullType(EbtFloat, left->getType().getQualifier().storage, 1);
-        clipCullType.getQualifier() = left->getType().getQualifier();
+        const int requiredInnerArraySize = arrayLoc * (useInnerSize ? internalInnerArraySize : 1);
+        const int requiredOuterArraySize = (internalArrayDims > 0) ? internalArraySizes->getDimSize(0) : 1;
+
+        TType clipCullType(EbtFloat, clipCullNode->getType().getQualifier().storage, 1);
+        clipCullType.getQualifier() = clipCullNode->getType().getQualifier();
 
         // Create required array dimension
         TArraySizes arraySizes;
-        arraySizes.addInnerSize(requiredArraySize);
+        if (isImplicitlyArrayed)
+            arraySizes.addInnerSize(requiredOuterArraySize);
+        arraySizes.addInnerSize(requiredInnerArraySize);
         clipCullType.newArraySizes(arraySizes);
 
         // Obtain symbol name: we'll use that for the symbol we introduce.
-        TIntermSymbol* sym = left->getAsSymbolNode();
+        TIntermSymbol* sym = clipCullNode->getAsSymbolNode();
         assert(sym != nullptr);
 
         // We are moving the semantic ID from the layout location, so it is no longer needed or
@@ -2354,66 +2404,105 @@
     }
 
     // Create symbol for the clip or cull variable.
-    left = intermediate.addSymbol(**clipCullVar);
+    TIntermSymbol* clipCullSym = intermediate.addSymbol(**clipCullVar);
+
+    // vector sizes:
+    const int clipCullVectorSize = clipCullSym->getType().getVectorSize();
 
     // array sizes, or 1 if it's not an array:
-    const int lhsArraySize = (left->getType().isArray() ? left->getType().getOuterArraySize() : 1);
-    // vector sizes:
-    const int lhsVectorSize = left->getType().getVectorSize();
+    const TArraySizes* const clipCullArraySizes = clipCullSym->getType().getArraySizes();
+    const int clipCullOuterArraySize = isImplicitlyArrayed ? clipCullArraySizes->getDimSize(0) : 1;
+    const int clipCullInnerArraySize = clipCullArraySizes->getDimSize(isImplicitlyArrayed ? 1 : 0);
 
-    // left has got to be an array of scalar floats, per SPIR-V semantics.
+    // clipCullSym has got to be an array of scalar floats, per SPIR-V semantics.
     // fixBuiltInIoType() should have handled that upstream.
-    assert(left->getType().isArray());
-    assert(left->getType().getVectorSize() == 1);
-    assert(left->getType().getBasicType() == EbtFloat);
+    assert(clipCullSym->getType().isArray());
+    assert(clipCullSym->getType().getVectorSize() == 1);
+    assert(clipCullSym->getType().getBasicType() == EbtFloat);
 
     // We may be creating multiple sub-assignments.  This is an aggregate to hold them.
     // TODO: it would be possible to be clever sometimes and avoid the sequence node if not needed.
     TIntermAggregate* assignList = nullptr;
 
+    // Holds individual component assignments as we make them.
+    TIntermTyped* clipCullAssign = nullptr;
+
     // If the types are homomorphic, use a simple assign.  No need to mess about with 
     // individual components.
-    if (left->getType().isArray() == right->getType().isArray() &&
-        lhsArraySize == rhsArraySize &&
-        lhsVectorSize == rhsVectorSize) {
-        assignList = intermediate.growAggregate(assignList, intermediate.addAssign(op, left, right, loc));
+    if (clipCullSym->getType().isArray() == internalNode->getType().isArray() &&
+        clipCullInnerArraySize == internalInnerArraySize &&
+        clipCullOuterArraySize == internalOuterArraySize &&
+        clipCullVectorSize == internalVectorSize) {
+
+        if (isOutput)
+            clipCullAssign = intermediate.addAssign(op, clipCullSym, internalNode, loc);
+        else
+            clipCullAssign = intermediate.addAssign(op, internalNode, clipCullSym, loc);
+
+        assignList = intermediate.growAggregate(assignList, clipCullAssign);
         assignList->setOperator(EOpSequence);
+
         return assignList;
     }
 
-    // We are going to copy each component of the right (per array element if indicated) to sequential
-    // array elements of the left.  This tracks the lhs element we're writing to as we go along.
+    // We are going to copy each component of the internal (per array element if indicated) to sequential
+    // array elements of the clipCullSym.  This tracks the lhs element we're writing to as we go along.
     // We may be starting in the middle - e.g, for a non-zero semantic ID calculated above.
-    int lhsArrayPos = semanticOffset[semanticId];
+    int clipCullInnerArrayPos = semanticOffset[semanticId];
+    int clipCullOuterArrayPos = 0;
 
-    // Loop through every component of every element of the RHS, and copy to LHS elements in turn.
-    for (int rhsArrayPos = 0; rhsArrayPos < rhsArraySize; ++rhsArrayPos) {
-        for (int rhsComponent = 0; rhsComponent < rhsVectorSize; ++rhsComponent) {
-            // LHS array member to write to:
-            TIntermTyped* lhsMember = intermediate.addIndex(EOpIndexDirect, left,
-                                                            intermediate.addConstantUnion(lhsArrayPos++, loc), loc);
+    // Lambda to add an index to a node, set the type of the result, and return the new node.
+    const auto addIndex = [this, &loc](TIntermTyped* node, int pos) -> TIntermTyped* {
+        const TType derefType(node->getType(), 0);
+        node = intermediate.addIndex(EOpIndexDirect, node, intermediate.addConstantUnion(pos, loc), loc);
+        node->setType(derefType);
+        return node;
+    };
 
-            TIntermTyped* rhsMember = right;
+    // Loop through every component of every element of the internal, and copy to or from the matching external.
+    for (int internalOuterArrayPos = 0; internalOuterArrayPos < internalOuterArraySize; ++internalOuterArrayPos) {
+        for (int internalInnerArrayPos = 0; internalInnerArrayPos < internalInnerArraySize; ++internalInnerArrayPos) {
+            for (int internalComponent = 0; internalComponent < internalVectorSize; ++internalComponent) {
+                // clip/cull array member to read from / write to:
+                TIntermTyped* clipCullMember = clipCullSym;
 
-            // If right is an array, extract the element of interest
-            if (right->getType().isArray()) {
-                const TType derefType(rhsMember->getType(), 0);
-                rhsMember = intermediate.addIndex(EOpIndexDirect, rhsMember,
-                                                  intermediate.addConstantUnion(rhsArrayPos, loc), loc);
-                rhsMember->setType(derefType);
+                // If implicitly arrayed, there is an outer array dimension involved
+                if (isImplicitlyArrayed)
+                    clipCullMember = addIndex(clipCullMember, clipCullOuterArrayPos);
+
+                // Index into proper array position for clip cull member
+                clipCullMember = addIndex(clipCullMember, clipCullInnerArrayPos++);
+
+                // if needed, start over with next outer array slice.
+                if (isImplicitlyArrayed && clipCullInnerArrayPos >= clipCullInnerArraySize) {
+                    clipCullInnerArrayPos = semanticOffset[semanticId];
+                    ++clipCullOuterArrayPos;
+                }
+
+                // internal member to read from / write to:
+                TIntermTyped* internalMember = internalNode;
+
+                // If internal node has outer array dimension, index appropriately.
+                if (internalArrayDims > 1)
+                    internalMember = addIndex(internalMember, internalOuterArrayPos);
+
+                // If internal node has inner array dimension, index appropriately.
+                if (internalArrayDims > 0)
+                    internalMember = addIndex(internalMember, internalInnerArrayPos);
+
+                // If internal node is a vector, extract the component of interest.
+                if (internalNode->getType().isVector())
+                    internalMember = addIndex(internalMember, internalComponent);
+
+                // Create an assignment: output from internal to clip cull, or input from clip cull to internal.
+                if (isOutput)
+                    clipCullAssign = intermediate.addAssign(op, clipCullMember, internalMember, loc);
+                else
+                    clipCullAssign = intermediate.addAssign(op, internalMember, clipCullMember, loc);
+
+                // Track assignment in the sequence.
+                assignList = intermediate.growAggregate(assignList, clipCullAssign);
             }
-
-            // If right is a vector, extract the component of interest.
-            if (right->getType().isVector()) {
-                const TType derefType(rhsMember->getType(), 0);
-                rhsMember = intermediate.addIndex(EOpIndexDirect, rhsMember,
-                                                  intermediate.addConstantUnion(rhsComponent, loc), loc);
-                rhsMember->setType(derefType);
-            }
-
-            // Assign: to the proper lhs member.
-            assignList = intermediate.growAggregate(assignList,
-                                                    intermediate.addAssign(op, lhsMember, rhsMember, loc));
         }
     }
 
@@ -2483,8 +2572,10 @@
     // isn't, we fall back to a member-wise copy.
     if (!isFlattenLeft && !isFlattenRight && !isSplitLeft && !isSplitRight) {
         // Clip and cull distance requires more processing.  See comment above assignClipCullDistance.
-        if (isClipOrCullDistance(left->getType())) {
-            const int semanticId = left->getType().getQualifier().layoutLocation;
+        if (isClipOrCullDistance(left->getType()) || isClipOrCullDistance(right->getType())) {
+            const bool isOutput = isClipOrCullDistance(left->getType());
+
+            const int semanticId = (isOutput ? left : right)->getType().getQualifier().layoutLocation;
             return assignClipCullDistance(loc, op, semanticId, left, right);
         }
 
@@ -2664,13 +2755,15 @@
                 TIntermTyped* subSplitRight = isSplitRight ? getMember(false, right, member, splitRight, memberR)
                                                            : subRight;
 
-                if (isClipOrCullDistance(subSplitLeft->getType())) {
+                if (isClipOrCullDistance(subSplitLeft->getType()) || isClipOrCullDistance(subSplitRight->getType())) {
                     // Clip and cull distance built-in assignment is complex in its own right, and is handled in
                     // a separate function dedicated to that task.  See comment above assignClipCullDistance;
 
+                    const bool isOutput = isClipOrCullDistance(subSplitLeft->getType());
+
                     // Since all clip/cull semantics boil down to the same built-in type, we need to get the
                     // semantic ID from the dereferenced type's layout location, to avoid an N-1 mapping.
-                    const TType derefType(left->getType(), member);
+                    const TType derefType((isOutput ? left : right)->getType(), member);
                     const int semanticId = derefType.getQualifier().layoutLocation;
 
                     TIntermAggregate* clipCullAssign = assignClipCullDistance(loc, op, semanticId,
@@ -5057,7 +5150,7 @@
     const auto setArgList = [&](int paramNum, const TVector<TIntermTyped*>& args) {
         if (args.size() == 1)
             setArg(paramNum, args.front());
-        else {
+        else if (args.size() > 1) {
             if (function.getParamCount() + functionParamNumberOffset == 1) {
                 arguments = intermediate.makeAggregate(args.front());
                 std::for_each(args.begin() + 1, args.end(), 
@@ -5068,8 +5161,8 @@
                 auto it = aggregate->getSequence().erase(aggregate->getSequence().begin() + paramNum);
                 aggregate->getSequence().insert(it, args.begin(), args.end());
             }
+            functionParamNumberOffset += (int)(args.size() - 1);
         }
-        functionParamNumberOffset += (args.size() - 1);
     };
 
     // Process each argument's conversion
@@ -8786,10 +8879,6 @@
         qualifier.sample = false;
     }
 
-    // TODO: handle clip/cull on the input side; this doesn't work, see overwrite of .layoutLocation later
-    if (isClipOrCullDistance(qualifier))
-        qualifier.layoutLocation = TQualifier::layoutLocationEnd;
-
     qualifier.clearStreamLayout();
     qualifier.clearXfbLayout();
 
diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h
index ab62625..a276d6e 100755
--- a/hlsl/hlslParseHelper.h
+++ b/hlsl/hlslParseHelper.h
@@ -435,12 +435,16 @@
 
     TVariable* gsStreamOutput;               // geometry shader stream outputs, for emit (Append method)
 
-    TVariable* clipDistanceOutput;           // synthesized clip distance output variable (shader might have >1)
-    TVariable* cullDistanceOutput;           // synthesized cull distance output variable (shader might have >1)
+    TVariable* clipDistanceOutput;           // synthesized clip distance out variable (shader might have >1)
+    TVariable* cullDistanceOutput;           // synthesized cull distance out variable (shader might have >1)
+    TVariable* clipDistanceInput;            // synthesized clip distance in variable (shader might have >1)
+    TVariable* cullDistanceInput;            // synthesized cull distance in variable (shader might have >1)
 
     static const int maxClipCullRegs = 2;
-    std::array<int, maxClipCullRegs> clipSemanticNSize; // vector, indexed by clip semantic ID
-    std::array<int, maxClipCullRegs> cullSemanticNSize; // vector, indexed by cull semantic ID
+    std::array<int, maxClipCullRegs> clipSemanticNSizeIn;  // vector, indexed by clip semantic ID
+    std::array<int, maxClipCullRegs> cullSemanticNSizeIn;  // vector, indexed by cull semantic ID
+    std::array<int, maxClipCullRegs> clipSemanticNSizeOut; // vector, indexed by clip semantic ID
+    std::array<int, maxClipCullRegs> cullSemanticNSizeOut; // vector, indexed by cull semantic ID
 
     // This tracks the first (mip level) argument to the .mips[][] operator.  Since this can be nested as
     // in tx.mips[tx.mips[0][1].x][2], we need a stack.  We also track the TSourceLoc for error reporting