本文整理汇总了C++中TType::getBasicType方法的典型用法代码示例。如果您正苦于以下问题:C++ TType::getBasicType方法的具体用法?C++ TType::getBasicType怎么用?C++ TType::getBasicType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TType
的用法示例。
在下文中一共展示了TType::getBasicType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: addUsedLocation
// Accumulate locations used for inputs, outputs, and uniforms, and check for collisions
// as the accumulation is done.
//
// Returns < 0 if no collision, >= 0 if collision and the value returned is a colliding value.
//
// typeCollision is set to true if there is no direct collision, but the types in the same location
// are different.
//
int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& type, bool& typeCollision)
{
typeCollision = false;
int set;
if (qualifier.isPipeInput())
set = 0;
else if (qualifier.isPipeOutput())
set = 1;
else if (qualifier.storage == EvqUniform)
set = 2;
else if (qualifier.storage == EvqBuffer)
set = 3;
else
return -1;
int size;
if (qualifier.isUniformOrBuffer()) {
if (type.isArray())
size = type.getCumulativeArraySize();
else
size = 1;
} else {
// Strip off the outer array dimension for those having an extra one.
if (type.isArray() && qualifier.isArrayedIo(language)) {
TType elementType(type, 0);
size = computeTypeLocationSize(elementType);
} else
size = computeTypeLocationSize(type);
}
TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1);
TRange componentRange(0, 3);
if (qualifier.hasComponent()) {
componentRange.start = qualifier.layoutComponent;
componentRange.last = componentRange.start + type.getVectorSize() - 1;
}
TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.layoutIndex : 0);
// check for collisions, except for vertex inputs on desktop
if (! (profile != EEsProfile && language == EShLangVertex && qualifier.isPipeInput())) {
for (size_t r = 0; r < usedIo[set].size(); ++r) {
if (range.overlap(usedIo[set][r])) {
// there is a collision; pick one
return std::max(locationRange.start, usedIo[set][r].location.start);
} else if (locationRange.overlap(usedIo[set][r].location) && type.getBasicType() != usedIo[set][r].basicType) {
// aliased-type mismatch
typeCollision = true;
return std::max(locationRange.start, usedIo[set][r].location.start);
}
}
}
usedIo[set].push_back(range);
return -1; // no collision
}
示例3: 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;
}
示例4: 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";
}
示例5: containsSampler
bool TParseContext::containsSampler(TType& type)
{
if (IsSampler(type.getBasicType()))
return true;
if (type.getBasicType() == EbtStruct) {
TTypeList& structure = *type.getStruct();
for (unsigned int i = 0; i < structure.size(); ++i) {
if (containsSampler(*structure[i].type))
return true;
}
}
return false;
}
示例6: getTypeName
TString TOutputGLSLBase::getTypeName(const TType &type)
{
if (type.getBasicType() == EbtStruct)
return hashName(type.getStruct()->name());
else
return type.getBuiltInTypeNameString();
}
示例7: 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);
}
}
示例8: TextureString
TString TextureString(const TType &type)
{
switch (type.getBasicType())
{
case EbtSampler2D: return "Texture2D";
case EbtSamplerCube: return "TextureCube";
case EbtSamplerExternalOES: return "Texture2D";
case EbtSampler2DArray: return "Texture2DArray";
case EbtSampler3D: return "Texture3D";
case EbtISampler2D: return "Texture2D<int4>";
case EbtISampler3D: return "Texture3D<int4>";
case EbtISamplerCube: return "Texture2DArray<int4>";
case EbtISampler2DArray: return "Texture2DArray<int4>";
case EbtUSampler2D: return "Texture2D<uint4>";
case EbtUSampler3D: return "Texture3D<uint4>";
case EbtUSamplerCube: return "Texture2DArray<uint4>";
case EbtUSampler2DArray: return "Texture2DArray<uint4>";
case EbtSampler2DShadow: return "Texture2D";
case EbtSamplerCubeShadow: return "TextureCube";
case EbtSampler2DArrayShadow: return "Texture2DArray";
default: UNREACHABLE();
}
return "<unknown texture type>";
}
示例9: 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);
}
}
示例10: assignUniformRegister
unsigned int UniformHLSL::assignUniformRegister(const TType &type,
const TString &name,
unsigned int *outRegisterCount)
{
unsigned int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
const Uniform *uniform = findUniformByName(name);
ASSERT(uniform);
mUniformRegisterMap[uniform->name] = registerIndex;
unsigned int registerCount = HLSLVariableRegisterCount(*uniform, mOutputType);
if (gl::IsSamplerType(uniform->type))
{
mSamplerRegister += registerCount;
}
else
{
mUniformRegister += registerCount;
}
if (outRegisterCount)
{
*outRegisterCount = registerCount;
}
return registerIndex;
}
示例11: computeTypeXfbSize
// Recursively figure out how many bytes of xfb buffer are used by the given type.
// Return the size of type, in bytes.
// Sets containsDouble to true if the type contains a double.
// N.B. Caller must set containsDouble to false before calling.
unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& containsDouble) const
{
// "...if applied to an aggregate containing a double, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8.
// ...within the qualified entity, subsequent components are each
// assigned, in order, to the next available offset aligned to a multiple of
// that component's size. Aggregate types are flattened down to the component
// level to get this sequence of components."
if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
assert(type.isExplicitlySizedArray());
TType elementType(type, 0);
return type.getOuterArraySize() * computeTypeXfbSize(elementType, containsDouble);
}
if (type.isStruct()) {
unsigned int size = 0;
bool structContainsDouble = false;
for (int member = 0; member < (int)type.getStruct()->size(); ++member) {
TType memberType(type, member);
// "... if applied to
// an aggregate containing a double, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8."
bool memberContainsDouble = false;
int memberSize = computeTypeXfbSize(memberType, memberContainsDouble);
if (memberContainsDouble) {
structContainsDouble = true;
RoundToPow2(size, 8);
}
size += memberSize;
}
if (structContainsDouble) {
containsDouble = true;
RoundToPow2(size, 8);
}
return size;
}
int numComponents;
if (type.isScalar())
numComponents = 1;
else if (type.isVector())
numComponents = type.getVectorSize();
else if (type.isMatrix())
numComponents = type.getMatrixCols() * type.getMatrixRows();
else {
assert(0);
numComponents = 1;
}
if (type.getBasicType() == EbtDouble) {
containsDouble = true;
return 8 * numComponents;
} else
return 4 * numComponents;
}
示例12: getBaseAlignmentScalar
// Return the size and alignment of a scalar.
// The size is returned in the 'size' parameter
// Return value is the alignment of the type.
int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
{
switch (type.getBasicType()) {
case EbtInt64:
case EbtUint64:
case EbtDouble: size = 8; return 8;
default: size = 4; return 4;
}
}
示例13: DecorateUniform
TString DecorateUniform(const TString &string, const TType &type)
{
if (type.getBasicType() == EbtSamplerExternalOES)
{
return "ex_" + string;
}
return Decorate(string);
}
示例14: DecorateUniform
TString DecorateUniform(const TName &name, const TType &type)
{
if (type.getBasicType() == EbtSamplerExternalOES)
{
return "ex_" + name.getString();
}
return DecorateIfNeeded(name);
}
示例15: declareUniformAndAssignRegister
int UniformHLSL::declareUniformAndAssignRegister(const TType &type, const TString &name)
{
int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
declareUniformToList(type, name, registerIndex, &mActiveUniforms);
unsigned int registerCount = HLSLVariableRegisterCount(mActiveUniforms.back(), mOutputType);
if (IsSampler(type.getBasicType()))
{
mSamplerRegister += registerCount;
}
else
{
mUniformRegister += registerCount;
}
return registerIndex;
}