This site is no longer active and is available for archival purposes only. Registration and login is disabled.

GapiDraw 2.0 development progress


Postby Johan » Apr 21, 2003 @ 1:38am

[Daily update - Sunday, April 20]

(1)
CGapiRGBASurface can now be either 16 or 32-bit (set using a flag in CreateSurface). Right now the performance of them are about the same (with the 16-bit 4-4-4-A RGBA version taking 50% less memory of course). I will add some more flags to AlphaBlt for more customization...

(2)
Support for incoming call minimization on Smartphones in CGapiApplication

(3)
I have decided that this really is GapiDraw 2.0 and will change the DLL and LIB versions accordingly.

(4)
I have begun working on updated documentation.

Next build will be out tomorrow or on Tuesday.... And it will be 2.0 beta... :)
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby Johan » Apr 21, 2003 @ 7:58pm

[Daily update - Monday, April 21]

Since many games seem to use alpha blends I decided to try and improve performance some...

(1) CRGBASurface
Storing alpha and image information together resulted in a nice performance boost on the Pocket PC. How much? It depends on the image really... On stationary PCs with their larger cache the performance was about the same..

(2) Using LUT for multiplications
I tried rewriting the current formulas (where two multiplications are required for each pixel) with three memory lookups. I created a 4kb LUT that used 4 bits of alpha and 5-bits of color information. After some hours of tweaking I found out that the current way with two multiplications is much faster. So much for look up tables...

No new build today.. The weather is far too nice to stay indoors... :)
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby efortier » Apr 22, 2003 @ 12:10am

User avatar
efortier
pm Insider
 
Posts: 373
Joined: May 15, 2002 @ 10:32pm


Postby Sm!rk » Apr 22, 2003 @ 8:05am

User avatar
Sm!rk
pm Member
 
Posts: 172
Joined: Dec 16, 2002 @ 4:40pm


Postby Johan » Apr 22, 2003 @ 10:29am

User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby efortier » Apr 22, 2003 @ 11:19am

User avatar
efortier
pm Insider
 
Posts: 373
Joined: May 15, 2002 @ 10:32pm


Postby Hosed » Apr 22, 2003 @ 3:23pm

LUTs are just an optimization option and like all optimizations, has it's time and place. They're useful, but not as a wholistic solution to all problems. As efortier said, sin/cos/tan luts are very useful. Namely because trig functions concist of atleast a couple dozen adds/divs/muls when expanded to series form (and all computers implement them in this form).
L. L. Goodwin<BR>Purveyor of Code<BR><A href="http://www.planettribes.com/hosed/">Hosed's House of Code</A>
User avatar
Hosed
pm Member
 
Posts: 249
Joined: Jan 3, 2002 @ 2:51am
Location: Montana, USA


Postby Johan » Apr 23, 2003 @ 12:50am

[Daily update - Tuesday, April 22]

"leet hacking".. 8) Today I increased the performance of BltFast with key source up to 40% (this also includes BltFast + keysource + opacity, and BltFast + keysource + colorfill + opacity + whatever).. The previous BltFast always operated on one pixel at the time. The new BltFast operates on multiple pixels simultaneously. The trick was to get this to work with the current template meta programming architecture (which actually works out really well).

