Skip to main content
Lucian Nertan
Participating Frequently
February 17, 2014
Question

setVector and GPU render mode

  • February 17, 2014
  • 2 replies
  • 1995 views

Hello,

If i use the setVector method on a BitmapData in GPU render mode on a mobile device, it works very slow.

This changes if the render mode is CPU. The method is fast enough.

The problem lies in the fact that if I use CPU render mode the app i;m developing is getting very slow, while on GPU it works great.

setPixel32 is even slower,it even won't work with lock/unlock.

Where the problem lies? How can I bipass this since setPixel32 or setVector is a must have when working with bitmaps.

UPDATE:

I've tested alot, and it seems the problem lies not with setVector method but with copying transparent pixels

//

You can find the code here since i've asked the question o stackexchange too:  http://stackoverflow.com/questions/21827049/gpu-vs-cpu-render-mode-adobe-air

This topic has been closed for replies.

2 replies

Colin Holgate
Inspiring
February 17, 2014

If you change a single pixel in a large bitmap using GPU mode, the whole image has to be re-cached. If you’re continually doing that sort of thing, you can run out of GPU memory quite quickly.

If you’re using CPU, and lots of vectors, the shape you are drawing will take a long time to draw. That can be solved by doing a cacheasbitmap after you have finished making changes.

One other thing to try is Direct render mode. You probably know that it’s used when doing Stage3D or StageVideo, but it can also be used with just regular Flash displaylist objects. It ends up being much the same as CPU, only the changes you make get sent to the video memory very quickly.

Now, even that won’t perform too well if you are changing large areas of the stage. If you don’t have a choice, and need to change large areas of the stage, you will find that iPad 3 Retina won’t perform well enough. That can be solved by excluding the iPad 3 in the XML, by including this in the requestedDisplayResolution section:

requestedDisplayResolution excludeDevices=“iPad3"

Doing that will force the iPad to run at 1024x768.

Lucian Nertan
Participating Frequently
February 17, 2014

I see.

Direct/CPU mode is out of the equation as the game is very slow using it since i work with alot of bitmaps.

Is there a way to force the GPU not to upload the full image like in CPU mode? Like, only smaller power of 2 areas of the image?

User Unknow
Legend
February 17, 2014

GPU don't have default pixel control over data. Just change 1 pixel and your texture must be re-uploaded again. In this canse you will performance issue and doesn't matter how big area you changed. 1x1 or 100x100. Main issue of Air developers - they don't understand hardware limitation It's like you want to fill 1 cup of tea using two cups and want avoid leaks. This is impossible

You need make app simpler.

User Unknow
Legend
February 17, 2014

Difference may be in that when you uploading new data to BitmapData via CPU - it's not require upload it to GPU. And when you upload data to GPU it's firstly come CPU and than uploads to GPU.

But CPU rendered much slower than GPU.

Lucian Nertan
Participating Frequently
February 17, 2014

It may be so, but i'm stuck. I need GPU rendering, but I can't erase a brush from a bitmapdata using it because is so slow while on CPU there's no lag.

Maybe there are some steps i'm missing or a better workaround, that's why I'm curios

User Unknow
Legend
February 17, 2014

Firstly let me know your Air version. It's latest from Jan 28 from labs.adobe.com?

I asking everyone because only 2 from 5 use updated SDK.