Home | History | Annotate | Download | only in randomshaders

Lines Matching refs:variable

21  * \brief Variable manager.
95 ValueEntry::ValueEntry (const Variable* variable)
96 : m_variable (variable)
97 , m_valueRange (variable->getType())
107 for (vector<Variable*>::iterator i = m_declaredVariables.begin(); i != m_declaredVariables.end(); i++)
110 for (vector<Variable*>::iterator i = m_liveVariables.begin(); i != m_liveVariables.end(); i++)
114 Variable* VariableScope::allocate (const VariableType& type, Variable::Storage storage, const char* name)
116 Variable* variable = new Variable(type, storage, name);
119 m_liveVariables.push_back(variable);
120 return variable;
124 delete variable;
129 void VariableScope::declare (Variable* variable)
131 m_declaredVariables.push_back(variable);
132 removeLive(variable);
135 void VariableScope::removeLive (const Variable* variable)
137 vector<Variable*>::iterator pos = std::find(m_liveVariables.begin(), m_liveVariables.end(), variable);
160 ValueEntry* ValueScope::allocate (const Variable* variable)
162 ValueEntry* entry = new ValueEntry(variable);
178 CompareEntryVariable (const Variable* variable)
179 : m_variable(variable)
189 const Variable* m_variable;
197 ValueEntry* ValueScope::findEntry (const Variable* variable) const
199 vector<ValueEntry*>::const_iterator pos = std::find(m_entries.begin(), m_entries.end(), CompareEntryVariable(variable));
203 void ValueScope::setValue (const Variable* variable, ConstValueRangeAccess value)
205 ValueEntry* entry = findEntry(variable);
213 void ValueScope::removeValue (const Variable* variable)
215 vector<ValueEntry*>::iterator pos = std::find(m_entries.begin(), m_entries.end(), CompareEntryVariable(variable));
237 Variable* VariableManager::allocate (const VariableType& type)
239 return allocate(type, Variable::STORAGE_LOCAL, m_nameAllocator.allocate().c_str());
242 Variable* VariableManager::allocate (const VariableType& type, Variable::Storage storage, const char* name)
249 Variable* variable = varScope.allocate(type, Variable::STORAGE_LOCAL, name);
252 ValueEntry* valueEntry = valueScope.allocate(variable);
260 setStorage(variable, storage);
262 return variable;
265 void VariableManager::setStorage (Variable* variable, Variable::Storage storage)
267 int numScalars = variable->getType().getScalarSize();
270 if (variable->getStorage() == Variable::STORAGE_SHADER_IN)
275 else if (variable->getStorage() == Variable::STORAGE_UNIFORM)
279 if (storage == Variable::STORAGE_SHADER_IN)
284 else if (storage == Variable::STORAGE_UNIFORM)
287 variable->setStorage(storage);
290 bool VariableManager::canDeclareInCurrentScope (const Variable* variable) const
292 const vector<Variable*>& curLiveVars = getCurVariableScope().getLiveVariables();
293 return std::find(curLiveVars.begin(), curLiveVars.end(), variable) != curLiveVars.end();
296 const vector<Variable*>& VariableManager::getLiveVariables (void) const
301 void VariableManager::declareVariable (Variable* variable)
304 std::vector<const ValueEntry*>::iterator pos = std::find(m_entryCache.begin(), m_entryCache.end(), CompareEntryVariable(variable));
308 DE_ASSERT(std::find(m_entryCache.begin(), m_entryCache.end(), CompareEntryVariable(variable)) == m_entryCache.end());
314 scope->removeValue(variable);
318 getCurVariableScope().declare(variable);
321 const ValueEntry* VariableManager::getValue (const Variable* variable) const
323 vector<const ValueEntry*>::const_iterator pos = std::find(m_entryCache.begin(), m_entryCache.end(), CompareEntryVariable(variable));
327 void VariableManager::removeValueFromCurrentScope (const Variable* variable)
330 std::vector<const ValueEntry*>::iterator pos = std::find(m_entryCache.begin(), m_entryCache.end(), CompareEntryVariable(variable));
335 getCurValueScope().removeValue(variable);
338 const ValueEntry* VariableManager::getParentValue (const Variable* variable) const
346 ValueEntry* entry = scope->findEntry(variable);
355 void VariableManager::setValue (const Variable* variable, ConstValueRangeAccess value)
359 if (!curScope.findEntry(variable))
362 ValueEntry* newEntry = curScope.allocate(variable);
363 std::vector<const ValueEntry*>::iterator cachePos = std::find(m_entryCache.begin(), m_entryCache.end(), CompareEntryVariable(variable));
371 curScope.setValue(variable, value);
405 vector<Variable*>& curLiveVars = curScope.getLiveVariables();
406 vector<Variable*>& parenLiveVars = parentScope.getLiveVariables();
410 Variable* liveVar = curLiveVars.back();
444 map<const Variable*, const ValueEntry*> oldValues;
450 set<const Variable*> addedVars;
461 const Variable* var = entry->getVariable();
488 addedVars.insert(var); // Record as cached variable.
496 const Variable* var = oldEntry->getVariable();