]> git.tdb.fi Git - libs/gl.git/commitdiff
Require all uniforms in a buffer-backed block to be present
authorMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:20:20 +0000 (17:20 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:35:10 +0000 (17:35 +0300)
source/error.h
source/programdata.cpp

index bb714506ccf908ced9aea4f057fa78dbfdd4370e..8af3ec6b4e3fb13394c943ecbc89280e3dfe9332 100644 (file)
@@ -41,6 +41,13 @@ public:
        virtual ~compile_error() throw() { }
 };
 
+class incomplete_uniform_block: public std::runtime_error
+{
+public:
+       incomplete_uniform_block(const std::string &w): std::runtime_error(w) { }
+       virtual ~incomplete_uniform_block() throw() { }
+};
+
 } // namespace GL
 } // namespace Msp
 
index f454fe5145f595ed1cd6c62488c5b433aaba9a83..912bc3c88a54c25a8c52199e8552a0d0a2b5eecc 100644 (file)
@@ -489,12 +489,25 @@ ProgramData::SharedBlock *ProgramData::get_shared_block(const Program::UniformBl
        if(i==blocks.end())
        {
                bool any_found = false;
-               for(vector<const Program::UniformInfo *>::const_iterator j=info.uniforms.begin(); (!any_found && j!=info.uniforms.end()); ++j)
-                       any_found = (find_uniform_index((*j)->name)>=0);
+               bool all_found = true;
+               for(vector<const Program::UniformInfo *>::const_iterator j=info.uniforms.begin(); j!=info.uniforms.end(); ++j)
+               {
+                       if(find_uniform_index((*j)->name)>=0)
+                               any_found = true;
+                       else
+                               all_found = false;
+               }
 
-               // TODO throw if all uniforms for a buffer-backed block are not found
                if(!any_found)
                        return 0;
+               else if(!all_found && info.bind_point>=0)
+               {
+#ifdef DEBUG
+                       IO::print(IO::cerr, "Warning: not all uniforms for block %s are present\n", info.name);
+#else
+                       throw incomplete_uniform_block(info.name);
+#endif
+               }
 
                UniformBlock *block;
                if(info.bind_point>=0)