Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 1 | /** @file rs_math.rsh |
| 2 | * \brief todo-jsams |
| 3 | * |
| 4 | * todo-jsams |
| 5 | * |
| 6 | */ |
Jason Sams | c4cdf45 | 2010-07-07 11:55:51 -0700 | [diff] [blame] | 7 | #ifndef __RS_MATH_RSH__ |
| 8 | #define __RS_MATH_RSH__ |
| 9 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 10 | |
| 11 | |
| 12 | /** |
| 13 | * \overload |
| 14 | */ |
| 15 | extern void __attribute__((overloadable)) |
| 16 | rsSetObject(rs_element *dst, rs_element src); |
| 17 | /** |
| 18 | * \overload |
| 19 | */ |
| 20 | extern void __attribute__((overloadable)) |
| 21 | rsSetObject(rs_type *dst, rs_type src); |
| 22 | /** |
| 23 | * \overload |
| 24 | */ |
| 25 | extern void __attribute__((overloadable)) |
| 26 | rsSetObject(rs_allocation *dst, rs_allocation src); |
| 27 | /** |
| 28 | * \overload |
| 29 | */ |
| 30 | extern void __attribute__((overloadable)) |
| 31 | rsSetObject(rs_sampler *dst, rs_sampler src); |
| 32 | /** |
| 33 | * \overload |
| 34 | */ |
| 35 | extern void __attribute__((overloadable)) |
| 36 | rsSetObject(rs_script *dst, rs_script src); |
| 37 | /** |
| 38 | * \overload |
| 39 | */ |
| 40 | extern void __attribute__((overloadable)) |
| 41 | rsSetObject(rs_mesh *dst, rs_mesh src); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 42 | /** |
| 43 | * Copy reference to the specified object. |
| 44 | * |
| 45 | * @param dst |
| 46 | * @param src |
| 47 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 48 | extern void __attribute__((overloadable)) |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 49 | rsSetObject(rs_program_fragment *dst, rs_program_fragment src); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 50 | /** |
| 51 | * \overload |
| 52 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 53 | extern void __attribute__((overloadable)) |
| 54 | rsSetObject(rs_program_vertex *dst, rs_program_vertex src); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 55 | /** |
| 56 | * \overload |
| 57 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 58 | extern void __attribute__((overloadable)) |
| 59 | rsSetObject(rs_program_raster *dst, rs_program_raster src); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 60 | /** |
| 61 | * \overload |
| 62 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 63 | extern void __attribute__((overloadable)) |
| 64 | rsSetObject(rs_program_store *dst, rs_program_store src); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 65 | /** |
| 66 | * \overload |
| 67 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 68 | extern void __attribute__((overloadable)) |
| 69 | rsSetObject(rs_font *dst, rs_font src); |
| 70 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 71 | /** |
| 72 | * Sets the object to NULL. |
| 73 | * |
| 74 | * @return bool |
| 75 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 76 | extern void __attribute__((overloadable)) |
| 77 | rsClearObject(rs_element *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 78 | /** |
| 79 | * \overload |
| 80 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 81 | extern void __attribute__((overloadable)) |
| 82 | rsClearObject(rs_type *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 83 | /** |
| 84 | * \overload |
| 85 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 86 | extern void __attribute__((overloadable)) |
| 87 | rsClearObject(rs_allocation *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 88 | /** |
| 89 | * \overload |
| 90 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 91 | extern void __attribute__((overloadable)) |
| 92 | rsClearObject(rs_sampler *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 93 | /** |
| 94 | * \overload |
| 95 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 96 | extern void __attribute__((overloadable)) |
| 97 | rsClearObject(rs_script *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 98 | /** |
| 99 | * \overload |
| 100 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 101 | extern void __attribute__((overloadable)) |
| 102 | rsClearObject(rs_mesh *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 103 | /** |
| 104 | * \overload |
| 105 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 106 | extern void __attribute__((overloadable)) |
| 107 | rsClearObject(rs_program_fragment *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 108 | /** |
| 109 | * \overload |
| 110 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 111 | extern void __attribute__((overloadable)) |
| 112 | rsClearObject(rs_program_vertex *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 113 | /** |
| 114 | * \overload |
| 115 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 116 | extern void __attribute__((overloadable)) |
| 117 | rsClearObject(rs_program_raster *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 118 | /** |
| 119 | * \overload |
| 120 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 121 | extern void __attribute__((overloadable)) |
| 122 | rsClearObject(rs_program_store *dst); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 123 | /** |
| 124 | * \overload |
| 125 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 126 | extern void __attribute__((overloadable)) |
| 127 | rsClearObject(rs_font *dst); |
| 128 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 129 | /** |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 130 | * \overload |
| 131 | */ |
| 132 | extern bool __attribute__((overloadable)) |
| 133 | rsIsObject(rs_element); |
| 134 | /** |
| 135 | * \overload |
| 136 | */ |
| 137 | extern bool __attribute__((overloadable)) |
| 138 | rsIsObject(rs_type); |
| 139 | /** |
| 140 | * \overload |
| 141 | */ |
| 142 | extern bool __attribute__((overloadable)) |
| 143 | rsIsObject(rs_allocation); |
| 144 | /** |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 145 | * Tests if the object is valid. Returns true if the object is valid, false if |
| 146 | * it is NULL. |
| 147 | * |
| 148 | * @return bool |
| 149 | */ |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 150 | |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 151 | extern bool __attribute__((overloadable)) |
| 152 | rsIsObject(rs_sampler); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 153 | /** |
| 154 | * \overload |
| 155 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 156 | extern bool __attribute__((overloadable)) |
| 157 | rsIsObject(rs_script); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 158 | /** |
| 159 | * \overload |
| 160 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 161 | extern bool __attribute__((overloadable)) |
| 162 | rsIsObject(rs_mesh); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 163 | /** |
| 164 | * \overload |
| 165 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 166 | extern bool __attribute__((overloadable)) |
| 167 | rsIsObject(rs_program_fragment); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 168 | /** |
| 169 | * \overload |
| 170 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 171 | extern bool __attribute__((overloadable)) |
| 172 | rsIsObject(rs_program_vertex); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 173 | /** |
| 174 | * \overload |
| 175 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 176 | extern bool __attribute__((overloadable)) |
| 177 | rsIsObject(rs_program_raster); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 178 | /** |
| 179 | * \overload |
| 180 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 181 | extern bool __attribute__((overloadable)) |
| 182 | rsIsObject(rs_program_store); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 183 | /** |
| 184 | * \overload |
| 185 | */ |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 186 | extern bool __attribute__((overloadable)) |
| 187 | rsIsObject(rs_font); |
| 188 | |
| 189 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 190 | /** |
| 191 | * Returns the Allocation for a given pointer. The pointer should point within |
| 192 | * a valid allocation. The results are undefined if the pointer is not from a |
| 193 | * valid allocation. |
| 194 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 195 | extern rs_allocation __attribute__((overloadable)) |
| 196 | rsGetAllocation(const void *); |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 197 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 198 | /** |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 199 | * Query the dimension of an allocation. |
| 200 | * |
| 201 | * @return uint32_t The X dimension of the allocation. |
| 202 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 203 | extern uint32_t __attribute__((overloadable)) |
| 204 | rsAllocationGetDimX(rs_allocation); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 205 | |
| 206 | /** |
| 207 | * Query the dimension of an allocation. |
| 208 | * |
| 209 | * @return uint32_t The Y dimension of the allocation. |
| 210 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 211 | extern uint32_t __attribute__((overloadable)) |
| 212 | rsAllocationGetDimY(rs_allocation); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 213 | |
| 214 | /** |
| 215 | * Query the dimension of an allocation. |
| 216 | * |
| 217 | * @return uint32_t The Z dimension of the allocation. |
| 218 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 219 | extern uint32_t __attribute__((overloadable)) |
| 220 | rsAllocationGetDimZ(rs_allocation); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 221 | |
| 222 | /** |
| 223 | * Query an allocation for the presence of more than one LOD. |
| 224 | * |
| 225 | * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise. |
| 226 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 227 | extern uint32_t __attribute__((overloadable)) |
| 228 | rsAllocationGetDimLOD(rs_allocation); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 229 | |
| 230 | /** |
| 231 | * Query an allocation for the presence of more than one face. |
| 232 | * |
| 233 | * @return uint32_t Returns 1 if more than one face is present, 0 otherwise. |
| 234 | */ |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 235 | extern uint32_t __attribute__((overloadable)) |
| 236 | rsAllocationGetDimFaces(rs_allocation); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 237 | |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 238 | /** |
| 239 | * Copy part of an allocation from another allocation. |
| 240 | * |
| 241 | * @param dstAlloc Allocation to copy data into. |
| 242 | * @param dstOff The offset of the first element to be copied in |
| 243 | * the destination allocation. |
| 244 | * @param dstMip Mip level in the destination allocation. |
| 245 | * @param count The number of elements to be copied. |
| 246 | * @param srcAlloc The source data allocation. |
| 247 | * @param srcOff The offset of the first element in data to be |
| 248 | * copied in the source allocation. |
| 249 | * @param srcMip Mip level in the source allocation. |
| 250 | */ |
| 251 | extern void __attribute__((overloadable)) |
| 252 | rsAllocationCopy1DRange(rs_allocation dstAlloc, |
| 253 | uint32_t dstOff, uint32_t dstMip, |
| 254 | uint32_t count, |
| 255 | rs_allocation srcAlloc, |
| 256 | uint32_t srcOff, uint32_t srcMip); |
| 257 | |
| 258 | /** |
| 259 | * Copy a rectangular region into the allocation from another |
| 260 | * allocation. |
| 261 | * |
| 262 | * @param dstAlloc allocation to copy data into. |
| 263 | * @param dstXoff X offset of the region to update in the |
| 264 | * destination allocation. |
| 265 | * @param dstYoff Y offset of the region to update in the |
| 266 | * destination allocation. |
| 267 | * @param dstMip Mip level in the destination allocation. |
| 268 | * @param dstFace Cubemap face of the destination allocation, |
| 269 | * ignored for allocations that aren't cubemaps. |
| 270 | * @param width Width of the incoming region to update. |
| 271 | * @param height Height of the incoming region to update. |
| 272 | * @param srcAlloc The source data allocation. |
| 273 | * @param srcXoff X offset in data of the source allocation. |
| 274 | * @param srcYoff Y offset in data of the source allocation. |
| 275 | * @param srcMip Mip level in the source allocation. |
| 276 | * @param srcFace Cubemap face of the source allocation, |
| 277 | * ignored for allocations that aren't cubemaps. |
| 278 | */ |
| 279 | extern void __attribute__((overloadable)) |
| 280 | rsAllocationCopy2DRange(rs_allocation dstAlloc, |
| 281 | uint32_t dstXoff, uint32_t dstYoff, |
| 282 | uint32_t dstMip, |
| 283 | rs_allocation_cubemap_face dstFace, |
| 284 | uint32_t width, uint32_t height, |
| 285 | rs_allocation srcAlloc, |
| 286 | uint32_t srcXoff, uint32_t srcYoff, |
| 287 | uint32_t srcMip, |
| 288 | rs_allocation_cubemap_face srcFace); |
| 289 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 290 | |
| 291 | /** |
| 292 | * Extract a single element from an allocation. |
| 293 | */ |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 294 | extern const void * __attribute__((overloadable)) |
| 295 | rsGetElementAt(rs_allocation, uint32_t x); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 296 | /** |
| 297 | * \overload |
| 298 | */ |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 299 | extern const void * __attribute__((overloadable)) |
| 300 | rsGetElementAt(rs_allocation, uint32_t x, uint32_t y); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 301 | /** |
| 302 | * \overload |
| 303 | */ |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 304 | extern const void * __attribute__((overloadable)) |
| 305 | rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 306 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 307 | /** |
| 308 | * Return a random value between 0 (or min_value) and max_malue. |
| 309 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 310 | extern int __attribute__((overloadable)) |
| 311 | rsRand(int max_value); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 312 | /** |
| 313 | * \overload |
| 314 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 315 | extern int __attribute__((overloadable)) |
| 316 | rsRand(int min_value, int max_value); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 317 | /** |
| 318 | * \overload |
| 319 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 320 | extern float __attribute__((overloadable)) |
| 321 | rsRand(float max_value); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 322 | /** |
| 323 | * \overload |
| 324 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 325 | extern float __attribute__((overloadable)) |
| 326 | rsRand(float min_value, float max_value); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 327 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 328 | /** |
| 329 | * Returns the fractional part of a float |
| 330 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 331 | extern float __attribute__((overloadable)) |
| 332 | rsFrac(float); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 333 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 334 | /** |
| 335 | * Send a message back to the client. Will not block and returns true |
| 336 | * if the message was sendable and false if the fifo was full. |
| 337 | * A message ID is required. Data payload is optional. |
| 338 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 339 | extern bool __attribute__((overloadable)) |
| 340 | rsSendToClient(int cmdID); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 341 | /** |
| 342 | * \overload |
| 343 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 344 | extern bool __attribute__((overloadable)) |
| 345 | rsSendToClient(int cmdID, const void *data, uint len); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 346 | /** |
| 347 | * Send a message back to the client, blocking until the message is queued. |
| 348 | * A message ID is required. Data payload is optional. |
| 349 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 350 | extern void __attribute__((overloadable)) |
| 351 | rsSendToClientBlocking(int cmdID); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 352 | /** |
| 353 | * \overload |
| 354 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 355 | extern void __attribute__((overloadable)) |
| 356 | rsSendToClientBlocking(int cmdID, const void *data, uint len); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 357 | |
Jason Sams | dd663fa | 2010-08-11 13:26:28 -0700 | [diff] [blame] | 358 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 359 | /** |
| 360 | * Launch order hint for rsForEach calls. This provides a hint to the system to |
| 361 | * determine in which order the root function of the target is called with each |
| 362 | * cell of the allocation. |
| 363 | * |
| 364 | * This is a hint and implementations may not obey the order. |
| 365 | */ |
Jason Sams | dd663fa | 2010-08-11 13:26:28 -0700 | [diff] [blame] | 366 | enum rs_for_each_strategy { |
| 367 | RS_FOR_EACH_STRATEGY_SERIAL, |
| 368 | RS_FOR_EACH_STRATEGY_DONT_CARE, |
| 369 | RS_FOR_EACH_STRATEGY_DST_LINEAR, |
| 370 | RS_FOR_EACH_STRATEGY_TILE_SMALL, |
| 371 | RS_FOR_EACH_STRATEGY_TILE_MEDIUM, |
| 372 | RS_FOR_EACH_STRATEGY_TILE_LARGE |
| 373 | }; |
| 374 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 375 | |
| 376 | /** |
| 377 | * Structure to provide extra information to a rsForEach call. Primarly used to |
| 378 | * restrict the call to a subset of cells in the allocation. |
| 379 | */ |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 380 | typedef struct rs_script_call { |
Jason Sams | dd663fa | 2010-08-11 13:26:28 -0700 | [diff] [blame] | 381 | enum rs_for_each_strategy strategy; |
Jason Sams | 479e292 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 382 | uint32_t xStart; |
| 383 | uint32_t xEnd; |
| 384 | uint32_t yStart; |
| 385 | uint32_t yEnd; |
| 386 | uint32_t zStart; |
| 387 | uint32_t zEnd; |
| 388 | uint32_t arrayStart; |
| 389 | uint32_t arrayEnd; |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 390 | } rs_script_call_t; |
Jason Sams | 479e292 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 391 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 392 | /** |
| 393 | * Make a script to script call to launch work. One of the input or output is |
| 394 | * required to be a valid object. The input and output must be of the same |
| 395 | * dimensions. |
| 396 | * API 10-13 |
| 397 | * |
| 398 | * @param script The target script to call |
| 399 | * @param input The allocation to source data from |
| 400 | * @param output the allocation to write date into |
| 401 | * @param usrData The user definied params to pass to the root script. May be |
| 402 | * NULL. |
| 403 | * @param sc Extra control infomation used to select a sub-region of the |
| 404 | * allocation to be processed or suggest a walking strategy. May be |
| 405 | * NULL. |
| 406 | * |
| 407 | * */ |
Jason Sams | eb0dfed | 2011-07-27 14:10:53 -0700 | [diff] [blame] | 408 | #if !defined(RS_VERSION) || (RS_VERSION < 14) |
| 409 | extern void __attribute__((overloadable)) |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 410 | rsForEach(rs_script script script, rs_allocation input, |
Jason Sams | eb0dfed | 2011-07-27 14:10:53 -0700 | [diff] [blame] | 411 | rs_allocation output, const void * usrData, |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 412 | const rs_script_call_t *sc); |
| 413 | /** |
| 414 | * \overload |
| 415 | */ |
Jason Sams | eb0dfed | 2011-07-27 14:10:53 -0700 | [diff] [blame] | 416 | extern void __attribute__((overloadable)) |
| 417 | rsForEach(rs_script script, rs_allocation input, |
| 418 | rs_allocation output, const void * usrData); |
| 419 | #else |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 420 | |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 421 | /** |
| 422 | * Make a script to script call to launch work. One of the input or output is |
| 423 | * required to be a valid object. The input and output must be of the same |
| 424 | * dimensions. |
| 425 | * API 14+ |
| 426 | * |
| 427 | * @param script The target script to call |
| 428 | * @param input The allocation to source data from |
| 429 | * @param output the allocation to write date into |
| 430 | * @param usrData The user definied params to pass to the root script. May be |
| 431 | * NULL. |
| 432 | * @param usrDataLen The size of the userData structure. This will be used to |
| 433 | * perform a shallow copy of the data if necessary. |
| 434 | * @param sc Extra control infomation used to select a sub-region of the |
| 435 | * allocation to be processed or suggest a walking strategy. May be |
| 436 | * NULL. |
| 437 | * |
| 438 | */ |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 439 | extern void __attribute__((overloadable)) |
| 440 | rsForEach(rs_script script, rs_allocation input, rs_allocation output, |
| 441 | const void * usrData, size_t usrDataLen, const rs_script_call_t *); |
Jason Sams | 9df3b2b | 2011-08-08 14:31:25 -0700 | [diff] [blame^] | 442 | /** |
| 443 | * \overload |
| 444 | */ |
| 445 | extern void __attribute__((overloadable)) |
| 446 | rsForEach(rs_script script, rs_allocation input, rs_allocation output, |
| 447 | const void * usrData, size_t usrDataLen); |
| 448 | /** |
| 449 | * \overload |
| 450 | */ |
| 451 | extern void __attribute__((overloadable)) |
| 452 | rsForEach(rs_script script, rs_allocation input, rs_allocation output); |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 453 | #endif |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 454 | |
Jason Sams | e1eb615 | 2011-06-21 16:42:30 -0700 | [diff] [blame] | 455 | |
| 456 | /** |
| 457 | * Atomic add one to the value at addr. |
| 458 | * Equal to rsAtomicAdd(addr, 1) |
| 459 | * |
| 460 | * @param addr Address of value to increment |
| 461 | * |
| 462 | * @return old value |
| 463 | */ |
| 464 | extern int32_t __attribute__((overloadable)) |
| 465 | rsAtomicInc(volatile int32_t* addr); |
| 466 | /** |
| 467 | * Atomic add one to the value at addr. |
| 468 | * Equal to rsAtomicAdd(addr, 1) |
| 469 | * |
| 470 | * @param addr Address of value to increment |
| 471 | * |
| 472 | * @return old value |
| 473 | */ |
| 474 | extern uint32_t __attribute__((overloadable)) |
| 475 | rsAtomicInc(volatile uint32_t* addr); |
| 476 | |
| 477 | /** |
| 478 | * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1) |
| 479 | * |
| 480 | * @param addr Address of value to decrement |
| 481 | * |
| 482 | * @return old value |
| 483 | */ |
| 484 | extern int32_t __attribute__((overloadable)) |
| 485 | rsAtomicDec(volatile int32_t* addr); |
| 486 | /** |
| 487 | * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1) |
| 488 | * |
| 489 | * @param addr Address of value to decrement |
| 490 | * |
| 491 | * @return old value |
| 492 | */ |
| 493 | extern uint32_t __attribute__((overloadable)) |
| 494 | rsAtomicDec(volatile uint32_t* addr); |
| 495 | |
| 496 | /** |
| 497 | * Atomic add a value to the value at addr. addr[0] += value |
| 498 | * |
| 499 | * @param addr Address of value to modify |
| 500 | * @param value Amount to add to the value at addr |
| 501 | * |
| 502 | * @return old value |
| 503 | */ |
| 504 | extern int32_t __attribute__((overloadable)) |
| 505 | rsAtomicAdd(volatile int32_t* addr, int32_t value); |
| 506 | /** |
| 507 | * Atomic add a value to the value at addr. addr[0] += value |
| 508 | * |
| 509 | * @param addr Address of value to modify |
| 510 | * @param value Amount to add to the value at addr |
| 511 | * |
| 512 | * @return old value |
| 513 | */ |
| 514 | extern uint32_t __attribute__((overloadable)) |
| 515 | rsAtomicAdd(volatile uint32_t* addr, uint32_t value); |
| 516 | |
| 517 | /** |
| 518 | * Atomic Subtract a value from the value at addr. addr[0] -= value |
| 519 | * |
| 520 | * @param addr Address of value to modify |
| 521 | * @param value Amount to subtract from the value at addr |
| 522 | * |
| 523 | * @return old value |
| 524 | */ |
| 525 | extern int32_t __attribute__((overloadable)) |
| 526 | rsAtomicSub(volatile int32_t* addr, int32_t value); |
| 527 | /** |
| 528 | * Atomic Subtract a value from the value at addr. addr[0] -= value |
| 529 | * |
| 530 | * @param addr Address of value to modify |
| 531 | * @param value Amount to subtract from the value at addr |
| 532 | * |
| 533 | * @return old value |
| 534 | */ |
| 535 | extern uint32_t __attribute__((overloadable)) |
| 536 | rsAtomicSub(volatile uint32_t* addr, uint32_t value); |
| 537 | |
| 538 | /** |
| 539 | * Atomic Bitwise and a value from the value at addr. addr[0] &= value |
| 540 | * |
| 541 | * @param addr Address of value to modify |
| 542 | * @param value Amount to and with the value at addr |
| 543 | * |
| 544 | * @return old value |
| 545 | */ |
| 546 | extern int32_t __attribute__((overloadable)) |
| 547 | rsAtomicAnd(volatile int32_t* addr, int32_t value); |
| 548 | /** |
| 549 | * Atomic Bitwise and a value from the value at addr. addr[0] &= value |
| 550 | * |
| 551 | * @param addr Address of value to modify |
| 552 | * @param value Amount to and with the value at addr |
| 553 | * |
| 554 | * @return old value |
| 555 | */ |
| 556 | extern uint32_t __attribute__((overloadable)) |
| 557 | rsAtomicAnd(volatile uint32_t* addr, uint32_t value); |
| 558 | |
| 559 | /** |
| 560 | * Atomic Bitwise or a value from the value at addr. addr[0] |= value |
| 561 | * |
| 562 | * @param addr Address of value to modify |
| 563 | * @param value Amount to or with the value at addr |
| 564 | * |
| 565 | * @return old value |
| 566 | */ |
| 567 | extern int32_t __attribute__((overloadable)) |
| 568 | rsAtomicOr(volatile int32_t* addr, int32_t value); |
| 569 | /** |
| 570 | * Atomic Bitwise or a value from the value at addr. addr[0] |= value |
| 571 | * |
| 572 | * @param addr Address of value to modify |
| 573 | * @param value Amount to or with the value at addr |
| 574 | * |
| 575 | * @return old value |
| 576 | */ |
| 577 | extern uint32_t __attribute__((overloadable)) |
| 578 | rsAtomicOr(volatile uint32_t* addr, uint32_t value); |
| 579 | |
| 580 | /** |
| 581 | * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value |
| 582 | * |
| 583 | * @param addr Address of value to modify |
| 584 | * @param value Amount to xor with the value at addr |
| 585 | * |
| 586 | * @return old value |
| 587 | */ |
| 588 | extern uint32_t __attribute__((overloadable)) |
| 589 | rsAtomicXor(volatile uint32_t* addr, uint32_t value); |
| 590 | /** |
| 591 | * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value |
| 592 | * |
| 593 | * @param addr Address of value to modify |
| 594 | * @param value Amount to xor with the value at addr |
| 595 | * |
| 596 | * @return old value |
| 597 | */ |
| 598 | extern int32_t __attribute__((overloadable)) |
| 599 | rsAtomicXor(volatile int32_t* addr, int32_t value); |
| 600 | |
| 601 | /** |
| 602 | * Atomic Set the value at addr to the min of addr and value |
| 603 | * addr[0] = rsMin(addr[0], value) |
| 604 | * |
| 605 | * @param addr Address of value to modify |
| 606 | * @param value comparison value |
| 607 | * |
| 608 | * @return old value |
| 609 | */ |
| 610 | extern uint32_t __attribute__((overloadable)) |
| 611 | rsAtomicMin(volatile uint32_t* addr, uint32_t value); |
| 612 | /** |
| 613 | * Atomic Set the value at addr to the min of addr and value |
| 614 | * addr[0] = rsMin(addr[0], value) |
| 615 | * |
| 616 | * @param addr Address of value to modify |
| 617 | * @param value comparison value |
| 618 | * |
| 619 | * @return old value |
| 620 | */ |
| 621 | extern int32_t __attribute__((overloadable)) |
| 622 | rsAtomicMin(volatile int32_t* addr, int32_t value); |
| 623 | |
| 624 | /** |
| 625 | * Atomic Set the value at addr to the max of addr and value |
| 626 | * addr[0] = rsMax(addr[0], value) |
| 627 | * |
| 628 | * @param addr Address of value to modify |
| 629 | * @param value comparison value |
| 630 | * |
| 631 | * @return old value |
| 632 | */ |
| 633 | extern uint32_t __attribute__((overloadable)) |
| 634 | rsAtomicMax(volatile uint32_t* addr, uint32_t value); |
| 635 | /** |
| 636 | * Atomic Set the value at addr to the max of addr and value |
| 637 | * addr[0] = rsMin(addr[0], value) |
| 638 | * |
| 639 | * @param addr Address of value to modify |
| 640 | * @param value comparison value |
| 641 | * |
| 642 | * @return old value |
| 643 | */ |
| 644 | extern int32_t __attribute__((overloadable)) |
| 645 | rsAtomicMax(volatile int32_t* addr, int32_t value); |
| 646 | |
| 647 | /** |
| 648 | * Compare-and-set operation with a full memory barrier. |
| 649 | * |
| 650 | * If the value at addr matches compareValue then newValue is written. |
| 651 | * |
| 652 | * @param addr The address to compare and replace if the compare passes. |
| 653 | * @param compareValue The value to test addr[0] against. |
| 654 | * @param newValue The value to write if the test passes. |
| 655 | * |
| 656 | * @return old value |
| 657 | */ |
| 658 | extern int32_t __attribute__((overloadable)) |
| 659 | rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue); |
| 660 | |
| 661 | /** |
| 662 | * Compare-and-set operation with a full memory barrier. |
| 663 | * |
| 664 | * If the value at addr matches compareValue then newValue is written. |
| 665 | * |
| 666 | * @param addr The address to compare and replace if the compare passes. |
| 667 | * @param compareValue The value to test addr[0] against. |
| 668 | * @param newValue The value to write if the test passes. |
| 669 | * |
| 670 | * @return old value |
| 671 | */ |
| 672 | extern uint32_t __attribute__((overloadable)) |
| 673 | rsAtomicCas(volatile uint32_t* addr, int32_t compareValue, int32_t newValue); |
| 674 | |
| 675 | |
Jason Sams | c4cdf45 | 2010-07-07 11:55:51 -0700 | [diff] [blame] | 676 | #endif |