本文整理汇总了C++中TIntermSelection::promoteTernary方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermSelection::promoteTernary方法的具体用法?C++ TIntermSelection::promoteTernary怎么用?C++ TIntermSelection::promoteTernary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermSelection
的用法示例。
在下文中一共展示了TIntermSelection::promoteTernary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ir_add_selection
// For "?:" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are specified
// as separate parameters.
TIntermTyped* ir_add_selection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc line, TInfoSink& infoSink)
{
bool bPromoteFromTrueBlockType = true;
if (cond->getBasicType() != EbtBool)
{
cond = ir_add_conversion (EOpConstructBool,
TType (EbtBool, cond->getPrecision(), cond->getQualifier(), cond->getColsCount(), cond->getRowsCount(), cond->isMatrix(), cond->isArray()),
cond, infoSink);
}
// Choose which one to try to promote to based on which has more precision
// By default, it will promote from the falseBlock type to the trueBlock type. However,
// what we want to do is promote to the type with the most precision of the two. So here,
// check whether the false block has more precision than the true block, and if so use
// its type instead.
if ( trueBlock->getBasicType() == EbtBool )
{
if ( falseBlock->getBasicType() == EbtInt ||
falseBlock->getBasicType() == EbtFloat )
{
bPromoteFromTrueBlockType = false;
}
}
else if ( trueBlock->getBasicType() == EbtInt )
{
if ( falseBlock->getBasicType() == EbtFloat )
{
bPromoteFromTrueBlockType = false;
}
}
//
// Get compatible types.
//
if ( bPromoteFromTrueBlockType )
{
TIntermTyped* child = ir_add_conversion(EOpSequence, trueBlock->getType(), falseBlock, infoSink);
if (child)
falseBlock = child;
else
{
child = ir_add_conversion(EOpSequence, falseBlock->getType(), trueBlock, infoSink);
if (child)
trueBlock = child;
else
return 0;
}
}
else
{
TIntermTyped* child = ir_add_conversion(EOpSequence, falseBlock->getType(), trueBlock, infoSink);
if (child)
trueBlock = child;
else
{
child = ir_add_conversion(EOpSequence, trueBlock->getType(), falseBlock, infoSink);
if (child)
falseBlock = child;
else
return 0;
}
}
//
// Make a selection node.
//
TIntermSelection* node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType());
node->setLine(line);
if (!node->promoteTernary(infoSink))
return 0;
return node;
}