diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e192b1f88..5c5a586af 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -126,9 +126,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); - MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), - window->getTriangleCount(), - window->getBatchCount()); + unsigned int tri, batch; + MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch); + MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch); MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame); } diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 95d66eb81..4ad9845f0 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -143,12 +143,12 @@ void HUD::setFPS(float fps) fpscounter->setCaption(boost::lexical_cast((int)fps)); } -void HUD::setTriangleCount(size_t count) +void HUD::setTriangleCount(unsigned int count) { trianglecounter->setCaption(boost::lexical_cast(count)); } -void HUD::setBatchCount(size_t count) +void HUD::setBatchCount(unsigned int count) { batchcounter->setCaption(boost::lexical_cast(count)); } diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 0bfe5c20f..c6bcdd4e9 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -16,8 +16,8 @@ namespace MWGui void setEffect(const char *img); void setValue (const std::string& id, const MWMechanics::DynamicStat& value); void setFPS(float fps); - void setTriangleCount(size_t count); - void setBatchCount(size_t count); + void setTriangleCount(unsigned int count); + void setBatchCount(unsigned int count); void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible); void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible); void setFpsLevel(const int level); diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 37f30c59a..fd1e61021 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -159,7 +159,7 @@ namespace MWGui MyGUI::Gui* getGui() const { return gui; } - void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount) + void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) { mFPS = fps; mTriangleCount = triangleCount; @@ -295,8 +295,8 @@ namespace MWGui int showFPSLevel; float mFPS; - size_t mTriangleCount; - size_t mBatchCount; + unsigned int mTriangleCount; + unsigned int mBatchCount; void onDialogueWindowBye(); diff --git a/apps/openmw/mwrender/compositors.cpp b/apps/openmw/mwrender/compositors.cpp index 6f97269ab..b1c98a306 100644 --- a/apps/openmw/mwrender/compositors.cpp +++ b/apps/openmw/mwrender/compositors.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include using namespace MWRender; @@ -69,3 +71,38 @@ void Compositors::removeAll() mCompositors.clear(); } + +bool Compositors::anyCompositorEnabled() +{ + for (CompositorMap::iterator it=mCompositors.begin(); + it != mCompositors.end(); ++it) + { + if (it->second.first && mEnabled) + return true; + } + return false; +} + +void Compositors::countTrianglesBatches(unsigned int &triangles, unsigned int &batches) +{ + triangles = 0; + batches = 0; + + Ogre::CompositorInstance* c = NULL; + Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain (mViewport); + // accumulate tris & batches from all compositors with all their render targets + for (unsigned int i=0; i < chain->getNumCompositors(); ++i) + { + if (chain->getCompositor(i)->getEnabled()) + { + c = chain->getCompositor(i); + for (unsigned int j = 0; j < c->getTechnique()->getNumTargetPasses(); ++j) + { + std::string textureName = c->getTechnique()->getTargetPass(j)->getOutputName(); + Ogre::RenderTarget* rt = c->getRenderTarget(textureName); + triangles += rt->getTriangleCount(); + batches += rt->getBatchCount(); + } + } + } +} diff --git a/apps/openmw/mwrender/compositors.hpp b/apps/openmw/mwrender/compositors.hpp index bbd838b8e..e5dd7503c 100644 --- a/apps/openmw/mwrender/compositors.hpp +++ b/apps/openmw/mwrender/compositors.hpp @@ -44,6 +44,10 @@ namespace MWRender */ void addCompositor (const std::string& name, const int priority); + bool anyCompositorEnabled(); + + void countTrianglesBatches(unsigned int &triangles, unsigned int &batches); + void removeAll (); protected: diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 266362f9b..1029b5b60 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -677,4 +677,17 @@ void RenderingManager::applyCompositors() mWater->assignTextures(); } +void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) +{ + if (mCompositors->anyCompositorEnabled()) + { + mCompositors->countTrianglesBatches(triangles, batches); + } + else + { + triangles = mRendering.getWindow()->getTriangleCount(); + batches = mRendering.getWindow()->getBatchCount(); + } +} + } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 642c42930..20f22fcca 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -118,14 +118,16 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList void disableLights(); void enableLights(); - bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }; - OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }; + bool occlusionQuerySupported() { return mOcclusionQuery->supported(); } + OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; } Shadows* getShadows(); void switchToInterior(); void switchToExterior(); + void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches); + void setGlare(bool glare); void skyEnable (); void skyDisable (); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index e8d555689..79fd03e36 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -1039,4 +1039,9 @@ namespace MWWorld { mRendering->processChangedSettings(settings); } + + void World::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) + { + mRendering->getTriangleBatchCount(triangles, batches); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index e8391773b..34990574e 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -133,6 +133,8 @@ namespace MWWorld void adjustSky(); + void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches); + void setFallbackValues(std::map fallbackMap); std::string getFallback(std::string key);