本文整理汇总了C++中TType类的典型用法代码示例。如果您正苦于以下问题:C++ TType类的具体用法?C++ TType怎么用?C++ TType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTypeName
TString TOutputGLSLBase::getTypeName(const TType &type)
{
if (type.getBasicType() == EbtStruct)
return hashName(type.getStruct()->name());
else
return type.getBuiltInTypeNameString();
}
示例2: switch
BuiltInFunctionEmulator::TBuiltInFunction
BuiltInFunctionEmulator::IdentifyFunction(
TOperator op, const TType& param)
{
if (param.getNominalSize() > 4 || param.getSecondarySize() > 4)
return TFunctionUnknown;
unsigned int function = TFunctionUnknown;
switch (op) {
case EOpCos:
function = TFunctionCos1;
break;
case EOpLength:
function = TFunctionLength1;
break;
case EOpNormalize:
function = TFunctionNormalize1;
break;
default:
break;
}
if (function == TFunctionUnknown)
return TFunctionUnknown;
if (param.isVector())
function += param.getNominalSize() - 1;
return static_cast<TBuiltInFunction>(function);
}
示例3: writeQualifier
void TOutputVulkanGLSL::writeQualifier(TQualifier qualifier,
const TType &type,
const TSymbol *symbol)
{
if (qualifier != EvqUniform && qualifier != EvqAttribute && qualifier != EvqVertexIn &&
!sh::IsVarying(qualifier))
{
TOutputGLSLBase::writeQualifier(qualifier, type, symbol);
return;
}
if (symbol == nullptr)
{
return;
}
ImmutableString name = symbol->name();
// For interface blocks, use the block name instead. When the qualifier is being replaced in
// the backend, that would be the name that's available.
if (type.isInterfaceBlock())
{
name = type.getInterfaceBlock()->name();
}
TInfoSinkBase &out = objSink();
out << "@@ QUALIFIER-" << name.data() << " @@ ";
}
示例4: OutputSpecification
bool OutputSpecification(TIntermSpecification* node, TIntermTraverser* it)
{
TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
TInfoSink& out = oit->infoSink;
OutputExtensionText(out, node);
OutputTreeText(out, node, oit->depth);
TType* t = node->getType();
out.debug << "specify '" << t->getTypeName().c_str() << "' (" << t->getCompleteString() << ")\n";
return true;
#if 0
TTypeList* tl = t->getStruct();
TTypeList::iterator iter = tl->begin();
for(; iter < tl->end(); iter++) {
out.debug << FormatSourceRange(iter->line);
for (i = 0; i < (oit->depth+1); ++i) out.debug << " ";
out.debug << "'" << iter->type->getFieldName().c_str() << "' (" <<
iter->type->getCompleteString().c_str() << ")\n";
}
#endif
}
示例5: traverse
void GetVariableTraverser::traverse(const TType &type, const TString &name, std::vector<VarT> *output)
{
const TStructure *structure = type.getStruct();
VarT variable;
variable.name = name.c_str();
variable.arraySize = static_cast<unsigned int>(type.getArraySize());
if (!structure)
{
variable.type = GLVariableType(type);
variable.precision = GLVariablePrecision(type);
}
else
{
// Note: this enum value is not exposed outside ANGLE
variable.type = GL_STRUCT_ANGLEX;
variable.structName = structure->name().c_str();
const TFieldList &fields = structure->fields();
for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{
TField *field = fields[fieldIndex];
traverse(*field->type(), field->name(), &variable.fields);
}
}
visitVariable(&variable);
ASSERT(output);
output->push_back(variable);
}
示例6: resolveInOutLocation
int resolveInOutLocation(EShLanguage /*stage*/, const char* /*name*/, const TType& type, bool /*is_live*/) override
{
// kick out of not doing this
if (!doAutoLocationMapping)
return -1;
// no locations added if already present, or a built-in variable
if (type.getQualifier().hasLocation() || type.isBuiltIn())
return -1;
// no locations on blocks of built-in variables
if (type.isStruct()) {
if (type.getStruct()->size() < 1)
return -1;
if ((*type.getStruct())[0].type->isBuiltIn())
return -1;
}
// Placeholder.
// TODO: It would be nice to flesh this out using
// intermediate->computeTypeLocationSize(type), or functions that call it like
// intermediate->addUsedLocation()
// These in turn would want the intermediate, which is not available here, but
// is available in many places, and a lot of copying from it could be saved if
// it were just available.
return 0;
}
示例7: if
TType *TCodeGenerator::EmitSimpleExpression(void)
{
TType *pOperandType; // ptr to operand's type
TType *pResultType; // ptr to result type
TTokenCode op; // operator
TTokenCode unaryOp = tcPlus; // unary operator
//--Unary + or -
if (TokenIn(token, tlUnaryOps)) {
unaryOp = token;
GetToken();
}
//--Emit code for the first term.
pResultType = EmitTerm();
//--If there was a unary operator, negate in integer value in ax
//--with the neg instruction, or negate a real value in dx:ax
//--by calling _FloatNegate.
if (unaryOp == tcMinus) {
if (pResultType->Base() == pIntegerType) Emit1(neg, Reg(ax))
else if (pResultType == pRealType) {
EmitPushOperand(pResultType);
Emit1(call, NameLit(FLOAT_NEGATE));
Emit2(add, Reg(sp), IntegerLit(4));
}
}
//--Loop to execute subsequent additive operators and terms.
while (TokenIn(token, tlAddOps)) {
op = token;
pResultType = pResultType->Base();
EmitPushOperand(pResultType);
GetToken();
pOperandType = EmitTerm()->Base();
//--Perform the operation, and push the resulting value
//--onto the stack.
if (op == tcOR) {
//--boolean OR boolean => boolean
//--ax = ax OR dx
Emit1(pop, Reg(dx));
Emit2(or, Reg(ax), Reg(dx));
pResultType = pBooleanType;
}
else if ((pResultType == pIntegerType) &&
(pOperandType == pIntegerType)) {
//--integer +|- integer => integer
Emit1(pop, Reg(dx));
if (op == tcPlus) Emit2(add, Reg(ax), Reg(dx))
else {
Emit2(sub, Reg(dx), Reg(ax));
Emit2(mov, Reg(ax), Reg(dx));
}
pResultType = pIntegerType;
}
else {
示例8: addConstArrayNode
//
// This function returns an element of an array accessed from a constant array. The values are retrieved from
// the symbol table and parse-tree is built for the type of the element. The input
// to the function could either be a symbol node (a[0] where a is a constant array)that represents a
// constant array or it could be the tree representation of the constant array (s.a1[0] where s is a constant structure)
//
TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line)
{
TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
TType arrayElementType = node->getType();
arrayElementType.clearArrayness();
if (index >= node->getType().getArraySize()) {
error(line, "", "[", "array field selection out of range '%d'", index);
recover();
index = 0;
}
int arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line);
} else {
error(line, "Cannot offset into the array", "Error", "");
recover();
return 0;
}
return typedNode;
}
示例9: ArrayString
TString ArrayString(const TType &type)
{
if (!type.isArray())
{
return "";
}
return "[" + str(type.getArraySize()) + "]";
}
示例10: parameterSamplerErrorCheck
bool TParseContext::parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type)
{
if ((qualifier == EvqOut || qualifier == EvqInOut) &&
type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) {
error(line, "samplers cannot be output parameters", type.getBasicString(), "");
return true;
}
return false;
}
示例11: writeLayoutQualifier
void TOutputGLSLBase::writeLayoutQualifier(const TType &type)
{
if (type.getQualifier() == EvqFragmentOut || type.getQualifier() == EvqVertexIn)
{
const TLayoutQualifier &layoutQualifier = type.getLayoutQualifier();
if (layoutQualifier.location >= 0)
{
TInfoSinkBase &out = objSink();
out << "layout(location = " << layoutQualifier.location << ") ";
}
}
}
示例12: SamplerString
void UniformHLSL::outputHLSL4_0_FL9_3Sampler(TInfoSinkBase &out,
const TType &type,
const TName &name,
const unsigned int registerIndex)
{
out << "uniform " << SamplerString(type.getBasicType()) << " sampler_"
<< DecorateUniform(name, type) << ArrayString(type) << " : register(s" << str(registerIndex)
<< ");\n";
out << "uniform " << TextureString(type.getBasicType()) << " texture_"
<< DecorateUniform(name, type) << ArrayString(type) << " : register(t" << str(registerIndex)
<< ");\n";
}
示例13: ASSERT
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{
ASSERT(symbol);
TType *type = symbol->getTypePointer();
ASSERT(type);
TStructure *userType = type->getStruct();
if (!userType)
return;
if (mSymbolTable.findBuiltIn(userType->name(), mShaderVersion))
{
// Built-in struct, do not touch it.
return;
}
int uniqueId = userType->uniqueId();
ASSERT(mScopeDepth > 0);
if (mScopeDepth == 1)
{
// If a struct is defined at global scope, we don't map its name.
// This is because at global level, the struct might be used to
// declare a uniform, so the same name needs to stay the same for
// vertex/fragment shaders. However, our mapping uses internal ID,
// which will be different for the same struct in vertex/fragment
// shaders.
// This is OK because names for any structs defined in other scopes
// will begin with "_webgl", which is reserved. So there will be
// no conflicts among unmapped struct names from global scope and
// mapped struct names from other scopes.
// However, we need to keep track of these global structs, so if a
// variable is used in a local scope, we don't try to modify the
// struct name through that variable.
mDeclaredGlobalStructs.insert(uniqueId);
return;
}
if (mDeclaredGlobalStructs.count(uniqueId) > 0)
return;
// Map {name} to _webgl_struct_{uniqueId}_{name}.
const char kPrefix[] = "_webgl_struct_";
if (userType->name().find(kPrefix) == 0)
{
// The name has already been regenerated.
return;
}
std::string id = Str(uniqueId);
TString tmp = kPrefix + TString(id.c_str());
tmp += "_" + userType->name();
userType->setName(tmp);
}
示例14: getTypeName
TString TOutputGLSLBase::getTypeName(const TType& type)
{
TInfoSinkBase out;
if (type.isMatrix())
{
out << "mat";
out << type.getNominalSize();
}
else if (type.isVector())
{
switch (type.getBasicType())
{
case EbtFloat: out << "vec"; break;
case EbtInt: out << "ivec"; break;
case EbtBool: out << "bvec"; break;
default: UNREACHABLE(); break;
}
out << type.getNominalSize();
}
else
{
if (type.getBasicType() == EbtStruct)
out << hashName(type.getTypeName());
else
out << type.getBasicString();
}
return TString(out.c_str());
}
示例15: objSink
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);
}
}