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
325
Test/baseResults/hlsl.clipdistance-5.frag.out
Normal file
325
Test/baseResults/hlsl.clipdistance-5.frag.out
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
hlsl.clipdistance-5.frag
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:7 Function Definition: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
|
||||
0:7 Function Parameters:
|
||||
0:7 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:? Sequence
|
||||
0:8 Branch: Return with expression
|
||||
0:8 add ( temp 4-component vector of float)
|
||||
0:8 add ( temp 4-component vector of float)
|
||||
0:8 Position: direct index for structure ( temp 4-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 direct index ( temp float)
|
||||
0:8 direct index ( temp 2-component vector of float)
|
||||
0:8 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 direct index ( temp float)
|
||||
0:8 direct index ( temp 2-component vector of float)
|
||||
0:8 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:7 Function Definition: main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Sequence
|
||||
0:7 move second child to first child ( temp 4-component vector of float)
|
||||
0:7 Position: direct index for structure ( temp 4-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:? 'v.Position' ( in 4-component vector of float FragCoord)
|
||||
0:? Sequence
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 2 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 3 (const int)
|
||||
0:7 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:7 Function Call: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
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.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:7 Function Definition: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
|
||||
0:7 Function Parameters:
|
||||
0:7 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:? Sequence
|
||||
0:8 Branch: Return with expression
|
||||
0:8 add ( temp 4-component vector of float)
|
||||
0:8 add ( temp 4-component vector of float)
|
||||
0:8 Position: direct index for structure ( temp 4-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 direct index ( temp float)
|
||||
0:8 direct index ( temp 2-component vector of float)
|
||||
0:8 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:8 direct index ( temp float)
|
||||
0:8 direct index ( temp 2-component vector of float)
|
||||
0:8 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:8 'v' ( const (read only) structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 1 (const int)
|
||||
0:8 Constant:
|
||||
0:8 0 (const int)
|
||||
0:7 Function Definition: main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Sequence
|
||||
0:7 move second child to first child ( temp 4-component vector of float)
|
||||
0:7 Position: direct index for structure ( temp 4-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:? 'v.Position' ( in 4-component vector of float FragCoord)
|
||||
0:? Sequence
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 0 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 2 (const int)
|
||||
0:7 move second child to first child ( temp float)
|
||||
0:7 direct index ( temp float)
|
||||
0:7 direct index ( temp 2-component vector of float)
|
||||
0:7 ClipRect: direct index for structure ( temp 2-element array of 2-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 Constant:
|
||||
0:7 1 (const int)
|
||||
0:7 direct index ( temp float)
|
||||
0:? 'v.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
0:7 Constant:
|
||||
0:7 3 (const int)
|
||||
0:7 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:7 Function Call: @main(struct-VS_OUTPUT-vf4-vf2[2]1; ( temp 4-component vector of float)
|
||||
0:? 'v' ( temp structure{ temp 4-component vector of float Position, temp 2-element array of 2-component vector of float ClipRect})
|
||||
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.ClipRect' ( in 4-element array of float ClipDistance)
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 62
|
||||
|
||||
Capability Shader
|
||||
Capability ClipDistance
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 33 40 59
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 12 "VS_OUTPUT"
|
||||
MemberName 12(VS_OUTPUT) 0 "Position"
|
||||
MemberName 12(VS_OUTPUT) 1 "ClipRect"
|
||||
Name 15 "@main(struct-VS_OUTPUT-vf4-vf2[2]1;"
|
||||
Name 14 "v"
|
||||
Name 31 "v"
|
||||
Name 33 "v.Position"
|
||||
Name 40 "v.ClipRect"
|
||||
Name 59 "@entryPointOutput"
|
||||
Decorate 33(v.Position) BuiltIn FragCoord
|
||||
Decorate 40(v.ClipRect) BuiltIn ClipDistance
|
||||
Decorate 59(@entryPointOutput) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeFloat 32
|
||||
7: TypeVector 6(float) 4
|
||||
8: TypeVector 6(float) 2
|
||||
9: TypeInt 32 0
|
||||
10: 9(int) Constant 2
|
||||
11: TypeArray 8(fvec2) 10
|
||||
12(VS_OUTPUT): TypeStruct 7(fvec4) 11
|
||||
13: TypeFunction 7(fvec4) 12(VS_OUTPUT)
|
||||
17: TypeInt 32 1
|
||||
18: 17(int) Constant 0
|
||||
20: 17(int) Constant 1
|
||||
21: 9(int) Constant 0
|
||||
30: TypePointer Function 12(VS_OUTPUT)
|
||||
32: TypePointer Input 7(fvec4)
|
||||
33(v.Position): 32(ptr) Variable Input
|
||||
35: TypePointer Function 7(fvec4)
|
||||
37: 9(int) Constant 4
|
||||
38: TypeArray 6(float) 37
|
||||
39: TypePointer Input 38
|
||||
40(v.ClipRect): 39(ptr) Variable Input
|
||||
41: TypePointer Input 6(float)
|
||||
44: TypePointer Function 6(float)
|
||||
48: 9(int) Constant 1
|
||||
50: 17(int) Constant 2
|
||||
54: 17(int) Constant 3
|
||||
58: TypePointer Output 7(fvec4)
|
||||
59(@entryPointOutput): 58(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
31(v): 30(ptr) Variable Function
|
||||
34: 7(fvec4) Load 33(v.Position)
|
||||
36: 35(ptr) AccessChain 31(v) 18
|
||||
Store 36 34
|
||||
42: 41(ptr) AccessChain 40(v.ClipRect) 18
|
||||
43: 6(float) Load 42
|
||||
45: 44(ptr) AccessChain 31(v) 20 18 21
|
||||
Store 45 43
|
||||
46: 41(ptr) AccessChain 40(v.ClipRect) 20
|
||||
47: 6(float) Load 46
|
||||
49: 44(ptr) AccessChain 31(v) 20 18 48
|
||||
Store 49 47
|
||||
51: 41(ptr) AccessChain 40(v.ClipRect) 50
|
||||
52: 6(float) Load 51
|
||||
53: 44(ptr) AccessChain 31(v) 20 20 21
|
||||
Store 53 52
|
||||
55: 41(ptr) AccessChain 40(v.ClipRect) 54
|
||||
56: 6(float) Load 55
|
||||
57: 44(ptr) AccessChain 31(v) 20 20 48
|
||||
Store 57 56
|
||||
60:12(VS_OUTPUT) Load 31(v)
|
||||
61: 7(fvec4) FunctionCall 15(@main(struct-VS_OUTPUT-vf4-vf2[2]1;) 60
|
||||
Store 59(@entryPointOutput) 61
|
||||
Return
|
||||
FunctionEnd
|
||||
15(@main(struct-VS_OUTPUT-vf4-vf2[2]1;): 7(fvec4) Function None 13
|
||||
14(v):12(VS_OUTPUT) FunctionParameter
|
||||
16: Label
|
||||
19: 7(fvec4) CompositeExtract 14(v) 0
|
||||
22: 6(float) CompositeExtract 14(v) 1 0 0
|
||||
23: 7(fvec4) CompositeConstruct 22 22 22 22
|
||||
24: 7(fvec4) FAdd 19 23
|
||||
25: 6(float) CompositeExtract 14(v) 1 1 0
|
||||
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