HLSL: support per control point patch const fn invocation

This PR emulates per control point inputs to patch constant functions.
Without either an extension to look across SIMD lanes or a dedicated
stage, the emulation must use separate invocations of the wrapped
entry point to obtain the per control point values.  This is provided
since shaders are wanting this functionality now, but such an extension
is not yet available.

Entry point arguments qualified as an invocation ID are replaced by the
current control point number when calling the wrapped entry point.  There
is no particular optimization for the case of the entry point not having
such an input but the PCF still accepting ctrl pt frequency data.  It'll
work, but anyway makes no so much sense.

The wrapped entry point must return the per control point data by value.
At this time it is not supported as an output parameter.
This commit is contained in:
steve-lunarg
2017-03-14 17:37:10 -06:00
parent e434ad923e
commit 9cee73e028
7 changed files with 815 additions and 68 deletions

View File

@@ -50,8 +50,8 @@ vertices = 4
0:? 'pid' ( in uint PrimitiveID)
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -62,8 +62,8 @@ vertices = 4
0:? Constant:
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -104,7 +104,8 @@ vertices = 4
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
Linked tessellation control stage:
@@ -161,8 +162,8 @@ vertices = 4
0:? 'pid' ( in uint PrimitiveID)
0:? Sequence
0:? move second child to first child ( temp float)
0:? direct index ( out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? Constant:
0:? 0 (const int)
0:? direct index ( temp float)
@@ -173,8 +174,8 @@ vertices = 4
0:? Constant:
0:? 0 (const int)
0:? move second child to first child ( temp float)
0:? direct index ( out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? direct index ( patch out float TessLevelOuter)
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
0:? Constant:
0:? 1 (const int)
0:? direct index ( temp float)
@@ -215,16 +216,17 @@ vertices = 4
0:? 'ip' (layout( location=0) in 4-element array of structure{ temp 3-component vector of float cpoint})
0:? 'm_cpid' ( in uint InvocationID)
0:? 'pid' ( in uint PrimitiveID)
0:? '@patchConstantOutput_edges' ( out 2-element array of float TessLevelOuter)
0:? '@patchConstantOutput' (layout( location=1) patch out structure{})
0:? '@patchConstantOutput_edges' ( patch out 2-element array of float TessLevelOuter)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 85
// Id's are bound by 88
Capability Tessellation
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TessellationControl 4 "main" 40 44 47 62 67
EntryPoint TessellationControl 4 "main" 40 44 47 62 67 87
ExecutionMode 4 OutputVertices 4
Name 4 "main"
Name 8 "VS_OUT"
@@ -251,11 +253,16 @@ vertices = 4
Name 63 "param"
Name 67 "@patchConstantOutput_edges"
Name 77 "output"
Name 85 "HS_CONSTANT_OUT"
Name 87 "@patchConstantOutput"
Decorate 40(ip) Location 0
Decorate 44(m_cpid) BuiltIn InvocationId
Decorate 47(@entryPointOutput) Location 0
Decorate 62(pid) BuiltIn PrimitiveId
Decorate 67(@patchConstantOutput_edges) Patch
Decorate 67(@patchConstantOutput_edges) BuiltIn TessLevelOuter
Decorate 87(@patchConstantOutput) Patch
Decorate 87(@patchConstantOutput) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -294,6 +301,9 @@ vertices = 4
73: 29(int) Constant 1
78: 6(float) Constant 1073741824
80: 6(float) Constant 1090519040
85(HS_CONSTANT_OUT): TypeStruct
86: TypePointer Output 85(HS_CONSTANT_OUT)
87(@patchConstantOutput): 86(ptr) Variable Output
4(main): 2 Function None 3
5: Label
38(ip): 12(ptr) Variable Function