[solved] What does Irrlicht do when vsync is activated?

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.
Post Reply
Roland
Posts: 11
Joined: Tue Jun 05, 2012 2:08 pm

[solved] What does Irrlicht do when vsync is activated?

Post by Roland »

As I wrote in an other thread, I am running my world and irrlicht in seperate threads. I want the world to run its own speed and let irrlicht draw the scene indepent of the word update cycle.

I figured, I dont need 3000 FPS, so I activated vsync in order to limit the amount of computation time, irrlicht requires. Now, I have a problem, the irrlicht thread does not yield its ressources in between frames. That meens, the world gets updated only once per frame, which was not the idea. Of course, I could take care of the synchronisation my self, but thats not particularly elegant. s there an option I have to activate in order to tell irrlicht to yield the thread if it is just waiting? Or is it in princliple not guild to do that?

Thx for your help,
Roland

edit: solved
Last edited by Roland on Tue Jun 12, 2012 12:13 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9688
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What does Irrlicht do when vsync is activated?

Post by CuteAlien »

Irrlicht uses this to set the corresponding flags to wait for a sync in the drivers. So D3DPRESENT_INTERVAL_ONE in DirectX and eglSwapInterval in OpenGL.
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
Roland
Posts: 11
Joined: Tue Jun 05, 2012 2:08 pm

Re: What does Irrlicht do when vsync is activated?

Post by Roland »

And what does it do during waiting so that the thread does not yield its ressources?

while(wait){}; ?
CuteAlien
Admin
Posts: 9688
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What does Irrlicht do when vsync is activated?

Post by CuteAlien »

Sorry, you have to ask that the driver vendors. I think neither OpenGL nor DirectX do specify that (or at least I didn't find any comments about it in the documentation I've seen).
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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: What does Irrlicht do when vsync is activated?

Post by hendu »

The usual behavior is to sleep, but I wouldn't be surprised if it was a busy-wait in some drivers.

BTW are you running on a single core? Why would yielding matter nowadays?
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Re: What does Irrlicht do when vsync is activated?

Post by nespa »

vsync is to make a constant dynamic behavior in the scene; (if you limit to 60f/sec will be good);
Roland
Posts: 11
Joined: Tue Jun 05, 2012 2:08 pm

Re: What does Irrlicht do when vsync is activated?

Post by Roland »

For my application, the gui is running independently of the core and takes only a fraction of the total computation power. Therefore, I want to give my "world" as much power as possible and not waste half the computation time on the GUI, waiting to take an other turn. On the other hand, I want both to run on independent speeds. I do not want either to depend on the other. Therefore, both run in sperated threads.

For games, the refreshrate should be as constant as possible and I just realised that the desired accuracy can not be provided by the sceduler of a general (= not realtime) OS. So its no wonder the driver makes a busy wait until the time has come to render an other frame. I was somehow hoping to find a "natural" solution for the waiting cycle, but I guess I have to do it manually. Its not importent for my application to have a absolut constant framerate, so I will use a manual sleep command using the boost library.

Thx everyone and cheers!
Roland

PS: Edith rephrased the text a it to make it more readable ;-)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: What does Irrlicht do when vsync is activated?

Post by Mel »

I think Irrlicht does actually nothing, it just sends the data to the screen, and waits for the vertical syncronization signal to continue. Irrlicht isn't multithreaded, so i think it is safe to asume it just waits, and keeps all its resources locked, so you can't do anything with it during that time.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
CuteAlien
Admin
Posts: 9688
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What does Irrlicht do when vsync is activated?

Post by CuteAlien »

@Mel: This hasn't to do much with Irrlicht at all. Irrlicht just passes the flag on to opengl and directX and they change their behavior when swapping buffers. As far as I can see this is happening inside driver code.
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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: What does Irrlicht do when vsync is activated?

Post by hybrid »

Yes, the wait happens after the full scene is rendered and the back buffer is to be swapped into the front. This swap will be delayed until the blank has happened. The driver will return immediately, though, so you can do other things. Only if you want to render again, it will block at some point. First, those commands will queue up, though.
Post Reply