[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.

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

Postby Roland » Mon Jun 11, 2012 8:56 am

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

Re: What does Irrlicht do when vsync is activated?

Postby CuteAlien » Mon Jun 11, 2012 9:07 am

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.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5396
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: What does Irrlicht do when vsync is activated?

Postby Roland » Mon Jun 11, 2012 9:18 am

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

while(wait){}; ?
Roland
 
Posts: 11
Joined: Tue Jun 05, 2012 2:08 pm

Re: What does Irrlicht do when vsync is activated?

Postby CuteAlien » Mon Jun 11, 2012 9:41 am

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.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5396
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: What does Irrlicht do when vsync is activated?

Postby hendu » Mon Jun 11, 2012 9:45 am

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?
hendu
 
Posts: 1619
Joined: Sat Dec 18, 2010 12:53 pm

Re: What does Irrlicht do when vsync is activated?

Postby nespa » Mon Jun 11, 2012 11:01 am

vsync is to make a constant dynamic behavior in the scene; (if you limit to 60f/sec will be good);
nespa
 
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Re: What does Irrlicht do when vsync is activated?

Postby Roland » Mon Jun 11, 2012 11:43 am

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

Re: What does Irrlicht do when vsync is activated?

Postby Mel » Mon Jun 11, 2012 8:14 pm

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.
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1788
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: What does Irrlicht do when vsync is activated?

Postby CuteAlien » Mon Jun 11, 2012 9:02 pm

@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.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5396
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: What does Irrlicht do when vsync is activated?

Postby hybrid » Mon Jun 11, 2012 10:15 pm

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.
hybrid
Admin
 
Posts: 13972
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany


Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest