Reputation: 1690
I noticed that I can actually use the same allocation for the input and output of ScriptIntrinsicBlur. Since I am not interested in the unfiltered allocation, this approach doesn't require creating another allocation and is better memory-wise.
However, is it safe? I couldn't find anything in the documentation.
Other intrinsics, like ScriptIntrinsicResize, specifically mention that the output allocation must not be the same as the input and throw an exception if it is. So, I guess that when this isn't mentioned, it's safe to assume that the output can be the same as the input.
I am also curious from an implementation perspective, how is it possible for Renderscript to read and write from / to the same allocation without a problem?
Upvotes: 1
Views: 189
Reputation: 1130
Generally, it is not safe to reuse the input as output. Artifacts / errors may show up when doing so. The actually results depend on multiple factors, e.g running on CPU or GPU, how many threads are there, what is the usage flags for the Allocations.
I would highly recommend using a separate output buffer.
Upvotes: 2