From 24c58bfd2c3c80d879ec796b2f206bdba8d9e58d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 25 Jan 2021 04:04:11 +0200 Subject: [PATCH] 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. --- source/programdata.cpp | 13 +++++++------ source/programdata.h | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) 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; -- 2.43.0