Skip to content

Commit aa16a2e

Browse files
Robert LyAndroid (Google) Code Review
authored andcommitted
Merge "docs: remove graphics rs docs and restructure existing docs" into jb-dev
2 parents 7017d51 + 864090e commit aa16a2e

File tree

5 files changed

+208
-161
lines changed

5 files changed

+208
-161
lines changed

docs/html/guide/guide_toc.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,26 +311,26 @@ localized titles are added in the language order specified below.
311311
<li><a href="<?cs var:toroot ?>guide/topics/graphics/hardware-accel.html">
312312
<span class="en">Hardware Acceleration</span>
313313
</a></li>
314-
<li class="nav-section">
315-
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/graphics/renderscript/index.html">
316-
<span class="en">Renderscript</span>
314+
</ul>
315+
</li><!-- end of graphics and animation-->
316+
317+
<li class="nav-section">
318+
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/renderscript/index.html">
319+
<span class="en">Computation</span>
317320
</a></div>
318321
<ul>
319-
<li><a href="<?cs var:toroot ?>guide/topics/graphics/renderscript/graphics.html">
320-
<span class="en">Graphics</span></a>
322+
<li><a href="<?cs var:toroot ?>guide/topics/renderscript/compute.html">
323+
<span class="en">Renderscript</span></a>
321324
</li>
322-
<li><a href="<?cs var:toroot ?>guide/topics/graphics/renderscript/compute.html">
323-
<span class="en">Compute</span></a>
325+
326+
<li><a href="<?cs var:toroot ?>guide/topics/renderscript/advanced.html">
327+
<span class="en">Advanced Renderscript</span></a>
324328
</li>
325-
<li><a href="<?cs var:toroot ?>guide/topics/graphics/renderscript/reference.html">
329+
<li><a href="<?cs var:toroot ?>guide/topics/renderscript/reference.html">
326330
<span class="en">Runtime API Reference</span></a>
327-
</li>
331+
</li>
328332
</ul>
329-
</li>
330-
</ul>
331-
</li><!-- end of graphics and animation-->
332-
333-
333+
</li>
334334
<li class="nav-section">
335335
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/media/index.html">
336336
<span class="en">Media and Camera</span>

docs/html/guide/topics/graphics/renderscript/index.jd renamed to docs/html/guide/topics/renderscript/advanced.jd

Lines changed: 24 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
page.title=Renderscript
1+
page.title=Advanced Renderscript
2+
parent.title=Computation
3+
parent.link=index.html
4+
25
@jd:body
36

47
<div id="qv-wrapper">
58
<div id="qv">
69
<h2>In this document</h2>
710

811
<ol>
9-
<li><a href="#overview">Renderscript Overview</a></li>
1012
<li><a href="#native">Renderscript Runtime Layer</a></li>
1113
<li><a href="#reflected">Reflected Layer</a>
1214
<ol>
@@ -33,86 +35,22 @@ page.title=Renderscript
3335
</div>
3436
</div>
3537

36-
<p>Renderscript offers a high performance 3D graphics rendering and compute API at the native
37-
level that you write in C (C99 standard). The main advantages of Renderscript are:</p>
38-
<ul>
39-
<li>Portability: Renderscript is designed to run on many types of devices with different
40-
processor (CPU, GPU, and DSP for instance) architectures. It supports all of these architectures without
41-
having to target each device, because the code is compiled and cached on the device
42-
at runtime.</li>
43-
44-
<li>Performance: Renderscript provides similar performance to OpenGL with the NDK and also
45-
provides a high performance compute API that is not offered by OpenGL.</li>
46-
47-
<li>Usability: Renderscript simplifies development when possible, such as eliminating JNI glue code
48-
and simplifying mesh setup.</li>
49-
</ul>
50-
51-
<p>The main disadvantages are:</p>
52-
53-
<ul>
54-
<li>Development complexity: Renderscript introduces a new set of APIs that you have to learn.
55-
Renderscript also allocates memory differently compared to OpenGL with the Android framework APIs.
56-
However, these issues are not hard to understand and Renderscript offers many features that
57-
make it easier than OpenGL to initialize rendering.</li>
58-
59-
<li>Debugging visibility: Renderscript can potentially execute (planned feature for later releases)
60-
on processors other than the main CPU (such as the GPU), so if this occurs, debugging becomes more difficult.
61-
</li>
62-
</ul>
63-
38+
<p></p>
6439

