本文整理汇总了C++中TType::getPrecision方法的典型用法代码示例。如果您正苦于以下问题:C++ TType::getPrecision方法的具体用法?C++ TType::getPrecision怎么用?C++ TType::getPrecision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TType
的用法示例。
在下文中一共展示了TType::getPrecision方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeVariableType
void TOutputGLSLBase::writeVariableType(const TType& type)
{
TInfoSinkBase& out = objSink();
TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for variable declarations.
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
out << type.getQualifierString() << " ";
// Declare the struct if we have not done so already.
if ((type.getBasicType() == EbtStruct) &&
(mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end()))
{
out << "struct " << type.getTypeName() << "{\n";
const TTypeList* structure = type.getStruct();
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
const TType* fieldType = (*structure)[i].type;
ASSERT(fieldType != NULL);
if (writeVariablePrecision(fieldType->getPrecision()))
out << " ";
out << getTypeName(*fieldType) << " " << fieldType->getFieldName();
if (fieldType->isArray())
out << arrayBrackets(*fieldType);
out << ";\n";
}
out << "}";
mDeclaredStructs.insert(type.getTypeName());
}
else
{
if (writeVariablePrecision(type.getPrecision()))
out << " ";
out << getTypeName(type);
}
}
示例2: writeVariableType
void TOutputGLSLBase::writeVariableType(const TType &type)
{
TInfoSinkBase &out = objSink();
TQualifier qualifier = type.getQualifier();
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
{
out << type.getQualifierString() << " ";
}
// Declare the struct if we have not done so already.
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
{
TStructure *structure = type.getStruct();
declareStruct(structure);
if (!structure->name().empty())
{
mDeclaredStructs.insert(structure->uniqueId());
}
}
else
{
if (writeVariablePrecision(type.getPrecision()))
out << " ";
out << getTypeName(type);
}
}
示例3: writeVariableType
void TOutputGLSLBase::writeVariableType(const TType &type)
{
TInfoSinkBase &out = objSink();
if (type.isInvariant())
{
out << "invariant ";
}
TQualifier qualifier = type.getQualifier();
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
{
if (IsGLSL130OrNewer(mOutput))
{
switch (qualifier)
{
case EvqAttribute:
out << "in ";
break;
case EvqVaryingIn:
out << "in ";
break;
case EvqVaryingOut:
out << "out ";
break;
default:
out << type.getQualifierString() << " ";
break;
}
}
else
{
out << type.getQualifierString() << " ";
}
}
// Declare the struct if we have not done so already.
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
{
TStructure *structure = type.getStruct();
declareStruct(structure);
if (!structure->name().empty())
{
mDeclaredStructs.insert(structure->uniqueId());
}
}
else
{
if (writeVariablePrecision(type.getPrecision()))
out << " ";
out << getTypeName(type);
}
}
示例4: GLVariablePrecision
GLenum GLVariablePrecision(const TType &type)
{
if (type.getBasicType() == EbtFloat)
{
switch (type.getPrecision())
{
case EbpHigh:
return GL_HIGH_FLOAT;
case EbpMedium:
return GL_MEDIUM_FLOAT;
case EbpLow:
return GL_LOW_FLOAT;
case EbpUndefined:
// Should be defined as the default precision by the parser
default:
UNREACHABLE();
}
}
else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt)
{
switch (type.getPrecision())
{
case EbpHigh:
return GL_HIGH_INT;
case EbpMedium:
return GL_MEDIUM_INT;
case EbpLow:
return GL_LOW_INT;
case EbpUndefined:
// Should be defined as the default precision by the parser
default:
UNREACHABLE();
}
}
// Other types (boolean, sampler) don't have a precision
return GL_NONE;
}
示例5: createTempVariable
TString ScalarizeVecAndMatConstructorArgs::createTempVariable(TIntermTyped *original)
{
TString tempVarName = "_webgl_tmp_";
if (original->isScalar())
{
tempVarName += "scalar_";
}
else if (original->isVector())
{
tempVarName += "vec_";
}
else
{
ASSERT(original->isMatrix());
tempVarName += "mat_";
}
tempVarName += Str(mTempVarCount).c_str();
mTempVarCount++;
ASSERT(original);
TType type = original->getType();
type.setQualifier(EvqTemporary);
if (mShaderType == GL_FRAGMENT_SHADER &&
type.getBasicType() == EbtFloat &&
type.getPrecision() == EbpUndefined)
{
// We use the highest available precision for the temporary variable
// to avoid computing the actual precision using the rules defined
// in GLSL ES 1.0 Section 4.5.2.
type.setPrecision(mFragmentPrecisionHigh ? EbpHigh : EbpMedium);
}
TIntermBinary *init = new TIntermBinary(EOpInitialize);
TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type);
init->setLeft(symbolNode);
init->setRight(original);
init->setType(type);
TIntermAggregate *decl = new TIntermAggregate(EOpDeclaration);
decl->getSequence()->push_back(init);
ASSERT(mSequenceStack.size() > 0);
TIntermSequence &sequence = mSequenceStack.back();
sequence.push_back(decl);
return tempVarName;
}
示例6: writeVariableType
void TOutputGLSLBase::writeVariableType(const TType& type)
{
TInfoSinkBase& out = objSink();
TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for variable declarations.
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
out << type.getQualifierString() << " ";
// Declare the struct if we have not done so already.
if ((type.getBasicType() == EbtStruct) && !structDeclared(type.getStruct()))
{
declareStruct(type.getStruct());
}
else
{
if (writeVariablePrecision(type.getPrecision()))
out << " ";
out << getTypeName(type);
}
}