本文整理汇总了C++中Symbol::dataoffset方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::dataoffset方法的具体用法?C++ Symbol::dataoffset怎么用?C++ Symbol::dataoffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::dataoffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
void
OSOReaderToMaster::symbol (SymType symtype, TypeSpec typespec, const char *name_)
{
ustring name(name_);
Symbol sym (name, typespec, symtype);
TypeDesc t = typespec.simpletype();
int nvals = t.aggregate * (t.is_unsized_array() ? 1 : t.numelements());
if (sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam) {
// Skip structs for now, they're just placeholders
if (typespec.is_structure()) {
}
else if (typespec.simpletype().basetype == TypeDesc::FLOAT) {
sym.dataoffset ((int) m_master->m_fdefaults.size());
expand (m_master->m_fdefaults, nvals);
} else if (typespec.simpletype().basetype == TypeDesc::INT) {
sym.dataoffset ((int) m_master->m_idefaults.size());
expand (m_master->m_idefaults, nvals);
} else if (typespec.simpletype().basetype == TypeDesc::STRING) {
sym.dataoffset ((int) m_master->m_sdefaults.size());
expand (m_master->m_sdefaults, nvals);
} else if (typespec.is_closure_based()) {
// Closures are pointers, so we allocate a string default taking
// adventage of their default being NULL as well.
sym.dataoffset ((int) m_master->m_sdefaults.size());
expand (m_master->m_sdefaults, nvals);
} else {
ASSERT (0 && "unexpected type");
}
}
if (sym.symtype() == SymTypeConst) {
if (typespec.simpletype().basetype == TypeDesc::FLOAT) {
sym.dataoffset ((int) m_master->m_fconsts.size());
expand (m_master->m_fconsts, nvals);
} else if (typespec.simpletype().basetype == TypeDesc::INT) {
sym.dataoffset ((int) m_master->m_iconsts.size());
expand (m_master->m_iconsts, nvals);
} else if (typespec.simpletype().basetype == TypeDesc::STRING) {
sym.dataoffset ((int) m_master->m_sconsts.size());
expand (m_master->m_sconsts, nvals);
} else {
ASSERT (0 && "unexpected type");
}
}
#if 0
// FIXME -- global_heap_offset is quite broken. But also not necessary.
// We made need to fix this later.
if (sym.symtype() == SymTypeGlobal) {
sym.dataoffset (m_shadingsys.global_heap_offset (sym.name()));
}
#endif
sym.lockgeom (m_shadingsys.lockgeom_default());
m_master->m_symbols.push_back (sym);
m_symmap[name] = int(m_master->m_symbols.size()) - 1;
// Start the index at which we add specified defaults
m_sym_default_index = 0;
}
示例2: lock
void
ShaderInstance::copy_code_from_master (ShaderGroup &group)
{
ASSERT (m_instops.empty() && m_instargs.empty());
// reserve with enough room for a few insertions
m_instops.reserve (master()->m_ops.size()+10);
m_instargs.reserve (master()->m_args.size()+10);
m_instops = master()->m_ops;
m_instargs = master()->m_args;
// Copy the symbols from the master
ASSERT (m_instsymbols.size() == 0 &&
"should not have copied m_instsymbols yet");
m_instsymbols = m_master->m_symbols;
// Copy the instance override data
// Also set the renderer_output flags where needed.
ASSERT (m_instoverrides.size() == (size_t)std::max(0,lastparam()));
ASSERT (m_instsymbols.size() >= (size_t)std::max(0,lastparam()));
if (m_instoverrides.size()) {
for (size_t i = 0, e = lastparam(); i < e; ++i) {
Symbol *si = &m_instsymbols[i];
if (m_instoverrides[i].valuesource() == Symbol::DefaultVal) {
// Fix the length of any default-value variable length array
// parameters.
if (si->typespec().is_unsized_array())
si->arraylen (si->initializers());
} else {
if (m_instoverrides[i].arraylen())
si->arraylen (m_instoverrides[i].arraylen());
si->valuesource (m_instoverrides[i].valuesource());
si->connected_down (m_instoverrides[i].connected_down());
si->lockgeom (m_instoverrides[i].lockgeom());
si->dataoffset (m_instoverrides[i].dataoffset());
si->data (param_storage(i));
}
if (shadingsys().is_renderer_output (layername(), si->name(), &group)) {
si->renderer_output (true);
renderer_outputs (true);
}
}
}
evaluate_writes_globals_and_userdata_params ();
off_t symmem = vectorbytes(m_instsymbols) - vectorbytes(m_instoverrides);
SymOverrideInfoVec().swap (m_instoverrides); // free it
// adjust stats
{
spin_lock lock (shadingsys().m_stat_mutex);
shadingsys().m_stat_mem_inst_syms += symmem;
shadingsys().m_stat_mem_inst += symmem;
shadingsys().m_stat_memory += symmem;
}
}