diff options
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 22ef4e6be..c0541f4c4 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -3894,7 +3894,23 @@ namespace Slang { auto targetVectorType = as<IRVectorType>(type); auto sourceVectorType = as<IRVectorType>(value->getDataType()); - if (!targetVectorType) + if (targetVectorType && !sourceVectorType) + { + auto elementType = targetVectorType->getElementType(); + Index elemCount = 1; + if(auto intLit = as<IRIntLit>(targetVectorType->getElementCount())) + { + elemCount = (Index)intLit->getValue(); + } + IRInst* zeroVal = emitDefaultConstruct(elementType); + List<IRInst*> defaultVals; + defaultVals.reserve(elemCount); + defaultVals.add(value); + for(auto i = 1; i < elemCount; i++) + defaultVals.add(zeroVal); + return emitMakeVector(targetVectorType, defaultVals); + } + else if (!targetVectorType) { if (!sourceVectorType) return emitCast(targetVectorType, value); |
