Re: [AD] Added yield_timeslice to vsync

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 2004-04-04 at 04:53, Jon Rafkind wrote:
> Attached is a very small patch( one line ) that adds yield_timeslice to 
> the vsync call for the xwindows driver. I suppose yielding in the loop 
> while waiting for the vsync to finish is a bit dangerous, but I didnt 
> encounter any problems with it. I guess yield_timeslice could be added 
> to the other drivers, but I wanted to wait and see if it is ok before I 
> go ahead and do that.

I just tried it, and I also notice no visual difference. Of course, the
X11 driver doesn't do a real vsync. XSync just forces synchronization
with the server - but that has nothing to do with the monitor refresh.
The busy loop is just the same as "rest" - so I see no problem at all
adding yield_timeslice with your patch.

For other drivers, where vsync synchronizes to the monitor refresh -
this really can be dangerous, since e.g. a 100 Hz monitor will refresh
every 10 ms - the timeslice in linux can be 20 ms :| To do this without
busy waiting in Allegro, there would need to be a blocking vsync command
built into the OS. It would say: Wait vor the vsync, and then return in
the very moment it occurs. Maybe this is the case e.g. with DirectX? In
that case, yield_timeslice wouldn't be needed.

I guess, we just need to try it. I don't have access to DirectX or DGA
currently, just X11 and OpenGL - so I can't do much more testing.

About yield_timeslice, maybe we should make a config option for it, like
this:

[system]
busy_waiting = on/off

Default would be off, so Allegro programs would behave nice. If you set
it to on, yield_timeslice would do the 4.1.12 behavior. Then we could
use yield_timeslice whereever something waits, but users/games would
have an option to just run without busy waiting and 100% CPU usage,
therefore possibly getting better precision.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/