blob: 9507c0c08df25727e609b240f71c37aa6022400b [file] [log] [blame]
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
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
Stephen Hines3f868232015-04-10 09:22:19 -070017// Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070018
19/*
Stephen Hines3f868232015-04-10 09:22:19 -070020 * rs_for_each.rsh: Kernel Invocation Functions and Types
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070021 *
Stephen Hines3f868232015-04-10 09:22:19 -070022 * The rsForEach() function can be used to invoke the root kernel of a script.
23 *
24 * The other functions are used to get the characteristics of the invocation of
25 * an executing kernel, like dimensions and current indexes. These functions take
26 * a rs_kernel_context as argument.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070027 */
Stephen Hines3f868232015-04-10 09:22:19 -070028
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070029#ifndef RENDERSCRIPT_RS_FOR_EACH_RSH
30#define RENDERSCRIPT_RS_FOR_EACH_RSH
31
32/*
Stephen Hines3f868232015-04-10 09:22:19 -070033 * rs_for_each_strategy_t: Suggested cell processing order
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070034 *
Stephen Hines3f868232015-04-10 09:22:19 -070035 * This type is used to suggest how the invoked kernel should iterate over the cells of the
36 * allocations. This is a hint only. Implementations may not follow the suggestion.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070037 *
Stephen Hines3f868232015-04-10 09:22:19 -070038 * This specification can help the caching behavior of the running kernel, e.g. the cache
39 * locality when the processing is distributed over multiple cores.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070040 */
41typedef enum rs_for_each_strategy {
Stephen Hines3f868232015-04-10 09:22:19 -070042 RS_FOR_EACH_STRATEGY_SERIAL = 0, // Prefer contiguous memory regions.
43 RS_FOR_EACH_STRATEGY_DONT_CARE = 1, // No prefrences.
44 RS_FOR_EACH_STRATEGY_DST_LINEAR = 2, // Prefer DST.
45 RS_FOR_EACH_STRATEGY_TILE_SMALL = 3, // Prefer processing small rectangular regions.
46 RS_FOR_EACH_STRATEGY_TILE_MEDIUM = 4, // Prefer processing medium rectangular regions.
47 RS_FOR_EACH_STRATEGY_TILE_LARGE = 5 // Prefer processing large rectangular regions.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070048} rs_for_each_strategy_t;
49
50/*
Stephen Hines3f868232015-04-10 09:22:19 -070051 * rs_kernel_context: Handle to a kernel invocation context
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070052 *
Stephen Hines3f868232015-04-10 09:22:19 -070053 * The kernel context contains common characteristics of the allocations being iterated
54 * over, like dimensions, and rarely used indexes, like the Array0 index or the current
55 * level of detail.
56 *
57 * A kernel may be executed in parallel over multiple threads. Each thread will have its
58 * own context.
59 *
Miao Wangcd72e382015-08-20 15:52:21 -070060 * You can access the context by adding a special parameter named "context" and of type
61 * rs_kernel_context to your kernel function. See rsGetDimX() and rsGetArray0() for examples.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070062 */
63#if (defined(RS_VERSION) && (RS_VERSION >= 23))
64typedef const struct rs_kernel_context_t * rs_kernel_context;
65#endif
66
67/*
Stephen Hines3f868232015-04-10 09:22:19 -070068 * rs_script_call_t: Cell iteration information
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070069 *
Stephen Hines3f868232015-04-10 09:22:19 -070070 * This structure is used to provide iteration information to a rsForEach call.
71 * It is currently used to restrict processing to a subset of cells. In future
72 * versions, it will also be used to provide hint on how to best iterate over
73 * the cells.
74 *
75 * The Start fields are inclusive and the End fields are exclusive. E.g. to iterate
76 * over cells 4, 5, 6, and 7 in the X dimension, set xStart to 4 and xEnd to 8.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070077 */
78typedef struct rs_script_call {
Stephen Hines3f868232015-04-10 09:22:19 -070079 rs_for_each_strategy_t strategy; // Currently ignored. In the future, will be suggested cell iteration strategy.
80 uint32_t xStart; // Starting index in the X dimension.
81 uint32_t xEnd; // Ending index (exclusive) in the X dimension.
82 uint32_t yStart; // Starting index in the Y dimension.
83 uint32_t yEnd; // Ending index (exclusive) in the Y dimension.
84 uint32_t zStart; // Starting index in the Z dimension.
85 uint32_t zEnd; // Ending index (exclusive) in the Z dimension.
86 uint32_t arrayStart; // Starting index in the Array0 dimension.
87 uint32_t arrayEnd; // Ending index (exclusive) in the Array0 dimension.
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -070088 uint32_t array1Start; // Starting index in the Array1 dimension.
89 uint32_t array1End; // Ending index (exclusive) in the Array1 dimension.
90 uint32_t array2Start; // Starting index in the Array2 dimension.
91 uint32_t array2End; // Ending index (exclusive) in the Array2 dimension.
92 uint32_t array3Start; // Starting index in the Array3 dimension.
93 uint32_t array3End; // Ending index (exclusive) in the Array3 dimension.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -070094} rs_script_call_t;
95
96/*
Stephen Hines3f868232015-04-10 09:22:19 -070097 * rsForEach: Invoke the root kernel of a script
98 *
99 * Invoke the kernel named "root" of the specified script. Like other kernels, this root()
100 * function will be invoked repeatedly over the cells of the specificed allocation, filling
101 * the output allocation with the results.
102 *
103 * When rsForEach is called, the root script is launched immediately. rsForEach returns
104 * only when the script has completed and the output allocation is ready to use.
105 *
106 * The rs_script argument is typically initialized using a global variable set from Java.
107 *
108 * The kernel can be invoked with just an input allocation or just an output allocation.
109 * This can be done by defining an rs_allocation variable and not initializing it. E.g.
110 * rs_script gCustomScript;
111 * void specializedProcessing(rs_allocation in) {
112 * rs_allocation ignoredOut;
113 * rsForEach(gCustomScript, in, ignoredOut);
114 * }
115 *
116 * If both input and output allocations are specified, they must have the same dimensions.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700117 *
118 * Parameters:
Stephen Hines3f868232015-04-10 09:22:19 -0700119 * script: Script to call.
120 * input: Allocation to source data from.
121 * output: Allocation to write date into.
122 * usrData: User defined data to pass to the script. May be NULL.
123 * sc: Extra control information used to select a sub-region of the allocation to be processed or suggest a walking strategy. May be NULL.
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700124 * usrDataLen: Size of the userData structure. This will be used to perform a shallow copy of the data if necessary.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700125 */
126#if !defined(RS_VERSION) || (RS_VERSION <= 13)
127extern void __attribute__((overloadable))
128 rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
129 const rs_script_call_t* sc);
130#endif
131
132#if !defined(RS_VERSION) || (RS_VERSION <= 13)
133extern void __attribute__((overloadable))
134 rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData);
135#endif
136
137#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
138extern void __attribute__((overloadable))
139 rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
140 size_t usrDataLen, const rs_script_call_t* sc);
141#endif
142
143#if (defined(RS_VERSION) && (RS_VERSION >= 14) && (RS_VERSION <= 20))
144extern void __attribute__((overloadable))
145 rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void* usrData,
146 size_t usrDataLen);
147#endif
148
149#if (defined(RS_VERSION) && (RS_VERSION >= 14))
150extern void __attribute__((overloadable))
151 rsForEach(rs_script script, rs_allocation input, rs_allocation output);
152#endif
153
154/*
155 * rsGetArray0: Index in the Array0 dimension for the specified context
156 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700157 * Returns the index in the Array0 dimension of the cell being processed, as specified
158 * by the supplied context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700159 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700160 * This context is created when a kernel is launched and updated at each iteration.
161 * It contains common characteristics of the allocations being iterated over and rarely
162 * used indexes, like the Array0 index.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700163 *
Miao Wangcd72e382015-08-20 15:52:21 -0700164 * You can access the context by adding a special parameter named "context" and of
165 * type rs_kernel_context to your kernel function. E.g.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700166 * short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {
167 * // The current index in the common x, y, z, w dimensions are accessed by
168 * // adding these variables as arguments. For the more rarely used indexes
169 * // to the other dimensions, extract them from the context:
170 * uint32_t index_a0 = rsGetArray0(context);
171 * //...
172 * }
173 *
174 * This function returns 0 if the Array0 dimension is not present.
175 */
176#if (defined(RS_VERSION) && (RS_VERSION >= 23))
177extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700178 rsGetArray0(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700179#endif
180
181/*
182 * rsGetArray1: Index in the Array1 dimension for the specified context
183 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700184 * Returns the index in the Array1 dimension of the cell being processed, as specified
185 * by the supplied context. See rsGetArray0() for an explanation of the context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700186 *
187 * Returns 0 if the Array1 dimension is not present.
188 */
189#if (defined(RS_VERSION) && (RS_VERSION >= 23))
190extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700191 rsGetArray1(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700192#endif
193
194/*
195 * rsGetArray2: Index in the Array2 dimension for the specified context
196 *
197 * Returns the index in the Array2 dimension of the cell being processed,
198 * as specified by the supplied context. See rsGetArray0() for an explanation
199 * of the context.
200 *
201 * Returns 0 if the Array2 dimension is not present.
202 */
203#if (defined(RS_VERSION) && (RS_VERSION >= 23))
204extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700205 rsGetArray2(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700206#endif
207
208/*
209 * rsGetArray3: Index in the Array3 dimension for the specified context
210 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700211 * Returns the index in the Array3 dimension of the cell being processed, as specified
212 * by the supplied context. See rsGetArray0() for an explanation of the context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700213 *
214 * Returns 0 if the Array3 dimension is not present.
215 */
216#if (defined(RS_VERSION) && (RS_VERSION >= 23))
217extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700218 rsGetArray3(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700219#endif
220
221/*
222 * rsGetDimArray0: Size of the Array0 dimension for the specified context
223 *
224 * Returns the size of the Array0 dimension for the specified context.
225 * See rsGetDimX() for an explanation of the context.
226 *
227 * Returns 0 if the Array0 dimension is not present.
228 */
229#if (defined(RS_VERSION) && (RS_VERSION >= 23))
230extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700231 rsGetDimArray0(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700232#endif
233
234/*
235 * rsGetDimArray1: Size of the Array1 dimension for the specified context
236 *
237 * Returns the size of the Array1 dimension for the specified context.
238 * See rsGetDimX() for an explanation of the context.
239 *
240 * Returns 0 if the Array1 dimension is not present.
241 */
242#if (defined(RS_VERSION) && (RS_VERSION >= 23))
243extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700244 rsGetDimArray1(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700245#endif
246
247/*
248 * rsGetDimArray2: Size of the Array2 dimension for the specified context
249 *
250 * Returns the size of the Array2 dimension for the specified context.
251 * See rsGetDimX() for an explanation of the context.
252 *
253 * Returns 0 if the Array2 dimension is not present.
254 */
255#if (defined(RS_VERSION) && (RS_VERSION >= 23))
256extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700257 rsGetDimArray2(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700258#endif
259
260/*
261 * rsGetDimArray3: Size of the Array3 dimension for the specified context
262 *
263 * Returns the size of the Array3 dimension for the specified context.
264 * See rsGetDimX() for an explanation of the context.
265 *
266 * Returns 0 if the Array3 dimension is not present.
267 */
268#if (defined(RS_VERSION) && (RS_VERSION >= 23))
269extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700270 rsGetDimArray3(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700271#endif
272
273/*
274 * rsGetDimHasFaces: Presence of more than one face for the specified context
275 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700276 * If the context refers to a cubemap, this function returns true if there's more than
277 * one face present. In all other cases, it returns false. See rsGetDimX() for an
278 * explanation of the context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700279 *
280 * rsAllocationGetDimFaces() is similar but returns 0 or 1 instead of a bool.
281 *
282 * Returns: Returns true if more than one face is present, false otherwise.
283 */
284#if (defined(RS_VERSION) && (RS_VERSION >= 23))
285extern bool __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700286 rsGetDimHasFaces(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700287#endif
288
289/*
290 * rsGetDimLod: Number of levels of detail for the specified context
291 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700292 * Returns the number of levels of detail for the specified context. This is useful
293 * for mipmaps. See rsGetDimX() for an explanation of the context.
294 *
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700295 * Returns 0 if Level of Detail is not used.
296 *
297 * rsAllocationGetDimLOD() is similar but returns 0 or 1 instead the actual
298 * number of levels.
299 */
300#if (defined(RS_VERSION) && (RS_VERSION >= 23))
301extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700302 rsGetDimLod(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700303#endif
304
305/*
306 * rsGetDimX: Size of the X dimension for the specified context
307 *
308 * Returns the size of the X dimension for the specified context.
309 *
310 * This context is created when a kernel is launched. It contains common
311 * characteristics of the allocations being iterated over by the kernel in
312 * a very efficient structure. It also contains rarely used indexes.
313 *
Miao Wangcd72e382015-08-20 15:52:21 -0700314 * You can access it by adding a special parameter named "context" and of
315 * type rs_kernel_context to your kernel function. E.g.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700316 * int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {
317 * uint32_t size = rsGetDimX(context); //...
Stephen Hines3f868232015-04-10 09:22:19 -0700318 *
319 * To get the dimension of specific allocation, use rsAllocationGetDimX().
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700320 */
321#if (defined(RS_VERSION) && (RS_VERSION >= 23))
322extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700323 rsGetDimX(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700324#endif
325
326/*
327 * rsGetDimY: Size of the Y dimension for the specified context
328 *
329 * Returns the size of the X dimension for the specified context.
330 * See rsGetDimX() for an explanation of the context.
331 *
332 * Returns 0 if the Y dimension is not present.
Stephen Hines3f868232015-04-10 09:22:19 -0700333 *
334 * To get the dimension of specific allocation, use rsAllocationGetDimY().
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700335 */
336#if (defined(RS_VERSION) && (RS_VERSION >= 23))
337extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700338 rsGetDimY(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700339#endif
340
341/*
342 * rsGetDimZ: Size of the Z dimension for the specified context
343 *
344 * Returns the size of the Z dimension for the specified context.
345 * See rsGetDimX() for an explanation of the context.
346 *
347 * Returns 0 if the Z dimension is not present.
Stephen Hines3f868232015-04-10 09:22:19 -0700348 *
349 * To get the dimension of specific allocation, use rsAllocationGetDimZ().
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700350 */
351#if (defined(RS_VERSION) && (RS_VERSION >= 23))
352extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700353 rsGetDimZ(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700354#endif
355
356/*
357 * rsGetFace: Coordinate of the Face for the specified context
358 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700359 * Returns the face on which the cell being processed is found, as specified by the
360 * supplied context. See rsGetArray0() for an explanation of the context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700361 *
362 * Returns RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X if the face dimension is not
363 * present.
364 */
365#if (defined(RS_VERSION) && (RS_VERSION >= 23))
366extern rs_allocation_cubemap_face __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700367 rsGetFace(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700368#endif
369
370/*
Stephen Hines3f868232015-04-10 09:22:19 -0700371 * rsGetLod: Index in the Levels of Detail dimension for the specified context
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700372 *
Pirama Arumuga Nainardb745862015-05-11 14:34:37 -0700373 * Returns the index in the Levels of Detail dimension of the cell being processed,
374 * as specified by the supplied context. See rsGetArray0() for an explanation of
375 * the context.
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700376 *
377 * Returns 0 if the Levels of Detail dimension is not present.
378 */
379#if (defined(RS_VERSION) && (RS_VERSION >= 23))
380extern uint32_t __attribute__((overloadable))
Miao Wangcd72e382015-08-20 15:52:21 -0700381 rsGetLod(rs_kernel_context context);
Jean-Luc Brouillet4fbd9032015-04-02 14:46:27 -0700382#endif
383
384#endif // RENDERSCRIPT_RS_FOR_EACH_RSH