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.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 173
// Id's are bound by 172
Capability Shader
Capability StorageUniformBufferBlock16
@ -204,9 +204,10 @@ spv.16bitstorage.frag
114: 20(int) Constant 7
115: 20(int) Constant 6
116: TypePointer Uniform 20(int)
166: 37(float) Constant 1073741824
167: 40(fvec2) ConstantComposite 83 166
170: 37(float) Constant 1077936128
166:6(float16_t) Constant 15360
167:6(float16_t) Constant 16384
168: 7(f16vec2) ConstantComposite 166 167
170:6(float16_t) Constant 16896
4(main): 2 Function None 3
5: Label
70(x0): 69(ptr) Variable Function
@ -326,11 +327,9 @@ spv.16bitstorage.frag
164:6(float16_t) Load 163
165: 28(ptr) AccessChain 19(b2) 21
Store 165 164
168: 7(f16vec2) FConvert 167
169: 43(ptr) AccessChain 19(b2) 32
Store 169 168
171:6(float16_t) FConvert 170
172: 28(ptr) AccessChain 19(b2) 21
Store 172 171
171: 28(ptr) AccessChain 19(b2) 21
Store 171 170
Return
FunctionEnd