本文整理汇总了C++中TIntermTyped::isVector方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermTyped::isVector方法的具体用法?C++ TIntermTyped::isVector怎么用?C++ TIntermTyped::isVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermTyped
的用法示例。
在下文中一共展示了TIntermTyped::isVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: traverseBinary
bool TGlslOutputTraverser::traverseBinary( bool preVisit, TIntermBinary *node, TIntermTraverser *it )
{
TString op = "??";
TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it);
GlslFunction *current = goit->current;
std::stringstream& out = current->getActiveOutput();
bool infix = true;
bool assign = false;
bool needsParens = true;
switch (node->getOp())
{
case EOpAssign: op = "="; infix = true; needsParens = false; break;
case EOpAddAssign: op = "+="; infix = true; needsParens = false; break;
case EOpSubAssign: op = "-="; infix = true; needsParens = false; break;
case EOpMulAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpDivAssign: op = "/="; infix = true; needsParens = false; break;
case EOpModAssign: op = "%="; infix = true; needsParens = false; break;
case EOpAndAssign: op = "&="; infix = true; needsParens = false; break;
case EOpInclusiveOrAssign: op = "|="; infix = true; needsParens = false; break;
case EOpExclusiveOrAssign: op = "^="; infix = true; needsParens = false; break;
case EOpLeftShiftAssign: op = "<<="; infix = true; needsParens = false; break;
case EOpRightShiftAssign: op = "??="; infix = true; needsParens = false; break;
case EOpIndexDirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
assert( left && right);
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left->isMatrix() && !left->isArray())
{
if (right->getAsConstant())
{
current->addLibFunction (EOpMatrixIndex);
out << "xll_matrixindex (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
else
{
current->addLibFunction (EOpTranspose);
current->addLibFunction (EOpMatrixIndex);
current->addLibFunction (EOpMatrixIndexDynamic);
out << "xll_matrixindexdynamic (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
}
left->traverse(goit);
// Special code for handling a vector component select (this improves readability)
if (left->isVector() && !left->isArray() && right->getAsConstant())
{
char swiz[] = "xyzw";
goit->visitConstantUnion = TGlslOutputTraverser::traverseImmediateConstant;
goit->generatingCode = false;
right->traverse(goit);
assert( goit->indexList.size() == 1);
assert( goit->indexList[0] < 4);
out << "." << swiz[goit->indexList[0]];
goit->indexList.clear();
goit->visitConstantUnion = TGlslOutputTraverser::traverseConstantUnion;
goit->generatingCode = true;
}
else
{
out << "[";
right->traverse(goit);
out << "]";
}
return false;
}
case EOpIndexIndirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left && right && left->isMatrix() && !left->isArray())
{
//.........这里部分代码省略.........
示例2: scalarizeArgs
void ScalarizeVecAndMatConstructorArgs::scalarizeArgs(
TIntermAggregate *aggregate, bool scalarizeVector, bool scalarizeMatrix)
{
ASSERT(aggregate);
int size = 0;
switch (aggregate->getOp())
{
case EOpConstructVec2:
case EOpConstructBVec2:
case EOpConstructIVec2:
size = 2;
break;
case EOpConstructVec3:
case EOpConstructBVec3:
case EOpConstructIVec3:
size = 3;
break;
case EOpConstructVec4:
case EOpConstructBVec4:
case EOpConstructIVec4:
case EOpConstructMat2:
size = 4;
break;
case EOpConstructMat2x3:
case EOpConstructMat3x2:
size = 6;
break;
case EOpConstructMat2x4:
case EOpConstructMat4x2:
size = 8;
break;
case EOpConstructMat3:
size = 9;
break;
case EOpConstructMat3x4:
case EOpConstructMat4x3:
size = 12;
break;
case EOpConstructMat4:
size = 16;
break;
default:
break;
}
TIntermSequence *sequence = aggregate->getSequence();
TIntermSequence original(*sequence);
sequence->clear();
for (size_t ii = 0; ii < original.size(); ++ii)
{
ASSERT(size > 0);
TIntermTyped *node = original[ii]->getAsTyped();
ASSERT(node);
TString varName = createTempVariable(node);
if (node->isScalar())
{
TIntermSymbol *symbolNode =
new TIntermSymbol(-1, varName, node->getType());
sequence->push_back(symbolNode);
size--;
}
else if (node->isVector())
{
if (scalarizeVector)
{
int repeat = std::min(size, node->getNominalSize());
size -= repeat;
for (int index = 0; index < repeat; ++index)
{
TIntermSymbol *symbolNode =
new TIntermSymbol(-1, varName, node->getType());
TIntermBinary *newNode = ConstructVectorIndexBinaryNode(
symbolNode, index);
sequence->push_back(newNode);
}
}
else
{
TIntermSymbol *symbolNode =
new TIntermSymbol(-1, varName, node->getType());
sequence->push_back(symbolNode);
size -= node->getNominalSize();
}
}
else
{
ASSERT(node->isMatrix());
if (scalarizeMatrix)
{
int colIndex = 0, rowIndex = 0;
int repeat = std::min(size, node->getCols() * node->getRows());
size -= repeat;
while (repeat > 0)
{
TIntermSymbol *symbolNode =
new TIntermSymbol(-1, varName, node->getType());
TIntermBinary *newNode = ConstructMatrixIndexBinaryNode(
symbolNode, colIndex, rowIndex);
sequence->push_back(newNode);
rowIndex++;
if (rowIndex >= node->getRows())
//.........这里部分代码省略.........