本文整理汇总了C++中TIntermConstantUnion::getNominalSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermConstantUnion::getNominalSize方法的具体用法?C++ TIntermConstantUnion::getNominalSize怎么用?C++ TIntermConstantUnion::getNominalSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermConstantUnion
的用法示例。
在下文中一共展示了TIntermConstantUnion::getNominalSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNodeVarName
// Returns name to be used in generated assembly for a given node
string ARBVar::GetNodeVarName(TIntermTyped* node) {
TIntermSymbol* symbol = node->getAsSymbolNode();
if (symbol) {
return string("symbol_") + symbol->getSymbol().c_str();
}
TIntermConstantUnion* cu = node->getAsConstantUnion();
if (cu) {
string ret = "";
if (cu->getBasicType() == EbtFloat) {
if (cu->getNominalSize() == 1) {
ret = "const_" + floattostr(cu->getUnionArrayPointer()[0].getFConst());
} else if (cu->isVector() && cu->getNominalSize() > 1 && cu->getNominalSize() <= 4) {
ret = "const_vec" + inttostr(cu->getNominalSize());
for (int i = 0; i < cu->getNominalSize(); ++i) {
ret += "_" + floattostr(cu->getUnionArrayPointer()[i].getFConst());
}
}
}
if (ret != "") {
for (unsigned int i = 0; i < ret.size(); ++i) {
if (ret[i] == '.') {
ret[i] = 'x';
}
}
return ret;
}
}
failmsg() << "Unknown node in GetNodeVarName [" << node->getCompleteString() << "]\n";
return "{unknown node}";
}
示例2: getARBVarDeclaration
// Returns textual ARB program declaration for a given variable, including initialization
// Returns "" to indicate that the variable shouldn't be declared, "ATTRIB" and "PARAM" for input, "TEMP" for temporary and "OUTPUT" for output variables
string ARBVar::getARBVarDeclaration() const {
if (isSampler()) {
return "";
} else if (node) {
TQualifier qual = node->getQualifier();
switch(node->getQualifier()) {
case EvqPosition:
return "OUTPUT out" + getasm() + " = result.position;\nTEMP " + getasm() + ";";
case EvqFragColor:
return "OUTPUT out" + getasm() + " = result.color;\nTEMP " + getasm() + ";";
case EvqAttribute:
return "ATTRIB " + getasm() + " = vertex.attrib[" + inttostr(getAttribNum(getasm())) + "]; # FIXME: Change to correct index";
case EvqConst: {
string value = "{ ??? }; # FIXME: Enter correct values";
TIntermConstantUnion* cu = node->getAsConstantUnion();
if (cu && cu->getBasicType() == EbtFloat) {
if (cu->getNominalSize() == 1) {
value = floattostr(cu->getUnionArrayPointer()[0].getFConst());
value = "{ " + value + ", " + value + ", " + value + ", " + value + " };";
} else if (cu->isVector() && cu->getNominalSize() >= 1 && cu->getNominalSize() <= 4) {
value = "{ ";
for (int i = 0; i < 4; ++i) {
if (i) {
value += ", ";
}
if (i < cu->getNominalSize()) {
value += floattostr(cu->getUnionArrayPointer()[i].getFConst());
} else {
value += "0.0";
}
}
value += " };";
}
}
return "PARAM " + getasm() + " = " + value;
}
case EvqVaryingOut:
return "OUTPUT out" + getasm() + " = result.texcoord[" + inttostr(getTexcoordNum(getasm())) + "]; # FIXME: Change to correct index;\nTEMP " + getasm() + ";";
case EvqVaryingIn:
return "ATTRIB " + getasm() + " = fragment.texcoord[" + inttostr(getTexcoordNum(getasm())) + "]; # FIXME: Change to correct index";
case EvqTemporary:
return "TEMP " + getasm() + ";";
case EvqUniform:
return "PARAM " + getasm() + " = program.env[" + inttostr(getUniformNum(getasm())) + "]; # FIXME: Change to correct index";
default:
return string("UNKNOWN NODE ") + getasm() + " - " + node->getQualifierString();
}
} else {
if (hardcodedName != "") {
return "";
} else {
return "TEMP " + getasm() + ";";
}
}
}
示例3: visitBinary
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpIndexDirect:
case EOpIndexIndirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << ".";
// TODO(alokp): ASSERT
out << node->getType().getFieldName();
visitChildren = false;
}
break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
out << ".";
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
TIntermSequence& sequence = rightChild->getSequence();
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
{
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
case 0: out << "x"; break;
case 1: out << "y"; break;
case 2: out << "z"; break;
case 3: out << "w"; break;
default: UNREACHABLE(); break;
}
}
visitChildren = false;
}
break;
case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break;
case EOpSub: writeTriplet(visit, "(", " - ", ")"); break;
case EOpMul: writeTriplet(visit, "(", " * ", ")"); break;
case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break;
case EOpMod: UNIMPLEMENTED(); break;
case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break;
case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break;
case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break;
case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break;
case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break;
case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break;
// Notice the fall-through.
case EOpVectorTimesScalar:
case EOpVectorTimesMatrix:
case EOpMatrixTimesVector:
case EOpMatrixTimesScalar:
case EOpMatrixTimesMatrix:
writeTriplet(visit, "(", " * ", ")");
break;
case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break;
case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break;
case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break;
default: UNREACHABLE(); break;
}
return visitChildren;
}
示例4: visitBinary
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpIndexDirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexIndirect:
if (node->getAddIndexClamp())
{
if (visit == InVisit)
{
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
out << "[int(clamp(float(";
} else {
out << "[webgl_int_clamp(";
}
}
else if (visit == PostVisit)
{
int maxSize;
TIntermTyped *left = node->getLeft();
TType leftType = left->getType();
if (left->isArray())
{
// The shader will fail validation if the array length is not > 0.
maxSize = leftType.getArraySize() - 1;
}
else
{
maxSize = leftType.getNominalSize() - 1;
}
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
out << "), 0.0, float(" << maxSize << ")))]";
} else {
out << ", 0, " << maxSize << ")]";
}
}
}
else
{
writeTriplet(visit, NULL, "[", "]");
}
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << ".";
// TODO(alokp): ASSERT
TString fieldName = node->getType().getFieldName();
const TType& structType = node->getLeft()->getType();
if (!mSymbolTable.findBuiltIn(structType.getTypeName()))
fieldName = hashName(fieldName);
out << fieldName;
visitChildren = false;
}
break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
out << ".";
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
TIntermSequence& sequence = rightChild->getSequence();
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
{
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
case 0: out << "x"; break;
//.........这里部分代码省略.........
示例5: visitBinary
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node)
{
bool visitChildren = true;
TInfoSinkBase &out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign:
writeTriplet(visit, "(", " = ", ")");
break;
case EOpAddAssign:
writeTriplet(visit, "(", " += ", ")");
break;
case EOpSubAssign:
writeTriplet(visit, "(", " -= ", ")");
break;
case EOpDivAssign:
writeTriplet(visit, "(", " /= ", ")");
break;
case EOpIModAssign:
writeTriplet(visit, "(", " %= ", ")");
break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpBitShiftLeftAssign:
writeTriplet(visit, "(", " <<= ", ")");
break;
case EOpBitShiftRightAssign:
writeTriplet(visit, "(", " >>= ", ")");
break;
case EOpBitwiseAndAssign:
writeTriplet(visit, "(", " &= ", ")");
break;
case EOpBitwiseXorAssign:
writeTriplet(visit, "(", " ^= ", ")");
break;
case EOpBitwiseOrAssign:
writeTriplet(visit, "(", " |= ", ")");
break;
case EOpIndexDirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexIndirect:
if (node->getAddIndexClamp())
{
if (visit == InVisit)
{
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
out << "[int(clamp(float(";
else
out << "[webgl_int_clamp(";
}
else if (visit == PostVisit)
{
int maxSize;
TIntermTyped *left = node->getLeft();
TType leftType = left->getType();
if (left->isArray())
{
// The shader will fail validation if the array length is not > 0.
maxSize = leftType.getArraySize() - 1;
}
else
{
maxSize = leftType.getNominalSize() - 1;
}
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
out << "), 0.0, float(" << maxSize << ")))]";
else
out << ", 0, " << maxSize << ")]";
}
}
else
{
writeTriplet(visit, NULL, "[", "]");
}
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
// Here we are writing out "foo.bar", where "foo" is struct
// and "bar" is field. In AST, it is represented as a binary
// node, where left child represents "foo" and right child "bar".
// The node itself represents ".". The struct field "bar" is
//.........这里部分代码省略.........