Add conversion folding when the source is a constant.

This change adds unary conversion folding when the source is a constant.
This fixes an ISV issue whereby:

```
const float16_t f = float16_t(42.0);
```

Wouldn't compile because the conversion operator would always produce an
EvqTemporary when it could have produced an EvqConst.

I've also added a test case that proves out that all basic-type to
basic-type conversions work.
This commit is contained in:
Neil Henning 2018-11-26 10:17:33 +00:00
parent 0e6c82ce93
commit 81a63f1de0
11 changed files with 1012 additions and 40 deletions

View file

@ -1,7 +1,7 @@
spv.16bitstorage-int.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 171
// Id's are bound by 172
Capability Shader
Capability StorageUniformBufferBlock16
@ -204,7 +204,10 @@ spv.16bitstorage-int.frag
114: 20(int) Constant 7
115: 20(int) Constant 6
116: TypePointer Uniform 20(int)
166: 39(ivec2) ConstantComposite 32 33
166: 6(int16_t) Constant 1
167: 6(int16_t) Constant 2
168: 7(i16vec2) ConstantComposite 166 167
170: 6(int16_t) Constant 3
4(main): 2 Function None 3
5: Label
69(x0): 68(ptr) Variable Function
@ -324,11 +327,9 @@ spv.16bitstorage-int.frag
164: 6(int16_t) Load 163
165: 28(ptr) AccessChain 19(b2) 21
Store 165 164
167: 7(i16vec2) SConvert 166
168: 42(ptr) AccessChain 19(b2) 32
Store 168 167
169: 6(int16_t) SConvert 58
170: 28(ptr) AccessChain 19(b2) 21
Store 170 169
169: 42(ptr) AccessChain 19(b2) 32
Store 169 168
171: 28(ptr) AccessChain 19(b2) 21
Store 171 170
Return
FunctionEnd