65-
<p>For an example of Renderscript in action, install the Renderscript sample applications that
66-
are shipped with the SDK in <code>&lt;sdk_root&gt;/samples/android-11/RenderScript</code>.
67-
You can also see a typical use of Renderscript with the 3D carousel view in the Android 3.x
68-
versions of Google Books and YouTube.</p>
69-
70-
<h2 id="overview">Renderscript Overview</h2>
71-
<p>The Renderscript runtime operates at the native level and still needs to communicate
72-
with the Android VM, so the way a Renderscript application is setup is different from a pure VM
73-
application. An application that uses Renderscript is still a traditional Android application that
74-
runs in the VM, but you write Renderscript code for the parts of your program that require
75-
it. Using Renderscript can be as simple as offloading a few math calculations or as complicated as
76-
rendering an entire 3D game. No matter what you use it for, Renderscript remains platform
77-
independent, so you do not have to target multiple architectures (for example,
78-
ARM v5, ARM v7, x86).</p>
79-
80-
<p>The Renderscript system adopts a control and slave architecture where the low-level Renderscript runtime
81-
code is controlled by the higher level Android system that runs in a virtual machine (VM). The
82-
Android VM still retains all control of memory management and binds memory that it allocates to
83-
the Renderscript runtime, so the Renderscript code can access it. The Android framework makes
84-
asynchronous calls to Renderscript, and the calls are placed in a message queue and processed
85-
as soon as possible. Figure 1 shows how the Renderscript system is structured.</p>
86-
87-
<img id="figure1" src="{@docRoot}images/rs_overview.png" />
88-
<p class="img-caption"><strong>Figure 1.</strong> Renderscript system overview</p>
89-
90-
<p>When using Renderscript, there are three layers of APIs that enable communication between the
91-
Renderscript runtime and Android framework code:</p>
92-
93-
<ul>
94-
<li>The Renderscript runtime APIs allow you to do the computation or graphics rendering
95-
that is required by your application.</li>
96-
97-
<li>The reflected layer APIs are a set of classes that are reflected from your Renderscript
98-
runtime code. It is basically a wrapper around the Renderscript code that allows the Android
99-
framework to interact with the Renderscript runtime. The Android build tools automatically generate the
100-
classes for this layer during the build process. These classes eliminate the need to write JNI glue
101-
code, like with the NDK.</li>
102-
103-
<li>The Android framework APIs, which include the {@link android.renderscript} package, allow you to
104-
build your application using traditional Android components such as activities and views. When
105-
using Renderscript, this layer calls the reflected layer to access the Renderscript
106-
runtime.</li>
107-
</ul>
108-
109-
<p></p>
40+
<p>Because applications that utilize Renderscript still run inside of the Android VM,
41+
you have access to all of the framework APIs that you are familiar with, but can
42+
utilize Renderscript when appropriate. To facilitate this interaction between
43+
the framework and the Renderscript runtime, an intermediate layer of code is also
44+
present to facilitate communication and memory management between the two levels of code.
45+
This document goes into more detail about these
46+
different layers of code as well as how memory is shared between the Android VM and
47+
Renderscript runtime.</p>
11048

11149
<h2 id="native">Renderscript Runtime Layer</h2>
11250

11351
<p>Your Renderscript code is compiled and
11452
executed in a compact and well-defined runtime layer. The Renderscript runtime APIs offer support for
115-
intensive computation and graphics rendering that is portable and automatically scalable to the
53+
intensive computation that is portable and automatically scalable to the
11654
amount of cores available on a processor.
11755
</p>
11856
<p class="note"><strong>Note:</strong> The standard C functions in the NDK must be
@@ -132,28 +70,22 @@ amount of cores available on a processor.
13270

