Re: [AD] PATCH: sleep in xwindows vsync emulation |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Tue, 2006-03-21 at 18:41 -0800, Chris wrote:
> On Tuesday 21 March 2006 04:47, Hans de Goede wrote:
> > I noticed while porting a game to allegro that it was a cpuhog, it
> > truned out that it used the vsync() call to regulate its framerate and
> > that the current vsync emulation in xwin.c busy waits, which is really
> > not the unix way.
> >
> > Attached a simple patch which causes allegro to sleep
> > while waiting in the vsync emulation function.
>
> Is it really safe to assume vsync should rest the cpu? From my experiences on
> Windows, it doesn't. In fact, if the return to the program isn't controlled
> by the actual sync interrupt on such platforms, it'd miss the actual sync.
> Granted X only emulates this, but it should still return ASAP once the
> retrace counter ticks.
>
> Attached is a patch that uses sched_yield() instead, which should keep the
> excessive waiting down, while keeping vsync responsive to return ASAP.
Well, I just tried it here, and with the rest(1), my CPU will stay at 0%
and keep cool and fans will rotate slow.
With shed_yield, I get 100% usage, CPU heats up and fans start blasting
at deafening volume.
For a real vsync() implemented in the system gfx driver, the system
itseld would only return CPU to the program at the exact point the vsync
is happening, so I also would expect CPU usage to be 0 there (maybe
there is some X extension we can use for it, anyone knows more?). But
with the emulation, all we can do is just wait for some time - and rest
is as good an implementation of a wait as we have.
--
Elias Pschernig