当前位置: 首页>>代码示例>>C++>>正文


C++ TIntermAggregate::getNodes方法代码示例

本文整理汇总了C++中TIntermAggregate::getNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermAggregate::getNodes方法的具体用法?C++ TIntermAggregate::getNodes怎么用?C++ TIntermAggregate::getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TIntermAggregate的用法示例。


在下文中一共展示了TIntermAggregate::getNodes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ir_set_aggregate_op

// This is the safe way to change the operator on an aggregate, as it
// does lots of error checking and fixing.  Especially for establishing
// a function call's operation on it's set of parameters.  Sequences
// of instructions are also aggregates, but they just direnctly set
// their operator to EOpSequence.
//
// Returns an aggregate node, which could be the one passed in if
// it was already an aggregate.
TIntermAggregate* ir_set_aggregate_op(TIntermNode* node, TOperator op, TSourceLoc line)
{
   TIntermAggregate* aggNode;

   //
   // Make sure we have an aggregate.  If not turn it into one.
   //
   if (node)
   {
      aggNode = node->getAsAggregate();
      if (aggNode == 0 || aggNode->getOp() != EOpNull)
      {
         //
         // Make an aggregate containing this node.
         //
         aggNode = new TIntermAggregate();
         aggNode->getNodes().push_back(node);
         if (line.line == 0)
            line = node->getLine();
      }
   }
   else
      aggNode = new TIntermAggregate();

   //
   // Set the operator.
   //
   aggNode->setOperator(op);
   if (line.line != 0)
      aggNode->setLine(line);

   return aggNode;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:41,代码来源:Intermediate.cpp

示例2: 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;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:38,代码来源:Intermediate.cpp

示例3: ir_grow_aggregate

// Safe way to combine two nodes into an aggregate.  Works with null pointers, 
// a node that's not a aggregate yet, etc.
//
// Returns the resulting aggregate, unless 0 was passed in for
// both existing nodes.
TIntermAggregate* ir_grow_aggregate(TIntermNode* left, TIntermNode* right, TSourceLoc line, TOperator expectedOp)
{
   if (left == 0 && right == 0)
      return 0;

   TIntermAggregate* aggNode = 0;
   if (left)
      aggNode = left->getAsAggregate();
   if (!aggNode || aggNode->getOp() != expectedOp)
   {
      aggNode = new TIntermAggregate;
      if (left)
         aggNode->getNodes().push_back(left);
   }

   if (right)
      aggNode->getNodes().push_back(right);

   if (line.line != 0)
      aggNode->setLine(line);

   return aggNode;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:28,代码来源:Intermediate.cpp

示例4: ir_add_swizzle

TIntermTyped* ir_add_swizzle(TVectorFields& fields, TSourceLoc line)
{
	TIntermAggregate* node = new TIntermAggregate(EOpSequence);

	node->setLine(line);
	TNodeArray& nodes = node->getNodes();

	for (int i = 0; i < fields.num; i++)
	{
		TIntermConstant* constant = ir_add_constant(TType(EbtInt, EbpUndefined, EvqConst), line);
		constant->setValue(fields.offsets[i]);
		nodes.push_back(constant);
	}

	return node;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:16,代码来源:Intermediate.cpp

示例5: 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;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:19,代码来源:Intermediate.cpp

示例6: promote


//.........这里部分代码省略.........
   // Downcast needed ?
   //
   if ( left->getColsCount() > cols || left->getRowsCount() > rows)
   {
       if (assignment)
           return false; //can't promote the destination

       //down convert left to match right
       TOperator convert = EOpNull;
       if (left->getTypePointer()->isMatrix())
       {
           convert = getMatrixConstructOp(*right, ctx);
		   if (convert == EOpNull)
			   return false;
       }
       else if (left->getTypePointer()->isVector())
       {
           switch (right->getTypePointer()->getBasicType())
           {
           case EbtBool:  convert = TOperator( EOpConstructBVec2 + rows - 2); break;
           case EbtInt:   convert = TOperator( EOpConstructIVec2 + rows - 2); break;
           case EbtFloat: convert = TOperator( EOpConstructVec2 +  rows - 2); break;
           default: break;
           }
       }
       else
       {
           assert(0); //size 1 case should have been handled
       }
       TIntermAggregate *node = new TIntermAggregate(convert);
       node->setLine(left->getLine());
       node->setType(TType(left->getBasicType(), left->getPrecision(), EvqTemporary,
                           right->getColsCount(), right->getRowsCount(), left->isMatrix()));
       node->getNodes().push_back(left);
       left = node;
       //now reset this node's type
       setType(TType(left->getBasicType(), left->getPrecision(), EvqTemporary,
                     right->getColsCount(), right->getRowsCount(), left->isMatrix()));
   }
   else if ( right->getColsCount() > cols || right->getRowsCount() > rows)
   {
       //down convert right to match left
       TOperator convert = EOpNull;
       if (right->getTypePointer()->isMatrix())
       {
           convert = getMatrixConstructOp(*left, ctx);
		   if (convert == EOpNull)
			   return false;
       }
       else if (right->getTypePointer()->isVector())
       {
           switch (left->getTypePointer()->getBasicType())
           {
           case EbtBool:  convert = TOperator( EOpConstructBVec2 + rows - 2); break;
           case EbtInt:   convert = TOperator( EOpConstructIVec2 + rows - 2); break;
           case EbtFloat: convert = TOperator( EOpConstructVec2  + rows - 2); break;
           default: break;
           }
       }
       else
       {
           assert(0); //size 1 case should have been handled
       }
       TIntermAggregate *node = new TIntermAggregate(convert);
       node->setLine(right->getLine());
       node->setType(TType(right->getBasicType(), right->getPrecision(), EvqTemporary,
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:67,代码来源:Intermediate.cpp

示例7: promote


//.........这里部分代码省略.........
      if ( left->getNominalSize() > right->getNominalSize() )
      {

         if (assignment)
            return false; //can't promote the destination

         //down convert left to match right
         TOperator convert = EOpNull;
         if (left->getTypePointer()->isMatrix())
         {
            switch (right->getNominalSize())
            {
            case 2: convert = EOpConstructMat2FromMat; break;
            case 3: convert = EOpConstructMat3FromMat; break;
            case 4: convert =  EOpConstructMat4; break; //should never need to down convert to mat4
            }
         }
         else if (left->getTypePointer()->isVector())
         {
            switch (left->getTypePointer()->getBasicType())
            {
            case EbtBool:  convert = TOperator( EOpConstructBVec2 + right->getNominalSize() - 2); break;
            case EbtInt:   convert = TOperator( EOpConstructIVec2 + right->getNominalSize() - 2); break;
            case EbtFloat: convert = TOperator( EOpConstructVec2 + right->getNominalSize() - 2); break;
            }
         }
         else
         {
            assert(0); //size 1 case should have been handled
         }
         TIntermAggregate *node = new TIntermAggregate(convert);
         node->setLine(left->getLine());
         node->setType(TType(left->getBasicType(), left->getPrecision(), EvqTemporary, right->getNominalSize(), left->isMatrix()));
         node->getNodes().push_back(left);
         left = node;
         //now reset this node's type
         setType(TType(left->getBasicType(), left->getPrecision(), EvqTemporary, right->getNominalSize(), left->isMatrix()));
      }
      else
      {
         //down convert right to match left
         TOperator convert = EOpNull;
         if (right->getTypePointer()->isMatrix())
         {
            switch (left->getNominalSize())
            {
            case 2: convert = EOpConstructMat2FromMat; break;
            case 3: convert = EOpConstructMat3FromMat; break;
            case 4: convert =  EOpConstructMat4; break; //should never need to down convert to mat4
            }
         }
         else if (right->getTypePointer()->isVector())
         {
            switch (right->getTypePointer()->getBasicType())
            {
            case EbtBool:  convert = TOperator( EOpConstructBVec2 + left->getNominalSize() - 2); break;
            case EbtInt:   convert = TOperator( EOpConstructIVec2 + left->getNominalSize() - 2); break;
            case EbtFloat: convert = TOperator( EOpConstructVec2 + left->getNominalSize() - 2); break;
            }
         }
         else
         {
            assert(0); //size 1 case should have been handled
         }
         TIntermAggregate *node = new TIntermAggregate(convert);
         node->setLine(right->getLine());
开发者ID:jjiezheng,项目名称:hlsl2glslfork,代码行数:67,代码来源:Intermediate.cpp


注:本文中的TIntermAggregate::getNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。