Performance speaks for itself. The MFC demo as re-programmed by Walter Rawdanik (owner of ZSurface, http://www.warmi.net/zaurus/blits.shtml ) in optimized ARM Assembler produced 290 sprites on each frame on the IPAQ. That is the current limit. GapiDraw 2.0 is now able to produce 270 sprites on that device. That is a mere 7% difference in performance.

AlphaBlendFast was also improved to work on multiple pixels (together with an overhaul of FillRect and a couple of other operations). As soon as I have QA'd all code I will release the first 2.0 beta (Thursday). Walter: Lots of thanks for the comments + input!

Oh, finally some further Smartphone-related changes to CGapiApplication. Thanks to all of you who have emailed!!

Image

Note: If you look closely at the image you may notice a small cosmetic error to some sprites. This was related to a small programming error and has been corrected. The correction did not alter performance.
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby stuff » Apr 23, 2003 @ 2:35pm

stuff
pm Member
 
Posts: 41
Joined: Feb 2, 2003 @ 5:22pm


Postby spacemonkey » Apr 23, 2003 @ 4:58pm

spacemonkey
pm Member
 
Posts: 11
Joined: Apr 20, 2003 @ 12:13pm


Postby stuff » Apr 23, 2003 @ 6:37pm

stuff
pm Member
 
Posts: 41
Joined: Feb 2, 2003 @ 5:22pm


Postby Johan » Apr 23, 2003 @ 7:57pm

[Daily update - Wednesday, April 23]

I have taken the time to rewrite most of the core operations, such as BltFast, AlphaBltFast and FillRect. BltFast and AlphaBltFast are now around 20-40% faster depending on data. FillRect has been "cleaned up" to allow for some nice cache re-use..

The rewriting of the core blit operations was planned for a long time, but I always felt that rewriting the core features would risk imposing errors in the rendering pipeline. It did not suit a 1.05 or a 1.1 release. With the release of a 2.0 version, there could be no better time to implement this. Thankfully it is very easy to test graphics code like this, and GapiDraw has never had any visual anomalies in previous releases.

The improved AlphaBltFast (when using separate surfaces for image and alpha) is now also significantly faster than the new RGBA surfaces.. <sigh>.. To simplify the use of the "old" alpha way I added a feature to CreateSurface: GDSURFACE_ALPHASURFACE. If you load a PNG image to a surface and set the flag GDSURFACE_ALPHASURFACE, the PNG loader will extract the alpha information stored in the image and set color values between RGB(0,0,0) and RGB(255,255,255). In other words, there is no longer a need to use the "alpha split" macro anymore, even if you use separate surfaces for image and alpha.

Now it's time for some serious testing of all the rewritten blit operations before I post the first 2.0 beta tomorrow.

stuff: It should be enough to capture WM_ACTIVATE. You never actually have to deal with SET/KILL focus. Please test the next build tomorrow and see how it works on your device.

*UPDATE* The RGBA surfaces are actually much faster when doing AlphaBlt (stretch). :D So the work done on creating them are not wasted after all!! Here are some figures:

--DESKTOP-

10 000 alpha blended sprites, AlphaBltFast (200x200)

2844 - 16bit RGBA aligned
2437 - 32bit RGBA aligned
2609 - 1.04 routine aligned
1984 - new routine aligned
2015 - new routine destination unaligned

1 000 alpha blended sprites, AlphaBlt (200x200)

797 - 16bit RGBA
688 - 32bit RGBA
1062 - separate image and alpha surfaces

--POCKETPC--

1 000 alpha blended sprites, AlphaBltFast (200x200)

4827 - 16bit RGBA aligned
5034 - 32bit RGBA aligned
5326 - 1.04 routine aligned
4030 - new routine aligned
4113 - new routine destination unaligned
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby stuff » Apr 23, 2003 @ 8:32pm

can't wait :P
stuff
pm Member
 
Posts: 41
Joined: Feb 2, 2003 @ 5:22pm


AlphaBlit

Postby warmi » Apr 23, 2003 @ 10:04pm

As far as AlphaBlend performance it is possible to get down to a single multiplication per pixel if you are willing to limit your alpha value to range 0-32.

Following logic in this article
and given aligned blit you can load 2 pixels at a time in this format:

standard 32 bit (2 pixel) register:
RGBRGB

First you separate GRB part:
_G_R_B

Then you separate RBG part
R_B_G_ and shift to the right to get
_R_B_G

Given this setup you can now do multiplication on
each register which will result in 2 multiplications
per 2 pixels.
The reason you are limited to max 32 alpha levels, is that we have only 5 bits to work with before we overflow into set of bits for another color ( these 5 bits were represented as _ in the above diagram.)

Basically you exchange multiplication for a shift/AND operation.
This can only be done on aligned pixels and works best (best performance) for static alpha blends ( alpha value is constant for the entire blit.)
warmi
pm Insider
 
Posts: 518
Joined: Aug 24, 2002 @ 8:07am
Location: Chicago USA


Postby Johan » Apr 24, 2003 @ 12:21am

User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


PreviousNext

Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum