Page 1 of 1

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

Posted: Mon Jun 11, 2012 8:56 am
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

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 9:07 am
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.

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 9:18 am
by Roland
And what does it do during waiting so that the thread does not yield its ressources?

while(wait){}; ?

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 9:41 am
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).

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 9:45 am
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?

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 11:01 am
by nespa
vsync is to make a constant dynamic behavior in the scene; (if you limit to 60f/sec will be good);

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 11:43 am
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 ;-)

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 8:14 pm
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.

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 9:02 pm
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.

Re: What does Irrlicht do when vsync is activated?

Posted: Mon Jun 11, 2012 10:15 pm
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.