FPS, batch count and triangle count error using compositor

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
robert_sasu
Google Summer of Code Student
Google Summer of Code Student
Posts: 237
Joined: Mon Apr 02, 2012 11:07 am
x 42

FPS, batch count and triangle count error using compositor

Post by robert_sasu »

There is a big difference between triangles and batch count written to the HUD if I use compositor (in this case bloom) or not. I want every time to watch FPS, batch count and triangle count. Another strange thing is that, when I put precipitation and I have planar reflection even if bloom is working I get the triangles and batch count from the planar reflection, but values are 6 times more then usual. (Precipitations are not done with compositor - it is an elipsoid rendered over the camera you are using and there are textures moving down - performance is better then compositor, and also the effects are slightly better).

This is the code where I get batchCount and TriangleCount. mAdditionalBatchCount and mAdditionalTriangleCount are from PLanarReflection which is another node is SceneManager if precipitation is on.

Code: Select all

    void VideoSystem::UpdateStatus()
    {
        // Sum Batch/triangle count across all render targets.
        unsigned int bc = mAdditionalBatchCount; 
		unsigned int tc = mAdditionalTriangleCount;
        Ogre::RenderSystem::RenderTargetIterator iter =
                Root->getRenderSystem()->getRenderTargetIterator();
        while (iter.hasMoreElements())
        {
            Ogre::RenderTarget* rt = iter.getNext();
			if(rt->isAutoUpdated() || this->PrecipitationsEnabled)
			{
				bc += rt->getBatchCount();
				tc += rt->getTriangleCount();
			}
        }

        // Count fps only from active render forms.
        double fps = 0;
        for each (RenderForm^ rf in this->RenderFormList) 
		{
			Ogre::RenderWindow *ogreWindow = rf->OgreWindow;
            if (ogreWindow) 
			{
                fps += ogreWindow->getAverageFPS();
				bc += ogreWindow->getBatchCount();
				tc += ogreWindow->getTriangleCount();
            }
        }
		// add environment cube map stats
		bc += VideoSystem::CubeMapStats->Batches;
		tc += VideoSystem::CubeMapStats->Triangles;

        fps /= this->RenderFormList->Count;

        AutoMonitorLock lock(SimplePropertyLock);
		
		// Update status
		mStatus.AverageFps = fps;
		mStatus.BatchCount = bc;
		mStatus.TriangleCount = tc;

		Ogre::ColourValue col;
		col = Scene->getAmbientLight();
		mStatus.SceneAmbient = Vector(col.r, col.g, col.b);

        if (Environment->SunLight != nullptr) {
		    col = Environment->SunLight->getDiffuseColour();
		    mStatus.SunDiffuse = Vector(col.r, col.g, col.b);
		    col = Environment->SunLight->getSpecularColour();
		    mStatus.SunSpecular = Vector(col.r, col.g, col.b);
        } else {
            mStatus.SunDiffuse = Vector::Zero;
            mStatus.SunSpecular = Vector::Zero;
        }
        if (Environment->MoonLight != nullptr) {
		    col = Environment->MoonLight->getDiffuseColour();
		    mStatus.MoonDiffuse = Vector(col.r, col.g, col.b);
		    col = Environment->MoonLight->getSpecularColour();
		    mStatus.MoonSpecular = Vector(col.r, col.g, col.b);
        } else {
            mStatus.MoonDiffuse = Vector::Zero;
            mStatus.MoonSpecular = Vector::Zero;
        }
	}
FPS values I consider to be correct, because the situations are slightly different (and there are also other processes running on my PC). The problem is with batchcount and triangle count.
I have tried to put status update before rendering and after rendering the values are the same.
Any suggestion what to do ?

Bloom off
Image

Bloom on
Image

Bloom on, but rain
Image
Google Summer of Code 2013 Student
Topic: "DirectX 11 & Tessellation samples"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: FPS, batch count and triangle count error using composit

Post by drwbns »

Looks like a compositor bug to me...
User avatar
robert_sasu
Google Summer of Code Student
Google Summer of Code Student
Posts: 237
Joined: Mon Apr 02, 2012 11:07 am
x 42

Re: FPS, batch count and triangle count error using composit

Post by robert_sasu »

I hoped it would not be a compositor bug, in this project I am using Ogre1.7, and will not port it just to Ogre1.9, but after I resolved most of the bugs of that repo when using DirectX 11 Render System.

In the last picture you can see a lot of triangles, which I can't really explain. As planar reflection adds just 360k (360000) triangles, the scene rendered again. The fog is totally ogre based.
The rain is created like this: a manual object, elipsoid with 16 rings and 16 segments and 3 textures using to texture that elipsoid, the textures are 1024*1024. The performance is barely affected by rain, without planar reflection there is a 3 FPS drop. (same place) So that plus 1.5million triangles are just error on calculation again (I think).
Can anyone help me out with this, by giving me suggestion what to modify in UpdateStatus function to work - just the second part when rain is on, as the first part I consider to be compositor bug?
Last edited by robert_sasu on Wed Mar 13, 2013 3:49 pm, edited 1 time in total.
Google Summer of Code 2013 Student
Topic: "DirectX 11 & Tessellation samples"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: FPS, batch count and triangle count error using composit

Post by drwbns »

Maybe the bug source is where the batch and triangle counts are calculated. Are compositors being ignored there?
User avatar
robert_sasu
Google Summer of Code Student
Google Summer of Code Student
Posts: 237
Joined: Mon Apr 02, 2012 11:07 am
x 42

Re: FPS, batch count and triangle count error using composit

Post by robert_sasu »

The code of calculating traingles and batches is on my first post. I do not ignore compositor.
Google Summer of Code 2013 Student
Topic: "DirectX 11 & Tessellation samples"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: FPS, batch count and triangle count error using composit

Post by scrawl »

Well I am using this code and it works fine even with compositors.

Code: Select all

        unsigned int triCount = 0;
        unsigned int batchCount = 0;

        if (compositorsEnabled)
        {
            CompositorInstance* c = NULL;
            CompositorChain* chain = CompositorManager::getSingleton().getCompositorChain (viewport);
            // accumlate 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);
                    RenderTarget* rt;
                    for (unsigned int j = 0; j < c->getTechnique()->getNumTargetPasses(); ++j)
                    {
                        std::string textureName = c->getTechnique()->getTargetPass(j)->getOutputName();
                        rt = c->getRenderTarget(textureName);
                        triCount += rt->getTriangleCount();
                        batchCount += rt->getBatchCount();
                    }
                }
            }
        }
        else
        {
            triCount = stats.triangleCount;
            batchCount = stats.batchCount;
        }
I guess compositor render targets are not present in the RenderTargetIterator, because they're pretty much internal.
User avatar
robert_sasu
Google Summer of Code Student
Google Summer of Code Student
Posts: 237
Joined: Mon Apr 02, 2012 11:07 am
x 42

Re: FPS, batch count and triangle count error using composit

Post by robert_sasu »

Thanks scrawl for your response and code :) I will try it Friday.
Google Summer of Code 2013 Student
Topic: "DirectX 11 & Tessellation samples"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Assaf Raman
Rykemapo
Gnoblar
Posts: 6
Joined: Wed Apr 30, 2014 2:35 pm
x 2

Re: FPS, batch count and triangle count error using composit

Post by Rykemapo »

I realize this thread is old, but there seemed to be no closure, i.e. "Thanks I tried it and it worked".
I ran into the same problem and scrawl's code works.

Thanks, I tried it and it worked.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: FPS, batch count and triangle count error using composit

Post by scrawl »

Haha, good to know :)
Post Reply