[SDL] N buffering and access to the hidden video surface
Alexis Naveros
alexis at rayforce.net
Thu Mar 1 10:05:09 PST 2007
Thanks for your reply, Ryan.
> If your OS supports it, call SDL_SetVideoMode() with SDL_HWSURFACE.
Obtaining a hardware surface would clearly solve the problem, though that doesn't seem to ever happen on the platforms used ( X11 shm mostly ).
> In ideal situations, this is one copy--the SDL_BlitSurface() call--and
> there's no shadow surface. In most cases, you're going to not get a
> HWSURFACE from SDL_SetVideoMode(), since most platforms don't offer it,
> and you'll get the shadow surface anyhow, but the same code will still
> work (the SDL_Flip() becomes a second copy, basically).
Understood. I think a proper solution would then be to make SDL continuously cycle through multiple "shadow" surfaces, copying the data directly from any of the allocated surfaces. If I'm not mistaken, all that would be required is changing current_video->shadow ( SDL_ShadowSurface macro ) to point to any other surface... yet the API does not appear to expose such a feature. I guess this could be patched without too much trouble though.
> Alternately, consider using OpenGL...there's one "copy" when uploading
> the surface as a texture to video RAM, then the actual selection of a
> buffer is basically "free." It's also the only way to avoid the extra
> copy on X11, since that target always gives you software surfaces even
> when requesting HWSURFACE.
Right. I'm considering it, I'm just stopped by how a hardware accelerated OpenGL implementation is not likely to be available ( typical Linux laptops hooked to the clusters or the number crunching boxes themselves ).
Do you have any thoughts on a quick SDL patch to perform N buffering with always just one "copy" per frame?
Alexis Naveros
More information about the SDL
mailing list