From 3419e07873bf29d4defb5cb155deddc4d064820f Mon Sep 17 00:00:00 2001 From: Robert Ly Date: Mon, 12 Nov 2012 19:42:52 -0800 Subject: docs: add fs to rs Change-Id: Icb08977ecf5acbddff35965fa1d7360cece0dd31 --- docs/html/guide/topics/renderscript/compute.jd | 123 ++++++++++++++++++------- 1 file changed, 91 insertions(+), 32 deletions(-) (limited to 'docs/html') diff --git a/docs/html/guide/topics/renderscript/compute.jd b/docs/html/guide/topics/renderscript/compute.jd index d464c90a52fe..5f466ce0ba17 100644 --- a/docs/html/guide/topics/renderscript/compute.jd +++ b/docs/html/guide/topics/renderscript/compute.jd @@ -10,12 +10,11 @@ parent.link=index.html
  1. Renderscript System Overview
  2. +
  3. Filterscript
  4. Creating a Computation Renderscript -
    1. Creating the Renderscript file
    2. -
    3. Calling the Renderscript code
  5. @@ -111,16 +110,34 @@ code, like with the NDK.

    For a more detailed explanation of how all of these layers work together, see Advanced Renderscript.

    +

    Filterscript

    + +

    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:

    + +

    Creating a 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 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.

    +that automatically partitions work across available processing cores on the device.

    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:

  6. A pragma declaration (#pragma version(1)) that declares the version of Renderscript that you are using (1 is the only value for now).
  7. - -
  8. 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 + +

  9. 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:

      @@ -172,10 +188,22 @@ Every .rs file generally contains the following items:

    • The size of the user-defined data.
    + +

    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) {
    +    ...
    +  }
    +  
  10. An optional 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.
  11. @@ -203,6 +231,46 @@ void root(const uchar4 *v_in, uchar4 *v_out) { } +

    Setting floating point precision

    +

    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:

    + + + +

    Script intrinsics

    +

    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: +

    +

    Calling the Renderscript code

    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.

    -

    Setting floating point precision

    -

    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:

    - \ No newline at end of file +

    Script groups

    + +

    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