Page 1 of 2

Change FB resolution without resetting

Posted: Mon Aug 15, 2016 11:51 am
by robmar
Anyone know how to change the main FB resolution in DX mode without resetting and reloading meshes and textures?

Re: Change FB resolution without resetting

Posted: Tue Aug 16, 2016 12:44 am
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.

Re: Change FB resolution without resetting

Posted: Tue Aug 16, 2016 8:11 am
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/

Re: Change FB resolution without resetting

Posted: Tue Aug 16, 2016 9:19 am
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.

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 12:10 am
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...

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 8:22 am
by robmar
Bad design.

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 9:24 am
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).

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 9:30 am
by robmar
Too inefficient for anything complex.

The question is what's tied to the FB such that recreation is needed?

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 9:40 am
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.

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 9:51 am
by robmar
Yes but with 2K or 4K screens, those extra texture copies will take many millisecs, which is bad news.

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 10:09 am
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).

Re: Change FB resolution without resetting

Posted: Wed Aug 17, 2016 10:13 am
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.

Re: Change FB resolution without resetting

Posted: Fri Aug 19, 2016 4:15 am
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)

Re: Change FB resolution without resetting

Posted: Fri Aug 19, 2016 8:21 am
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 :(

Re: Change FB resolution without resetting

Posted: Fri Aug 19, 2016 7:55 pm
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.