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.
This commit is contained in:
John Kessenich
2016-05-20 12:06:03 -06:00
parent 823fc65644
commit 8d72f1a2c4
9 changed files with 152 additions and 29 deletions

View File

@@ -1366,7 +1366,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
{
// 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 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
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 @@ spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstUnionArray(const glsla
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()) {