1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-29 22:36:43 +00:00

Make suspending viewer threads the responsibility of the caller, not the shader manager.

This commit is contained in:
AnyOldName3 2017-12-17 23:55:19 +00:00
parent 229cc9696f
commit b08938485f
3 changed files with 6 additions and 9 deletions

View file

@ -244,7 +244,8 @@ namespace MWRender
for (auto itr = shadowDefines.begin(); itr != shadowDefines.end(); itr++) for (auto itr = shadowDefines.begin(); itr != shadowDefines.end(); itr++)
globalDefines[itr->first] = itr->second; globalDefines[itr->first] = itr->second;
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines, mViewer); // It is unnecessary to stop/start the viewer as no frames are being rendered yet.
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines);
mPathgrid.reset(new Pathgrid(mRootNode)); mPathgrid.reset(new Pathgrid(mRootNode));

View file

@ -337,12 +337,9 @@ namespace Shader
return DefineMap(mGlobalDefines); return DefineMap(mGlobalDefines);
} }
void ShaderManager::setGlobalDefines(DefineMap & defines, osg::ref_ptr<osgViewer::Viewer> viewer) void ShaderManager::setGlobalDefines(DefineMap & globalDefines)
{ {
mGlobalDefines = defines; mGlobalDefines = globalDefines;
bool threadsStarted = viewer->areThreadsRunning();
if (threadsStarted)
viewer->stopThreading();
for (auto shaderMapElement: mShaders) for (auto shaderMapElement: mShaders)
{ {
std::string templateId = shaderMapElement.first.first; std::string templateId = shaderMapElement.first.first;
@ -358,8 +355,6 @@ namespace Shader
continue; continue;
shader->setShaderSource(shaderSource); shader->setShaderSource(shaderSource);
} }
if (threadsStarted)
viewer->startThreading();
} }
void ShaderManager::releaseGLObjects(osg::State *state) void ShaderManager::releaseGLObjects(osg::State *state)

View file

@ -39,7 +39,8 @@ namespace Shader
/// Set the DefineMap used to construct all shaders /// Set the DefineMap used to construct all shaders
/// @param defines The DefineMap to use /// @param defines The DefineMap to use
void setGlobalDefines(DefineMap & defines, osg::ref_ptr<osgViewer::Viewer> viewer); /// @note This will change the source code for any shaders already created, potentially causing problems if they're being used to render a frame. It is recommended that any associated Viewers have their threading stopped while this function is running if any shaders are in use.
void setGlobalDefines(DefineMap & globalDefines);
void releaseGLObjects(osg::State* state); void releaseGLObjects(osg::State* state);