2

What's the fastest way to render a few dozen 16x16 bitmaps tens of thousand times at random locations on a 800x600 screen?

1) Use CopyPixel() to blit each sprite to the 800*600 screen buffer? Of course, call unlock(), lock() on the screen buffer.

2) Using Alchemy? At c++ side create a uint* screenBuffer = new uint[800*600]; and create many: uint* spriteBmp = new uint[16*16]; And copy each spriteBmp to thousands of (x,y) locations in screenBuffer?

3) Pixel bender?

Additionally I'm curious which method can potentially use hardware rendering. I.e., if 1) and 3) can take advantage of user graphics cards, they should be magnitudes faster than any software rasterizer I create with 2).

I don't need scaling or rotation on each bmp, but I do wonder if they would break any as3 API optimizations made for screen aligned bitmaps.

Thanks

user703047
  • 151
  • 1
  • 1
  • 4
  • 1
    Currently, none of those methods use GPU. The only GPU access you can get via Flash is through the Molehill APIs – scriptocalypse May 05 '11 at 13:46
  • What speed do you get with BitmapData.copyPixels? It is by far easier method than others you mentioned. Pixel Bender isn't probably even valid approach here - you'll need to process entire screen with it, and use complex conditions to choose texture and coordinates in every pixel. – alxx May 05 '11 at 13:53
  • Scaling or rotation will forbid fast blitting with BitmapData.draw method. – alxx May 05 '11 at 13:56
  • @alxx I get draw perhaps 10k such bitmaps with copyPixels(). This seems slow compared with some Flash 3D engines, which can render that many projected, texture mapped, and scan-converted triangles --- way more work than my list of 2D bitmaps. – user703047 May 05 '11 at 15:53
  • @scriptocalypse @alxx In terms of raw performance, which is faster for blitting a single 800x600 image to cover 800x600 screen? Pixelbender or CopyPixels()? Or Alchemy C++? – user703047 May 05 '11 at 16:01
  • 2
    10K bitmaps per second? That's not slow. Alchemy approach would be a lot more complex, I can't say whether it will be faster, but I doubt it. And PixelBender... How do you write kernel which will draw hundreds of textures in a single pass? Forget about it, PB is not for this. – alxx May 05 '11 at 17:16

1 Answers1

0

Have you tried Starling? It's a free library that uses the GPU!

You can really render huge amount of bitmaps using the GPU.

btw: If you use the same bitmap, it'll be even faster!

j0k
  • 22,600
  • 28
  • 79
  • 90
gilamran
  • 7,090
  • 4
  • 31
  • 50