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); } }
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()); }
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 }
void OutputParameter(TIntermParameter* 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(); if (t->getBasicType() != EbtStruct) { out.debug << "param '" << t->getFieldName() << "' (" << t->getCompleteString() << ")\n"; } else { out.debug << "param '" << t->getFieldName() << "' (" << t->getCompleteString() << " '" << t->getTypeName() << "')\n"; } }
bool TParseContext::structNestingErrorCheck(TSourceLoc line, const TType& fieldType) { if (shaderSpec != SH_WEBGL_SPEC) { return false; } if (fieldType.getBasicType() != EbtStruct) { return false; } // We're already inside a structure definition at this point, so add // one to the field's struct nesting. if (1 + fieldType.getDeepestStructNesting() > kWebGLMaxStructNesting) { error(line, "", "", "Reference of struct type %s exceeds maximum struct nesting of %d", fieldType.getTypeName().c_str(), kWebGLMaxStructNesting); return true; } return false; }
bool TParseContext::structNestingErrorCheck(TSourceLoc line, const TType& fieldType) { if (!isWebGLBasedSpec(shaderSpec)) { return false; } if (fieldType.getBasicType() != EbtStruct) { return false; } // We're already inside a structure definition at this point, so add // one to the field's struct nesting. if (1 + fieldType.getDeepestStructNesting() > kWebGLMaxStructNesting) { std::stringstream extraInfoStream; extraInfoStream << "Reference of struct type " << fieldType.getTypeName() << " exceeds maximum struct nesting of " << kWebGLMaxStructNesting; std::string extraInfo = extraInfoStream.str(); error(line, "", "", extraInfo.c_str()); return true; } return false; }