X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramdata.cpp;h=f75a4ebda945cbadd62de17f2c6c214eca121d0c;hb=30b779a9542b8e8ae5d23758c8b6da24d22c7fd7;hp=7705fac9786420bf47b5fc02edf088cd54b64ec5;hpb=5ae4b0008b25072b5716f0cb585133315625a661;p=libs%2Fgl.git diff --git a/source/programdata.cpp b/source/programdata.cpp index 7705fac9..f75a4ebd 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -21,6 +21,7 @@ ProgramData::ProgramData(): // Blocks are intentionally left uncopied ProgramData::ProgramData(const ProgramData &other): + uniform_slots(other.uniform_slots), uniforms(other.uniforms), last_block(0), buffer(0), @@ -36,6 +37,7 @@ ProgramData &ProgramData::operator=(const ProgramData &other) delete *i; uniforms.clear(); + uniform_slots = other.uniform_slots; for(vector::const_iterator i=other.uniforms.begin(); i!=other.uniforms.end(); ++i) uniforms.push_back((*i)->clone()); @@ -61,6 +63,9 @@ ProgramData::~ProgramData() void ProgramData::uniform(const string &name, Uniform *uni) { + if(name[name.size()-1]==']') + throw invalid_argument("ProgramData::uniform"); + SlotMap::iterator i = uniform_slots.find(name); if(i!=uniform_slots.end()) { @@ -142,11 +147,21 @@ void ProgramData::uniform4(const string &name, const float *v) uniform(name, new Uniform4f(v)); } +void ProgramData::uniform(const string &name, const LinAl::Matrix &m) +{ + uniform_matrix2(name, &m(0, 0)); +} + void ProgramData::uniform_matrix2(const string &name, const float *v) { uniform(name, new UniformMatrix2x2f(v)); } +void ProgramData::uniform(const string &name, const LinAl::Matrix &m) +{ + uniform_matrix3(name, &m(0, 0)); +} + void ProgramData::uniform_matrix3(const string &name, const float *v) { uniform(name, new UniformMatrix3x3f(v)); @@ -162,6 +177,11 @@ void ProgramData::uniform_matrix4(const string &name, const float *v) uniform(name, new UniformMatrix4x4f(v)); } +void ProgramData::uniform1_array(const string &name, unsigned n, const int *v) +{ + uniform(name, new UniformArray(n, v)); +} + void ProgramData::uniform1_array(const string &name, unsigned n, const float *v) { uniform(name, new UniformArray(n, v)); @@ -250,14 +270,15 @@ void ProgramData::apply() const Program::LayoutHash layout = prog->get_uniform_layout_hash(); ProgramUniforms &pu = programs[layout]; - if((dirty&pu.used)|pu.dirty) + Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U); + Mask affected = (dirty&pu.used) | force_dirty; + if(affected|pu.dirty) { /* If the global dirty flag affects this program, add it to per-program dirty flags and clear the global flag. A previously unseen program will always cause this to happen. */ - if(dirty&pu.used) + if(affected) { - Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U); for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i) i->second.dirty |= (dirty&i->second.used) | force_dirty; for(ProgramMap::iterator i=programs.begin(); i!=programs.end(); ++i)