Full stack: distinguish between a scalar and a vector of size 1.
There have been GLSL extensions considering this, and HLSL does it.
This is a fully backward compatible change that allows this distinction.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index ec63d63..d9d3555 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1366,7 +1366,7 @@
{
// for scalar dot product, use multiply
glslang::TIntermSequence& glslangOperands = node->getSequence();
- if (! glslangOperands[0]->getAsTyped()->isVector())
+ if (glslangOperands[0]->getAsTyped()->getVectorSize() == 1)
binOp = glslang::EOpMul;
break;
}
@@ -2750,7 +2750,7 @@
break;
case glslang::EOpVectorTimesScalar:
case glslang::EOpVectorTimesScalarAssign:
- if (isFloat) {
+ if (isFloat && (builder.isVector(left) || builder.isVector(right))) {
if (builder.isVector(right))
std::swap(left, right);
assert(builder.isScalar(right));
@@ -4096,7 +4096,7 @@
glslang::TVector<glslang::TTypeLoc>::const_iterator iter;
for (iter = glslangType.getStruct()->begin(); iter != glslangType.getStruct()->end(); ++iter)
spvConsts.push_back(createSpvConstantFromConstUnionArray(*iter->type, consts, nextConst, false));
- } else if (glslangType.isVector()) {
+ } else if (glslangType.getVectorSize() > 1) {
for (unsigned int i = 0; i < (unsigned int)glslangType.getVectorSize(); ++i) {
bool zero = nextConst >= consts.size();
switch (glslangType.getBasicType()) {