WIP: HLSL: handle clip/cull distance array semantic matching

In HLSL, there are three (TODO: ??) dimensions of clip and cull
distance values:

  * The semantic's value N, ala SV_ClipDistanceN.
  * The array demension, if the value is an array.
  * The vector element, if the value is a vector or array of vectors.

In SPIR-V, clip and cull distance are arrays of scalar floats, always.

This PR currently ignores the semantic N axis, and handles the other
two axes by sequentially copying each vector element of each array member
into sequential floats in the output array.

Fixes: #946
This commit is contained in:
LoopDawg
2017-06-22 12:08:00 -06:00
parent 4329d555ad
commit c44b95fdec
15 changed files with 2280 additions and 200 deletions

View File

@@ -24,18 +24,26 @@ output primitive = line_strip
0:12 Function Call: @main(u1[3];struct-S-f1-f1-u1-u1-i11; ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 move second child to first child ( temp float)
0:? 'OutputStream_clip0' ( out float ClipDistance)
0:12 clip0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 0 (const int)
0:12 move second child to first child ( temp float)
0:? 'OutputStream_cull0' ( out float CullDistance)
0:12 cull0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 1 (const int)
0:? Sequence
0:12 move second child to first child ( temp float)
0:12 direct index ( temp float)
0:? 'OutputStream_clip0' ( out 1-element array of float ClipDistance)
0:12 Constant:
0:12 0 (const int)
0:12 clip0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 0 (const int)
0:? Sequence
0:12 move second child to first child ( temp float)
0:12 direct index ( temp float)
0:? 'OutputStream_cull0' ( out 1-element array of float CullDistance)
0:12 Constant:
0:12 0 (const int)
0:12 cull0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 1 (const int)
0:12 move second child to first child ( temp uint)
0:? 'OutputStream_vpai' ( out uint ViewportIndex)
0:12 vpai: direct index for structure ( temp uint)
@@ -92,18 +100,26 @@ output primitive = line_strip
0:12 Function Call: @main(u1[3];struct-S-f1-f1-u1-u1-i11; ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 move second child to first child ( temp float)
0:? 'OutputStream_clip0' ( out float ClipDistance)
0:12 clip0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 0 (const int)
0:12 move second child to first child ( temp float)
0:? 'OutputStream_cull0' ( out float CullDistance)
0:12 cull0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 1 (const int)
0:? Sequence
0:12 move second child to first child ( temp float)
0:12 direct index ( temp float)
0:? 'OutputStream_clip0' ( out 1-element array of float ClipDistance)
0:12 Constant:
0:12 0 (const int)
0:12 clip0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 0 (const int)
0:? Sequence
0:12 move second child to first child ( temp float)
0:12 direct index ( temp float)
0:? 'OutputStream_cull0' ( out 1-element array of float CullDistance)
0:12 Constant:
0:12 0 (const int)
0:12 cull0: direct index for structure ( temp float)
0:12 'flattenTemp' ( temp structure{ temp float clip0, temp float cull0, temp uint vpai, temp uint rtai, temp int ii})
0:12 Constant:
0:12 1 (const int)
0:12 move second child to first child ( temp uint)
0:? 'OutputStream_vpai' ( out uint ViewportIndex)
0:12 vpai: direct index for structure ( temp uint)
@@ -133,7 +149,7 @@ output primitive = line_strip
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 66
// Id's are bound by 71
Capability Geometry
Capability ClipDistance
@@ -141,7 +157,7 @@ output primitive = line_strip
Capability MultiViewport
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Geometry 4 "main" 25 35 40 45 50 56 65
EntryPoint Geometry 4 "main" 25 37 44 50 55 61 70
ExecutionMode 4 Triangles
ExecutionMode 4 Invocations 1
ExecutionMode 4 OutputLineStrip
@@ -164,23 +180,23 @@ output primitive = line_strip
Name 28 "OutputStream"
Name 29 "param"
Name 31 "param"
Name 35 "OutputStream_clip0"
Name 40 "OutputStream_cull0"
Name 45 "OutputStream_vpai"
Name 50 "OutputStream_rtai"
Name 54 "S"
MemberName 54(S) 0 "ii"
Name 56 "@entryPointOutput"
Name 63 "S"
MemberName 63(S) 0 "ii"
Name 65 "OutputStream"
Name 37 "OutputStream_clip0"
Name 44 "OutputStream_cull0"
Name 50 "OutputStream_vpai"
Name 55 "OutputStream_rtai"
Name 59 "S"
MemberName 59(S) 0 "ii"
Name 61 "@entryPointOutput"
Name 68 "S"
MemberName 68(S) 0 "ii"
Name 70 "OutputStream"
Decorate 25(VertexID) Location 0
Decorate 35(OutputStream_clip0) BuiltIn ClipDistance
Decorate 40(OutputStream_cull0) BuiltIn CullDistance
Decorate 45(OutputStream_vpai) BuiltIn ViewportIndex
Decorate 50(OutputStream_rtai) BuiltIn Layer
Decorate 56(@entryPointOutput) Location 0
Decorate 65(OutputStream) Location 1
Decorate 37(OutputStream_clip0) BuiltIn ClipDistance
Decorate 44(OutputStream_cull0) BuiltIn CullDistance
Decorate 50(OutputStream_vpai) BuiltIn ViewportIndex
Decorate 55(OutputStream_rtai) BuiltIn Layer
Decorate 61(@entryPointOutput) Location 0
Decorate 70(OutputStream) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@@ -194,27 +210,30 @@ output primitive = line_strip
14: TypeFunction 12(S) 9(ptr) 13(ptr)
24: TypePointer Input 8
25(VertexID): 24(ptr) Variable Input
34: TypePointer Output 10(float)
35(OutputStream_clip0): 34(ptr) Variable Output
36: 11(int) Constant 0
37: TypePointer Function 10(float)
40(OutputStream_cull0): 34(ptr) Variable Output
41: 11(int) Constant 1
44: TypePointer Output 6(int)
45(OutputStream_vpai): 44(ptr) Variable Output
46: 11(int) Constant 2
47: TypePointer Function 6(int)
50(OutputStream_rtai): 44(ptr) Variable Output
51: 11(int) Constant 3
54(S): TypeStruct 11(int)
55: TypePointer Output 54(S)
56(@entryPointOutput): 55(ptr) Variable Output
57: 11(int) Constant 4
58: TypePointer Function 11(int)
61: TypePointer Output 11(int)
63(S): TypeStruct 11(int)
64: TypePointer Output 63(S)
65(OutputStream): 64(ptr) Variable Output
34: 6(int) Constant 1
35: TypeArray 10(float) 34
36: TypePointer Output 35
37(OutputStream_clip0): 36(ptr) Variable Output
38: 11(int) Constant 0
39: TypePointer Function 10(float)
42: TypePointer Output 10(float)
44(OutputStream_cull0): 36(ptr) Variable Output
45: 11(int) Constant 1
49: TypePointer Output 6(int)
50(OutputStream_vpai): 49(ptr) Variable Output
51: 11(int) Constant 2
52: TypePointer Function 6(int)
55(OutputStream_rtai): 49(ptr) Variable Output
56: 11(int) Constant 3
59(S): TypeStruct 11(int)
60: TypePointer Output 59(S)
61(@entryPointOutput): 60(ptr) Variable Output
62: 11(int) Constant 4
63: TypePointer Function 11(int)
66: TypePointer Output 11(int)
68(S): TypeStruct 11(int)
69: TypePointer Output 68(S)
70(OutputStream): 69(ptr) Variable Output
4(main): 2 Function None 3
5: Label
23(VertexID): 9(ptr) Variable Function
@@ -230,22 +249,24 @@ output primitive = line_strip
33: 12(S) Load 31(param)
Store 28(OutputStream) 33
Store 27(flattenTemp) 32
38: 37(ptr) AccessChain 27(flattenTemp) 36
39: 10(float) Load 38
Store 35(OutputStream_clip0) 39
42: 37(ptr) AccessChain 27(flattenTemp) 41
43: 10(float) Load 42
Store 40(OutputStream_cull0) 43
48: 47(ptr) AccessChain 27(flattenTemp) 46
49: 6(int) Load 48
Store 45(OutputStream_vpai) 49
52: 47(ptr) AccessChain 27(flattenTemp) 51
53: 6(int) Load 52
Store 50(OutputStream_rtai) 53
59: 58(ptr) AccessChain 27(flattenTemp) 57
60: 11(int) Load 59
62: 61(ptr) AccessChain 56(@entryPointOutput) 36
Store 62 60
40: 39(ptr) AccessChain 27(flattenTemp) 38
41: 10(float) Load 40
43: 42(ptr) AccessChain 37(OutputStream_clip0) 38
Store 43 41
46: 39(ptr) AccessChain 27(flattenTemp) 45
47: 10(float) Load 46
48: 42(ptr) AccessChain 44(OutputStream_cull0) 38
Store 48 47
53: 52(ptr) AccessChain 27(flattenTemp) 51
54: 6(int) Load 53
Store 50(OutputStream_vpai) 54
57: 52(ptr) AccessChain 27(flattenTemp) 56
58: 6(int) Load 57
Store 55(OutputStream_rtai) 58
64: 63(ptr) AccessChain 27(flattenTemp) 62
65: 11(int) Load 64
67: 66(ptr) AccessChain 61(@entryPointOutput) 38
Store 67 65
Return
FunctionEnd
17(@main(u1[3];struct-S-f1-f1-u1-u1-i11;): 12(S) Function None 14