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:
LoopDawg 2017-08-23 12:34:42 -06:00
parent 778806a692
commit e2cda3c2d7
27 changed files with 3272 additions and 247 deletions

View file

@ -0,0 +1,153 @@
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