diff --git a/OgreMain/include/OgreCompositor.h b/OgreMain/include/OgreCompositor.h index ebc3775404d..c3713270791 100644 --- a/OgreMain/include/OgreCompositor.h +++ b/OgreMain/include/OgreCompositor.h @@ -166,10 +166,10 @@ namespace Ogre { //TODO GSOC : These typedefs are duplicated from CompositorInstance. Solve? /// Map from name->local texture - typedef std::map GlobalTextureMap; + typedef std::unordered_map GlobalTextureMap; GlobalTextureMap mGlobalTextures; /// Store a list of MRTs we've created - typedef std::map GlobalMRTMap; + typedef std::unordered_map GlobalMRTMap; GlobalMRTMap mGlobalMRTs; }; /** @} */ diff --git a/OgreMain/include/OgreCompositorInstance.h b/OgreMain/include/OgreCompositorInstance.h index 364c3984990..9a211814772 100644 --- a/OgreMain/include/OgreCompositorInstance.h +++ b/OgreMain/include/OgreCompositorInstance.h @@ -327,10 +327,10 @@ namespace Ogre { /// Is this instance allocating resources? bool mAlive; /// Map from name->local texture. - typedef std::map LocalTextureMap; + typedef std::unordered_map LocalTextureMap; LocalTextureMap mLocalTextures; /// Store a list of MRTs we've created. - typedef std::map LocalMRTMap; + typedef std::unordered_map LocalMRTMap; LocalMRTMap mLocalMRTs; typedef std::map ReserveTextureMap; /** Textures that are not currently in use, but that we want to keep for now, diff --git a/OgreMain/src/OgreCompositor.cpp b/OgreMain/src/OgreCompositor.cpp index 534e6918b39..6fe67984900 100644 --- a/OgreMain/src/OgreCompositor.cpp +++ b/OgreMain/src/OgreCompositor.cpp @@ -157,7 +157,6 @@ CompositionTechnique* Compositor::getSupportedTechnique(const String& schemeName //----------------------------------------------------------------------- void Compositor::createGlobalTextures() { - static size_t dummyCounter = 0; if (mSupportedTechniques.empty()) return; @@ -184,14 +183,14 @@ void Compositor::createGlobalTextures() //TODO GSOC : Heavy copy-pasting from CompositorInstance. How to we solve it? + // unique, even without dummyCounter, as these are global + String baseName = StringUtil::format("%s.%s", def->name.c_str(), mName.c_str()); + /// Make the tetxure RenderTarget* rendTarget; if (def->formatList.size() > 1) { - String MRTbaseName = "mrt/c" + StringConverter::toString(dummyCounter++) + - "/" + mName + "/" + def->name; - MultiRenderTarget* mrt = - Root::getSingleton().getRenderSystem()->createMultiRenderTarget(MRTbaseName); + MultiRenderTarget* mrt = Root::getSingleton().getRenderSystem()->createMultiRenderTarget(baseName); mGlobalMRTs[def->name] = mrt; // create and bind individual surfaces @@ -200,7 +199,7 @@ void Compositor::createGlobalTextures() p != def->formatList.end(); ++p, ++atch) { - String texname = MRTbaseName + "/" + StringConverter::toString(atch); + String texname = StringUtil::format("mrt%zu.%s", atch, baseName.c_str()); TexturePtr tex; tex = TextureManager::getSingleton().createManual( @@ -223,8 +222,7 @@ void Compositor::createGlobalTextures() } else { - String texName = "c" + StringConverter::toString(dummyCounter++) + - "/" + mName + "/" + def->name; + String texName = baseName; // space in the name mixup the cegui in the compositor demo // this is an auto generated name - so no spaces can't hart us. diff --git a/OgreMain/src/OgreCompositorInstance.cpp b/OgreMain/src/OgreCompositorInstance.cpp index 6327b13292e..10c4c22ccb4 100644 --- a/OgreMain/src/OgreCompositorInstance.cpp +++ b/OgreMain/src/OgreCompositorInstance.cpp @@ -684,23 +684,24 @@ void CompositorInstance::createResources(bool forResizeOnly) fsaaHint = BLANKSTRING; } hwGamma = hwGamma || def->hwGammaWrite; - + + // need dummy counter as there may be multiple definitions with the same name in the chain + String baseName = StringUtil::format("%s.chain%zu.%s", def->name.c_str(), dummyCounter++, + mChain->getViewport()->getTarget()->getName().c_str()); + /// Make the tetxure if (def->formatList.size() > 1) { - String MRTbaseName = "mrt/c" + StringConverter::toString(dummyCounter++) + - "/" + def->name + "/" + mChain->getViewport()->getTarget()->getName(); - MultiRenderTarget* mrt = - Root::getSingleton().getRenderSystem()->createMultiRenderTarget(MRTbaseName); + MultiRenderTarget* mrt = Root::getSingleton().getRenderSystem()->createMultiRenderTarget(baseName); mLocalMRTs[def->name] = mrt; - + // create and bind individual surfaces size_t atch = 0; for (PixelFormatList::iterator p = def->formatList.begin(); p != def->formatList.end(); ++p, ++atch) { - String texname = MRTbaseName + "/" + StringConverter::toString(atch); + String texname = StringUtil::format("mrt%zu.%s", atch, baseName.c_str()); String mrtLocalName = getMRTTexLocalName(def->name, atch); TexturePtr tex; if (def->pooled) @@ -733,9 +734,8 @@ void CompositorInstance::createResources(bool forResizeOnly) } else { - String texName = "c" + StringConverter::toString(dummyCounter++) + - "/" + def->name + "/" + mChain->getViewport()->getTarget()->getName(); - + String texName = baseName; + // space in the name mixup the cegui in the compositor demo // this is an auto generated name - so no spaces can't hart us. std::replace( texName.begin(), texName.end(), ' ', '_' ); @@ -882,7 +882,7 @@ void CompositorInstance::deriveTextureRenderTargetOptions( //--------------------------------------------------------------------- String CompositorInstance::getMRTTexLocalName(const String& baseName, size_t attachment) { - return StringUtil::format("%s/%zu", baseName.c_str(), attachment); + return StringUtil::format("mrt%zu.%s", attachment, baseName.c_str()); } //----------------------------------------------------------------------- void CompositorInstance::freeResources(bool forResizeOnly, bool clearReserveTextures)