HLSL: pass tessellation execution modes through to SPIR-V
authorsteve-lunarg <steve_gh@khasekhemwy.net>
Thu, 23 Mar 2017 17:56:07 +0000 (11:56 -0600)
committersteve-lunarg <steve_gh@khasekhemwy.net>
Fri, 31 Mar 2017 17:47:18 +0000 (11:47 -0600)
The SPIR-V generator had assumed tessellation modes such as
primitive type and vertex order would only appear in tess eval
(domain) shaders.  SPIR-V allows either, and HLSL allows and
possibly requires them to be in the hull shader.

This change:

1. Passes them through for either tessellation stage, and,

2. Does not set up defaults in the domain stage for HLSl compilation,
to avoid conflicting definitions.

12 files changed:
SPIRV/GlslangToSpv.cpp
Test/baseResults/hlsl.domain.1.tese.out [new file with mode: 0644]
Test/baseResults/hlsl.hull.1.tesc.out
Test/baseResults/hlsl.hull.2.tesc.out
Test/baseResults/hlsl.hull.ctrlpt-1.tesc.out
Test/baseResults/hlsl.hull.void.tesc.out
Test/hlsl.domain.1.tese [new file with mode: 0644]
glslang/MachineIndependent/intermOut.cpp
glslang/MachineIndependent/linkValidate.cpp
gtests/Hlsl.FromFile.cpp
hlsl/hlslParseHelper.cpp
hlsl/hlslParseHelper.h

index d2a9085..1e03909 100755 (executable)
@@ -869,14 +869,20 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
         builder.addCapability(spv::CapabilityShader);
         break;
 
+    case EShLangTessEvaluation:
     case EShLangTessControl:
         builder.addCapability(spv::CapabilityTessellation);
-        builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
-        break;
 
