本文整理汇总了C++中TIntermAggregate::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermAggregate::setType方法的具体用法?C++ TIntermAggregate::setType怎么用?C++ TIntermAggregate::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermAggregate
的用法示例。
在下文中一共展示了TIntermAggregate::setType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: promoteTernary
bool TIntermSelection::promoteTernary(TInfoSink& infoSink)
{
if (!condition->isVector())
return true;
int size = condition->getRowsCount();
TIntermTyped* trueb = trueBlock->getAsTyped();
TIntermTyped* falseb = falseBlock->getAsTyped();
if (!trueb || !falseb)
return false;
if (trueb->getRowsCount() == size && falseb->getRowsCount() == size)
return true;
// Base assumption: just make the type a float vector
TPrecision higherPrecision = GetHigherPrecision(trueb->getPrecision(), falseb->getPrecision());
setType(TType(EbtFloat, higherPrecision, EvqTemporary, 1, size, condition->isMatrix()));
TOperator convert = EOpNull;
{
convert = TOperator( EOpConstructVec2 + size - 2);
TIntermAggregate *node = new TIntermAggregate(convert);
node->setLine(trueb->getLine());
node->setType(TType(condition->getBasicType(), higherPrecision, trueb->getQualifier() == EvqConst ? EvqConst : EvqTemporary, 1, size, condition->isMatrix()));
node->getNodes().push_back(trueb);
trueBlock = node;
}
{
convert = TOperator( EOpConstructVec2 + size - 2);
TIntermAggregate *node = new TIntermAggregate(convert);
node->setLine(falseb->getLine());
node->setType(TType(condition->getBasicType(), higherPrecision, falseb->getQualifier() == EvqConst ? EvqConst : EvqTemporary, 1, size, condition->isMatrix()));
node->getNodes().push_back(falseb);
falseBlock = node;
}
return true;
}
示例2: ir_make_aggregate
// Turn an existing node into an aggregate.
TIntermAggregate* ir_make_aggregate(TIntermNode* node, TSourceLoc line)
{
if (node == 0)
return 0;
TIntermAggregate* aggNode = new TIntermAggregate;
if (node->getAsTyped())
aggNode->setType(*node->getAsTyped()->getTypePointer());
aggNode->getNodes().push_back(node);
if (line.line != 0)
aggNode->setLine(line);
else
aggNode->setLine(node->getLine());
return aggNode;
}
示例3: promote
//
// Establishes the type of the resultant operation, as well as
// makes the operator the correct one for the operands.
//
// Returns false if operator can't work on operands.
//
bool TIntermBinary::promote(TParseContext& ctx)
{
TBasicType type = left->getBasicType();
//
// Arrays have to be exact matches.
//
if ((left->isArray() || right->isArray()) && (left->getType() != right->getType()))
return false;
//
// Base assumption: just make the type the same as the left
// operand. Then only deviations from this need be coded.
//
setType(TType(type, left->getPrecision(), EvqTemporary, left->getColsCount(), left->getRowsCount(), left->isMatrix()));
// The result gets promoted to the highest precision.
TPrecision higherPrecision = GetHigherPrecision(left->getPrecision(), right->getPrecision());
getTypePointer()->setPrecision(higherPrecision);
//
// Array operations.
//
if (left->isArray())
{
switch (op)
{
//
// Promote to conditional
//
case EOpEqual:
case EOpNotEqual:
setType(TType(EbtBool, EbpUndefined));
break;
//
// Set array information.
//
case EOpAssign:
getType().setArraySize(left->getType().getArraySize());
getType().setArrayInformationType(left->getType().getArrayInformationType());
break;
default:
return false;
}
return true;
}
//
// All scalars. Code after this test assumes this case is removed!
//
if (left->isScalar() && right->isScalar())
{
switch (op)
{
//
// Promote to conditional
//
case EOpEqual:
case EOpNotEqual:
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
setType(TType(EbtBool, EbpUndefined));
break;
//
// And and Or operate on conditionals
//
case EOpLogicalAnd:
case EOpLogicalOr:
if (left->getBasicType() != EbtBool || right->getBasicType() != EbtBool)
return false;
setType(TType(EbtBool, EbpUndefined));
break;
//
// Check for integer only operands.
//
case EOpRightShift:
case EOpLeftShift:
case EOpAnd:
case EOpInclusiveOr:
case EOpExclusiveOr:
if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)
return false;
//.........这里部分代码省略.........
示例4: promote
//
// Establishes the type of the resultant operation, as well as
// makes the operator the correct one for the operands.
//
// Returns false if operator can't work on operands.
//
bool TIntermBinary::promote(TInfoSink& infoSink)
{
int size = left->getNominalSize();
if (right->getNominalSize() < size)
size = right->getNominalSize();
if (size == 1)
{
size = left->getNominalSize();
if (right->getNominalSize() > size)
size = right->getNominalSize();
}
TBasicType type = left->getBasicType();
//
// Arrays have to be exact matches.
//
if ((left->isArray() || right->isArray()) && (left->getType() != right->getType()))
return false;
//
// Base assumption: just make the type the same as the left
// operand. Then only deviations from this need be coded.
//
setType(TType(type, left->getPrecision(), EvqTemporary, left->getNominalSize(), left->isMatrix()));
// The result gets promoted to the highest precision.
TPrecision higherPrecision = GetHigherPrecision(left->getPrecision(), right->getPrecision());
getTypePointer()->setPrecision(higherPrecision);
//
// Array operations.
//
if (left->isArray())
{
switch (op)
{
//
// Promote to conditional
//
case EOpEqual:
case EOpNotEqual:
setType(TType(EbtBool, EbpUndefined));
break;
//
// Set array information.
//
case EOpAssign:
getType().setArraySize(left->getType().getArraySize());
getType().setArrayInformationType(left->getType().getArrayInformationType());
break;
default:
return false;
}
return true;
}
//
// All scalars. Code after this test assumes this case is removed!
//
if (size == 1)
{
switch (op)
{
//
// Promote to conditional
//
case EOpEqual:
case EOpNotEqual:
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
setType(TType(EbtBool, EbpUndefined));
break;
//
// And and Or operate on conditionals
//
case EOpLogicalAnd:
case EOpLogicalOr:
if (left->getBasicType() != EbtBool || right->getBasicType() != EbtBool)
return false;
setType(TType(EbtBool, EbpUndefined));
break;
//.........这里部分代码省略.........