From David Callu, "I found a bug in osg::Program.

in osg::Program::PerContextProgram :

typedef std::vector<UniformModifiedCountPair> LastAppliedUniformList;
should be
typedef std::map<unsigned int, UniformModifiedCountPair> LastAppliedUniformList;

Intel driver can use index uniform value > 200000.
With a std::vector, this index uniform value generate an out of memory error

Nothing in OpenGL or GLSL specification define index uniform value rules.
And all other implementation that deal with uniform index in osg::Program
use a std::map.
This fix could have a little performance impact but this is the cost
to pay to work with
all driver."
This commit is contained in:
Robert Osfield 2012-03-01 10:38:28 +00:00
parent 2907284d00
commit 2c7b82b401

View File

@ -268,13 +268,7 @@ class OSG_EXPORT Program : public osg::StateAttribute
void resetAppliedUniforms() const
{
for(LastAppliedUniformList::iterator itr=_lastAppliedUniformList.begin();
itr!=_lastAppliedUniformList.end();
++itr)
{
(*itr).first = 0;
(*itr).second = 0;
}
_lastAppliedUniformList.clear();
}
@ -283,7 +277,6 @@ class OSG_EXPORT Program : public osg::StateAttribute
GLint location = getUniformLocation(uniform.getNameID());
if (location>=0)
{
if ((unsigned int)location>=_lastAppliedUniformList.size()) _lastAppliedUniformList.resize(location+1);
const Uniform* lastAppliedUniform = _lastAppliedUniformList[location].first.get();
if (lastAppliedUniform != &uniform)
{
@ -352,7 +345,7 @@ class OSG_EXPORT Program : public osg::StateAttribute
UniformBlockMap _uniformBlockMap;
typedef std::pair<osg::ref_ptr<const osg::Uniform>, unsigned int> UniformModifiedCountPair;
typedef std::vector<UniformModifiedCountPair> LastAppliedUniformList;
typedef std::map<unsigned int, UniformModifiedCountPair> LastAppliedUniformList;
mutable LastAppliedUniformList _lastAppliedUniformList;
typedef std::vector< ref_ptr<Shader> > ShaderList;