Introduction to Renderscript

Renderscript - an important feature of Honeycomb, which was not discussed previously. There will be two articles, this - a simple overview Renderscript, following the same will contain more technical detail and a simple example. 

Renderscript - this is a new API, aimed at high performance in 3D rendering and complex computing operations.Renderscript will be of interest to developers who are trying to maximize their overall experience and feel comfortable when working at low levels. For developers, there are three tools: a simple API for 3D rendering that supports hardware acceleration, API to model complex algorithms (similar to CUDA ), and standard language is close to C99 .

Renderscript has been used previously to create a new, more beautiful visually, applications Books and YouTube.He has also been used to write living wallpaper that shipped with Honeycomb.
Improved performance is achieved through the implementation of native code on the device. However, in contrast to the NDK, this solution is cross-platform. Language development for Renderscript - this C99 with some extensions during the development process, it is compiled into a hardware-independent intermediate format and placed in the application package. When the application starts, the script is compiled into native code and optimized. This avoids the problems associated with the need to choose any particular machine architecture.

Renderscript not intended to replace existing high-level API, it should be used in cases where the current need for performance is not provided with the API.

It may seem interesting that nothing was said earlier about where the code runs - on the GPU or CPU. The reason is that it is defined on the device at run time. When there is a corresponding hardware support, simple scripts can be executed on the GPU in a small computational load. More complex scripts run on the CPU (or multiple CPU). The role of the CPU in this case also is to provide a reserve if there is no additional hardware support in the form of suitable GPU. In fact, this should be transparent to the developer. Generally, in the future will be able to run simple scripts in many places, but so far all that is needed in practice - to distribute the load across multiple CPU, supported on the device.

This is a video obtained by image capture from HDMI output on the tablet Honeycomb. It shows Renderscript work. Here we present a "brutforsnuyu" implementation of physics for 900 particles. Computing the script runs each frame a picture and automatically takes advantage of two cores. As soon as the physics simulation is completed, the second graphic script renders an image. In the video we push one of the larger particles, in order to show their interaction. After that, cannot tablet to the work for us has made gravity. The whole process demonstrates good computing power of the new processor A9.

On we went with Honeycomb GL ES 1.1 to 2.0 as to render Renderscript. With version 2.0 we were able to add software support for shaders, download 3D models and more efficient memory management. However, the most important change - that's what Renderscript and related tools are now available to all.


Screenshot shows one of our test applications. Application implements a three-dimensional scene, which shows a recursive call scripts. Androids, shown in the screenshot downloaded from A3D file created in Maya and broadcast from a file Collada . A3D - a format for storing objects Renderscript on the device.

Later, the article will be provided with more technical information and sample code.