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-1.frag.out
Normal file
190
Test/baseResults/hlsl.clipdistance-1.frag.out
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
hlsl.clipdistance-1.frag
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:4 Function Definition: @main(vf4;f1;f1; ( temp 4-component vector of float)
|
||||
0:4 Function Parameters:
|
||||
0:4 'pos' ( in 4-component vector of float)
|
||||
0:4 'clip' ( in float)
|
||||
0:4 'cull' ( in 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 'clip' ( in float)
|
||||
0:5 'cull' ( in float)
|
||||
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 float)
|
||||
0:? 'clip' ( temp float)
|
||||
0:4 direct index ( temp float)
|
||||
0:? 'clip' ( in 1-element array of float ClipDistance)
|
||||
0:4 Constant:
|
||||
0:4 0 (const int)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp float)
|
||||
0:? 'cull' ( temp float)
|
||||
0:4 direct index ( temp float)
|
||||
0:? 'cull' ( in 1-element array of float CullDistance)
|
||||
0:4 Constant:
|
||||
0:4 0 (const int)
|
||||
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;f1; ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'clip' ( temp float)
|
||||
0:? 'cull' ( temp 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 1-element array of float ClipDistance)
|
||||
0:? 'cull' ( in 1-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;f1; ( temp 4-component vector of float)
|
||||
0:4 Function Parameters:
|
||||
0:4 'pos' ( in 4-component vector of float)
|
||||
0:4 'clip' ( in float)
|
||||
0:4 'cull' ( in 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 'clip' ( in float)
|
||||
0:5 'cull' ( in float)
|
||||
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 float)
|
||||
0:? 'clip' ( temp float)
|
||||
0:4 direct index ( temp float)
|
||||
0:? 'clip' ( in 1-element array of float ClipDistance)
|
||||
0:4 Constant:
|
||||
0:4 0 (const int)
|
||||
0:? Sequence
|
||||
0:4 move second child to first child ( temp float)
|
||||
0:? 'cull' ( temp float)
|
||||
0:4 direct index ( temp float)
|
||||
0:? 'cull' ( in 1-element array of float CullDistance)
|
||||
0:4 Constant:
|
||||
0:4 0 (const int)
|
||||
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;f1; ( temp 4-component vector of float)
|
||||
0:? 'pos' ( temp 4-component vector of float)
|
||||
0:? 'clip' ( temp float)
|
||||
0:? 'cull' ( temp 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 1-element array of float ClipDistance)
|
||||
0:? 'cull' ( in 1-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" 27 34 41 45
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 14 "@main(vf4;f1;f1;"
|
||||
Name 11 "pos"
|
||||
Name 12 "clip"
|
||||
Name 13 "cull"
|
||||
Name 25 "pos"
|
||||
Name 27 "pos"
|
||||
Name 29 "clip"
|
||||
Name 34 "clip"
|
||||
Name 40 "cull"
|
||||
Name 41 "cull"
|
||||
Name 45 "@entryPointOutput"
|
||||
Name 46 "param"
|
||||
Name 48 "param"
|
||||
Name 50 "param"
|
||||
Decorate 27(pos) BuiltIn FragCoord
|
||||
Decorate 34(clip) BuiltIn ClipDistance
|
||||
Decorate 41(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: TypePointer Function 6(float)
|
||||
10: TypeFunction 7(fvec4) 8(ptr) 9(ptr) 9(ptr)
|
||||
26: TypePointer Input 7(fvec4)
|
||||
27(pos): 26(ptr) Variable Input
|
||||
30: TypeInt 32 0
|
||||
31: 30(int) Constant 1
|
||||
32: TypeArray 6(float) 31
|
||||
33: TypePointer Input 32
|
||||
34(clip): 33(ptr) Variable Input
|
||||
35: TypeInt 32 1
|
||||
36: 35(int) Constant 0
|
||||
37: TypePointer Input 6(float)
|
||||
41(cull): 33(ptr) Variable Input
|
||||
44: TypePointer Output 7(fvec4)
|
||||
45(@entryPointOutput): 44(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
25(pos): 8(ptr) Variable Function
|
||||
29(clip): 9(ptr) Variable Function
|
||||
40(cull): 9(ptr) Variable Function
|
||||
46(param): 8(ptr) Variable Function
|
||||
48(param): 9(ptr) Variable Function
|
||||
50(param): 9(ptr) Variable Function
|
||||
28: 7(fvec4) Load 27(pos)
|
||||
Store 25(pos) 28
|
||||
38: 37(ptr) AccessChain 34(clip) 36
|
||||
39: 6(float) Load 38
|
||||
Store 29(clip) 39
|
||||
42: 37(ptr) AccessChain 41(cull) 36
|
||||
43: 6(float) Load 42
|
||||
Store 40(cull) 43
|
||||
47: 7(fvec4) Load 25(pos)
|
||||
Store 46(param) 47
|
||||
49: 6(float) Load 29(clip)
|
||||
Store 48(param) 49
|
||||
51: 6(float) Load 40(cull)
|
||||
Store 50(param) 51
|
||||
52: 7(fvec4) FunctionCall 14(@main(vf4;f1;f1;) 46(param) 48(param) 50(param)
|
||||
Store 45(@entryPointOutput) 52
|
||||
Return
|
||||
FunctionEnd
|
||||
14(@main(vf4;f1;f1;): 7(fvec4) Function None 10
|
||||
11(pos): 8(ptr) FunctionParameter
|
||||
12(clip): 9(ptr) FunctionParameter
|
||||
13(cull): 9(ptr) FunctionParameter
|
||||
15: Label
|
||||
16: 7(fvec4) Load 11(pos)
|
||||
17: 6(float) Load 12(clip)
|
||||
18: 7(fvec4) CompositeConstruct 17 17 17 17
|
||||
19: 7(fvec4) FAdd 16 18
|
||||
20: 6(float) Load 13(cull)
|
||||
21: 7(fvec4) CompositeConstruct 20 20 20 20
|
||||
22: 7(fvec4) FAdd 19 21
|
||||
ReturnValue 22
|
||||
FunctionEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue