diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 5992d549..7af9595f 100755 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -1174,9 +1174,9 @@ void Builder::promoteScalar(Decoration precision, Id& left, Id& right) int direction = getNumComponents(right) - getNumComponents(left); if (direction > 0) - left = smearScalar(precision, left, getTypeId(right)); + left = smearScalar(precision, left, makeVectorType(getTypeId(left), getNumComponents(right))); else if (direction < 0) - right = smearScalar(precision, right, getTypeId(left)); + right = smearScalar(precision, right, makeVectorType(getTypeId(right), getNumComponents(left))); return; } @@ -1185,15 +1185,12 @@ void Builder::promoteScalar(Decoration precision, Id& left, Id& right) Id Builder::smearScalar(Decoration /*precision*/, Id scalar, Id vectorType) { assert(getNumComponents(scalar) == 1); + assert(getTypeId(scalar) == getScalarTypeId(vectorType)); int numComponents = getNumTypeComponents(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); diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index 6e95e141..2d10ef6e 100755 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -279,12 +279,17 @@ public: // - promoteScalar(scalar, scalar) // do nothing // Other forms are not allowed. // + // Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'. + // The type of the created vector is a vector of components of the same type as the scalar. + // // Note: One of the arguments will change, with the result coming back that way rather than // through the return value. void promoteScalar(Decoration precision, Id& left, Id& right); - // make a value by smearing the scalar to fill the type - Id smearScalar(Decoration precision, Id scalarVal, Id); + // Make a value by smearing the scalar to fill the type. + // vectorType should be the correct type for making a vector of scalarVal. + // (No conversions are done.) + Id smearScalar(Decoration precision, Id scalarVal, Id vectorType); // Create a call to a built-in function. Id createBuiltinCall(Decoration precision, Id resultType, Id builtins, int entryPoint, std::vector& args); diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index b14834f8..dd8f2d1a 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "SPIRV99.831" -#define GLSLANG_DATE "08-Dec-2015" +#define GLSLANG_REVISION "SPIRV99.836" +#define GLSLANG_DATE "09-Dec-2015"