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

@@ -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:10 Constant:
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 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:10 Constant:
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 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})
@@ -97,8 +97,8 @@ Shader version: 500
0:? 'ins.ii' ( in int InstanceIndex)
0:? 'ins.clip0' (layout( location=0) in float)
0:? 'ins.clip1' (layout( location=1) in float)
0:? 'ins.cull0' (layout( location=2) in float)
0:? 'ins.cull1' (layout( location=3) in float)
0:? 'ins.cull0' (layout( location=0) in float)
0:? 'ins.cull1' (layout( location=1) in float)
0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
@@ -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:10 Constant:
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 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:10 Constant:
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 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})
@@ -204,8 +204,8 @@ Shader version: 500
0:? 'ins.ii' ( in int InstanceIndex)
0:? 'ins.clip0' (layout( location=0) in float)
0:? 'ins.clip1' (layout( location=1) in float)
0:? 'ins.cull0' (layout( location=2) in float)
0:? 'ins.cull1' (layout( location=3) in float)
0:? 'ins.cull0' (layout( location=0) in float)
0:? 'ins.cull1' (layout( location=1) in float)
0:? '@entryPointOutput.clip1' ( out 2-element array of float ClipDistance)
0:? '@entryPointOutput.cull1' ( out 2-element array of float CullDistance)
@@ -243,8 +243,8 @@ Shader version: 500
Name 67 "@entryPointOutput.ii"
Decorate 21(ins.clip0) Location 0
Decorate 26(ins.clip1) Location 1
Decorate 30(ins.cull0) Location 2
Decorate 34(ins.cull1) Location 3
Decorate 30(ins.cull0) Location 0
Decorate 34(ins.cull1) Location 1
Decorate 39(ins.ii) BuiltIn InstanceIndex
Decorate 51(@entryPointOutput.clip1) BuiltIn ClipDistance
Decorate 59(@entryPointOutput.cull1) BuiltIn CullDistance