13371
<ul>
13472

135-
<li>Graphics rendering functions</li>
136-
13773
<li>Memory allocation request features</li>
13874

13975
<li>A large collection of math functions with both scalar and vector typed overloaded versions
14076
of many common routines. Operations such as adding, multiplying, dot product, and cross product
14177
are available as well as atomic arithmetic and comparison functions.</li>
14278

143-
<li>Conversion routines for primitive data types and vectors, matrix routines, date and time
144-
routines, and graphics routines.</li>
79+
<li>Conversion routines for primitive data types and vectors, matrix routines, and date and time
80+
routines</li>
14581

14682
<li>Data types and structures to support the Renderscript system such as Vector types for
14783
defining two-, three-, or four-vectors.</li>
14884

14985
<li>Logging functions</li>
15086
</ul>
15187

152-
<p>See the Renderscript runtime API reference for more information on the available functions. The
153-
Renderscript header files are automatically included for you, except for the Renderscript graphics header file, which
154-
you can include as follows:</p>
155-
156-
<pre>#include "rs_graphics.rsh"</pre>
88+
<p>See the Renderscript runtime API reference for more information on the available functions.
15789

15890
<h2 id="reflected">Reflected Layer</h2>
15991

@@ -428,14 +360,9 @@ in memory. Each <code>struct</code>'s class defines the following methods and co
428360
specified memory spaces. The following example allocates memory for a custom data type
429361
in both the script and vertex memory spaces:</p>
430362
<pre>
431-
ScriptField_Point touchPoints = new ScriptField_Point(glRenderer, 2,
363+
ScriptField_Point touchPoints = new ScriptField_Point(myRenderscript, 2,
432364
Allocation.USAGE_SCRIPT | Allocation.USAGE_GRAPHICS_VERTEX);
433365
</pre>
434-
435-
<p>If you modify the memory in one memory space and want to push the updates to the rest of
436-
the memory spaces, call <a href="{@docRoot}reference/renderscript/rs__graphics_8rsh.html">
437-
<code>rsgAllocationSyncAll()</code></a> in your Renderscript code to
438-
synchronize the memory.</p>
439366
</li>
440367

441368
<li>A static nested class, <code>Item</code>, allows you to create an instance of the
@@ -665,23 +592,22 @@ appropriate layer.</p>
665592
<code>intPointer</code>, and a pointer to a struct, <code>touchPoints</code>. It also binds the memory to the
666593
Renderscript:</p>
667594
<pre>
668-
private RenderScriptGL glRenderer;
595+
private RenderScript myRenderscript;
669596
private ScriptC_example script;
670597
private Resources resources;
671598

672-
public void init(RenderScriptGL rs, Resources res) {
673-
//get the rendering context and resources from the calling method
674-
glRenderer = rs;
599+
public void init(RenderScript rs, Resources res) {
600+
myRenderscript = rs;
675601
resources = res;
676602

677603
//allocate memory for the struct pointer, calling the constructor
678-
ScriptField_Point touchPoints = new ScriptField_Point(glRenderer, 2);
604+
ScriptField_Point touchPoints = new ScriptField_Point(myRenderscript, 2);
679605

680606
//Create an element manually and allocate memory for the int pointer
681-
intPointer = Allocation.createSized(glRenderer, Element.I32(glRenderer), 2);
607+
intPointer = Allocation.createSized(myRenderscript, Element.I32(myRenderscript), 2);
682608

683609
//create an instance of the Renderscript, pointing it to the bytecode resource
684-
mScript = new ScriptC_example(glRenderer, resources, R.raw.example);
610+
mScript = new ScriptC_example(myRenderscript, resources, R.raw.example);
685611

686612
//bind the struct and int pointers to the Renderscript
687613
mScript.bind_touchPoints(touchPoints);

0 commit comments

Comments
 (0)