From 3419e07873bf29d4defb5cb155deddc4d064820f Mon Sep 17 00:00:00 2001
From: Robert Ly For a more detailed explanation of how all of these layers work together, see
Advanced Renderscript.
+ Introduced in Android 4.2 (API Level 17), Filterscript defines a subset of Renderscript
+that focuses on image processing operations, such as those
+that you would typically write with an OpenGL ES fragment shader. You still write your scripts
+using the standard Renderscript runtime APIs, but within stricter
+constraints that ensure wider compatibility and improved optimization across
+CPUs, GPUs, and DSPs. At compile time, the precompiler evaluates Filterscript files and
+applies a more stringent set of warnings and errors than
+it does for standard Renderscript files. The following list describes the major constraints
+of Filterscript when compared to Renderscript: Renderscripts scale to the amount of
+ Renderscript scales to the amount of
processing cores available on the device. This is enabled through a function named
Filterscript
+
+
+
__attribute__((kernel)) attribute to declare a custom
+root function when using Filterscript.rs_fp_relaxed pragma..fs extension, instead of an .rs extension.Creating a Renderscript
-rsForEach() (or the forEach_root() method at the Android framework level).
-that automatically partitions work across available processing cores on the device.
-For now, Renderscript can only take advantage of CPU
-cores, but in the future, they can potentially run on other types of processors such as GPUs and
-DSPs.
Implementing a Renderscript involves creating a .rs file that contains
your Renderscript code and calling it at the Android framework level with the
@@ -149,10 +166,9 @@ Every .rs file generally contains the following items:
#pragma version(1)) that declares the version of
Renderscript that you are using (1 is the only value for now).A root() function that is the main worker function. The root function is
- called by the rsForEach function, which allows the Renderscript code to be called and
- executed on multiple cores if they are available. The root() function must return
+
+
A root function (or kernel) that is the main entry point to your Renderscript.
+ The default root() function must return
void and accept the following arguments:
.rs file generally contains the following items:
Starting in Android 4.1 (API Level 16), you can choose to define your own root function arguments
+ without adhering to the default root function signature described previously. In addition,
+ you can declare multiple root functions in the same Renderscript. To do this, use the __attribute__((kernel))
+ attribute to define a custom root function. For example, here's a root function
+ that returns a uchar4 and accepts two uint32_t types:
+ uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) {
+ ...
+ }
+
init() function. This allows you to do any initialization
- before the root() function runs, such as initializing variables. This
+ before the root function runs, such as initializing variables. This
function runs once and is called automatically when the Renderscript starts, before anything
else in your Renderscript.You can define the floating point precision required by your compute algorithms. This is useful if you + require less precision than the IEEE 754-2008 standard (used by default). You can define +the floating-point precision level of your script with the following pragmas:
+ +#pragma rs_fp_full (default if nothing is specified): For apps that
+ require floating point precision as outlined by the IEEE 754-2008 standard.
+#pragma rs_fp_relaxed - For apps that don’t require
+ strict IEEE 754-2008 compliance and can tolerate less precision. This mode enables
+ flush-to-zero for denorms and round-towards-zero.
+#pragma rs_fp_imprecise - For apps that don’t have stringent precision requirements. This mode enables
+ everything in rs_fp_relaxed along with the following:
+Renderscript adds support for a set of script intrinsics, which are pre-implemented +filtering primitives that reduce the amount of +code that you need to write. They also are implemented to ensure that your app gets the +maximum performance gain possible.
+ ++Intrinsics are available for the following: +
You can call the Renderscript from your Android framework code by @@ -317,24 +385,15 @@ declared previously. Passing a pointer to a struct and the size of the struct to is optional, but useful if your Renderscript requires additional information other than the necessary memory allocations.
-You can define the floating point precision required by your compute algorithms. This is useful if you - require less precision than the IEEE 754-2008 standard (used by default). You can define -the floating-point precision level of your script with the following pragmas:
-#pragma rs_fp_full (default if nothing is specified): For apps that
- require floating point precision as outlined by the IEEE 754-2008 standard.
-#pragma rs_fp_relaxed - For apps that don’t require
- strict IEEE 754-2008 compliance and can tolerate less precision. This mode enables
- flush-to-zero for denorms and round-towards-zero.
-#pragma rs_fp_imprecise - For apps that don’t have stringent precision requirements. This mode enables
- everything in rs_fp_relaxed along with the following:
-You can group Renderscript scripts together and execute them all with a single call as though +they were part of a single script. This allows Renderscript to optimize execution of the scripts +in ways that it could not do if the scripts were executed individually.
+ +To build a script groupm, use the {@link android.renderscript.ScriptGroup.Builder} class to create a {@link android.renderscript.ScriptGroup} +defining the operations. At execution time, Renderscript optimizes the run order and the connections between these +operations for best performance. + +
Important: The script group must be a direct acyclic graph for this feature to work.
-- cgit v1.2.3-59-g8ed1b