Bug in DGA SDL driver

Hi!

I don’t see how this can cause flickering. This is what’s supposed to happen:

client calls SDL_Flip():
waits for previous flip to complete
XDGASetViewport() to the other buffer (to complete asynchronously)

client draws something on the screen (either by locking the display and
bashing bits directly or by doing a BlitSurface or FillRect):
DGA_WaitHardware() waits for above XDGASetViewport to take effect
(in essence waiting for retrace)
client then updates the not currently displayed buffer

client calls SDL_Flip():
waits for the flip above to complete, which is a no-op (since the client
already did a wait when drawing something to the screen)
XDGASetViewport() to the other buffer (to complete asynchronously)

Why the second SDL_Flip() ?

Anyway, the way you explained it seems like the way it was intended, but it
really doesn’t work very well. Shouldn’t it rather be:

setup_some_offscreen_buffer ();
clear_screen ();

do
{
// remember offscreen
draw_some_stuff_to_offscreen_buffer ();
// now get the screen ready for the vertical retrace
// to start so that we can update the screen
wait_for_vertical_retrace ();
// drop the bomb
flip_the_offscreen_buffer_to_onscreen_buffer ();
}
while (not_finished);

That’s the easiest and most logical way imho. Of course, I’ve attached 2
examples to illustrate what I’m talking about. It’s a line based
kaleidoscope object thingy that moves all over the screen. There’s lotsa
line blitting so it clearly shows flickering (if any). The one is the SDL
version and the other the DGA (my own implementation of DGA) version.

All the code is basically the same, so ignore everything except main.c in
both cases. Look at the main loop. The SDL version goes like this:

do
{
if (!mustlock) SDL_LockSurface (surface);
kal_draw (&buffer,COLOR_WHITE);
if (!mustlock) SDL_UnlockSurface (surface);
SDL_Flip (surface);
SDL_FillRect (surface,NULL,COLOR_BLACK);
kal_update (buffer.width,buffer.height);
frames++;
}
while (frames < 1000);

No, kal_draw() is the routine that actually does the drawing, the
kal_update() function can be safely ignored - it just updates some data
structures.

The DGA version’s main loop is as follows:

do
{
dga_waitretrace (&device);
kal_draw (&buffer,EGA_WHITE);
XDGACopyArea (device.display,
device.screen,0,
device.device->mode.viewportHeight,
buffer.width,
buffer.height,0,0);
XDGAFillRectangle (device.display,
device.screen,0,
device.device->mode.viewportHeight,
buffer.width,
buffer.height,
EGA_BLACK);
kal_update (buffer.width,buffer.height);
frames++;
handle_events (&device);
}
while (true);

Compile them and see the difference.

Oh yes, the coloring won’t be right in the SDL version. I never set the
palette…

PS: Don’t confuse this with some examples I sent a week or two ago. Not
the same thing!!!–

Regards
Abraham


Abraham vd Merwe [ZR1BBQ] - Frogfoot Networks
P.O. Box 3472, Matieland, Stellenbosch, 7602
Cell: +27 82 565 4451 - Tel: +27 21 887 8703
Http: http://www.frogfoot.net
Email: @Abraham_vd_Merwe

-------------- next part --------------
A non-text attachment was scrubbed…
Name: examples.tar.gz
Type: application/octet-stream
Size: 47553 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010110/b764ee18/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010110/b764ee18/attachment.pgp

  if (!mustlock) SDL_LockSurface (surface);

you inverted the test

Hi Mattias!

if (!mustlock) SDL_LockSurface (surface);

you inverted the test

dope :P–

Regards
Abraham


Abraham vd Merwe [ZR1BBQ] - Frogfoot Networks
P.O. Box 3472, Matieland, Stellenbosch, 7602
Cell: +27 82 565 4451 - Tel: +27 21 887 8703
Http: http://www.frogfoot.net
Email: @Abraham_vd_Merwe

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010110/16ffef02/attachment.pgp