Change FB resolution without resetting

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Change FB resolution without resetting

Post by robmar »

Anyone know how to change the main FB resolution in DX mode without resetting and reloading meshes and textures?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Change FB resolution without resetting

Post by Mel »

There is no way to change the device resolution (neither DX nor GL), you have to either reset the whole engine, or use a rendering target.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Change FB resolution without resetting

Post by devsh »

You could allow irrlicht to do this in OpenGL if you were open to change a few lines of code :D

http://www.lighthouse3d.com/tutorials/g ... a-reshape/
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

Don't see why it should be so difficult, at the moment every time the player changes his view resolution he needs to reset the game... very inefficient.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Change FB resolution without resetting

Post by Mel »

Applications do reset stuff when they change the resolution, If it looks like it isn't a big deal is because their developers have made the effort to back up every resource and recreate it after the resolution has changed, but changing the device resolution is costly. Why is it so dificult? ask the API creators...
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

Bad design.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Change FB resolution without resetting

Post by CuteAlien »

Alternative option: Use one resolution (the desktop resolution). Render to texture (of any size) and then scale that texture to that resolution. I haven't tested that yet myself, so not sure yet if that's a good option. But I'm planning to do so for my game in the future. Reason is that it's likely the better solution on systems outside of Windows anyway. Changing fullscreen resolution in X11 just messes with WindowManagers and on mobile systems it's even more tricky (or even impossible?). Also I read some months ago that some (new) monitors don't like resolution switches at all. Search for screenquad class in forum for how to do that (I think some implementation posted to code-snippets in the past, otherwise check XEffects which should also have one).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

Too inefficient for anything complex.

The question is what's tied to the FB such that recreation is needed?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Change FB resolution without resetting

Post by CuteAlien »

I think it has something to do with the texture-handling. Maybe because not just resolution but also bit-depth is connected to the device.
But I don't think the solution with the rendertarget will be that inefficient, it just takes 2 triangles to render that. And for any kind of full-screen effect (or good shadows) you will have that code anyway - so as bonus you are half-way there to do nice effects.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

Yes but with 2K or 4K screens, those extra texture copies will take many millisecs, which is bad news.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Change FB resolution without resetting

Post by CuteAlien »

Hm, can't tell without testing. But it's all happening in graphic-card memory, so I hope it won't be too expensive. I suspect with some screens something like that is going on anyway (as LCD screens really only have one resolution), thought not sure where this is done currently (graphic card or some kinda solution inside the monitors).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

Yes you're right, the RT will be in video memory, as is the FB, so it should be much quicker.

Still seems a bit messy somehow, but it might be the way to go.
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Change FB resolution without resetting

Post by Cube_ »

an RT isn't significantly more costly, two triangles and one texture (since it's render to texture, then render that texture to your RT) - it doesn't add much in terms of overhead, one drawcall or so (and is required for most all interesting postpro effects anyway).

This isn't really a problem with irrlicht anyway, that's because of how microsoft designed directx and how the opengl consortium designed opengl - to change a framebuffer you need to reinitialize, this is SIGNIFICANTLY more expensive than changing a RT and still won't let you do anything interesting in postpro (or have good shadows that aren't extremely expensive)
"this is not the bottleneck you are looking for"
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Change FB resolution without resetting

Post by robmar »

I do my post effects in the pixel shader, so for my code its an extra op when I already can't achieve good frame rates on even mid/high GPUs.

That said I guess you must be right :(
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Change FB resolution without resetting

Post by Cube_ »

robmar wrote:I do my post effects in the pixel shader, so for my code its an extra op when I already can't achieve good frame rates on even mid/high GPUs.

That said I guess you must be right :(
profile your code, I guarantee the bottleneck lies elsewhere, find what's slow then find why it's slow and see what can be done to remedy it.
Still, the other option which can yield a minute boost per frame is to re-set up the FB, but that will stall while applying the new settings - a lot of older games do this.
"this is not the bottleneck you are looking for"
Post Reply