]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programdata.cpp
Always update program uniforms if uniform names have changed
[libs/gl.git] / source / programdata.cpp
index 535ade962207103f29fc8db0b87ddefa2551a8cc..4b39d196affa388f2db9d005a50be087a2ed6f14 100644 (file)
@@ -147,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<float, 2, 2> &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<float, 3, 3> &m)
+{
+       uniform_matrix3(name, &m(0, 0));
+}
+
 void ProgramData::uniform_matrix3(const string &name, const float *v)
 {
        uniform(name, new UniformMatrix3x3f(v));
@@ -255,14 +265,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)