src/liboslexec/instance.cpp
// We can statically init an int, not an atomic
We can statically init an int, not an atomic
We can statically init an int not an atomic
ShaderInstance::ShaderInstance (ShaderMaster::ref master,
                                string_view layername)
    : m_master(master),
      m_layername(layername),
      m_writes_globals(false),
      m_outgoing_connections(false),
      m_renderer_outputs(false), m_has_error_op(false), m_merged_unused(false),
      m_last_layer(false), m_entry_layer(false),
      m_firstparam(m_master->m_firstparam), m_lastparam(m_master->m_lastparam),
      m_maincodebegin(m_master->m_maincodebegin),
      m_maincodeend(m_master->m_maincodeend)
{
    m_id = ++(*(atomic_int *)&next_id);
    shadingsys().m_stat_instances += 1;
    m_Psym = findsymbol (Strings::P);
    m_Nsym = findsymbol (Strings::N);
    ShadingSystemImpl &ss (shadingsys());
    off_t parammem = vectorbytes (m_iparams)
        + vectorbytes (m_fparams) + vectorbytes (m_sparams);
    off_t totalmem = (parammem + sizeof(ShaderInstance));
    {
        spin_lock lock (ss.m_stat_mutex);
        ss.m_stat_mem_inst_paramvals += parammem;
        ss.m_stat_mem_inst += totalmem;
        ss.m_stat_memory += totalmem;
    }
}
ShaderInstance :: ShaderInstance ( ShaderMaster :: ref master , string_view layername ) : m_master ( master ) , m_layername ( layername ) , m_writes_globals ( false ) , m_outgoing_connections ( false ) , m_renderer_outputs ( false ) , m_has_error_op ( false ) , m_merged_unused ( false ) , m_last_layer ( false ) , m_entry_layer ( false ) , m_firstparam ( m_master -> m_firstparam ) , m_lastparam ( m_master -> m_lastparam ) , m_maincodebegin ( m_master -> m_maincodebegin ) , m_maincodeend ( m_master -> m_maincodeend ) { m_id = ++ ( * ( atomic_int * ) & next_id ) ; shadingsys ( ) . m_stat_instances += 1 ; m_Psym = findsymbol ( Strings :: P ) ; m_Nsym = findsymbol ( Strings :: N ) ; ShadingSystemImpl & ss ( shadingsys ( ) ) ; off_t parammem = vectorbytes ( m_iparams ) + vectorbytes ( m_fparams ) + vectorbytes ( m_sparams ) ; off_t totalmem = ( parammem + sizeof ( ShaderInstance ) ) ; { spin_lock lock ( ss . m_stat_mutex ) ; ss . m_stat_mem_inst_paramvals += parammem ; ss . m_stat_mem_inst += totalmem ; ss . m_stat_memory += totalmem ; } }
We can statically init an int, not an atomic
We can statically init an int not an atomic
//DON'T COPY  m_instsymbols(m_master->m_symbols), //DON'T COPY  m_instops(m_master->m_ops), m_instargs(m_master->m_args), // We don't copy the symbol table yet, it stays with the master, but // we'll keep track of local override information in m_instoverrides. // Make it easy for quick lookups of common symbols // Adjust statistics