Written by Dan Galpin, Developer attorney
We introduced RenderScript in Android 3.0 so that applications can run computationally intensive code on the CPU or GPU without having to use the NDK or GPU specific APIs. In the course of the further development of Android, the NDK tools and APIs for GPU computation with OpenGL have improved significantly. In Android 7.0 (API level 24), we added the Vulkan API, which provides low-level access to GPU hardware functions. In Android 10.0 (API level 29) we added the ability to easily share bitmap hardware buffers between Android SDK and NDK code to speed up image processing.
We no longer recommend RenderScript as the optimal way to do these performance-critical tasks, and we’re ditching the APIs in Android 12. We want you to be sure that your high-performance workloads are running on GPU hardware and that many devices are already running Shipping only with CPU support for RenderScript. The APIs still work, but compiling RenderScript code when targeting Android 12 gives a warning.
How we approach the RenderScript properties
The RenderScript subsystem has also been used to implement a number of useful image processing features. We provide an open source library that contains the highly tuned CPU implementations for all but the BLAS (Basic Linear Algebra Subprograms) features. In the cases we measured, intrinsics run faster (often significantly) on the CPU using our library than in RenderScript, even on devices that could support GPU.
For BLAS, we recommend using one of the many libraries that already provide this functionality, e.g. B. the libblas from netlib.
Please report problems with the library here.
If you are using RenderScript scripts:
To get the most out of GPU acceleration, we recommend migrating RenderScript scripts to the cross-platform Vulkan API. To help you get started with this transition, we’ve provided a sample app that demonstrates two RenderScript scripts with Vulkan equivalents.
- The first script is the “Hello World” from RenderScript. it rotates the hue of the image.
- The second script implements blurring and uses multiple input map cells to figure out one output map cell. (Note that the highly optimized fuzziness in our static library has, in many cases, wider device compatibility and faster performance than this sample script.)
Since Vulkan is not available on older devices, you may need to manage two code paths: RenderScript on older devices and Vulkan on newer ones. Please see our documentation for more information on migration.
You can submit problems with the example here.
We in the RenderScript team thank you for your support over the years. We understand that transitions are never easy; Our focus on cross-platform APIs like Vulkan means even better tools and support for your GPU-accelerated applications.