From 8d2f6e4ddceb83009bb5f6b3d49001a2fd3cd761 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Mon, 24 Jun 2024 10:20:19 -0400 Subject: Add case to `emitVectorReshape` for when using a `vector` type with `T` value (#4419) * Add case to `emitVectorReshape` for `vector<>` type, `scalar` value 1. Add new case 2. Add test * fix warning * fix warning --- source/slang/slang-ir.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source/slang') 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(type); auto sourceVectorType = as(value->getDataType()); - if (!targetVectorType) + if (targetVectorType && !sourceVectorType) + { + auto elementType = targetVectorType->getElementType(); + Index elemCount = 1; + if(auto intLit = as(targetVectorType->getElementCount())) + { + elemCount = (Index)intLit->getValue(); + } + IRInst* zeroVal = emitDefaultConstruct(elementType); + List 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); -- cgit v1.2.3