TString DisambiguateFunctionName(const TIntermSequence *parameters) { TString disambiguatingString; for (auto parameter : *parameters) { const TType ¶mType = parameter->getAsTyped()->getType(); // Parameter types are only added to function names if they are ambiguous according to the // native HLSL compiler. Other parameter types are not added to function names to avoid // making function names longer. if (paramType.getObjectSize() == 4 && paramType.getBasicType() == EbtFloat) { // Disambiguation is needed for float2x2 and float4 parameters. These are the only // built-in types that HLSL thinks are identical. float2x3 and float3x2 are different // types, for example. disambiguatingString += "_" + TypeString(paramType); } else if (paramType.getBasicType() == EbtStruct) { // Disambiguation is needed for struct parameters, since HLSL thinks that structs with // the same fields but a different name are identical. ASSERT(paramType.getStruct()->name() != ""); disambiguatingString += "_" + TypeString(paramType); } } return disambiguatingString; }
//========================================================================================= static void StackEntryString( lua_State* L, int idx, char* stackEntryStr, int stackEntryStrSize ) { int type = lua_type( L, idx ); const char* typeStr = TypeString( type ); switch( type ) { case LUA_TNONE: case LUA_TNIL: case LUA_TBOOLEAN: case LUA_TNUMBER: case LUA_TSTRING: { const char* valueStr = lua_tostring( L, idx ); sprintf_s( stackEntryStr, stackEntryStrSize, "%d -> %s -> %s", idx, typeStr, valueStr ); break; } case LUA_TTABLE: case LUA_TLIGHTUSERDATA: case LUA_TFUNCTION: case LUA_TUSERDATA: case LUA_TTHREAD: { sprintf_s( stackEntryStr, stackEntryStrSize, "%d -> %s", idx, typeStr ); break; } default: { stackEntryStr[0] = '?'; stackEntryStr[1] = '\0'; break; } } }
UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section) { std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T(""))); std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString); if (i != StringToType.end()) { Type = i->second; } else { Type = Unknown; } switch(Type) { case VDMActive: return 1; case DesktopCountTotal: { LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T("")); if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns; else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows; if (FindVirtuaWinWindow()) { return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0); } break; } } return 0; }
static void MatchString(d_String* s, const adbus_Match* m) { if (m->addMatchToBusDaemon) ds_cat_f(s, "Add to bus\n"); if (m->callback) ds_cat_f(s, "%-15s %p %p\n", "Callback", m->callback, m->cuser); if (m->release[0]) ds_cat_f(s, "%-15s %p %p\n", "Release 0", m->release[0], m->ruser[0]); if (m->release[1]) ds_cat_f(s, "%-15s %p %p\n", "Release 1", m->release[1], m->ruser[1]); if (m->type) ds_cat_f(s, "%-15s %s\n", "Type", TypeString(m->type)); if (m->replySerial >= 0) ds_cat_f(s, "%-15s %u\n", "Reply serial", (unsigned int) m->replySerial); Append(s, "Sender", m->sender, m->senderSize); Append(s, "Destination", m->destination, m->destinationSize); Append(s, "Interface", m->interface, m->interfaceSize); Append(s, "Path", m->path, m->pathSize); Append(s, "Member", m->member, m->memberSize); Append(s, "Error", m->error, m->errorSize); for (size_t i = 0; i < m->argumentsSize; ++i) { adbus_Argument* arg = &m->arguments[i]; if (arg->value) { if (arg->size >= 0) { ds_cat_f(s, "Argument %-2d \"%*s\"\n", i, arg->size, arg->value); } else { ds_cat_f(s, "Argument %-2d \"%s\"\n", i, arg->value); } } } }
std::string Piece::ToString() const { std::stringstream xml; xml << "<piece "; xml << "type=\"" << TypeString() << "\" "; xml << "color=\"" << ColorString() << "\" "; xml << "column=\"" << col << "\" "; xml << "row=\"" << row << "\" "; xml << "/>"; return xml.str(); }
//-------------------------------------------------------------------------------------------------- ni_IteratorRef_t ni_CreateIterator ( le_msg_SessionRef_t sessionRef, ///< The user session this request occured on. tu_UserRef_t userRef, ///< Create the iterator for this user. tdb_TreeRef_t treeRef, ///< The tree to create the iterator with. ni_IteratorType_t type, ///< The type of iterator we are creating, read or write? const char* initialPathPtr ///< The node to move to in the specified tree. ) //-------------------------------------------------------------------------------------------------- { LE_ASSERT(sessionRef != NULL); LE_ASSERT(userRef != NULL); LE_ASSERT(treeRef != NULL); // Allocate the object and setup it's initial properties. ni_IteratorRef_t iteratorRef = le_mem_ForceAlloc(IteratorPoolRef); iteratorRef->sessionRef = sessionRef; iteratorRef->userRef = userRef; iteratorRef->treeRef = treeRef; iteratorRef->type = type; iteratorRef->reference = NULL; iteratorRef->isClosed = false; // If this is a write iterator, then shadow the tree instead of accessing it directly. if (iteratorRef->type == NI_WRITE) { iteratorRef->treeRef = tdb_ShadowTree(iteratorRef->treeRef); } // Get the root node of the requested tree, or if this is a write iterator... Get the shadowed // root node of the tree. iteratorRef->currentNodeRef = tdb_GetRootNode(iteratorRef->treeRef); iteratorRef->pathIterRef = le_pathIter_CreateForUnix("/"); LE_DEBUG("Created a new %s iterator object <%p> for user %u (%s) on tree %s.", TypeString(type), iteratorRef, tu_GetUserId(userRef), tu_GetUserName(userRef), tdb_GetTreeName(treeRef)); // If we were given an initial path, go to it now. Otherwise stay on the root node. if (initialPathPtr) { ni_GoToNode(iteratorRef, initialPathPtr); } // Update the tree so that it can keep track of this iterator. tdb_RegisterIterator(treeRef, iteratorRef); // All done. return iteratorRef; }
Real CartesianTrackingObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; //printf("Delta\n"); const CartesianTrackingObjective* cartObj = dynamic_cast<const CartesianTrackingObjective*>(priorGoal); if(link != cartObj->link) return Inf; if(localPosition != cartObj->localPosition) return Inf; //TODO: allow different time scales? size_t n = std::min(positions.size(),cartObj->positions.size()); Real sum=0.0; for(size_t i=0;i+1<n;i++) { Real dt = times[i+1]-times[i]; Vector3 p0 = positions[i]; Vector3 p1 = positions[i+1]; Vector3 pmid = (p1 + p0)*0.5; Vector3 q0 = cartObj->positions[i]; Vector3 q1 = cartObj->positions[i+1]; Vector3 qmid = (q1 + q0)*0.5; Real w = (weights.empty() ? 1.0 : weights[i]); Real err = (matWeights.empty() ? w*(qmid.distanceSquared(pmid) + (p1-p0+q0-q1).normSquared()/12.0) : (qmid-pmid).dot(matWeights[i]*(qmid-pmid)) + (p1-p0+q0-q1).dot(matWeights[i]*(p1-p0+q0-q1))/12.0); sum += err*dt; } for(size_t i=n;i+1<positions.size();i++) { Real dt = times[i+1]-times[i]; Vector3 p0 = positions[i]; Vector3 p1 = positions[i+1]; Vector3 pmid = (p1 + p0)*0.5; Vector3 q = cartObj->positions.back(); Real w = (weights.empty() ? 1.0 : weights[i]); Real err = (matWeights.empty() ? w*(q.distanceSquared(pmid) + (p1-p0+q).normSquared()/12.0) : (q-pmid).dot(matWeights[i]*(q-pmid)) + (p1-p0+q).dot(matWeights[i]*(p1-p0+q))/12.0); sum += err*dt; } for(size_t i=n;i+1<cartObj->positions.size();i++) { Real dt = cartObj->times[i+1]-cartObj->times[i]; Vector3 p0 = cartObj->positions[i]; Vector3 p1 = cartObj->positions[i+1]; Vector3 pmid = (p1 + p0)*0.5; Vector3 q = positions.back(); Real w = (cartObj->weights.empty() ? 1.0 : cartObj->weights[i]); Real err = (cartObj->matWeights.empty() ? w*(q.distanceSquared(pmid) + (p1-p0+q).normSquared()/12.0) : (q-pmid).dot(cartObj->matWeights[i]*(q-pmid)) + (p1-p0+q).dot(matWeights[i]*(p1-p0+q))/12.0); sum += err*dt; } return sum*10; }
static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage) { const TType &fieldType = *field.type(); const TLayoutMatrixPacking matrixPacking = fieldType.getLayoutQualifier().matrixPacking; ASSERT(matrixPacking != EmpUnspecified); TStructure *structure = fieldType.getStruct(); if (fieldType.isMatrix()) { // Use HLSL row-major packing for GLSL column-major matrices const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major"); return matrixPackString + " " + TypeString(fieldType); } else if (structure) { // Use HLSL row-major packing for GLSL column-major matrices return QualifiedStructNameString(*structure, matrixPacking == EmpColumnMajor, blockStorage == EbsStd140); } else { return TypeString(fieldType); } }
DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR iniFile, LPCTSTR section) { std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T(""))); if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id); else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id); else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id); else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id); else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id); else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id); else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id); else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id); return nullptr; }
Node::Node(const string & name, NodeType type, const string & content, const class Namespace & ns) { _xmlNode * newNode = nullptr; switch (type) { case NodeType::Element: // needs subclass break; case NodeType::Text: // needs subclass break; case NodeType::Attribute: // Not Applicable break; case NodeType::CDATASection: #ifdef LIBXML_DOCBOOK_ENABLED case NodeType::DocbookSGMLDocument: #endif case NodeType::Document: case NodeType::DocumentFragment: case NodeType::DTD: case NodeType::HTMLDocument: // need document ptr to create these break; case NodeType::Comment: // needs subclass break; case NodeType::ProcessingInstruction: newNode = xmlNewPI(name.utf8(), content.utf8()); break; default: newNode = xmlNewNode(const_cast<_xmlNs*>(ns.xml()), name.utf8()); break; } if ( newNode == nullptr ) throw InvalidNodeType(std::string("NodeType '") + TypeString(type) + "' is not supported"); _xml = newNode; _xml->_private = new LibXML2Private<Node>(this); }
string CompositeObjective::Description() { string desc = TypeString(); desc += "("; for(size_t i=0;components.size();i++) { if(i > 0) desc += ","; desc += components[i]->Description(); if(!weights.empty() && weights[i] != 1.0) { char buf[64]; sprintf(buf,"*%g\n",weights[i]); desc += buf; } } desc += ")"; return desc; }
TString DisambiguateFunctionName(const TIntermSequence *parameters) { TString disambiguatingString; for (auto parameter : *parameters) { const TType ¶mType = parameter->getAsTyped()->getType(); // Disambiguation is needed for float2x2 and float4 parameters. These are the only parameter // types that HLSL thinks are identical. float2x3 and float3x2 are different types, for // example. Other parameter types are not added to function names to avoid making function // names longer. if (paramType.getObjectSize() == 4 && paramType.getBasicType() == EbtFloat) { disambiguatingString += "_" + TypeString(paramType); } } return disambiguatingString; }
Real CompositeObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; CompositeObjective* pcomposite = dynamic_cast<CompositeObjective*>(priorGoal); if(pcomposite->components.size() != components.size()) return Inf; ErrorAccumulator accum(norm); for(size_t i=0;i<pcomposite->components.size();i++) { Real w1 = (weights.empty()?1.0:weights[i]); Real w2 = (pcomposite->weights.empty()?1.0:pcomposite->weights[i]); Real d=components[i]->Delta(pcomposite->components[i]); if(IsInf(d)) return Inf; accum.Add(d,w1); accum.Add(w1-w2); } return accum.Value(); }
bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node) { TInfoSinkBase &out = mOutputHLSL->getBodyStream(); // Unfold "b ? x : y" into "type s; if(b) s = x; else s = y;" if (node->usesTernaryOperator()) { int i = mTemporaryIndex; out << TypeString(node->getType()) << " s" << i << ";\n"; out << "{\n"; mTemporaryIndex = i + 1; node->getCondition()->traverse(this); out << "if ("; mTemporaryIndex = i + 1; node->getCondition()->traverse(mOutputHLSL); out << ")\n" "{\n"; mTemporaryIndex = i + 1; node->getTrueBlock()->traverse(this); out << " s" << i << " = "; mTemporaryIndex = i + 1; node->getTrueBlock()->traverse(mOutputHLSL); out << ";\n" "}\n" "else\n" "{\n"; mTemporaryIndex = i + 1; node->getFalseBlock()->traverse(this); out << " s" << i << " = "; mTemporaryIndex = i + 1; node->getFalseBlock()->traverse(mOutputHLSL); out << ";\n" "}\n"; out << "}\n"; mTemporaryIndex = i + 1; } return false; }
xmlNodePtr Node::createChild(const string &name, const string &prefix) const { xmlNs * ns = nullptr; if ( Type() != NodeType::Element ) throw InternalError("Cannot add children to non-element node of type '" + TypeString(Type()) + "'"); if ( prefix.empty() ) { ns = xmlSearchNs(_xml->doc, _xml, nullptr); } else { // use the existing namespace if one exists ns = xmlSearchNs(_xml->doc, _xml, prefix.utf8()); if ( ns == nullptr ) throw InternalError(std::string("The namespace prefix '") + prefix.c_str() + "' is unknown"); } return xmlNewNode(ns, name.utf8()); }
TString StructureHLSL::define(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing, Std140PaddingHelper *padHelper) { const TFieldList &fields = structure.fields(); const bool isNameless = (structure.name() == ""); const TString &structName = QualifiedStructNameString(structure, useHLSLRowMajorPacking, useStd140Packing); const TString declareString = (isNameless ? "struct" : "struct " + structName); TString string; string += declareString + "\n" "{\n"; for (unsigned int i = 0; i < fields.size(); i++) { const TField &field = *fields[i]; const TType &fieldType = *field.type(); const TStructure *fieldStruct = fieldType.getStruct(); const TString &fieldTypeString = fieldStruct ? QualifiedStructNameString(*fieldStruct, useHLSLRowMajorPacking, useStd140Packing) : TypeString(fieldType); if (padHelper) { string += padHelper->prePaddingString(fieldType); } string += " " + fieldTypeString + " " + DecorateField(field.name(), structure) + ArrayString(fieldType) + ";\n"; if (padHelper) { string += padHelper->postPaddingString(fieldType, useHLSLRowMajorPacking); } } // Nameless structs do not finish with a semicolon and newline, to leave room for an instance variable string += (isNameless ? "} " : "};\n"); return string; }
void UniformHLSL::outputUniform(TInfoSinkBase &out, const TType &type, const TName &name, const unsigned int registerIndex) { const TStructure *structure = type.getStruct(); // If this is a nameless struct, we need to use its full definition, rather than its (empty) // name. // TypeString() will invoke defineNameless in this case; qualifier prefixes are unnecessary for // nameless structs in ES, as nameless structs cannot be used anywhere that layout qualifiers // are permitted. const TString &typeName = ((structure && !structure->name().empty()) ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; out << "uniform " << typeName << " "; out << DecorateUniform(name, type); out << ArrayString(type) << " : " << registerString << ";\n"; }
Real CartesianObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; const CartesianObjective* cartObj = dynamic_cast<const CartesianObjective*>(priorGoal); return ikGoal.endPosition.distance(cartObj->ikGoal.endPosition); }
Real VelocityObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; return priorGoal->TerminalCost(0.0,Config(),vgoal); }
//-------------------------------------------------------------------------------------------------- ni_IteratorRef_t ni_CreateIterator ( le_msg_SessionRef_t sessionRef, ///< [IN] The user session this request occured on. tu_UserRef_t userRef, ///< [IN] Create the iterator for this user. tdb_TreeRef_t treeRef, ///< [IN] The tree to create the iterator with. ni_IteratorType_t type, ///< [IN] The type of iterator we are creating, read or write? const char* initialPathPtr ///< [IN] The node to move to in the specified tree. ) //-------------------------------------------------------------------------------------------------- { LE_ASSERT(treeRef != NULL); // Allocate the object and setup it's initial properties. ni_IteratorRef_t iteratorRef = le_mem_ForceAlloc(IteratorPoolRef); iteratorRef->creationTime = le_clk_GetRelativeTime(); iteratorRef->sessionRef = sessionRef; iteratorRef->userRef = userRef; iteratorRef->treeRef = treeRef; iteratorRef->type = type; iteratorRef->reference = NULL; iteratorRef->isClosed = false; iteratorRef->isTerminated = false; // Setup the timeout timer for this transaction, if it's been configured. time_t configTimeout = ic_GetTransactionTimeout(); if (configTimeout > 0) { le_clk_Time_t timeout = { configTimeout, 0 }; iteratorRef->timerRef = le_timer_Create("Transaction Timer"); LE_ASSERT(le_timer_SetInterval(iteratorRef->timerRef, timeout) == LE_OK); LE_ASSERT(le_timer_SetHandler(iteratorRef->timerRef, OnTransactionTimeout) == LE_OK); LE_ASSERT(le_timer_SetContextPtr(iteratorRef->timerRef, iteratorRef) == LE_OK); LE_ASSERT(le_timer_Start(iteratorRef->timerRef) == LE_OK); } else { iteratorRef->timerRef = NULL; } // If this is a write iterator, then shadow the tree instead of accessing it directly. if (iteratorRef->type == NI_WRITE) { iteratorRef->treeRef = tdb_ShadowTree(iteratorRef->treeRef); } // Get the root node of the requested tree, or if this is a write iterator... Get the shadowed // root node of the tree. iteratorRef->currentNodeRef = tdb_GetRootNode(iteratorRef->treeRef); iteratorRef->pathIterRef = le_pathIter_CreateForUnix("/"); LE_DEBUG("Created a new %s iterator object <%p> for user %u (%s) on tree %s.", TypeString(type), iteratorRef, tu_GetUserId(userRef), tu_GetUserName(userRef), tdb_GetTreeName(treeRef)); // If we were given an initial path, go to it now. Otherwise stay on the root node. if (initialPathPtr) { ni_GoToNode(iteratorRef, initialPathPtr); } // Update the tree so that it can keep track of this iterator. tdb_RegisterIterator(treeRef, iteratorRef); // All done. return iteratorRef; }
Real IKObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; return ikGoal.endPosition.distance(dynamic_cast<const IKObjective*>(priorGoal)->ikGoal.endPosition); }
TString UniformHLSL::uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) { TString uniforms; for (ReferencedSymbols::const_iterator uniformIt = referencedUniforms.begin(); uniformIt != referencedUniforms.end(); uniformIt++) { const TIntermSymbol &uniform = *uniformIt->second; const TType &type = uniform.getType(); const TString &name = uniform.getSymbol(); unsigned int registerIndex = declareUniformAndAssignRegister(type, name); if (outputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture { uniforms += "uniform " + SamplerString(type) + " sampler_" + DecorateUniform(name, type) + ArrayString(type) + " : register(s" + str(registerIndex) + ");\n"; uniforms += "uniform " + TextureString(type) + " texture_" + DecorateUniform(name, type) + ArrayString(type) + " : register(t" + str(registerIndex) + ");\n"; } else { const TStructure *structure = type.getStruct(); // If this is a nameless struct, we need to use its full definition, rather than its (empty) name. // TypeString() will invoke defineNameless in this case; qualifier prefixes are unnecessary for // nameless structs in ES, as nameless structs cannot be used anywhere that layout qualifiers are // permitted. const TString &typeName = ((structure && !structure->name().empty()) ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; uniforms += "uniform " + typeName + " " + DecorateUniform(name, type) + ArrayString(type) + " : " + registerString + ";\n"; } } return (uniforms.empty() ? "" : ("// Uniforms\n\n" + uniforms)); }
TString UniformHLSL::uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) { TString uniforms; for (ReferencedSymbols::const_iterator uniformIt = referencedUniforms.begin(); uniformIt != referencedUniforms.end(); uniformIt++) { const TIntermSymbol &uniform = *uniformIt->second; const TType &type = uniform.getType(); const TString &name = uniform.getSymbol(); int registerIndex = declareUniformAndAssignRegister(type, name); if (outputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture { uniforms += "uniform " + SamplerString(type) + " sampler_" + DecorateUniform(name, type) + ArrayString(type) + " : register(s" + str(registerIndex) + ");\n"; uniforms += "uniform " + TextureString(type) + " texture_" + DecorateUniform(name, type) + ArrayString(type) + " : register(t" + str(registerIndex) + ");\n"; } else { const TStructure *structure = type.getStruct(); const TString &typeName = (structure ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; uniforms += "uniform " + typeName + " " + DecorateUniform(name, type) + ArrayString(type) + " : " + registerString + ";\n"; } } return (uniforms.empty() ? "" : ("// Uniforms\n\n" + uniforms)); }
Real ConfigObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; return priorGoal->TerminalCost(0.0,qgoal,Vector()); }
void UniformHLSL::uniformsHeader(TInfoSinkBase &out, ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) { if (!referencedUniforms.empty()) { out << "// Uniforms\n\n"; } // In the case of HLSL 4, sampler uniforms need to be grouped by type before the code is // written. They are grouped based on the combination of the HLSL texture type and // HLSL sampler type, enumerated in HLSLTextureSamplerGroup. TVector<TVector<const TIntermSymbol *>> groupedSamplerUniforms; groupedSamplerUniforms.resize(HLSL_TEXTURE_MAX + 1); for (auto &uniformIt : referencedUniforms) { // Output regular uniforms. Group sampler uniforms by type. const TIntermSymbol &uniform = *uniformIt.second; const TType &type = uniform.getType(); const TString &name = uniform.getSymbol(); if (outputType == SH_HLSL_4_1_OUTPUT && IsSampler(type.getBasicType())) { HLSLTextureSamplerGroup group = TextureGroup(type.getBasicType()); groupedSamplerUniforms[group].push_back(&uniform); } else if (outputType == SH_HLSL_4_0_FL9_3_OUTPUT && IsSampler(type.getBasicType())) { unsigned int registerIndex = declareUniformAndAssignRegister(type, name); 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"; } else { unsigned int registerIndex = declareUniformAndAssignRegister(type, name); const TStructure *structure = type.getStruct(); // If this is a nameless struct, we need to use its full definition, rather than its (empty) name. // TypeString() will invoke defineNameless in this case; qualifier prefixes are unnecessary for // nameless structs in ES, as nameless structs cannot be used anywhere that layout qualifiers are // permitted. const TString &typeName = ((structure && !structure->name().empty()) ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; out << "uniform " << typeName << " " << DecorateUniform(name, type) << ArrayString(type) << " : " << registerString << ";\n"; } } if (outputType == SH_HLSL_4_1_OUTPUT) { unsigned int groupTextureRegisterIndex = 0; // TEXTURE_2D is special, index offset is assumed to be 0 and omitted in that case. ASSERT(HLSL_TEXTURE_MIN == HLSL_TEXTURE_2D); for (int groupId = HLSL_TEXTURE_MIN; groupId < HLSL_TEXTURE_MAX; ++groupId) { outputHLSLSamplerUniformGroup(out, HLSLTextureSamplerGroup(groupId), groupedSamplerUniforms[groupId], &groupTextureRegisterIndex); } } }
void StructureHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters) { if (name == "") { return; // Nameless structures don't have constructors } if (type.getStruct() && mStructNames.find(name) != mStructNames.end()) { return; // Already added } TType ctorType = type; ctorType.clearArrayness(); ctorType.setPrecision(EbpHigh); ctorType.setQualifier(EvqTemporary); typedef std::vector<TType> ParameterArray; ParameterArray ctorParameters; const TStructure* structure = type.getStruct(); if (structure) { mStructNames.insert(name); // Add element index storeStd140ElementIndex(*structure, false); storeStd140ElementIndex(*structure, true); const TString &structString = defineQualified(*structure, false, false); if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structString) == mStructDeclarations.end()) { // Add row-major packed struct for interface blocks TString rowMajorString = "#pragma pack_matrix(row_major)\n" + defineQualified(*structure, true, false) + "#pragma pack_matrix(column_major)\n"; TString std140String = defineQualified(*structure, false, true); TString std140RowMajorString = "#pragma pack_matrix(row_major)\n" + defineQualified(*structure, true, true) + "#pragma pack_matrix(column_major)\n"; mStructDeclarations.push_back(structString); mStructDeclarations.push_back(rowMajorString); mStructDeclarations.push_back(std140String); mStructDeclarations.push_back(std140RowMajorString); } const TFieldList &fields = structure->fields(); for (unsigned int i = 0; i < fields.size(); i++) { ctorParameters.push_back(*fields[i]->type()); } } else if (parameters) { for (TIntermSequence::const_iterator parameter = parameters->begin(); parameter != parameters->end(); parameter++) { ctorParameters.push_back((*parameter)->getAsTyped()->getType()); } } else UNREACHABLE(); TString constructor; if (ctorType.getStruct()) { constructor += name + " " + name + "_ctor("; } else // Built-in type { constructor += TypeString(ctorType) + " " + name + "("; } for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++) { const TType ¶mType = ctorParameters[parameter]; constructor += TypeString(paramType) + " x" + str(parameter) + ArrayString(paramType); if (parameter < ctorParameters.size() - 1) { constructor += ", "; } } constructor += ")\n" "{\n"; if (ctorType.getStruct()) { constructor += " " + name + " structure = {"; } else { constructor += " return " + TypeString(ctorType) + "("; } if (ctorType.isMatrix() && ctorParameters.size() == 1) { int rows = ctorType.getRows(); int cols = ctorType.getCols(); const TType ¶meter = ctorParameters[0]; if (parameter.isScalar()) { for (int col = 0; col < cols; col++) { for (int row = 0; row < rows; row++) { constructor += TString((row == col) ? "x0" : "0.0"); if (row < rows - 1 || col < cols - 1) { constructor += ", "; } } } } else if (parameter.isMatrix()) { for (int col = 0; col < cols; col++) { for (int row = 0; row < rows; row++) { if (row < parameter.getRows() && col < parameter.getCols()) { constructor += TString("x0") + "[" + str(col) + "][" + str(row) + "]"; } else { constructor += TString((row == col) ? "1.0" : "0.0"); } if (row < rows - 1 || col < cols - 1) { constructor += ", "; } } } } else { ASSERT(rows == 2 && cols == 2 && parameter.isVector() && parameter.getNominalSize() == 4); constructor += "x0"; } } else { size_t remainingComponents = ctorType.getObjectSize(); size_t parameterIndex = 0; while (remainingComponents > 0) { const TType ¶meter = ctorParameters[parameterIndex]; const size_t parameterSize = parameter.getObjectSize(); bool moreParameters = parameterIndex + 1 < ctorParameters.size(); constructor += "x" + str(parameterIndex); if (ctorType.getStruct()) { ASSERT(remainingComponents == parameterSize || moreParameters); ASSERT(parameterSize <= remainingComponents); remainingComponents -= parameterSize; } else if (parameter.isScalar()) { remainingComponents -= parameter.getObjectSize(); } else if (parameter.isVector()) { if (remainingComponents == parameterSize || moreParameters) { ASSERT(parameterSize <= remainingComponents); remainingComponents -= parameterSize; } else if (remainingComponents < static_cast<size_t>(parameter.getNominalSize())) { switch (remainingComponents) { case 1: constructor += ".x"; break; case 2: constructor += ".xy"; break; case 3: constructor += ".xyz"; break; case 4: constructor += ".xyzw"; break; default: UNREACHABLE(); } remainingComponents = 0; } else UNREACHABLE(); } else if (parameter.isMatrix()) { int column = 0; while (remainingComponents > 0 && column < parameter.getCols()) { constructor += "[" + str(column) + "]"; if (remainingComponents < static_cast<size_t>(parameter.getRows())) { switch (remainingComponents) { case 1: constructor += ".x"; break; case 2: constructor += ".xy"; break; case 3: constructor += ".xyz"; break; default: UNREACHABLE(); } remainingComponents = 0; } else { remainingComponents -= parameter.getRows(); if (remainingComponents > 0) { constructor += ", x" + str(parameterIndex); } } column++; } } else UNREACHABLE(); if (moreParameters) { parameterIndex++; } if (remainingComponents) { constructor += ", "; } } } if (ctorType.getStruct()) { constructor += "};\n" " return structure;\n" "}\n"; } else { constructor += ");\n" "}\n"; } mConstructors.insert(constructor); }
// this function is meant to be called from under debugger to see the // proprieties of the given type id extern "C" void DumpTI(ULONG ti) { SYMBOL_INFO sym = { sizeof(SYMBOL_INFO) }; sym.ModBase = 0x400000; // it's a constant under Win32 sym.TypeIndex = ti; wxDbgHelpDLL::SymbolTag tag = wxDbgHelpDLL::SYMBOL_TAG_NULL; DoGetTypeInfo(&sym, TI_GET_SYMTAG, &tag); DoGetTypeInfo(&sym, TI_GET_TYPEID, &ti); OutputDebugString(wxString::Format(_T("Type 0x%x: "), sym.TypeIndex)); wxString name = wxDbgHelpDLL::GetSymbolName(&sym); if ( !name.empty() ) { OutputDebugString(wxString::Format(_T("name=\"%s\", "), name.c_str())); } DWORD nested; if ( !DoGetTypeInfo(&sym, TI_GET_NESTED, &nested) ) { nested = FALSE; } OutputDebugString(wxString::Format(_T("tag=%s%s"), nested ? _T("nested ") : wxEmptyString, TagString(tag).c_str())); if ( tag == wxDbgHelpDLL::SYMBOL_TAG_UDT ) { wxDbgHelpDLL::UdtKind udtKind; if ( DoGetTypeInfo(&sym, TI_GET_UDTKIND, &udtKind) ) { OutputDebugString(_T(" (") + UdtKindString(udtKind) + _T(')')); } } wxDbgHelpDLL::DataKind kind = wxDbgHelpDLL::DATA_UNKNOWN; if ( DoGetTypeInfo(&sym, TI_GET_DATAKIND, &kind) ) { OutputDebugString(wxString::Format( _T(", kind=%s"), KindString(kind).c_str())); if ( kind == wxDbgHelpDLL::DATA_MEMBER ) { DWORD ofs = 0; if ( DoGetTypeInfo(&sym, TI_GET_OFFSET, &ofs) ) { OutputDebugString(wxString::Format(_T(" (ofs=0x%x)"), ofs)); } } } wxDbgHelpDLL::BasicType bt = GetBasicType(&sym); if ( bt ) { OutputDebugString(wxString::Format(_T(", type=%s"), TypeString(bt).c_str())); } if ( ti != sym.TypeIndex ) { OutputDebugString(wxString::Format(_T(", next ti=0x%x"), ti)); } OutputDebugString(_T("\r\n")); }
Real TimeObjective::Delta(PlannerObjectiveBase* priorGoal) { if(priorGoal->TypeString() != TypeString()) return Inf; return 0; }