This project has moved and is read-only. For the latest updates, please go here.

Quicke spritebatch drawing horsepower question

Jan 5, 2015 at 3:15 AM
Edited Jan 5, 2015 at 5:48 AM
I'm working on fine tuning some of my 2D drawing routines and I'm curious about some CPU usage.

When drawing from a source to destination (normal spritebatch.draw operation) I assume reading the source area is easier for the CPU than writing to the destination area? I am curious how much less (if any) CPU would be used when drawing from a 32x32 pixel area to a 1024x1024 pixel area, Vs. drawing from a 1024x1024 area to a 1024x1024 area? Is it significantly less or the same? If writing the pixel data is the bottleneck I would assume it's about the same since the destinations are both the same size, even though the sources are different sizes.

Also, again if writing the data is the bottleneck, would an area with completely transparent pixels (alpha 0) be easier for the CPU than an equal area with semi-transparent pixels (alpha>0), even if the overall dimensions were the same?

I may have worded the questions a bit funny; let me know if they don't make sense.

I'm ultimately looking at a goal of lowering the CPU usage and raising the battery life for mobile devices. Depending on the answers to these questions I can take different steps.
Jan 5, 2015 at 5:37 AM
These things make no difference at all for the CPU, but potentially a big difference for the GPU.
Jan 5, 2015 at 5:40 AM
Edited Jan 5, 2015 at 5:47 AM
I should have been more specific. Yes, the GPU (not the CPU). Ultimately I'm after power consumed.

So, what sort of differences do these situations make regarding the GPU usage?

I've been trying some different things and have thus far cut the power usage (according to Visual Studio's diagnostics) by about 30%, which is great, but I'd like to get it whittled down more. Any info is much appreciated.
Jan 5, 2015 at 6:07 PM
These details can be quite different depending on the type of GPU. For tile based hardware such as is found in most phones, alpha blending is irrelevant (unlike a typical desktop GPU where opaque vs. alpha can have a huge impact on performance). The most important factor for a tile based GPU is memory bandwidth usage, which is affected both by source reads and destination writes. Bandwidth used for each is approximately width * height * bytes per pixel - anything you can do to reduce any of these values will likely improve perf.
Jan 5, 2015 at 6:19 PM
Interesting, thanks a bunch Shawn. So dealing with a typical mobile GPU and equal bytes per pixel is it safe to assume the following?

1) Reading from a 32x32 source and writing to a 1024x1024 destination will use more power in the write.
2) Reading from a 1024x1024 source and writing to a 1024x1024 destination will use equal power for both.
3) Reading from a 1024x1024 source and writing to a 32x32 destination will use more power in the read.
4) Dealing with transparent pixels makes no difference.