Porting a Smalltalk system from X to SDL - Worthwhile?

I’m considering porting Squeak


from the X Window System to SDL.

I don’t have much background in graphics programming, so please correct
any errors that I make. For the purposes of this discussion, I’m mainly
interested in 2D graphics performance, even though Squeak has 3D
capabilities.

When I run Squeak at home on Linux, it seems that I get worse
performance than on the slower Windows boxes at work. Squeak is a
Smalltalk-80 descendent, which started out on the Alto. On this
computer, Smalltalk pretty much ran as the operating system, so
Smalltalk assumes that it can directly blit the framebuffer. X Windows
doesn’t fit this paradigm very well because it introduces many context
switches between the app, the X server and the window manager. While
some provisions for higher-performance local graphics have been added
later, X Windows doesn’t have any means of taking advantage of many of
the powerful graphics acceleration techniques that are available on
today’s graphics cards, such as transparent blit. From what I have
learned about X’s architecture, I’d like to be able to completely bypass
it for Squeak.

Recently, I saw some Linux 3D game performance figures on Slashdot that
gave me some hope because they showed Linux being comparable with
Windows in performance.

My understanding is that SDL uses the DGA architecture of Xfree86 for 2D
acceleration and the DRI architecture, through OpenGL, for 3D
acceleration. DGA 2.0 is being added to Xfree86 4.0. Assuming that SDL
is using DGA 2.0, will I see significant improvements in 2D graphics
performance over X? Will this performance be comparable with what
Windows can do with DirectX?

TIA

I’m considering porting Squeak
http://www.squeak.org/
from the X Window System to SDL.

Cool!

My understanding is that SDL uses the DGA architecture of Xfree86 for 2D
acceleration and the DRI architecture, through OpenGL, for 3D
acceleration. DGA 2.0 is being added to Xfree86 4.0. Assuming that SDL
is using DGA 2.0, will I see significant improvements in 2D graphics
performance over X?

Maybe, this depends entirely on what you are doing. If you do all your
rendering manually (i.e. unaccelerated), then classic X11 forces you
to work in a memory buffer, which is then copied to the frame buffer.
This transfer is usually the bottleneck, though XFree 4.0 is faster in
that respect.

DGA basically gives you access to a frame buffer, and you can fiddle with
its bits directly. DGA 2 also provides some accelerated operations that SDL
can use, but for others, DGA can even be slower than X11 in some cases
since reading from the frame buffer is slower than reading from memory.

The main reason for using DGA is that you can get screen updates
synchronised with the vertical refresh and avoid some tearing that way

Mattias Engdeg?rd wrote:

My understanding is that SDL uses the DGA architecture of Xfree86 for 2D
acceleration and the DRI architecture, through OpenGL, for 3D
acceleration. DGA 2.0 is being added to Xfree86 4.0. Assuming that SDL
is using DGA 2.0, will I see significant improvements in 2D graphics
performance over X?

Maybe, this depends entirely on what you are doing. If you do all your
rendering manually (i.e. unaccelerated), then classic X11 forces you
to work in a memory buffer, which is then copied to the frame buffer.
This transfer is usually the bottleneck, though XFree 4.0 is faster in
that respect.

DGA basically gives you access to a frame buffer, and you can fiddle with
its bits directly. DGA 2 also provides some accelerated operations that SDL
can use, but for others, DGA can even be slower than X11 in some cases
since reading from the frame buffer is slower than reading from memory.

The main reason for using DGA is that you can get screen updates
synchronised with the vertical refresh and avoid some tearing that way

Thanks. Well, I guess it sounds like the advantage of using SDL could
be pretty marginal. (I really do like the vertical refresh
synchronization capability though.) It’s hard for me to figure out
whether it would be worthwhile to port Squeak to SDL. What kind of X11
graphics operations should I look for to figure out whether they would
be better done with SDL? Does anybody know about benchmarking on what
works well and what doesn’t work well with SDL on Linux? (Again, my
main interest is 2D graphics.)

Thanks. Well, I guess it sounds like the advantage of using SDL could
be pretty marginal. (I really do like the vertical refresh
synchronization capability though.) It’s hard for me to figure out
whether it would be worthwhile to port Squeak to SDL. What kind of X11
graphics operations should I look for to figure out whether they would
be better done with SDL?

The point of SDL is partly being cross-platform, partly providing a common
low-level graphics interface even on a single platform. Instead of guessing
whether GGI, X11, DGA2, fbcon, or svgalib will give you better performance,
SDL allows you to write your code for all of them at once and simply
use what’s best for you.

Does anybody know about benchmarking on what
works well and what doesn’t work well with SDL on Linux? (Again, my
main interest is 2D graphics.)

SDL is biased towards the needs of games. Game programmers have a peculiar
inclination for preferring direct access to pixels in the frame buffer, so
SDL gives you that when possible, and emulates it otherwise. They also seem
to like fast copies of rectangles or shaped figures, and alpha-blended
images, so SDL gives you that, accelerated when possible. On the wish-list
are linear transforms of 2d surfaces (stretching, rotating, etc).

Operations that X11 usually does in hardware but SDL does not include
drawing thin lines, arcs, solid polygons, text, and moving rectangles
on-screen (i.e. scrolling in xterms).

If you follow the Smalltalk tradition and have an integrated windowed
environment, then maybe doing the rest in X11 is better. SDL is mostly
for applications that take over the screen, though you can run it in
a window.

Thanks. Well, I guess it sounds like the advantage of using SDL could
be pretty marginal. (I really do like the vertical refresh
synchronization capability though.) It’s hard for me to figure out
whether it would be worthwhile to port Squeak to SDL. What kind of X11
graphics operations should I look for to figure out whether they would
be better done with SDL? Does anybody know about benchmarking on what
works well and what doesn’t work well with SDL on Linux? (Again, my
main interest is 2D graphics.)

Among other things, an SDL port would greatly simplify portability. SDL
supports quite a few platforms, and you wouldn’t need separate drawing
(or sound) code for Win32/Linux/BeOS/MacOS.

-John