-    case EShLangTessEvaluation:
-        builder.addCapability(spv::CapabilityTessellation);
-        switch (glslangIntermediate->getInputPrimitive()) {
+        glslang::TLayoutGeometry primitive;
+
+        if (glslangIntermediate->getStage() == EShLangTessControl) {
+            builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
+            primitive = glslangIntermediate->getOutputPrimitive();
+        } else {
+            primitive = glslangIntermediate->getInputPrimitive();
+        }
+
+        switch (primitive) {
         case glslang::ElgTriangles:           mode = spv::ExecutionModeTriangles;     break;
         case glslang::ElgQuads:               mode = spv::ExecutionModeQuads;         break;
         case glslang::ElgIsolines:            mode = spv::ExecutionModeIsolines;      break;
diff --git a/Test/baseResults/hlsl.domain.1.tese.out b/Test/baseResults/hlsl.domain.1.tese.out
new file mode 100644 (file)
index 0000000..550ead0
--- /dev/null
@@ -0,0 +1,393 @@
+hlsl.domain.1.tese
+Shader version: 450
+input primitive = triangles
+vertex spacing = none
+triangle order = none
+0:? Sequence
+0:22  Function Definition: @main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11; ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22    Function Parameters: 
+0:22      'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22      'tesscoord' ( in 3-component vector of float)
+0:22      'pcf_data' ( in structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:?     Sequence
+0:25      move second child to first child ( temp 4-component vector of float)
+0:25        pos: direct index for structure ( temp 4-component vector of float)
+0:25          'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25          Constant:
+0:25            0 (const int)
+0:25        add ( temp 4-component vector of float)
+0:25          pos: direct index for structure ( temp 4-component vector of float)
+0:25            direct index ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25              'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25              Constant:
+0:25                0 (const int)
+0:25            Constant:
+0:25              0 (const int)
+0:25          direct index ( temp float)
+0:25            'tesscoord' ( in 3-component vector of float)
+0:25            Constant:
+0:25              0 (const int)
+0:26      move second child to first child ( temp 3-component vector of float)
+0:26        norm: direct index for structure ( temp 3-component vector of float)
+0:26          'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26          Constant:
+0:26            1 (const int)
+0:26        add ( temp 3-component vector of float)
+0:26          norm: direct index for structure ( temp 3-component vector of float)
+0:26            direct index ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26              'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26              Constant:
+0:26                0 (const int)
+0:26            Constant:
+0:26              1 (const int)
+0:26          direct index ( temp float)
+0:26            'tesscoord' ( in 3-component vector of float)
+0:26            Constant:
+0:26              1 (const int)
+0:28      direct index ( temp float)
+0:28        'tesscoord' ( in 3-component vector of float)
+0:28        Constant:
+0:28          2 (const int)
+0:30      Branch: Return with expression
+0:30        'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22  Function Definition: main( ( temp void)
+0:22    Function Parameters: 
+0:?     Sequence
+0:22      move second child to first child ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         'i' ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22      move second child to first child ( temp 3-component vector of float)
+0:?         'tesscoord' ( temp 3-component vector of float)
+0:?         'tesscoord' ( patch in 3-component vector of float TessCoord)
+0:22      Sequence
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              0 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              0 (const int)
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              1 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              1 (const int)
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              2 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              2 (const int)
+0:22        move second child to first child ( temp float)
+0:22          flInsideTessFactor: direct index for structure ( temp float)
+0:?             'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22            Constant:
+0:22              1 (const int)
+0:22          direct index ( patch in float TessLevelInner)
+0:?             'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner)
+0:22            Constant:
+0:22              0 (const int)
+0:22      move second child to first child ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         '@entryPointOutput' (layout( location=0) out structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22        Function Call: @main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11; ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?           'i' ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?           'tesscoord' ( temp 3-component vector of float)
+0:?           'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?     'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?     'tesscoord' ( patch in 3-component vector of float TessCoord)
+0:?     'pcf_data' (layout( location=2) patch in structure{})
+0:?     'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:?     'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner)
+
+
+Linked tessellation evaluation stage:
+
+
+Shader version: 450
+input primitive = triangles
+vertex spacing = none
+triangle order = none
+0:? Sequence
+0:22  Function Definition: @main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11; ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22    Function Parameters: 
+0:22      'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22      'tesscoord' ( in 3-component vector of float)
+0:22      'pcf_data' ( in structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:?     Sequence
+0:25      move second child to first child ( temp 4-component vector of float)
+0:25        pos: direct index for structure ( temp 4-component vector of float)
+0:25          'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25          Constant:
+0:25            0 (const int)
+0:25        add ( temp 4-component vector of float)
+0:25          pos: direct index for structure ( temp 4-component vector of float)
+0:25            direct index ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25              'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:25              Constant:
+0:25                0 (const int)
+0:25            Constant:
+0:25              0 (const int)
+0:25          direct index ( temp float)
+0:25            'tesscoord' ( in 3-component vector of float)
+0:25            Constant:
+0:25              0 (const int)
+0:26      move second child to first child ( temp 3-component vector of float)
+0:26        norm: direct index for structure ( temp 3-component vector of float)
+0:26          'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26          Constant:
+0:26            1 (const int)
+0:26        add ( temp 3-component vector of float)
+0:26          norm: direct index for structure ( temp 3-component vector of float)
+0:26            direct index ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26              'i' ( const (read only) 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:26              Constant:
+0:26                0 (const int)
+0:26            Constant:
+0:26              1 (const int)
+0:26          direct index ( temp float)
+0:26            'tesscoord' ( in 3-component vector of float)
+0:26            Constant:
+0:26              1 (const int)
+0:28      direct index ( temp float)
+0:28        'tesscoord' ( in 3-component vector of float)
+0:28        Constant:
+0:28          2 (const int)
+0:30      Branch: Return with expression
+0:30        'o' ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22  Function Definition: main( ( temp void)
+0:22    Function Parameters: 
+0:?     Sequence
+0:22      move second child to first child ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         'i' ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22      move second child to first child ( temp 3-component vector of float)
+0:?         'tesscoord' ( temp 3-component vector of float)
+0:?         'tesscoord' ( patch in 3-component vector of float TessCoord)
+0:22      Sequence
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              0 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              0 (const int)
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              1 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              1 (const int)
+0:22        move second child to first child ( temp float)
+0:22          direct index ( temp float)
+0:22            flTessFactor: direct index for structure ( temp 3-element array of float)
+0:?               'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22              Constant:
+0:22                0 (const int)
+0:22            Constant:
+0:22              2 (const int)
+0:22          direct index ( patch in float TessLevelOuter)
+0:?             'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:22            Constant:
+0:22              2 (const int)
+0:22        move second child to first child ( temp float)
+0:22          flInsideTessFactor: direct index for structure ( temp float)
+0:?             'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:22            Constant:
+0:22              1 (const int)
+0:22          direct index ( patch in float TessLevelInner)
+0:?             'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner)
+0:22            Constant:
+0:22              0 (const int)
+0:22      move second child to first child ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?         '@entryPointOutput' (layout( location=0) out structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:22        Function Call: @main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11; ( temp structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?           'i' ( temp 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?           'tesscoord' ( temp 3-component vector of float)
+0:?           'pcf_data' ( temp structure{ temp 3-element array of float flTessFactor,  temp float flInsideTessFactor})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?     'i' (layout( location=0) in 3-element array of structure{ temp 4-component vector of float pos,  temp 3-component vector of float norm})
+0:?     'tesscoord' ( patch in 3-component vector of float TessCoord)
+0:?     'pcf_data' (layout( location=2) patch in structure{})
+0:?     'pcf_data_flTessFactor' ( patch in 4-element array of float TessLevelOuter)
+0:?     'pcf_data_flInsideTessFactor' ( patch in 2-element array of float TessLevelInner)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 91
+
+                              Capability Tessellation
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint TessellationEvaluation 4  "main" 51 55 61 76 81 90
+                              ExecutionMode 4 Triangles
+                              Name 4  "main"
+                              Name 9  "ds_in_t"
+                              MemberName 9(ds_in_t) 0  "pos"
+                              MemberName 9(ds_in_t) 1  "norm"
+                              Name 15  "pcf_in_t"
+                              MemberName 15(pcf_in_t) 0  "flTessFactor"
+                              MemberName 15(pcf_in_t) 1  "flInsideTessFactor"
+                              Name 17  "gs_in_t"
+                              MemberName 17(gs_in_t) 0  "pos"
+                              MemberName 17(gs_in_t) 1  "norm"
+                              Name 22  "@main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11;"
+                              Name 19  "i"
+                              Name 20  "tesscoord"
+                              Name 21  "pcf_data"
+                              Name 25  "o"
+                              Name 49  "i"
+                              Name 51  "i"
+                              Name 53  "tesscoord"
+                              Name 55  "tesscoord"
+                              Name 57  "pcf_data"
+                              Name 61  "pcf_data_flTessFactor"
+                              Name 76  "pcf_data_flInsideTessFactor"
+                              Name 81  "@entryPointOutput"
+                              Name 83  "param"
+                              Name 85  "param"
+                              Name 88  "pcf_in_t"
+                              Name 90  "pcf_data"
+                              Decorate 51(i) Location 0
+                              Decorate 55(tesscoord) Patch
+                              Decorate 55(tesscoord) BuiltIn TessCoord
+                              Decorate 61(pcf_data_flTessFactor) Patch
+                              Decorate 61(pcf_data_flTessFactor) BuiltIn TessLevelOuter
+                              Decorate 76(pcf_data_flInsideTessFactor) Patch
+                              Decorate 76(pcf_data_flInsideTessFactor) BuiltIn TessLevelInner
+                              Decorate 81(@entryPointOutput) Location 0
+                              Decorate 90(pcf_data) Patch
+                              Decorate 90(pcf_data) Location 2
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeVector 6(float) 3
+      9(ds_in_t):             TypeStruct 7(fvec4) 8(fvec3)
+              10:             TypeInt 32 0
+              11:     10(int) Constant 3
+              12:             TypeArray 9(ds_in_t) 11
+              13:             TypePointer Function 8(fvec3)
+              14:             TypeArray 6(float) 11
+    15(pcf_in_t):             TypeStruct 14 6(float)
+              16:             TypePointer Function 15(pcf_in_t)
+     17(gs_in_t):             TypeStruct 7(fvec4) 8(fvec3)
+              18:             TypeFunction 17(gs_in_t) 12 13(ptr) 16(ptr)
+              24:             TypePointer Function 17(gs_in_t)
+              26:             TypeInt 32 1
+              27:     26(int) Constant 0
+              29:     10(int) Constant 0
+              30:             TypePointer Function 6(float)
+              35:             TypePointer Function 7(fvec4)
+              37:     26(int) Constant 1
+              39:     10(int) Constant 1
+              48:             TypePointer Function 12
+              50:             TypePointer Input 12
+           51(i):     50(ptr) Variable Input
+              54:             TypePointer Input 8(fvec3)
+   55(tesscoord):     54(ptr) Variable Input
+              58:     10(int) Constant 4
+              59:             TypeArray 6(float) 58
+              60:             TypePointer Input 59
+61(pcf_data_flTessFactor):     60(ptr) Variable Input
+              62:             TypePointer Input 6(float)
+              69:     26(int) Constant 2
+              73:     10(int) Constant 2
+              74:             TypeArray 6(float) 73
+              75:             TypePointer Input 74
+76(pcf_data_flInsideTessFactor):     75(ptr) Variable Input
+              80:             TypePointer Output 17(gs_in_t)
+81(@entryPointOutput):     80(ptr) Variable Output
+    88(pcf_in_t):             TypeStruct
+              89:             TypePointer Input 88(pcf_in_t)
+    90(pcf_data):     89(ptr) Variable Input
+         4(main):           2 Function None 3
+               5:             Label
+           49(i):     48(ptr) Variable Function
+   53(tesscoord):     13(ptr) Variable Function
+    57(pcf_data):     16(ptr) Variable Function
+       83(param):     13(ptr) Variable Function
+       85(param):     16(ptr) Variable Function
+              52:          12 Load 51(i)
+                              Store 49(i) 52
+              56:    8(fvec3) Load 55(tesscoord)
+                              Store 53(tesscoord) 56
+              63:     62(ptr) AccessChain 61(pcf_data_flTessFactor) 27
+              64:    6(float) Load 63
+              65:     30(ptr) AccessChain 57(pcf_data) 27 27
+                              Store 65 64
+              66:     62(ptr) AccessChain 61(pcf_data_flTessFactor) 37
+              67:    6(float) Load 66
+              68:     30(ptr) AccessChain 57(pcf_data) 27 37
+                              Store 68 67
+              70:     62(ptr) AccessChain 61(pcf_data_flTessFactor) 69
+              71:    6(float) Load 70
+              72:     30(ptr) AccessChain 57(pcf_data) 27 69
+                              Store 72 71
+              77:     62(ptr) AccessChain 76(pcf_data_flInsideTessFactor) 27
+              78:    6(float) Load 77
+              79:     30(ptr) AccessChain 57(pcf_data) 37
+                              Store 79 78
+              82:          12 Load 49(i)
+              84:    8(fvec3) Load 53(tesscoord)
+                              Store 83(param) 84
+              86:15(pcf_in_t) Load 57(pcf_data)
+                              Store 85(param) 86
+              87: 17(gs_in_t) FunctionCall 22(@main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11;) 82 83(param) 85(param)
+                              Store 81(@entryPointOutput) 87
+                              Return
+                              FunctionEnd
+22(@main(struct-ds_in_t-vf4-vf31[3];vf3;struct-pcf_in_t-f1[3]-f11;): 17(gs_in_t) Function None 18
+           19(i):          12 FunctionParameter
+   20(tesscoord):     13(ptr) FunctionParameter
+    21(pcf_data):     16(ptr) FunctionParameter
+              23:             Label
+           25(o):     24(ptr) Variable Function
+              28:    7(fvec4) CompositeExtract 19(i) 0 0
+              31:     30(ptr) AccessChain 20(tesscoord) 29
+              32:    6(float) Load 31
+              33:    7(fvec4) CompositeConstruct 32 32 32 32
+              34:    7(fvec4) FAdd 28 33
+              36:     35(ptr) AccessChain 25(o) 27
+                              Store 36 34
+              38:    8(fvec3) CompositeExtract 19(i) 0 1
+              40:     30(ptr) AccessChain 20(tesscoord) 39
+              41:    6(float) Load 40
+              42:    8(fvec3) CompositeConstruct 41 41 41
+              43:    8(fvec3) FAdd 38 42
+              44:     13(ptr) AccessChain 25(o) 37
+                              Store 44 43
+              45: 17(gs_in_t) Load 25(o)
+                              ReturnValue 45
+                              FunctionEnd
index 7500045..a60c122 100644 (file)
@@ -1,6 +1,7 @@
 hlsl.hull.1.tesc
 Shader version: 450
 vertices = 4
+vertex spacing = equal_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[4];u1; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -115,6 +116,7 @@ Linked tessellation control stage:
 
 Shader version: 450
 vertices = 4
+vertex spacing = equal_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[4];u1; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -232,6 +234,8 @@ vertices = 4
                               MemoryModel Logical GLSL450
                               EntryPoint TessellationControl 4  "main" 40 44 48 66 72 92
                               ExecutionMode 4 OutputVertices 4
+                              ExecutionMode 4 Isolines
+                              ExecutionMode 4 SpacingEqual
                               Name 4  "main"
                               Name 8  "VS_OUT"
                               MemberName 8(VS_OUT) 0  "cpoint"
index 4099d6b..f7c7389 100644 (file)
@@ -1,6 +1,7 @@
 hlsl.hull.2.tesc
 Shader version: 450
 vertices = 4
+vertex spacing = equal_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[4]; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -113,6 +114,7 @@ Linked tessellation control stage:
 
 Shader version: 450
 vertices = 4
+vertex spacing = equal_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[4]; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -228,6 +230,8 @@ vertices = 4
                               MemoryModel Logical GLSL450
                               EntryPoint TessellationControl 4  "main" 42 46 48 64 66 74 94
                               ExecutionMode 4 OutputVertices 4
+                              ExecutionMode 4 Isolines
+                              ExecutionMode 4 SpacingEqual
                               Name 4  "main"
                               Name 8  "VS_OUT"
                               MemberName 8(VS_OUT) 0  "cpoint"
index 6dc167b..e6deae4 100644 (file)
@@ -1,6 +1,8 @@
 hlsl.hull.ctrlpt-1.tesc
 Shader version: 450
 vertices = 3
+vertex spacing = fractional_odd_spacing
+triangle order = cw
 0:? Sequence
 0:27  Function Definition: @main(struct-hs_in_t-vf31[3];u1; ( temp structure{ temp 3-component vector of float val})
 0:27    Function Parameters: 
@@ -200,6 +202,8 @@ Linked tessellation control stage:
 
 Shader version: 450
 vertices = 3
+vertex spacing = fractional_odd_spacing
+triangle order = cw
 0:? Sequence
 0:27  Function Definition: @main(struct-hs_in_t-vf31[3];u1; ( temp structure{ temp 3-component vector of float val})
 0:27    Function Parameters: 
@@ -402,6 +406,9 @@ vertices = 3
                               MemoryModel Logical GLSL450
                               EntryPoint TessellationControl 4  "main" 41 45 48 94 108 126
                               ExecutionMode 4 OutputVertices 3
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 SpacingFractionalOdd
+                              ExecutionMode 4 VertexOrderCw
                               Name 4  "main"
                               Name 8  "hs_in_t"
                               MemberName 8(hs_in_t) 0  "val"
index bc88cdc..20b8dd3 100644 (file)
@@ -1,6 +1,7 @@
 hlsl.hull.void.tesc
 Shader version: 450
 vertices = 3
+vertex spacing = fractional_even_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[3]; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -55,6 +56,7 @@ Linked tessellation control stage:
 
 Shader version: 450
 vertices = 3
+vertex spacing = fractional_even_spacing
 0:? Sequence
 0:26  Function Definition: @main(struct-VS_OUT-vf31[3]; ( temp structure{ temp 3-component vector of float cpoint})
 0:26    Function Parameters: 
@@ -112,6 +114,8 @@ vertices = 3
                               MemoryModel Logical GLSL450
                               EntryPoint TessellationControl 4  "main" 33 37 39
                               ExecutionMode 4 OutputVertices 3
+                              ExecutionMode 4 Triangles
+                              ExecutionMode 4 SpacingFractionalEven
                               Name 4  "main"
                               Name 8  "VS_OUT"
                               MemberName 8(VS_OUT) 0  "cpoint"
diff --git a/Test/hlsl.domain.1.tese b/Test/hlsl.domain.1.tese
new file mode 100644 (file)
index 0000000..5039410
--- /dev/null
@@ -0,0 +1,32 @@
+
+struct ds_in_t 
+{ 
+    float4 pos  : POSITION; 
+    float3 norm : TEXCOORD0; 
+}; 
+
+struct pcf_in_t 
+{ 
+    float flTessFactor [3]   : SV_TessFactor; 
+    float flInsideTessFactor : SV_InsideTessFactor; 
+}; 
+
+struct gs_in_t 
+{ 
+    float4 pos  : POSITION; 
+    float3 norm : TEXCOORD0; 
+}; 
+
+[domain ( "tri" )] 
+gs_in_t main (const OutputPatch <ds_in_t, 3> i, float3 tesscoord : SV_DomainLocation, pcf_in_t pcf_data ) 
+{ 
+    gs_in_t o; 
+
+    o.pos  = i[0].pos + tesscoord.x;
+    o.norm = i[0].norm + tesscoord.y;
+
+    tesscoord.z;
+    
+    return o; 
+}
+
index b8a6969..c0c60c5 100644 (file)
@@ -884,6 +884,13 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
 
     case EShLangTessControl:
         infoSink.debug << "vertices = " << vertices << "\n";
+
+        if (inputPrimitive != ElgNone)
+            infoSink.debug << "input primitive = " << TQualifier::getGeometryString(inputPrimitive) << "\n";
+        if (vertexSpacing != EvsNone)
+            infoSink.debug << "vertex spacing = " << TQualifier::getVertexSpacingString(vertexSpacing) << "\n";
+        if (vertexOrder != EvoNone)
+            infoSink.debug << "triangle order = " << TQualifier::getVertexOrderString(vertexOrder) << "\n";
         break;
 
     case EShLangTessEvaluation:
index 761cb41..0328009 100644 (file)
@@ -461,10 +461,12 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
     case EShLangTessEvaluation:
         if (inputPrimitive == ElgNone)
             error(infoSink, "At least one shader must specify an input layout primitive");
-        if (vertexSpacing == EvsNone)
-            vertexSpacing = EvsEqual;
-        if (vertexOrder == EvoNone)
-            vertexOrder = EvoCcw;
+        if (source == EShSourceGlsl) {
+            if (vertexSpacing == EvsNone)
+                vertexSpacing = EvsEqual;
+            if (vertexOrder == EvoNone)
+                vertexOrder = EvoCcw;
+        }
         break;
     case EShLangGeometry:
         if (inputPrimitive == ElgNone)
index 756f4df..54320a5 100644 (file)
@@ -122,6 +122,7 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.getdimensions.rw.dx10.frag", "main"},
         {"hlsl.getdimensions.dx10.vert", "main"},
         {"hlsl.getsampleposition.dx10.frag", "main"},
+        {"hlsl.domain.1.tese", "main"},
         {"hlsl.hull.1.tesc", "main"},
         {"hlsl.hull.2.tesc", "main"},
         {"hlsl.hull.void.tesc", "main"},
index e179a71..986a1a4 100755 (executable)
@@ -1386,7 +1386,7 @@ void HlslParseContext::trackLinkage(TSymbol& symbol)
 // Some types require fixed array sizes in SPIR-V, but can be scalars or
 // arrays of sizes SPIR-V doesn't allow.  For example, tessellation factors.
 // This creates the right size.  A conversion is performed when the internal
-// type is copied to or from the external
+// type is copied to or from the external type.
 void HlslParseContext::fixBuiltInArrayType(TType& type)
 {
     int requiredSize = 0;
@@ -1600,7 +1600,7 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
 
 
 // Handle all [attrib] attribute for the shader entry point
-void HlslParseContext::handleEntryPointAttributes(const TSourceLoc& loc, TFunction& userFunction, const TAttributeMap& attributes)
+void HlslParseContext::handleEntryPointAttributes(const TSourceLoc& loc, const TAttributeMap& attributes)
 {
     // Handle entry-point function attributes
     const TIntermAggregate* numThreads = attributes[EatNumThreads];
@@ -1779,7 +1779,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
     entryPointFunction = &userFunction; // needed in finish()
 
     // Handle entry point attributes
-    handleEntryPointAttributes(loc, userFunction, attributes);
+    handleEntryPointAttributes(loc, attributes);
 
     // entry point logic...
 
@@ -1853,6 +1853,9 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
     if (entryPointOutput) {
         TIntermTyped* returnAssign;
 
+        // For hull shaders, the wrapped entry point return value is written to
+        // an array element as indexed by invocation ID, which we might have to make up.
+        // This is required to match SPIR-V semantics.
         if (language == EShLangTessControl) {
             TIntermSymbol* invocationIdSym = findLinkageSymbol(EbvInvocationId);
 
index f826e2f..f631eed 100755 (executable)
@@ -80,7 +80,7 @@ public:
     void handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
     TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&, TIntermNode*& entryPointTree);
     TIntermNode* transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&);
-    void handleEntryPointAttributes(const TSourceLoc&, TFunction&, const TAttributeMap&);
+    void handleEntryPointAttributes(const TSourceLoc&, const TAttributeMap&);
     void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
     void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
     void remapNonEntryPointIO(TFunction& function);