Merge remote branch 'scrawl/trianglebatchcount'

actorid
Marc Zinnschlag 13 years ago
commit 2b68e4d489

@ -126,9 +126,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// update GUI // update GUI
Ogre::RenderWindow* window = mOgre->getWindow(); Ogre::RenderWindow* window = mOgre->getWindow();
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), unsigned int tri, batch;
window->getTriangleCount(), MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
window->getBatchCount()); MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame); MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame);
} }

@ -143,12 +143,12 @@ void HUD::setFPS(float fps)
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps)); fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
} }
void HUD::setTriangleCount(size_t count) void HUD::setTriangleCount(unsigned int count)
{ {
trianglecounter->setCaption(boost::lexical_cast<std::string>(count)); trianglecounter->setCaption(boost::lexical_cast<std::string>(count));
} }
void HUD::setBatchCount(size_t count) void HUD::setBatchCount(unsigned int count)
{ {
batchcounter->setCaption(boost::lexical_cast<std::string>(count)); batchcounter->setCaption(boost::lexical_cast<std::string>(count));
} }

@ -16,8 +16,8 @@ namespace MWGui
void setEffect(const char *img); void setEffect(const char *img);
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value); void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
void setFPS(float fps); void setFPS(float fps);
void setTriangleCount(size_t count); void setTriangleCount(unsigned int count);
void setBatchCount(size_t count); void setBatchCount(unsigned int count);
void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible); void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible);
void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible); void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible);
void setFpsLevel(const int level); void setFpsLevel(const int level);

@ -159,7 +159,7 @@ namespace MWGui
MyGUI::Gui* getGui() const { return gui; } 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; mFPS = fps;
mTriangleCount = triangleCount; mTriangleCount = triangleCount;
@ -295,8 +295,8 @@ namespace MWGui
int showFPSLevel; int showFPSLevel;
float mFPS; float mFPS;
size_t mTriangleCount; unsigned int mTriangleCount;
size_t mBatchCount; unsigned int mBatchCount;
void onDialogueWindowBye(); void onDialogueWindowBye();

@ -2,6 +2,8 @@
#include <OgreViewport.h> #include <OgreViewport.h>
#include <OgreCompositorManager.h> #include <OgreCompositorManager.h>
#include <OgreCompositorChain.h>
#include <OgreCompositionTargetPass.h>
using namespace MWRender; using namespace MWRender;
@ -69,3 +71,38 @@ void Compositors::removeAll()
mCompositors.clear(); 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();
}
}
}
}

@ -44,6 +44,10 @@ namespace MWRender
*/ */
void addCompositor (const std::string& name, const int priority); void addCompositor (const std::string& name, const int priority);
bool anyCompositorEnabled();
void countTrianglesBatches(unsigned int &triangles, unsigned int &batches);
void removeAll (); void removeAll ();
protected: protected:

@ -677,4 +677,17 @@ void RenderingManager::applyCompositors()
mWater->assignTextures(); 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 } // namespace

@ -118,14 +118,16 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
void disableLights(); void disableLights();
void enableLights(); void enableLights();
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }; bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }; OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
Shadows* getShadows(); Shadows* getShadows();
void switchToInterior(); void switchToInterior();
void switchToExterior(); void switchToExterior();
void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
void setGlare(bool glare); void setGlare(bool glare);
void skyEnable (); void skyEnable ();
void skyDisable (); void skyDisable ();

@ -1039,4 +1039,9 @@ namespace MWWorld
{ {
mRendering->processChangedSettings(settings); mRendering->processChangedSettings(settings);
} }
void World::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches)
{
mRendering->getTriangleBatchCount(triangles, batches);
}
} }

@ -133,6 +133,8 @@ namespace MWWorld
void adjustSky(); void adjustSky();
void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
void setFallbackValues(std::map<std::string,std::string> fallbackMap); void setFallbackValues(std::map<std::string,std::string> fallbackMap);
std::string getFallback(std::string key); std::string getFallback(std::string key);

Loading…
Cancel
Save