blob: c1c96aa152b6c7db1053ad15cdbcbab8fd0e9663 [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
Alex Sakhartchoukf8e195e2012-03-22 10:50:55 -07002 * Copyright (C) 2011-2012 The Android Open Source Project
Jason Sams044e2ee2011-08-08 16:52:30 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070017 /*! \mainpage notitle
18 *
Stephen Hinese227f9a2013-05-29 14:48:19 -070019 * RenderScript is a high-performance runtime that provides
20 * compute operations at the native level. RenderScript code is compiled on devices
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070021 * at runtime to allow platform-independence as well.
Stephen Hinese227f9a2013-05-29 14:48:19 -070022 * This reference documentation describes the RenderScript runtime APIs, which you
23 * can utilize to write RenderScript code in C99. The RenderScript compute header
24 * files are automatically included for you.
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070025 *
Stephen Hinese227f9a2013-05-29 14:48:19 -070026 * To use RenderScript, you need to utilize the RenderScript runtime APIs documented here
27 * as well as the Android framework APIs for RenderScript.
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070028 * For documentation on the Android framework APIs, see the <a target="_parent" href=
29 * "http://developer.android.com/reference/android/renderscript/package-summary.html">
30 * android.renderscript</a> package reference.
Stephen Hinese227f9a2013-05-29 14:48:19 -070031 * For more information on how to develop with RenderScript and how the runtime and
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070032 * Android framework APIs interact, see the <a target="_parent" href=
Stephen Hinese227f9a2013-05-29 14:48:19 -070033 * "http://developer.android.com/guide/topics/renderscript/index.html">RenderScript
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070034 * developer guide</a> and the <a target="_parent" href=
35 * "http://developer.android.com/resources/samples/RenderScript/index.html">
Stephen Hinese227f9a2013-05-29 14:48:19 -070036 * RenderScript samples</a>.
Alex Sakhartchouk3c0c6062012-03-22 16:59:38 -070037 */
38
Jason Sams1d526a42011-08-08 15:54:14 -070039/** @file rs_core.rsh
40 * \brief todo-jsams
41 *
42 * todo-jsams
43 *
44 */
Jason Sams044e2ee2011-08-08 16:52:30 -070045
Jason Sams275b1e92010-05-28 18:08:16 -070046#ifndef __RS_CORE_RSH__
47#define __RS_CORE_RSH__
48
Shih-wei Liao7a430312011-01-26 14:47:17 -080049#define _RS_RUNTIME extern
Stephen Hinesf6a28c62011-01-18 16:53:19 -080050
Chris Wailes9d261712014-05-22 14:37:49 -070051#define RS_KERNEL __attribute__((kernel))
52
Jason Sams044e2ee2011-08-08 16:52:30 -070053#include "rs_types.rsh"
54#include "rs_allocation.rsh"
55#include "rs_atomic.rsh"
Jason Sams29087fa2014-01-09 17:06:17 -080056#include "rs_core_math.rsh"
Jason Sams044e2ee2011-08-08 16:52:30 -070057#include "rs_debug.rsh"
Alex Sakhartchouk14607a62012-03-21 09:58:15 -070058#include "rs_element.rsh"
Jason Sams044e2ee2011-08-08 16:52:30 -070059#include "rs_math.rsh"
60#include "rs_matrix.rsh"
61#include "rs_object.rsh"
62#include "rs_quaternion.rsh"
Alex Sakhartchouk14607a62012-03-21 09:58:15 -070063#include "rs_sampler.rsh"
Jason Sams044e2ee2011-08-08 16:52:30 -070064#include "rs_time.rsh"
65
Jason Sams09aeb8a2011-01-28 15:49:07 -080066/**
Jason Sams044e2ee2011-08-08 16:52:30 -070067 * Send a message back to the client. Will not block and returns true
68 * if the message was sendable and false if the fifo was full.
69 * A message ID is required. Data payload is optional.
Jason Sams09aeb8a2011-01-28 15:49:07 -080070 */
Jason Sams044e2ee2011-08-08 16:52:30 -070071extern bool __attribute__((overloadable))
72 rsSendToClient(int cmdID);
Jason Sams1d526a42011-08-08 15:54:14 -070073/**
74 * \overload
75 */
Jason Sams044e2ee2011-08-08 16:52:30 -070076extern bool __attribute__((overloadable))
77 rsSendToClient(int cmdID, const void *data, uint len);
Jason Sams1d526a42011-08-08 15:54:14 -070078/**
Jason Sams044e2ee2011-08-08 16:52:30 -070079 * Send a message back to the client, blocking until the message is queued.
80 * A message ID is required. Data payload is optional.
Jason Sams09aeb8a2011-01-28 15:49:07 -080081 */
Jason Sams693080e2011-01-25 21:33:44 -080082extern void __attribute__((overloadable))
Jason Sams044e2ee2011-08-08 16:52:30 -070083 rsSendToClientBlocking(int cmdID);
Jason Sams1d526a42011-08-08 15:54:14 -070084/**
85 * \overload
86 */
Jason Sams693080e2011-01-25 21:33:44 -080087extern void __attribute__((overloadable))
Jason Sams044e2ee2011-08-08 16:52:30 -070088 rsSendToClientBlocking(int cmdID, const void *data, uint len);
89
Jason Sams7fe6bce2010-06-24 13:54:11 -070090
Jason Sams1d526a42011-08-08 15:54:14 -070091/**
Jason Sams044e2ee2011-08-08 16:52:30 -070092 * Launch order hint for rsForEach calls. This provides a hint to the system to
93 * determine in which order the root function of the target is called with each
94 * cell of the allocation.
Jason Sams1d526a42011-08-08 15:54:14 -070095 *
Jason Sams044e2ee2011-08-08 16:52:30 -070096 * This is a hint and implementations may not obey the order.
Jason Sams1d526a42011-08-08 15:54:14 -070097 */
Jason Sams044e2ee2011-08-08 16:52:30 -070098enum rs_for_each_strategy {
Stephen Hinesf5988112012-10-16 00:05:46 -070099 RS_FOR_EACH_STRATEGY_SERIAL = 0,
100 RS_FOR_EACH_STRATEGY_DONT_CARE = 1,
101 RS_FOR_EACH_STRATEGY_DST_LINEAR = 2,
102 RS_FOR_EACH_STRATEGY_TILE_SMALL= 3,
103 RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4,
104 RS_FOR_EACH_STRATEGY_TILE_LARGE = 5
Jason Sams044e2ee2011-08-08 16:52:30 -0700105};
106
Jason Sams7fe6bce2010-06-24 13:54:11 -0700107
Jason Sams1d526a42011-08-08 15:54:14 -0700108/**
Jason Sams044e2ee2011-08-08 16:52:30 -0700109 * Structure to provide extra information to a rsForEach call. Primarly used to
110 * restrict the call to a subset of cells in the allocation.
111 */
112typedef struct rs_script_call {
113 enum rs_for_each_strategy strategy;
114 uint32_t xStart;
115 uint32_t xEnd;
116 uint32_t yStart;
117 uint32_t yEnd;
118 uint32_t zStart;
119 uint32_t zEnd;
120 uint32_t arrayStart;
121 uint32_t arrayEnd;
122} rs_script_call_t;
123
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800124#if !defined(RS_VERSION) || (RS_VERSION < 14)
Jason Sams044e2ee2011-08-08 16:52:30 -0700125/**
126 * Make a script to script call to launch work. One of the input or output is
127 * required to be a valid object. The input and output must be of the same
128 * dimensions.
129 * API 10-13
Jason Sams1d526a42011-08-08 15:54:14 -0700130 *
Jason Sams044e2ee2011-08-08 16:52:30 -0700131 * @param script The target script to call
132 * @param input The allocation to source data from
133 * @param output the allocation to write date into
134 * @param usrData The user definied params to pass to the root script. May be
135 * NULL.
136 * @param sc Extra control infomation used to select a sub-region of the
137 * allocation to be processed or suggest a walking strategy. May be
138 * NULL.
Jason Sams1d526a42011-08-08 15:54:14 -0700139 *
Jason Sams044e2ee2011-08-08 16:52:30 -0700140 * */
Jason Sams044e2ee2011-08-08 16:52:30 -0700141extern void __attribute__((overloadable))
142 rsForEach(rs_script script, rs_allocation input,
143 rs_allocation output, const void * usrData,
144 const rs_script_call_t *sc);
Jason Sams1d526a42011-08-08 15:54:14 -0700145/**
146 * \overload
147 */
Jason Sams044e2ee2011-08-08 16:52:30 -0700148extern void __attribute__((overloadable))
149 rsForEach(rs_script script, rs_allocation input,
150 rs_allocation output, const void * usrData);
Jason Samseb0dfed2011-07-27 14:10:53 -0700151
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800152#elif (RS_VERSION < 21)
Jason Sams1d526a42011-08-08 15:54:14 -0700153/**
Jason Sams044e2ee2011-08-08 16:52:30 -0700154 * Make a script to script call to launch work. One of the input or output is
155 * required to be a valid object. The input and output must be of the same
156 * dimensions.
157 * API 14+
158 *
159 * @param script The target script to call
160 * @param input The allocation to source data from
161 * @param output the allocation to write date into
162 * @param usrData The user definied params to pass to the root script. May be
Tim Murray2f6dc842014-11-14 13:27:05 -0800163 * NULL. Not supported in API 21 or higher.
Jason Sams044e2ee2011-08-08 16:52:30 -0700164 * @param usrDataLen The size of the userData structure. This will be used to
165 * perform a shallow copy of the data if necessary.
166 * @param sc Extra control infomation used to select a sub-region of the
167 * allocation to be processed or suggest a walking strategy. May be
168 * NULL.
169 *
170 */
171extern void __attribute__((overloadable))
172 rsForEach(rs_script script, rs_allocation input, rs_allocation output,
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800173 const void * usrData, size_t usrDataLen, const rs_script_call_t *sc);
Jason Sams044e2ee2011-08-08 16:52:30 -0700174/**
Jason Sams1d526a42011-08-08 15:54:14 -0700175 * \overload
176 */
Jason Sams044e2ee2011-08-08 16:52:30 -0700177extern void __attribute__((overloadable))
178 rsForEach(rs_script script, rs_allocation input, rs_allocation output,
179 const void * usrData, size_t usrDataLen);
Tim Murray2f6dc842014-11-14 13:27:05 -0800180
Jason Sams1d526a42011-08-08 15:54:14 -0700181/**
182 * \overload
183 */
Jason Sams044e2ee2011-08-08 16:52:30 -0700184extern void __attribute__((overloadable))
185 rsForEach(rs_script script, rs_allocation input, rs_allocation output);
Jean-Luc Brouillet462e62c2014-12-12 13:42:24 -0800186
187#else
188/**
189 * Make a script to script call to launch work. One of the input or output is
190 * required to be a valid object. The input and output must be of the same
191 * dimensions.
192 * API 21+
193 *
194 * @param script The target script to call
195 * @param input The allocation to source data from
196 * @param output the allocation to write date into
197 */
198extern void __attribute__((overloadable))
199 rsForEach(rs_script script, rs_allocation input, rs_allocation output);
Jason Samseb0dfed2011-07-27 14:10:53 -0700200#endif
Jason Sams7fe6bce2010-06-24 13:54:11 -0700201
Shih-wei Liao7a430312011-01-26 14:47:17 -0800202#undef _RS_RUNTIME
Jason Sams275b1e92010-05-28 18:08:16 -0700203
204#endif