1044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams/*
2f8e195ee50ac7b01fc0130af6634afe475d2deaeAlex Sakhartchouk * Copyright (C) 2011-2012 The Android Open Source Project
31d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams *
4044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Licensed under the Apache License, Version 2.0 (the "License");
5044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * you may not use this file except in compliance with the License.
6044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * You may obtain a copy of the License at
71d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams *
8044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *      http://www.apache.org/licenses/LICENSE-2.0
909aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams *
10044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Unless required by applicable law or agreed to in writing, software
11044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * distributed under the License is distributed on an "AS IS" BASIS,
12044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * See the License for the specific language governing permissions and
14044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * limitations under the License.
1509aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams */
16275b1e98bb949643d35546f10f8b1af009349526Jason Sams
173c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk /*! \mainpage notitle
183c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  *
193c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * Renderscript is a high-performance runtime that provides graphics rendering and
203c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * compute operations at the native level. Renderscript code is compiled on devices
213c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * at runtime to allow platform-independence as well.
223c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * This reference documentation describes the Renderscript runtime APIs, which you
233c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * can utilize to write Renderscript code in C99. The Renderscript header
243c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * files are automatically included for you, except for the rs_graphics.rsh header. If
253c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * you are doing graphics rendering, include the graphics header file like this:
263c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  *
273c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * <code>#include "rs_graphics.rsh"</code>
283c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  *
293c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * To use Renderscript, you need to utilize the Renderscript runtime APIs documented here
303c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * as well as the Android framework APIs for Renderscript.
313c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * For documentation on the Android framework APIs, see the <a target="_parent" href=
323c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * "http://developer.android.com/reference/android/renderscript/package-summary.html">
333c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * android.renderscript</a> package reference.
343c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * For more information on how to develop with Renderscript and how the runtime and
353c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * Android framework APIs interact, see the <a target="_parent" href=
363c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * "http://developer.android.com/guide/topics/renderscript/index.html">Renderscript
373c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * developer guide</a> and the <a target="_parent" href=
383c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * "http://developer.android.com/resources/samples/RenderScript/index.html">
393c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  * Renderscript samples</a>.
403c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk  */
413c0c6061ce428609182eedcf82c7f75df074fcf4Alex Sakhartchouk
42044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams/** @file rs_core.rsh
43044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *  \brief todo-jsams
4409aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams *
45044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *  todo-jsams
4609aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams *
4709aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams */
48275b1e98bb949643d35546f10f8b1af009349526Jason Sams
49044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#ifndef __RS_CORE_RSH__
50044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#define __RS_CORE_RSH__
51275b1e98bb949643d35546f10f8b1af009349526Jason Sams
52044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#define _RS_RUNTIME extern
53275b1e98bb949643d35546f10f8b1af009349526Jason Sams
54044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_types.rsh"
55044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_allocation.rsh"
56044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_atomic.rsh"
57044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_cl.rsh"
58044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_debug.rsh"
5914607a6bd1e909a7944e39b7ec71dc0ba65de2cdAlex Sakhartchouk#include "rs_element.rsh"
60044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_math.rsh"
61044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_matrix.rsh"
62044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_object.rsh"
63044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_quaternion.rsh"
6414607a6bd1e909a7944e39b7ec71dc0ba65de2cdAlex Sakhartchouk#include "rs_sampler.rsh"
65044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#include "rs_time.rsh"
662a63bf6c293d89c8e3725cfb7ee2add3dd3f0246Jason Sams
6709aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams/**
68044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Send a message back to the client.  Will not block and returns true
69044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * if the message was sendable and false if the fifo was full.
70044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * A message ID is required.  Data payload is optional.
7109aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams */
72044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samsextern bool __attribute__((overloadable))
73044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsSendToClient(int cmdID);
741d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
751d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams * \overload
761d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
77044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samsextern bool __attribute__((overloadable))
78044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsSendToClient(int cmdID, const void *data, uint len);
791d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
80044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Send a message back to the client, blocking until the message is queued.
81044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * A message ID is required.  Data payload is optional.
821d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
83044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samsextern void __attribute__((overloadable))
84044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsSendToClientBlocking(int cmdID);
851d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
861d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams * \overload
871d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
88044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samsextern void __attribute__((overloadable))
89044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsSendToClientBlocking(int cmdID, const void *data, uint len);
9009aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams
9109aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams
9209aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams/**
93044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Launch order hint for rsForEach calls.  This provides a hint to the system to
94044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * determine in which order the root function of the target is called with each
95044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * cell of the allocation.
9609aeb8ac1b0b976c2de40dd00da0c6841e4e882aJason Sams *
97044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * This is a hint and implementations may not obey the order.
981d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
99044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samsenum rs_for_each_strategy {
100f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_SERIAL = 0,
101f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
102f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
103f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_TILE_SMALL= 3,
104f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
105f598811a60088236222bb1879503842094ca378bStephen Hines    RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
106044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams};
1077fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1087fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1091d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
110044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Structure to provide extra information to a rsForEach call.  Primarly used to
111044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * restrict the call to a subset of cells in the allocation.
1121d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
113044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Samstypedef struct rs_script_call {
114044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    enum rs_for_each_strategy strategy;
115044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t xStart;
116044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t xEnd;
117044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t yStart;
118044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t yEnd;
119044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t zStart;
120044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t zEnd;
121044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t arrayStart;
122044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    uint32_t arrayEnd;
123044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams} rs_script_call_t;
1247fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1251d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
126044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Make a script to script call to launch work. One of the input or output is
127044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * required to be a valid object. The input and output must be of the same
128044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * dimensions.
129044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * API 10-13
1301d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams *
131044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param script The target script to call
132044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param input The allocation to source data from
133044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param output the allocation to write date into
134044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param usrData The user definied params to pass to the root script.  May be
135044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *                NULL.
136044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param sc Extra control infomation used to select a sub-region of the
137044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *           allocation to be processed or suggest a walking strategy.  May be
138044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *           NULL.
1391d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams *
140044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *  */
141044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#if !defined(RS_VERSION) || (RS_VERSION < 14)
142693080efdafbf49d675fe5f959f0286f83b30c81Jason Samsextern void __attribute__((overloadable))
143044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsForEach(rs_script script, rs_allocation input,
144044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams              rs_allocation output, const void * usrData,
145044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams              const rs_script_call_t *sc);
1461d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
1471d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams * \overload
1481d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
149693080efdafbf49d675fe5f959f0286f83b30c81Jason Samsextern void __attribute__((overloadable))
150044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsForEach(rs_script script, rs_allocation input,
151044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams              rs_allocation output, const void * usrData);
152044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams#else
1537fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1541d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
155044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * Make a script to script call to launch work. One of the input or output is
156044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * required to be a valid object. The input and output must be of the same
157044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * dimensions.
158044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * API 14+
159044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *
160044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param script The target script to call
161044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param input The allocation to source data from
162044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param output the allocation to write date into
163044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param usrData The user definied params to pass to the root script.  May be
164044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *                NULL.
165044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param usrDataLen The size of the userData structure.  This will be used to
166044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *                   perform a shallow copy of the data if necessary.
167044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams * @param sc Extra control infomation used to select a sub-region of the
168044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *           allocation to be processed or suggest a walking strategy.  May be
169044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams *           NULL.
1701d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams *
1711d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
1721d526a448325cd9678b12b7de9263a254ec8fdc8Jason Samsextern void __attribute__((overloadable))
173044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
174044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams              const void * usrData, size_t usrDataLen, const rs_script_call_t *);
1751d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
1761d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams * \overload
1771d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
1781d526a448325cd9678b12b7de9263a254ec8fdc8Jason Samsextern void __attribute__((overloadable))
179044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
180044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams              const void * usrData, size_t usrDataLen);
1811d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams/**
1821d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams * \overload
1831d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams */
184693080efdafbf49d675fe5f959f0286f83b30c81Jason Samsextern void __attribute__((overloadable))
185044e2ee36ffe6520570a7f0207d75a8fce8b8e91Jason Sams    rsForEach(rs_script script, rs_allocation input, rs_allocation output);
186eb0dfedaf861049858a365d56d67cc85bfcad3c3Jason Sams#endif
1877fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1881d526a448325cd9678b12b7de9263a254ec8fdc8Jason Sams
1897fe6bce13c30b8d14dc833e06468666d28e56ee1Jason Sams
1907a43031a3f3e06f0257b507d5f197afaa21e2a3aShih-wei Liao#undef _RS_RUNTIME
191275b1e98bb949643d35546f10f8b1af009349526Jason Sams
192275b1e98bb949643d35546f10f8b1af009349526Jason Sams#endif
193