1/* 2 * Copyright (C) 2011-2012 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 17 /*! \mainpage notitle 18 * 19 * RenderScript is a high-performance runtime that provides 20 * compute operations at the native level. RenderScript code is compiled on devices 21 * at runtime to allow platform-independence as well. 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. 25 * 26 * To use RenderScript, you need to utilize the RenderScript runtime APIs documented here 27 * as well as the Android framework APIs for RenderScript. 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. 31 * For more information on how to develop with RenderScript and how the runtime and 32 * Android framework APIs interact, see the <a target="_parent" href= 33 * "http://developer.android.com/guide/topics/renderscript/index.html">RenderScript 34 * developer guide</a> and the <a target="_parent" href= 35 * "http://developer.android.com/resources/samples/RenderScript/index.html"> 36 * RenderScript samples</a>. 37 */ 38 39/** @file rs_core.rsh 40 * \brief todo-jsams 41 * 42 * todo-jsams 43 * 44 */ 45 46#ifndef __RS_CORE_RSH__ 47#define __RS_CORE_RSH__ 48 49#define _RS_RUNTIME extern 50 51#define RS_KERNEL __attribute__((kernel)) 52 53#include "rs_types.rsh" 54#include "rs_allocation.rsh" 55#include "rs_atomic.rsh" 56#include "rs_core_math.rsh" 57#include "rs_debug.rsh" 58#include "rs_element.rsh" 59#include "rs_math.rsh" 60#include "rs_matrix.rsh" 61#include "rs_object.rsh" 62#include "rs_quaternion.rsh" 63#include "rs_sampler.rsh" 64#include "rs_time.rsh" 65 66/** 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. 70 */ 71extern bool __attribute__((overloadable)) 72 rsSendToClient(int cmdID); 73/** 74 * \overload 75 */ 76extern bool __attribute__((overloadable)) 77 rsSendToClient(int cmdID, const void *data, uint len); 78/** 79 * Send a message back to the client, blocking until the message is queued. 80 * A message ID is required. Data payload is optional. 81 */ 82extern void __attribute__((overloadable)) 83 rsSendToClientBlocking(int cmdID); 84/** 85 * \overload 86 */ 87extern void __attribute__((overloadable)) 88 rsSendToClientBlocking(int cmdID, const void *data, uint len); 89 90 91/** 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. 95 * 96 * This is a hint and implementations may not obey the order. 97 */ 98enum rs_for_each_strategy { 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 105}; 106 107 108/** 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 */ 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 124/** 125 * Make a script to script call to launch work. One of the input or output is 126 * required to be a valid object. The input and output must be of the same 127 * dimensions. 128 * API 10-13 129 * 130 * @param script The target script to call 131 * @param input The allocation to source data from 132 * @param output the allocation to write date into 133 * @param usrData The user definied params to pass to the root script. May be 134 * NULL. 135 * @param sc Extra control infomation used to select a sub-region of the 136 * allocation to be processed or suggest a walking strategy. May be 137 * NULL. 138 * 139 * */ 140#if !defined(RS_VERSION) || (RS_VERSION < 14) 141extern 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); 145/** 146 * \overload 147 */ 148extern void __attribute__((overloadable)) 149 rsForEach(rs_script script, rs_allocation input, 150 rs_allocation output, const void * usrData); 151#else 152 153/** 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 163 * NULL. 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 */ 171extern void __attribute__((overloadable)) 172 rsForEach(rs_script script, rs_allocation input, rs_allocation output, 173 const void * usrData, size_t usrDataLen, const rs_script_call_t *); 174/** 175 * \overload 176 */ 177extern void __attribute__((overloadable)) 178 rsForEach(rs_script script, rs_allocation input, rs_allocation output, 179 const void * usrData, size_t usrDataLen); 180/** 181 * \overload 182 */ 183extern void __attribute__((overloadable)) 184 rsForEach(rs_script script, rs_allocation input, rs_allocation output); 185#endif 186 187 188 189#undef _RS_RUNTIME 190 191#endif 192