PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

CGapiSurface vs. CGapiRGBASurface

Hi all,

Does anybody know what the performance implications of using CGapiRGBASurface compared to CGapiSurface.

Say I have two identical images loaded into a CGapiSurface and a CGapiRGBASurface respectively. All pixels in both images are at full opacity (the image in CGapiSurface because it cannot store alpha-channel info even if it was present, the image in CGapiRGBASurface because the image was stoned into a PNG file without transparence).

Will it be faster to blit the image in CGapiSurface (using BltFast) than blitting the image in CGapiRGBASurface (also using BltFast)?

regards
Bjørn
stoned = stored.... I'm not on drugs :oops:
Hi Bjørn,

Will it be faster to blit the image in CGapiSurface (using BltFast) than blitting the image in CGapiRGBASurface (also using BltFast)?


I would recommend reading through the documentation on CGapiSurface a bit. :)

1. CGapiRGBASurface only works with AlphaBlt and AlphaBltFast
2. From the documentation:

[AlphaBlt]
"AlphaBlt performs best when RGBA surfaces are used."

[AlphaBltFast]
"AlphaBltFast performs best when separate surfaces for image and alpha are used. If separate surfaces for image and alpha + option (1) above is used, GapiDraw will use a fast 32-bit alpha blend routine."
He, he. IOW RTFM, point taken. Cheers for your time, though.
Hello,

I tried to summarize, what to do to get the best possible performance using AlphaBlending. Summarizing the information from manual, I get the following:

1. AlphaBlt() is slower than AlphaBltFast(), because it offers rotations and scaling. However, AlphaBlt() works best with RGBASurfaces.

2. On the other hand, AlphaBltFast() is much faster than AlphaBlt(), and AlphaBltFast() works best with separate RGB and Alpha surfaces.

Does that mean, that if I wan to achieve the maximum possible speed with AlphaBlended sprites, should I use separate RGB surfaces with AlphaBltFast() and forget about convenient RGBA surfaces?

Thank you very much,
with regards, Rene.
Does that mean, that if I wan to achieve the maximum possible speed with AlphaBlended sprites, should I use separate RGB surfaces with AlphaBltFast() and forget about convenient RGBA surfaces?


Unfortunately yes. But I guess in the end it depends on how many sprites you want to show on the display simultaneously, maybe performance is "good enough" to use RGBA surfaces?

Sincerely
Johan
Hello Johan,

I would like to use alphablended edges on every sprite in my game. Is even RGBA format optimized for white/black that is opaque/transparent please, so I would design the sprites with maximum of these two colors and minimum of alphablended parts?

Thank you and
with regards,
Rene.
I studied this subject a bit more. I think the maximum speed gained from two separate files is because Alpha value is stored in RGB format too in the second file. Therefore, RGB can simply get multiplied by alpha without any precomputations.

I can use separate buffers, one for alpha value and one for RGB, if it helps to gain some speed. However, I would like to know, if I can use single transparent PNG file to load RGB and ALPHA value (using GDSURFACE_ALPHA), or if I get faster resutls by loading Alpha value from separate file, where alpha is stored as RGB. If that helps, I will enerate two separate files directly from photoshop: one for RGB and another for Alpha.

Thank you very much,
have a nice day,
Rene.