gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 774 forks source link

Registry::programRepo is shared across all contexts #2462

Closed calumr closed 5 months ago

calumr commented 6 months ago

If you use osgEarth in more than one context in a single process, a VirtualProgram that is identical in both contexts will not be compiled on the second context to use it. This eventually causes a crash when trying to link an uncompiled program.

Registry::programRepo uses a key for each program that is a hash of the source, but it should probably include the context id too.

gwaldron commented 6 months ago

Can you please provide some evidence of this? Or a reproduction case? The osg::Program object tracks its own per-context state in its internal osg::Program::PerContextProgram (PCP) construct. So when VirtualProgram pulls an existing program from the repo, it always checks the currently active PCP and compiles it on demand as necessary.