19 April 2021
Posted by Dan Galpin, Developer Advocate
We introduced RenderScript in Android 3.0 as a way for applications to run computationally-intensive code on the CPU or GPU without having to make use of the NDK or GPU-specific APIs. As Android has evolved, the NDK tooling and APIs for GPU compute using OpenGL have dramatically improved. In Android 7.0 (API level 24), we added the Vulkan API, which allows for low-level access to GPU hardware features. In Android 10.0 (API level 29) we added the capability to easily share Bitmap hardware buffers between Android SDK and NDK code to speed image processing.
We no longer recommend RenderScript as the optimal way to accomplish these performance-critical tasks, and will be deprecating the APIs in Android 12. We want you to have confidence that your high-performance workloads will run on GPU hardware, and many devices are already shipping with only CPU support for RenderScript. The APIs will continue to function, but compiling RenderScript code when targeting Android 12 will give a warning.
The RenderScript subsystem was also used to implement a number of useful image-processing intrinsics. We're providing an open-source library that contains the highly-tuned CPU implementations for all but the Basic Linear Algebra Subprograms (BLAS) intrinsics. For the cases that we have measured, intrinsics execute faster (often substantially so) on the CPU using our library than running within RenderScript, even on devices where GPU support was possible.
For BLAS, we suggest using one of the many libraries that already provide this functionality, such as netlib’s libblas.
Please file issues with the library here.
To take full advantage of GPU acceleration, we recommend migrating RenderScript scripts to the cross-platform Vulkan API. To help get you started with this transition, we have provided a sample app that demonstrates two RenderScript scripts with Vulkan equivalents.
Because Vulkan is not available on older devices, you may need to manage two code paths: RenderScript on older devices and Vulkan on newer ones. Our documentation has more details on how to migrate.
You can file issues with the sample here.
We on the RenderScript team thank you for your support over the years. We understand that transitions are never easy; our focus on cross-platform APIs such as Vulkan will mean even better tools and support for your GPU-accelerated applications.