From: Mikko Rasa Date: Mon, 25 Jan 2021 02:04:11 +0000 (+0200) Subject: Throw an exception if there's too many uniforms in a ProgramData X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=24c58bfd2c3c80d879ec796b2f206bdba8d9e58d;p=libs%2Fgl.git Throw an exception if there's too many uniforms in a ProgramData I'd rather find out I need to make the mask wider than have a program unexplainably slow down. --- diff --git a/source/programdata.cpp b/source/programdata.cpp index 4a6c262a..4d8ca4dd 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -109,15 +109,16 @@ void ProgramData::uniform(const string &name, Uniform *uni) if(i>=0) { uniforms[i].replace_value(uni); - - if(static_cast(i)=MASK_BITS) + { + delete uni; + throw too_many_uniforms(name); + } + vector::iterator j = lower_bound(uniforms.begin(), uniforms.end(), name, uniform_name_compare); NamedUniform nu; diff --git a/source/programdata.h b/source/programdata.h index c367097b..d9eaf746 100644 --- a/source/programdata.h +++ b/source/programdata.h @@ -2,6 +2,7 @@ #define MSP_GL_PROGRAMDATA_H_ #include +#include #include #include "datatype.h" #include "matrix.h" @@ -11,6 +12,13 @@ namespace Msp { namespace GL { +class too_many_uniforms: public std::runtime_error +{ +public: + too_many_uniforms(const std::string &w): std::runtime_error(w) { } + virtual ~too_many_uniforms() throw() { } +}; + class Buffer; class Uniform; class UniformBlock;