HLSL: handle clip and cull distance input builtin type conversion
HLSL allows a range of types for clip and cull distances. There are three dimensions, including arrayness, vectorness, and semantic ID. SPIR-V requires clip and cull distance be a single array of floats in all cases. This code provides input side conversion between the SPIR-V form and the HLSL form. (Output conversion was added in PR #947 and #997). This PR extends HlslParseContext::assignClipCullDistance to cope with the input side conversion. Not as much changed as appears: there was also a lot of renaming to reflect the fact that the code now handles either direction. Currently, non-{frag,vert} stages are not handled, and are explicitly rejected. Fixes #1026.
This commit is contained in:
parent
778806a692
commit
e2cda3c2d7
27 changed files with 3272 additions and 247 deletions
399
Test/baseResults/hlsl.clipdistance-6.frag.out
Normal file
399
Test/baseResults/hlsl.clipdistance-6.frag.out
Normal file
|
|
@ -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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue