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
250
Test/baseResults/hlsl.clipdistance-9.frag.out
Normal file
250
Test/baseResults/hlsl.clipdistance-9.frag.out
Normal file
|
|
@ -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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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 ( temp float)
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue