[SDL] Retrace sync. in Linux
David Olofson
david at olofson.net
Wed Sep 24 10:01:01 PDT 2003
On Wednesday 24 September 2003 12.11, eddie at odense.kollegienet.dk
wrote:
[...]
> I found this old post by Olofson:
> http://www.libsdl.org/pipermail/sdl/2001-January/032774.html
>
> Do anyone know if there has been some progress on the matter?
> Without having to run as root.
Dunno if anything is done to fix DGA, but I'm quite sure it could be
done. However, there's one major difference between DGA and other low
level "direct video" APIs, and OpenGL; the latter is asynchronous,
while the former are synchronous. This means that in the case of
OpenGL, the driver is the only part that has to be in strict "hard
sync" with the retrace, whereas with DGA, the application has to be
sync'ed as well. This turns out to be a real PITA in general purpose
OSes. You basically need an RTOS to do that kind of stuff properly.
Anyway, OpenGL is the way to go. It's the only remotely portable
solution that can reliably provide serious h/w acceleration. OpenGL
also provides asynchronous rendering, which cuts the applications
some more slack, allowing for more scheduling jitter without dropping
frames. Finally, the best part: Most OpenGL drivers for current
hardware (ie the closed source ones...) support retrace sync.
IMNSHO, "traditional" 2D acceleration is effectively obsolete, and s/w
2D rendering directly into VRAM has been an absolute last resort for
a good while. There are many different 2D APIs, most of which are
platform specific and/or have serious limitations and/or very few -
if any - accelerated drivers. As to "pure" s/w rendering, that's
practically useless for high quality animation due to performance
issues with CPU transfers through PCI and AGP. If you really want s/w
rendering, you should use busmaster DMA to transfer the output to the
screen - but unfortutately, virtually no targets, apart from
DirectDraw on reasonably well supported hardware, support this.
That said, s/w 2D rendering can still be useful for less demanding
applications. It allows the applications to run on pretty much
anything, and even though this method scales very poorly (ie your 3+
GHz CPU and 500 MHz GPU won't help much at all), there are ways to
add full h/w acceleration very easily to most such applications.
glSDL (the "compile-in" wrapper) is one way (which is used by Kobo
Deluxe: http://www.olofson.net/kobodl ), and in a not too distant
future, we (the Not So Secret Backend Team ;-) hope to get a true
backend version into SDL, so users can make use of OpenGL without
even recompiling applications.
glSDL/wrapper:
http://olofson.net/mixed.html
Another way is to think twice (or more ;-) when designing your
application, so you can snap in an alternative rendering backend
which uses OpenGL natively. There's a very simple demonstration of
that technique in my smoothscroll example:
smoothscroll:
http://olofson.net/examples.html
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
--- http://olofson.net --- http://www.reologica.se ---
More information about the SDL
mailing list