Alpha blending is too slow

Hi!

When I use alpha blending in my game, it slows down considerably. My main
surface is in hardware, 16 bit. If I turn on alpha on my surfaces while
blitting to main surface, I loose a lot of FPS. I understand this is
because reading pixel data from the video memory is slow. However, I have
seen alpha blending in a lot of games I have played. Is there a special
trick to it?

regards,
Pallav--------------------------------------------------
Will you be the Last Man Standing?
http://www.ironcode.com

Let The Games Begin!

OpenGL.On Sat, Oct 04, 2003 at 04:58:22PM +0530, Pallav Nawani wrote:

When I use alpha blending in my game, it slows down considerably. My main
surface is in hardware, 16 bit. If I turn on alpha on my surfaces while
blitting to main surface, I loose a lot of FPS. I understand this is
because reading pixel data from the video memory is slow. However, I have
seen alpha blending in a lot of games I have played. Is there a special
trick to it?


Glenn Maynard

Well, the biggest issue is reading from VRAM. You avoid that by
doing the rendering into a s/w surface and blit that to the screen,
but that adds some overhead for the “fake flipping”, obviously.

Anyway, even if you’re lucky and have busmaster DMA blits, alpha
blending is rather heavy work for the CPU. Try making use of the
special 50% alpha case if you can.

Also make sure you use RLE acceleration, especially if you’re
blitting surfaces with alpha channels (RGBA) and large opaque and/or
transparent areas. That way, those areas can be rendered at full
speed (plain copying and skipping, respectively), avoiding the
expensive alpha blending operations where they would have no visible
effect.

If that still doesn’t cut it, it’s either glSDL or native OpenGL. The
former gives you nothing but the SDL 2D API, except with the brutal
speed of accelerated OpenGL. The latter gives you about the same
speed, but much more control (transformations, more kinds of blending
etc) - and maybe also a serious excercise in software rendering, if
you ever want your game to run at all without OpenGL.

//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.nethttp://www.reologica.se —On Saturday 04 October 2003 13.28, Pallav Nawani wrote:

Hi!

When I use alpha blending in my game, it slows down considerably.
My main surface is in hardware, 16 bit. If I turn on alpha on my
surfaces while blitting to main surface, I loose a lot of FPS. I
understand this is because reading pixel data from the video memory
is slow. However, I have seen alpha blending in a lot of games I
have played. Is there a special trick to it?

Pallav Nawani wrote:

When I use alpha blending in my game, it slows down considerably. My
main surface is in hardware, 16 bit. If I turn on alpha on my
surfaces while blitting to main surface, I loose a lot of FPS. I
understand this is because reading pixel data from the video memory
is slow. However, I have seen alpha blending in a lot of games I have
played. Is there a special trick to it?

It’s called “OpenGL”.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com