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
190
Test/baseResults/hlsl.clipdistance-3.frag.out
Normal file
190
Test/baseResults/hlsl.clipdistance-3.frag.out
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
hlsl.clipdistance-3.frag
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:4 Function Definition: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
|
||||
0:4 Function Parameters:
|
||||
0:4 'pos' ( in 4-component vector of float)
|
||||
0:4 'clip' ( in 2-element array of float)
|
||||
0:4 'cull' ( in 2-element array of float)
|
||||
0:? Sequence
|
||||
0:5 Branch: Return with expression
|
||||
0:5 add ( temp 4-component vector of float)
|
||||
0:5 add ( temp 4-component vector of float)
|
||||
0:5 'pos' ( in 4-component vector of float)
|
||||
0:5 direct index ( temp float)
|
||||
0:5 'clip' ( in 2-element array of float)
|
||||
0:5 Constant:
|
||||
0:5 0 (const int)
|
||||
0:5 direct index ( temp float)
|
||||
0:5 'cull' ( in 2-element array of float)
|
||||
0:5 Constant:
|
||||
0:5 0 (const int)
|
||||
0:4 Function Definition: main( ( temp void)
|
||||
0:4 Function Parameters:
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'pos' ( in 4-component vector of float FragCoord)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 2-element array of float)
|
||||
0:? 'clip' ( temp 2-element array of float)
|
||||
0:? 'clip' ( in 2-element array of float ClipDistance)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 2-element array of float)
|
||||
0:? 'cull' ( temp 2-element array of float)
|
||||
0:? 'cull' ( in 2-element array of float CullDistance)
|
||||
0:4 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:4 Function Call: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'clip' ( temp 2-element array of float)
|
||||
0:? 'cull' ( temp 2-element array of float)
|
||||
0:? Linker Objects
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:? 'pos' ( in 4-component vector of float FragCoord)
|
||||
0:? 'clip' ( in 2-element array of float ClipDistance)
|
||||
0:? 'cull' ( in 2-element array of float CullDistance)
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:4 Function Definition: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
|
||||
0:4 Function Parameters:
|
||||
0:4 'pos' ( in 4-component vector of float)
|
||||
0:4 'clip' ( in 2-element array of float)
|
||||
0:4 'cull' ( in 2-element array of float)
|
||||
0:? Sequence
|
||||
0:5 Branch: Return with expression
|
||||
0:5 add ( temp 4-component vector of float)
|
||||
0:5 add ( temp 4-component vector of float)
|
||||
0:5 'pos' ( in 4-component vector of float)
|
||||
0:5 direct index ( temp float)
|
||||
0:5 'clip' ( in 2-element array of float)
|
||||
0:5 Constant:
|
||||
0:5 0 (const int)
|
||||
0:5 direct index ( temp float)
|
||||
0:5 'cull' ( in 2-element array of float)
|
||||
0:5 Constant:
|
||||
0:5 0 (const int)
|
||||
0:4 Function Definition: main( ( temp void)
|
||||
0:4 Function Parameters:
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'pos' ( in 4-component vector of float FragCoord)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 2-element array of float)
|
||||
0:? 'clip' ( temp 2-element array of float)
|
||||
0:? 'clip' ( in 2-element array of float ClipDistance)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp 2-element array of float)
|
||||
0:? 'cull' ( temp 2-element array of float)
|
||||
0:? 'cull' ( in 2-element array of float CullDistance)
|
||||
0:4 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:4 Function Call: @main(vf4;f1[2];f1[2]; ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'clip' ( temp 2-element array of float)
|
||||
0:? 'cull' ( temp 2-element array of float)
|
||||
0:? Linker Objects
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:? 'pos' ( in 4-component vector of float FragCoord)
|
||||
0:? 'clip' ( in 2-element array of float ClipDistance)
|
||||
0:? 'cull' ( in 2-element array of float CullDistance)
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 53
|
||||
|
||||
Capability Shader
|
||||
Capability ClipDistance
|
||||
Capability CullDistance
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 35 39 42 45
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 17 "@main(vf4;f1[2];f1[2];"
|
||||
Name 14 "pos"
|
||||
Name 15 "clip"
|
||||
Name 16 "cull"
|
||||
Name 33 "pos"
|
||||
Name 35 "pos"
|
||||
Name 37 "clip"
|
||||
Name 39 "clip"
|
||||
Name 41 "cull"
|
||||
Name 42 "cull"
|
||||
Name 45 "@entryPointOutput"
|
||||
Name 46 "param"
|
||||
Name 48 "param"
|
||||
Name 50 "param"
|
||||
Decorate 35(pos) BuiltIn FragCoord
|
||||
Decorate 39(clip) BuiltIn ClipDistance
|
||||
Decorate 42(cull) BuiltIn CullDistance
|
||||
Decorate 45(@entryPointOutput) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeFloat 32
|
||||
7: TypeVector 6(float) 4
|
||||
8: TypePointer Function 7(fvec4)
|
||||
9: TypeInt 32 0
|
||||
10: 9(int) Constant 2
|
||||
11: TypeArray 6(float) 10
|
||||
12: TypePointer Function 11
|
||||
13: TypeFunction 7(fvec4) 8(ptr) 12(ptr) 12(ptr)
|
||||
20: TypeInt 32 1
|
||||
21: 20(int) Constant 0
|
||||
22: TypePointer Function 6(float)
|
||||
34: TypePointer Input 7(fvec4)
|
||||
35(pos): 34(ptr) Variable Input
|
||||
38: TypePointer Input 11
|
||||
39(clip): 38(ptr) Variable Input
|
||||
42(cull): 38(ptr) Variable Input
|
||||
44: TypePointer Output 7(fvec4)
|
||||
45(@entryPointOutput): 44(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
33(pos): 8(ptr) Variable Function
|
||||
37(clip): 12(ptr) Variable Function
|
||||
41(cull): 12(ptr) Variable Function
|
||||
46(param): 8(ptr) Variable Function
|
||||
48(param): 12(ptr) Variable Function
|
||||
50(param): 12(ptr) Variable Function
|
||||
36: 7(fvec4) Load 35(pos)
|
||||
Store 33(pos) 36
|
||||
40: 11 Load 39(clip)
|
||||
Store 37(clip) 40
|
||||
43: 11 Load 42(cull)
|
||||
Store 41(cull) 43
|
||||
47: 7(fvec4) Load 33(pos)
|
||||
Store 46(param) 47
|
||||
49: 11 Load 37(clip)
|
||||
Store 48(param) 49
|
||||
51: 11 Load 41(cull)
|
||||
Store 50(param) 51
|
||||
52: 7(fvec4) FunctionCall 17(@main(vf4;f1[2];f1[2];) 46(param) 48(param) 50(param)
|
||||
Store 45(@entryPointOutput) 52
|
||||
Return
|
||||
FunctionEnd
|
||||
17(@main(vf4;f1[2];f1[2];): 7(fvec4) Function None 13
|
||||
14(pos): 8(ptr) FunctionParameter
|
||||
15(clip): 12(ptr) FunctionParameter
|
||||
16(cull): 12(ptr) FunctionParameter
|
||||
18: Label
|
||||
19: 7(fvec4) Load 14(pos)
|
||||
23: 22(ptr) AccessChain 15(clip) 21
|
||||
24: 6(float) Load 23
|
||||
25: 7(fvec4) CompositeConstruct 24 24 24 24
|
||||
26: 7(fvec4) FAdd 19 25
|
||||
27: 22(ptr) AccessChain 16(cull) 21
|
||||
28: 6(float) Load 27
|
||||
29: 7(fvec4) CompositeConstruct 28 28 28 28
|
||||
30: 7(fvec4) FAdd 26 29
|
||||
ReturnValue 30
|
||||
FunctionEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue