Render to Texture performance

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Render to Texture performance

Post by The_Glitch »

I've tracked down a huge frame rate drop I've been having in my project to using render to texture effects. I also did a further test and did regular rendering in my project no rtt effects at all and frame rate stays solid. I've read a old thread from 2014 about someone having similar issues and there were a lot of proposed changes for irrlicht were they ever made?



http://irrlicht.sourceforge.net/forum/v ... =4&t=49634
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Render to Texture performance

Post by Nadro »

In trunk or shader-pipeline? In trunk you should use new setRenderTargetEx.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

[url]svn://svn.code.sf.net/p/irrlicht/code/branches/shader-pipeline[/url]

Is this the latest shader-pipeline? If so I have this one, if not then link please.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

Nadro I don't think I have the one that has latest changes did you make changes to shader-pipeline? In svn tortoise is says your latest changes are from at least mid to early 2015?????


Also an trunk example I checked render to texture example and I saw these changes

Code: Select all

driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0));
 

Mine does not have these.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render to Texture performance

Post by hendu »

I'm not saying there isn't an issue with irr, but that old thread had none. It was about wrong expectations, hw and sw performed as they should.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

I think my version of irrlicht doesn't reflect the newest changes. Also hendu I did a test and did not use any of my shaders and did a simple rtt and aplid it to a screenquad and assigned an EMT_SOLID material to it for testing purposes and my app starts at 60 fps with vsync and a few seconds into the application it drops to 40 and never recovers.

If I disable rtt and just use default rendering it never happens stays at 60fps.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Render to Texture performance

Post by Nadro »

Hi,

setRenderTargetEx is available only in trunk, I'll update shader-pipeline when v1.9 will be finished (it's really close).

Cheers,
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render to Texture performance

Post by hendu »

Vsynced numbers are not useful. They don't tell you if the real perf is 60 or something more - if it was 60, then a RTT switch can easily drop it to 59, which in a vsynced display means 40.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

I reduced my rtt buffers to just 4 and frame rate is solid. I just need to figure a way for decent blur without adding more rtt buffers.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Render to Texture performance

Post by Mel »

You can chain effects most of the times using just 2 rendertargets. One holds the results of the last operation, while the other is used to render the next operation, then, swap. Also, downsampling helps. Using a rendertarget half of the dimensions of the original rendertarget is almost unnoticeable, and produces good results when blurring.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

How can I make the rendertargets swap when I tried one just overwrites the other.

Code: Select all

 
 
driver->setRenderTarget(blur3, true, true, video::SColor(0, 0, 0, 0));
 
            quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)blur_shaderH);
            quad->getMaterial(0).setTexture(0, extracted_scene);
            quad->setMaterialFlag(EMF_TRILINEAR_FILTER, true);
            quad->render();
 
            driver->setRenderTarget(0, true, true, 0);
 
            driver->setRenderTarget(blur4, true, true, video::SColor(0, 0, 0, 0));
 
            quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)blur_shaderV);
            quad->getMaterial(0).setTexture(0, blur3);
            quad->setMaterialFlag(EMF_TRILINEAR_FILTER, true);
            quad->render();
 
            driver->setRenderTarget(0, true, true, 0);
 
 
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render to Texture performance

Post by hendu »

You are doing pointless clears there, and the switch back to framebuffer before switching to a RTT is costing you performance too.

Is that my quad? In that case, render() draws to the framebuffer, not the RTT - you should use render(rtt), no need to switch to it yourself.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Render to Texture performance

Post by The_Glitch »

Thanks hendu reduced the clears to just one. Also what do you mean with the render()?? Do you mean quad->render()??
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render to Texture performance

Post by hendu »

Yes.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Render to Texture performance

Post by devsh »

One of the problems with irrlicht is that there is no MRT object, so an FBO is made for each render target texture instead, and that is mutated to attach other textures as outputs 1 and onwards. This is really slow in some drivers according to Valve and Intel
Post Reply