From 56133280d92c08c1c649a725260a6c4d5afb5e75 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 23 Jun 2020 17:20:20 +0300 Subject: [PATCH] Require all uniforms in a buffer-backed block to be present --- source/error.h | 7 +++++++ source/programdata.cpp | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/error.h b/source/error.h index bb714506..8af3ec6b 100644 --- a/source/error.h +++ b/source/error.h @@ -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 diff --git a/source/programdata.cpp b/source/programdata.cpp index f454fe51..912bc3c8 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -489,12 +489,25 @@ ProgramData::SharedBlock *ProgramData::get_shared_block(const Program::UniformBl if(i==blocks.end()) { bool any_found = false; - for(vector::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_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) -- 2.45.2