Akshay Panday
Akshay Panday

Reputation: 31

Time taken for Bitmap to Allocation

I've been experimenting with Renderscript for a little while now. I've written small test kernels to do histogram, filtering, etc on images from local storage to verify their functionality. If I get the trace for this sequence of operations - at 8MP image size - by far the most time is taken by the Allocation.createFromBitmap call. I see something like 22 ms for this call as against ~1ms for my kernel to run.

As a result, the gain offered by RS is more or less completely wiped out by this overhead. Is this unavoidable or am I missing something basic?

Thanks,

Akshay

Upvotes: 2

Views: 138

Answers (1)

R. Jason Sams
R. Jason Sams

Reputation: 1469

The basic solution to this is "USAGE_SHARED". Which API version are you testing against?

New (API 18+) RS implementation will create allocations with this flag by default. You should still call copyTo/From but they may (should) turn into NOPs. The HW drivers are still improving support for this usage flag and will in some cases fall back to an actual copy. Over time you should see the copy overhead disappear on newer devices.

Upvotes: 1

Related Questions