Commit 6d2b07dc by John Kessenich

Front-end: propagate specialization-constness through conversions and swizzles.

parent a5845766
......@@ -740,6 +740,7 @@ public:
}
void makeSpecConstant()
{
storage = EvqConst;
specConstant = true;
}
static const char* getLayoutPackingString(TLayoutPacking packing)
......
......@@ -262,6 +262,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
//
// For constructors, we are now done, it was all in the conversion.
// TODO: but, did this bypass constant folding?
//
switch (op) {
case EOpConstructInt:
......@@ -291,7 +292,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
if (child->getAsConstantUnion())
return child->getAsConstantUnion()->fold(op, node->getType());
// If it's a specialiation constant, the result is too.
// If it's a specialization constant, the result is too.
if (child->getType().getQualifier().isSpecConstant())
node->getWritableType().getQualifier().makeSpecConstant();
......@@ -616,6 +617,12 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
newNode->setLoc(node->getLoc());
newNode->setOperand(node);
// TODO: it seems that some unary folding operations should occur here, but are not
// Propagate specialization-constant-ness.
if (node->getType().getQualifier().isSpecConstant())
newNode->getWritableType().getQualifier().makeSpecConstant();
return newNode;
}
......@@ -883,7 +890,6 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseT
TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, const TSourceLoc& loc)
{
TIntermAggregate* node = new TIntermAggregate(EOpSequence);
node->setLoc(loc);
......
......@@ -820,6 +820,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
return result;
else {
TType type(base->getBasicType(), EvqTemporary, fields.num);
// Swizzle operations propagate specialization-constantness
if (base->getQualifier().isSpecConstant())
type.getQualifier().makeSpecConstant();
return addConstructor(loc, base, type, mapTypeToConstructorOp(type));
}
}
......@@ -837,6 +840,9 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
result = intermediate.addIndex(EOpVectorSwizzle, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, (int) vectorString.size()));
}
// Swizzle operations propagate specialization-constantness
if (base->getType().getQualifier().isSpecConstant())
result->getWritableType().getQualifier().makeSpecConstant();
}
} else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
const TTypeList* fields = base->getType().getStruct();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment