Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | f8e195e | 2012-03-22 10:50:55 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 3 | * |
| 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 Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 17 | /*! \mainpage notitle |
| 18 | * |
Stephen Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 19 | * RenderScript is a high-performance runtime that provides |
| 20 | * compute operations at the native level. RenderScript code is compiled on devices |
Alex Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 21 | * at runtime to allow platform-independence as well. |
Stephen Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 22 | * 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 Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 25 | * |
Stephen Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 26 | * To use RenderScript, you need to utilize the RenderScript runtime APIs documented here |
| 27 | * as well as the Android framework APIs for RenderScript. |
Alex Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 28 | * 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 Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 31 | * For more information on how to develop with RenderScript and how the runtime and |
Alex Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 32 | * Android framework APIs interact, see the <a target="_parent" href= |
Stephen Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 33 | * "http://developer.android.com/guide/topics/renderscript/index.html">RenderScript |
Alex Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 34 | * developer guide</a> and the <a target="_parent" href= |
| 35 | * "http://developer.android.com/resources/samples/RenderScript/index.html"> |
Stephen Hines | e227f9a | 2013-05-29 14:48:19 -0700 | [diff] [blame] | 36 | * RenderScript samples</a>. |
Alex Sakhartchouk | 3c0c606 | 2012-03-22 16:59:38 -0700 | [diff] [blame] | 37 | */ |
| 38 | |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 39 | /** @file rs_core.rsh |
| 40 | * \brief todo-jsams |
| 41 | * |
| 42 | * todo-jsams |
| 43 | * |
| 44 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 45 | |
Jason Sams | 275b1e9 | 2010-05-28 18:08:16 -0700 | [diff] [blame] | 46 | #ifndef __RS_CORE_RSH__ |
| 47 | #define __RS_CORE_RSH__ |
| 48 | |
Shih-wei Liao | 7a43031 | 2011-01-26 14:47:17 -0800 | [diff] [blame] | 49 | #define _RS_RUNTIME extern |
Stephen Hines | f6a28c6 | 2011-01-18 16:53:19 -0800 | [diff] [blame] | 50 | |
Chris Wailes | 9d26171 | 2014-05-22 14:37:49 -0700 | [diff] [blame] | 51 | #define RS_KERNEL __attribute__((kernel)) |
| 52 | |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 53 | #include "rs_types.rsh" |
| 54 | #include "rs_allocation.rsh" |
| 55 | #include "rs_atomic.rsh" |
Jason Sams | 29087fa | 2014-01-09 17:06:17 -0800 | [diff] [blame] | 56 | #include "rs_core_math.rsh" |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 57 | #include "rs_debug.rsh" |
Alex Sakhartchouk | 14607a6 | 2012-03-21 09:58:15 -0700 | [diff] [blame] | 58 | #include "rs_element.rsh" |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 59 | #include "rs_math.rsh" |
| 60 | #include "rs_matrix.rsh" |
| 61 | #include "rs_object.rsh" |
| 62 | #include "rs_quaternion.rsh" |
Alex Sakhartchouk | 14607a6 | 2012-03-21 09:58:15 -0700 | [diff] [blame] | 63 | #include "rs_sampler.rsh" |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 64 | #include "rs_time.rsh" |
| 65 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 66 | /** |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 67 | * 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 Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 70 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 71 | extern bool __attribute__((overloadable)) |
| 72 | rsSendToClient(int cmdID); |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 73 | /** |
| 74 | * \overload |
| 75 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 76 | extern bool __attribute__((overloadable)) |
| 77 | rsSendToClient(int cmdID, const void *data, uint len); |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 78 | /** |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 79 | * Send a message back to the client, blocking until the message is queued. |
| 80 | * A message ID is required. Data payload is optional. |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 81 | */ |
Jason Sams | 693080e | 2011-01-25 21:33:44 -0800 | [diff] [blame] | 82 | extern void __attribute__((overloadable)) |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 83 | rsSendToClientBlocking(int cmdID); |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 84 | /** |
| 85 | * \overload |
| 86 | */ |
Jason Sams | 693080e | 2011-01-25 21:33:44 -0800 | [diff] [blame] | 87 | extern void __attribute__((overloadable)) |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 88 | rsSendToClientBlocking(int cmdID, const void *data, uint len); |
| 89 | |
Jason Sams | 7fe6bce | 2010-06-24 13:54:11 -0700 | [diff] [blame] | 90 | |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 91 | /** |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 92 | * 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 Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 95 | * |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 96 | * This is a hint and implementations may not obey the order. |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 97 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 98 | enum rs_for_each_strategy { |
Stephen Hines | f598811 | 2012-10-16 00:05:46 -0700 | [diff] [blame] | 99 | 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 Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
Jason Sams | 7fe6bce | 2010-06-24 13:54:11 -0700 | [diff] [blame] | 107 | |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 108 | /** |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 109 | * 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 | */ |
| 112 | typedef 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 Brouillet | 462e62c | 2014-12-12 13:42:24 -0800 | [diff] [blame^] | 124 | #if !defined(RS_VERSION) || (RS_VERSION < 14) |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 125 | /** |
| 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 Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 130 | * |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 131 | * @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 Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 139 | * |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 140 | * */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 141 | extern 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 Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 145 | /** |
| 146 | * \overload |
| 147 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 148 | extern void __attribute__((overloadable)) |
| 149 | rsForEach(rs_script script, rs_allocation input, |
| 150 | rs_allocation output, const void * usrData); |
Jason Sams | eb0dfed | 2011-07-27 14:10:53 -0700 | [diff] [blame] | 151 | |
Jean-Luc Brouillet | 462e62c | 2014-12-12 13:42:24 -0800 | [diff] [blame^] | 152 | #elif (RS_VERSION < 21) |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 153 | /** |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 154 | * 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 Murray | 2f6dc84 | 2014-11-14 13:27:05 -0800 | [diff] [blame] | 163 | * NULL. Not supported in API 21 or higher. |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 164 | * @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 | */ |
| 171 | extern void __attribute__((overloadable)) |
| 172 | rsForEach(rs_script script, rs_allocation input, rs_allocation output, |
Jean-Luc Brouillet | 462e62c | 2014-12-12 13:42:24 -0800 | [diff] [blame^] | 173 | const void * usrData, size_t usrDataLen, const rs_script_call_t *sc); |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 174 | /** |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 175 | * \overload |
| 176 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 177 | extern void __attribute__((overloadable)) |
| 178 | rsForEach(rs_script script, rs_allocation input, rs_allocation output, |
| 179 | const void * usrData, size_t usrDataLen); |
Tim Murray | 2f6dc84 | 2014-11-14 13:27:05 -0800 | [diff] [blame] | 180 | |
Jason Sams | 1d526a4 | 2011-08-08 15:54:14 -0700 | [diff] [blame] | 181 | /** |
| 182 | * \overload |
| 183 | */ |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 184 | extern void __attribute__((overloadable)) |
| 185 | rsForEach(rs_script script, rs_allocation input, rs_allocation output); |
Jean-Luc Brouillet | 462e62c | 2014-12-12 13:42:24 -0800 | [diff] [blame^] | 186 | |
| 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 | */ |
| 198 | extern void __attribute__((overloadable)) |
| 199 | rsForEach(rs_script script, rs_allocation input, rs_allocation output); |
Jason Sams | eb0dfed | 2011-07-27 14:10:53 -0700 | [diff] [blame] | 200 | #endif |
Jason Sams | 7fe6bce | 2010-06-24 13:54:11 -0700 | [diff] [blame] | 201 | |
Shih-wei Liao | 7a43031 | 2011-01-26 14:47:17 -0800 | [diff] [blame] | 202 | #undef _RS_RUNTIME |
Jason Sams | 275b1e9 | 2010-05-28 18:08:16 -0700 | [diff] [blame] | 203 | |
| 204 | #endif |