SPV: Scalar smear operation should use type of the scalar to make the

expected vector type when the provided vector type is incompatible with
the scalar.
This commit is contained in:
Rex Xu
2015-12-07 19:07:17 +08:00
parent e00e72ded1
commit e723b45bca
4 changed files with 90 additions and 0 deletions

View File

@@ -1190,6 +1190,10 @@ Id Builder::smearScalar(Decoration /*precision*/, Id scalar, Id vectorType)
if (numComponents == 1)
return scalar;
// Make new vector type if the provided one is incompatible with type of the scalar
if (getTypeId(scalar) != getScalarTypeId(vectorType))
vectorType = makeVectorType(getTypeId(scalar), numComponents);
Instruction* smear = new Instruction(getUniqueId(), vectorType, OpCompositeConstruct);
for (int c = 0; c < numComponents; ++c)
smear->addIdOperand(scalar);