Add swizzles to scalars.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23580 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
8d8f4cc408
commit
8f13e1322d
8 changed files with 159 additions and 60 deletions
|
|
@ -270,7 +270,7 @@ void TParseContext::handlePragma(const char **tokens, int numTokens)
|
|||
|
||||
//
|
||||
// Look at a '.' field selector string and change it into offsets
|
||||
// for a vector.
|
||||
// for a vector or scalar
|
||||
//
|
||||
// Returns true if there is no error.
|
||||
//
|
||||
|
|
@ -561,13 +561,28 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
|
|||
result = intermediate.addMethod(base, TType(EbtInt), &field, loc);
|
||||
} else
|
||||
error(loc, "only the length method is supported for array", field.c_str(), "");
|
||||
} else if (base->isVector()) {
|
||||
} else if (base->isVector() || base->isScalar()) {
|
||||
if (base->isScalar()) {
|
||||
const char* dotFeature = "scalar swizzle";
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, dotFeature);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, dotFeature);
|
||||
}
|
||||
|
||||
TVectorFields fields;
|
||||
if (! parseVectorFields(loc, field, base->getVectorSize(), fields)) {
|
||||
fields.num = 1;
|
||||
fields.offsets[0] = 0;
|
||||
}
|
||||
|
||||
if (base->isScalar()) {
|
||||
if (fields.num == 1)
|
||||
return result;
|
||||
else {
|
||||
TType type(base->getBasicType(), EvqTemporary, fields.num);
|
||||
return addConstructor(loc, base, type, mapTypeToConstructorOp(type));
|
||||
}
|
||||
}
|
||||
|
||||
if (base->getType().getQualifier().storage == EvqConst) { // constant folding for vector fields
|
||||
result = addConstVectorNode(fields, base, loc);
|
||||
if (result == 0)
|
||||
|
|
@ -625,7 +640,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
|
|||
error(loc, " no such field in structure", field.c_str(), "");
|
||||
}
|
||||
} else
|
||||
error(loc, " dot operator requires structure, array, vector, or matrix on left hand side", field.c_str(), "");
|
||||
error(loc, " dot operator does not operater on this type:", field.c_str(), base->getType().getCompleteString().c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1211,7 +1226,7 @@ void TParseContext::constantValueCheck(TIntermTyped* node, const char* token)
|
|||
//
|
||||
void TParseContext::integerCheck(TIntermTyped* node, const char* token)
|
||||
{
|
||||
if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->isScalar() && ! node->isArray())
|
||||
if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->isScalar())
|
||||
return;
|
||||
|
||||
error(node->getLoc(), "scalar integer expression required", token, "");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue