Renderscript is an important feature of Honeycomb that was not previously discussed. There will be two articles in total, this one is a simple overview of Renderscript, the next one will contain more technical details and a simple example.
Renderscript is a new API aimed at high performance in 3D rendering and complex computational operations. Renderscript will be of interest to developers trying to maximize the performance of their applications and feeling comfortable when working at a low level. Three tools are available for developers: a simple API for 3D rendering that supports hardware acceleration, an API for modeling complex calculations (similar to CUDA ), and a standard language close to C99 . Renderscript has been previously used to create new, more beautiful visually, Books and YouTube applications. Also, it has already been used to write live wallpapers supplied with Honeycomb.
Performance improvement is achieved by running native code on the device. However, unlike NDK, this solution is cross-platform. The development language for Renderscript is 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 a particular machine architecture. ')
Renderscript is not intended to replace the existing high-level API, it should be used in cases where the current need for performance is not provided by the API.
It may seem interesting that previously nothing was said about where the code runs - on the GPU or the CPU. The reason is that it is determined on the device at run time. When there is appropriate hardware support, simple scripts can run on the GPU as a small computational load. More complex scripts run on the CPU (or on multiple CPUs). The role of the CPU in this case is also to provide a reserve if there is no additional hardware support in the form of suitable GPUs. In fact, all this should be invisible to the developer. In general, in the future, simple scripts will be able to run in many places, but for now all that is needed in practice is to distribute the load among several CPUs supported on the device.
This video is obtained by intercepting images from the HDMI output of the tablet to Honeycomb. It shows Renderscript at work. Here we present the “brutal” implementation of physics for 900 particles. The computational script runs each frame of the picture and automatically takes advantage of the two cores. As soon as the physics simulation is completed, the second graphical script renders the image. In the video, we push one of the larger particles in order to show their interaction. After that, we tilt the tablet so that gravity does some of the work for us. This whole process demonstrates the good computing power of the new A9 processor.
We switched to Honeycomb from GL ES 1.1 to 2.0 as a render for Renderscript. With version 2.0, we were able to add software support for shaders, loading 3D models, and more efficient memory management. However, the most important change is that Renderscript and related tools are now publicly available.
The screenshot shows one of our test applications. The application implements a three-dimensional scene that demonstrates the recursive invocation of scripts. The Androids shown in the screenshot are downloaded from an A3D file created in Maya and translated from the Collada file. A3D is a format for storing Renderscript objects on a device.
Later, an article with more technical information and sample code will be submitted.