Q: SDL_ASYNCBLIT and it's behaviour

Hello, All!

I have question about the flag SDL_ASYNCBLIT which was introduced in SDL
1.1.3. In SDL 1.2.8 looks like it’s not used. I haven’t found any code which
works with this flag, except the some special locking case when ASYNCBLIT
flag is used. So what was general purpose of this flag ?

Why I am asking about that ? On most platforms it’s possible to create
queued blits, which can give significant speed improvement while blitting
numerous images, but there is no FLUSH function or something like
WaitForBlit()/WaitHWIdle(), that’s why I can’t do queued blits under
QNX/Photon. For example, SDL examples:

testalpha.c: contain this code, function MoveSprite():

/* Save the area behind the sprite */
updates[1] = position;
SDL_BlitSurface(screen, &updates[1], backing, NULL);

/* Blit the sprite onto the screen */
updates[1] = position;
SDL_BlitSurface(sprite, NULL, screen, &updates[1]);

/* Make it so! */
SDL_UpdateRects(screen, 2, updates);

There made two blits: from screen and to screen, in case of using queued
blits, first blit will not be executed immediately, and ‘backing’ surface
will contain trash when blit will be performed actually. The closest by
behavior flag is SDL_ASYNCBLIT for this, but without “blit flush” function
it’s useless anyway.

Maybe need to add new API entry for 1.3 branch (or even maybe for 1.2.x ?).

P.S. Performing some benchmarks, testsprite test gives me 110fps when blits
flushed immediately and over 600fps when blits are queued. So I think SDL
API must be revisited in this way.

With best regards, Mike Gorchak. E-mail: @Mike_Gorchak

I have question about the flag SDL_ASYNCBLIT which was introduced in SDL
1.1.3. In SDL 1.2.8 looks like it’s not used. I haven’t found any code which
works with this flag, except the some special locking case when ASYNCBLIT
flag is used. So what was general purpose of this flag ?

It’s to allow exactly what you describe below.
The trick is any pending blits must complete before a lock on the surface
returns - you’ll notice having SDL_ASYNCBLIT set is one of the conditions
of requiring a lock on a surface before accessing it.

Why I am asking about that ? On most platforms it’s possible to create
queued blits, which can give significant speed improvement while blitting
numerous images, but there is no FLUSH function or something like
WaitForBlit()/WaitHWIdle(), that’s why I can’t do queued blits under
QNX/Photon.

As I mentioned above, the flush is implicit in the lock. You’ll probably
also want to flush any queued blits when the main surface is updated or
flipped.

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment