Commit e2cda3c2 by LoopDawg

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.
parent 778806a6
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
hlsl.clipdistance-1.geom
ERROR: 0:13: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 0:13: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 0:20: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 0:20: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 4 compilation errors. No code generated.
Shader version: 500
invocations = -1
max_vertices = 3
input primitive = triangles
output primitive = line_strip
ERROR: node is still EOpNull!
0:13 Function Definition: @main(vf4[3];u1[3];struct-S-vf4-f1-f11;f1[3];f1[3]; ( temp void)
0:13 Function Parameters:
0:13 'pos' ( in 3-element array of 4-component vector of float)
0:13 'VertexID' ( in 3-element array of uint)
0:13 'OutputStream' ( out structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:13 'clip' ( in 3-element array of float)
0:13 'cull' ( in 3-element array of float)
0:? Sequence
0:16 move second child to first child ( temp 4-component vector of float)
0:16 pos: direct index for structure ( temp 4-component vector of float)
0:16 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:16 Constant:
0:16 0 (const int)
0:16 direct index ( temp 4-component vector of float)
0:16 'pos' ( in 3-element array of 4-component vector of float)
0:16 Constant:
0:16 0 (const int)
0:17 move second child to first child ( temp float)
0:17 clip: direct index for structure ( temp float)
0:17 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:17 Constant:
0:17 1 (const int)
0:17 direct index ( temp float)
0:17 'clip' ( in 3-element array of float)
0:17 Constant:
0:17 0 (const int)
0:18 move second child to first child ( temp float)
0:18 cull: direct index for structure ( temp float)
0:18 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:18 Constant:
0:18 2 (const int)
0:18 direct index ( temp float)
0:18 'cull' ( in 3-element array of float)
0:18 Constant:
0:18 0 (const int)
0:20 Sequence
0:20 Sequence
0:20 move second child to first child ( temp 4-component vector of float)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
0:20 pos: direct index for structure ( temp 4-component vector of float)
0:20 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:20 Constant:
0:20 0 (const int)
0:20 EmitVertex ( temp void)
0:13 Function Definition: main( ( temp void)
0:13 Function Parameters:
0:? Sequence
0:13 move second child to first child ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:13 move second child to first child ( temp 3-element array of uint)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:13 Function Call: @main(vf4[3];u1[3];struct-S-vf4-f1-f11;f1[3];f1[3]; ( temp void)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:? 'clip' ( temp 3-element array of float)
0:? 'cull' ( temp 3-element array of float)
0:? Linker Objects
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
Linked geometry stage:
Shader version: 500
invocations = 1
max_vertices = 3
input primitive = triangles
output primitive = line_strip
ERROR: node is still EOpNull!
0:13 Function Definition: @main(vf4[3];u1[3];struct-S-vf4-f1-f11;f1[3];f1[3]; ( temp void)
0:13 Function Parameters:
0:13 'pos' ( in 3-element array of 4-component vector of float)
0:13 'VertexID' ( in 3-element array of uint)
0:13 'OutputStream' ( out structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:13 'clip' ( in 3-element array of float)
0:13 'cull' ( in 3-element array of float)
0:? Sequence
0:16 move second child to first child ( temp 4-component vector of float)
0:16 pos: direct index for structure ( temp 4-component vector of float)
0:16 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:16 Constant:
0:16 0 (const int)
0:16 direct index ( temp 4-component vector of float)
0:16 'pos' ( in 3-element array of 4-component vector of float)
0:16 Constant:
0:16 0 (const int)
0:17 move second child to first child ( temp float)
0:17 clip: direct index for structure ( temp float)
0:17 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:17 Constant:
0:17 1 (const int)
0:17 direct index ( temp float)
0:17 'clip' ( in 3-element array of float)
0:17 Constant:
0:17 0 (const int)
0:18 move second child to first child ( temp float)
0:18 cull: direct index for structure ( temp float)
0:18 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:18 Constant:
0:18 2 (const int)
0:18 direct index ( temp float)
0:18 'cull' ( in 3-element array of float)
0:18 Constant:
0:18 0 (const int)
0:20 Sequence
0:20 Sequence
0:20 move second child to first child ( temp 4-component vector of float)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
0:20 pos: direct index for structure ( temp 4-component vector of float)
0:20 's' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:20 Constant:
0:20 0 (const int)
0:20 EmitVertex ( temp void)
0:13 Function Definition: main( ( temp void)
0:13 Function Parameters:
0:? Sequence
0:13 move second child to first child ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:13 move second child to first child ( temp 3-element array of uint)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:13 Function Call: @main(vf4[3];u1[3];struct-S-vf4-f1-f11;f1[3];f1[3]; ( temp void)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp 4-component vector of float pos, temp float clip, temp float cull})
0:? 'clip' ( temp 3-element array of float)
0:? 'cull' ( temp 3-element array of float)
0:? Linker Objects
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
SPIR-V is not generated for failed compile or link
hlsl.clipdistance-2.geom
ERROR: 0:11: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 0:18: '' : unimplemented: clip/cull not currently implemented for this stage
ERROR: 2 compilation errors. No code generated.
Shader version: 500
invocations = -1
max_vertices = 3
input primitive = triangles
output primitive = line_strip
ERROR: node is still EOpNull!
0:11 Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
0:11 Function Parameters:
0:11 'pos' ( in 3-element array of 4-component vector of float)
0:11 'VertexID' ( in 3-element array of uint)
0:11 'OutputStream' ( out structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:11 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:? Sequence
0:14 move second child to first child ( temp 4-component vector of float)
0:14 pos: direct index for structure ( temp 4-component vector of float)
0:14 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:14 Constant:
0:14 0 (const int)
0:14 direct index ( temp 4-component vector of float)
0:14 'pos' ( in 3-element array of 4-component vector of float)
0:14 Constant:
0:14 0 (const int)
0:15 move second child to first child ( temp 2-component vector of float)
0:15 direct index ( temp 2-component vector of float)
0:15 clip: direct index for structure ( temp 2-element array of 2-component vector of float)
0:15 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:15 Constant:
0:15 1 (const int)
0:15 Constant:
0:15 0 (const int)
0:15 direct index ( temp 2-component vector of float)
0:15 direct index ( temp 2-element array of 2-component vector of float)
0:15 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:15 Constant:
0:15 0 (const int)
0:15 Constant:
0:15 0 (const int)
0:16 move second child to first child ( temp 2-component vector of float)
0:16 direct index ( temp 2-component vector of float)
0:16 clip: direct index for structure ( temp 2-element array of 2-component vector of float)
0:16 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:16 Constant:
0:16 1 (const int)
0:16 Constant:
0:16 1 (const int)
0:16 direct index ( temp 2-component vector of float)
0:16 direct index ( temp 2-element array of 2-component vector of float)
0:16 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:16 Constant:
0:16 0 (const int)
0:16 Constant:
0:16 1 (const int)
0:18 Sequence
0:18 Sequence
0:18 move second child to first child ( temp 4-component vector of float)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
0:18 pos: direct index for structure ( temp 4-component vector of float)
0:18 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:18 Constant:
0:18 0 (const int)
0:18 EmitVertex ( temp void)
0:11 Function Definition: main( ( temp void)
0:11 Function Parameters:
0:? Sequence
0:11 move second child to first child ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:11 move second child to first child ( temp 3-element array of uint)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:11 Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:? 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
0:? Linker Objects
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
Linked geometry stage:
Shader version: 500
invocations = 1
max_vertices = 3
input primitive = triangles
output primitive = line_strip
ERROR: node is still EOpNull!
0:11 Function Definition: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
0:11 Function Parameters:
0:11 'pos' ( in 3-element array of 4-component vector of float)
0:11 'VertexID' ( in 3-element array of uint)
0:11 'OutputStream' ( out structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:11 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:? Sequence
0:14 move second child to first child ( temp 4-component vector of float)
0:14 pos: direct index for structure ( temp 4-component vector of float)
0:14 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:14 Constant:
0:14 0 (const int)
0:14 direct index ( temp 4-component vector of float)
0:14 'pos' ( in 3-element array of 4-component vector of float)
0:14 Constant:
0:14 0 (const int)
0:15 move second child to first child ( temp 2-component vector of float)
0:15 direct index ( temp 2-component vector of float)
0:15 clip: direct index for structure ( temp 2-element array of 2-component vector of float)
0:15 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:15 Constant:
0:15 1 (const int)
0:15 Constant:
0:15 0 (const int)
0:15 direct index ( temp 2-component vector of float)
0:15 direct index ( temp 2-element array of 2-component vector of float)
0:15 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:15 Constant:
0:15 0 (const int)
0:15 Constant:
0:15 0 (const int)
0:16 move second child to first child ( temp 2-component vector of float)
0:16 direct index ( temp 2-component vector of float)
0:16 clip: direct index for structure ( temp 2-element array of 2-component vector of float)
0:16 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:16 Constant:
0:16 1 (const int)
0:16 Constant:
0:16 1 (const int)
0:16 direct index ( temp 2-component vector of float)
0:16 direct index ( temp 2-element array of 2-component vector of float)
0:16 'clip' ( in 3-element array of 2-element array of 2-component vector of float)
0:16 Constant:
0:16 0 (const int)
0:16 Constant:
0:16 1 (const int)
0:18 Sequence
0:18 Sequence
0:18 move second child to first child ( temp 4-component vector of float)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
0:18 pos: direct index for structure ( temp 4-component vector of float)
0:18 's' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:18 Constant:
0:18 0 (const int)
0:18 EmitVertex ( temp void)
0:11 Function Definition: main( ( temp void)
0:11 Function Parameters:
0:? Sequence
0:11 move second child to first child ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:11 move second child to first child ( temp 3-element array of uint)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:11 Function Call: @main(vf4[3];u1[3];struct-S-vf4-vf2[2]1;vf2[3][2]; ( temp void)
0:? 'pos' ( temp 3-element array of 4-component vector of float)
0:? 'VertexID' ( temp 3-element array of uint)
0:? 'OutputStream' ( temp structure{ temp 4-component vector of float pos, temp 2-element array of 2-component vector of float clip})
0:? 'clip' ( temp 3-element array of 2-element array of 2-component vector of float)
0:? Linker Objects
0:? 'pos' ( in 3-element array of 4-component vector of float Position)
0:? 'VertexID' (layout( location=0) in 3-element array of uint)
0:? 'OutputStream.pos' ( out 4-component vector of float Position)
SPIR-V is not generated for failed compile or link
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
...@@ -28,13 +28,13 @@ Shader version: 500 ...@@ -28,13 +28,13 @@ Shader version: 500
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
0:10 Constant: 0:10 Constant:
0:10 2 (const int) 0:10 2 (const int)
0:? 'ins.cull0' (layout( location=2) in float) 0:? 'ins.cull0' (layout( location=0) in float)
0:10 move second child to first child ( temp float) 0:10 move second child to first child ( temp float)
0:10 cull1: direct index for structure ( temp float) 0:10 cull1: direct index for structure ( temp float)
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
0:10 Constant: 0:10 Constant:
0:10 3 (const int) 0:10 3 (const int)
0:? 'ins.cull1' (layout( location=3) in float) 0:? 'ins.cull1' (layout( location=1) in float)
0:10 move second child to first child ( temp int) 0:10 move second child to first child ( temp int)
0:10 ii: direct index for structure ( temp int) 0:10 ii: direct index for structure ( temp int)
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
...@@ -97,8 +97,8 @@ Shader version: 500 ...@@ -97,8 +97,8 @@ Shader version: 500
0:? 'ins.ii' ( in int InstanceIndex) 0:? 'ins.ii' ( in int InstanceIndex)
0:? 'ins.clip0' (layout( location=0) in float) 0:? 'ins.clip0' (layout( location=0) in float)
0:? 'ins.clip1' (layout( location=1) in float) 0:? 'ins.clip1' (layout( location=1) in float)
0:? 'ins.cull0' (layout( location=2) in float) 0:? 'ins.cull0' (layout( location=0) in float)
0:? 'ins.cull1' (layout( location=3) in float) 0:? 'ins.cull1' (layout( location=1) in float)
0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance) 0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance) 0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
...@@ -135,13 +135,13 @@ Shader version: 500 ...@@ -135,13 +135,13 @@ Shader version: 500
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
0:10 Constant: 0:10 Constant:
0:10 2 (const int) 0:10 2 (const int)
0:? 'ins.cull0' (layout( location=2) in float) 0:? 'ins.cull0' (layout( location=0) in float)
0:10 move second child to first child ( temp float) 0:10 move second child to first child ( temp float)
0:10 cull1: direct index for structure ( temp float) 0:10 cull1: direct index for structure ( temp float)
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
0:10 Constant: 0:10 Constant:
0:10 3 (const int) 0:10 3 (const int)
0:? 'ins.cull1' (layout( location=3) in float) 0:? 'ins.cull1' (layout( location=1) in float)
0:10 move second child to first child ( temp int) 0:10 move second child to first child ( temp int)
0:10 ii: direct index for structure ( temp int) 0:10 ii: direct index for structure ( temp int)
0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii}) 0:? 'ins' ( temp structure{ temp float clip0, temp float clip1, temp float cull0, temp float cull1, temp int ii})
...@@ -204,8 +204,8 @@ Shader version: 500 ...@@ -204,8 +204,8 @@ Shader version: 500
0:? 'ins.ii' ( in int InstanceIndex) 0:? 'ins.ii' ( in int InstanceIndex)
0:? 'ins.clip0' (layout( location=0) in float) 0:? 'ins.clip0' (layout( location=0) in float)
0:? 'ins.clip1' (layout( location=1) in float) 0:? 'ins.clip1' (layout( location=1) in float)
0:? 'ins.cull0' (layout( location=2) in float) 0:? 'ins.cull0' (layout( location=0) in float)
0:? 'ins.cull1' (layout( location=3) in float) 0:? 'ins.cull1' (layout( location=1) in float)
0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance) 0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance) 0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
...@@ -243,8 +243,8 @@ Shader version: 500 ...@@ -243,8 +243,8 @@ Shader version: 500
Name 67 "@entryPointOutput.ii" Name 67 "@entryPointOutput.ii"
Decorate 21(ins.clip0) Location 0 Decorate 21(ins.clip0) Location 0
Decorate 26(ins.clip1) Location 1 Decorate 26(ins.clip1) Location 1
Decorate 30(ins.cull0) Location 2 Decorate 30(ins.cull0) Location 0
Decorate 34(ins.cull1) Location 3 Decorate 34(ins.cull1) Location 1
Decorate 39(ins.ii) BuiltIn InstanceIndex Decorate 39(ins.ii) BuiltIn InstanceIndex
Decorate 51(@entryPointOutput.clip1) BuiltIn ClipDistance Decorate 51(@entryPointOutput.clip1) BuiltIn ClipDistance
Decorate 59(@entryPointOutput.cull1) BuiltIn CullDistance Decorate 59(@entryPointOutput.cull1) BuiltIn CullDistance
......
float4 main(in float4 pos : SV_Position,
in float clip : SV_ClipDistance,
in float cull : SV_CullDistance) : SV_Target0
{
return pos + clip + cull;
}
struct S {
float4 pos : SV_Position;
float clip : SV_ClipDistance0;
float cull : SV_CullDistance0;
};
[maxvertexcount(3)]
void main(triangle in float4 pos[3] : SV_Position,
triangle in uint VertexID[3] : VertexID,
inout LineStream<S> OutputStream,
triangle in float clip[3] : SV_ClipDistance, // scalar float
triangle in float cull[3] : SV_CullDistance) // scalar float
{
S s;
s.pos = pos[0];
s.clip = clip[0];
s.cull = cull[0];
OutputStream.Append(s);
}
float4 main(in float4 pos : SV_Position,
in float2 clip[2] : SV_ClipDistance, // array of vector float
in float2 cull[2] : SV_CullDistance) : SV_Target0 // array of vector float
{
return pos + clip[0][0] + cull[0][0];
}
struct S {
float4 pos : SV_Position;
float2 clip[2] : SV_ClipDistance0;
};
[maxvertexcount(3)]
void main(triangle in float4 pos[3] : SV_Position,
triangle in uint VertexID[3] : VertexID,
inout LineStream<S> OutputStream,
triangle in float2 clip[3][2] : SV_ClipDistance) // scalar float
{
S s;
s.pos = pos[0];
s.clip[0] = clip[0][0];
s.clip[1] = clip[0][1];
OutputStream.Append(s);
}
float4 main(in float4 pos : SV_Position,
in float clip[2] : SV_ClipDistance, // array of scalar float
in float cull[2] : SV_CullDistance) : SV_Target0 // array of scalar float
{
return pos + clip[0] + cull[0];
}
struct VS_OUTPUT {
float4 Position : SV_Position;
float4 ClipRect : SV_ClipDistance0; // vector in split struct
};
float4 main(const VS_OUTPUT v) : SV_Target0
{
return v.Position + v.ClipRect;
}
struct VS_OUTPUT {
float4 Position : SV_Position;
float2 ClipRect[2] : SV_ClipDistance0; // array of float2 in split struct
};
float4 main(const VS_OUTPUT v) : SV_Target0
{
return v.Position + v.ClipRect[0].x + v.ClipRect[1].x;
}
struct VS_OUTPUT {
float4 Position : SV_Position;
float4 clip0 : SV_ClipDistance0; // multiple semantic IDs, two vec4s (no extra packing)
float4 clip1 : SV_ClipDistance1; // ...
};
float4 main(VS_OUTPUT v) : SV_Target0
{
return v.Position + v.clip0 + v.clip1;
}
struct VS_OUTPUT {
float4 Position : SV_Position;
float3 clip0 : SV_ClipDistance0; // multiple semantic IDs, vec3+vec4 (skip)
float4 clip1 : SV_ClipDistance1; // ...
};
float4 main(VS_OUTPUT v) : SV_Target0
{
return v.Position + v.clip0.x + v.clip1.x;
}
struct VS_OUTPUT {
float4 Position : SV_Position;
float3 clip0 : SV_ClipDistance0; // multiple semantic IDs, vec3+float (pack)
float clip1 : SV_ClipDistance1; // ...
};
float4 main(VS_OUTPUT v) : SV_Target0
{
return v.Position + v.clip0.x + v.clip1;
}
// Test packing 0 and 1 semantics into single array[4], from in fn params.
float4 main(in float4 Position : SV_Position,
in float3 clip0 : SV_ClipDistance0,
in float clip1 : SV_ClipDistance1) : SV_Target0
{
return Position + clip0.x + clip1;
}
...@@ -97,14 +97,25 @@ INSTANTIATE_TEST_CASE_P( ...@@ -97,14 +97,25 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.cast.frag", "PixelShaderFunction"}, {"hlsl.cast.frag", "PixelShaderFunction"},
{"hlsl.charLit.vert", "main"}, {"hlsl.charLit.vert", "main"},
{"hlsl.clip.frag", "main"}, {"hlsl.clip.frag", "main"},
{"hlsl.clipdistance-1.frag", "main"},
{"hlsl.clipdistance-1.geom", "main"},
{"hlsl.clipdistance-1.vert", "main"}, {"hlsl.clipdistance-1.vert", "main"},
{"hlsl.clipdistance-2.frag", "main"},
{"hlsl.clipdistance-2.geom", "main"},
{"hlsl.clipdistance-2.vert", "main"}, {"hlsl.clipdistance-2.vert", "main"},
{"hlsl.clipdistance-3.frag", "main"},
{"hlsl.clipdistance-3.vert", "main"}, {"hlsl.clipdistance-3.vert", "main"},
{"hlsl.clipdistance-4.frag", "main"},
{"hlsl.clipdistance-4.vert", "main"}, {"hlsl.clipdistance-4.vert", "main"},
{"hlsl.clipdistance-5.frag", "main"},
{"hlsl.clipdistance-5.vert", "main"}, {"hlsl.clipdistance-5.vert", "main"},
{"hlsl.clipdistance-6.frag", "main"},
{"hlsl.clipdistance-6.vert", "main"}, {"hlsl.clipdistance-6.vert", "main"},
{"hlsl.clipdistance-7.frag", "main"},
{"hlsl.clipdistance-7.vert", "main"}, {"hlsl.clipdistance-7.vert", "main"},
{"hlsl.clipdistance-8.frag", "main"},
{"hlsl.clipdistance-8.vert", "main"}, {"hlsl.clipdistance-8.vert", "main"},
{"hlsl.clipdistance-9.frag", "main"},
{"hlsl.clipdistance-9.vert", "main"}, {"hlsl.clipdistance-9.vert", "main"},
{"hlsl.comparison.vec.frag", "main"}, {"hlsl.comparison.vec.frag", "main"},
{"hlsl.conditional.frag", "PixelShaderFunction"}, {"hlsl.conditional.frag", "PixelShaderFunction"},
......
...@@ -435,8 +435,8 @@ protected: ...@@ -435,8 +435,8 @@ protected:
TVariable* gsStreamOutput; // geometry shader stream outputs, for emit (Append method) TVariable* gsStreamOutput; // geometry shader stream outputs, for emit (Append method)
TVariable* clipDistanceOutput; // synthesized clip distance output variable (shader might have >1) TVariable* clipDistanceVariable; // synthesized clip distance variable (shader might have >1)
TVariable* cullDistanceOutput; // synthesized cull distance output variable (shader might have >1) TVariable* cullDistanceVariable; // synthesized cull distance variable (shader might have >1)
static const int maxClipCullRegs = 2; static const int maxClipCullRegs = 2;
std::array<int, maxClipCullRegs> clipSemanticNSize; // vector, indexed by clip semantic ID std::array<int, maxClipCullRegs> clipSemanticNSize; // vector, indexed by clip semantic ID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment