blob: b927ed217b07765bc19388aa36c7b2267d29ec2d [file] [log] [blame]
Jason Samsfcf72312011-04-20 15:09:01 -07001/*
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -07002 * Copyright (C) 2011 The Android Open Source Project
Jason Samsfcf72312011-04-20 15:09:01 -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
Glenn Kastene80a4cc2011-12-15 09:51:17 -080017#include <cutils/compiler.h>
18
Jason Samsfcf72312011-04-20 15:09:01 -070019#include "rsContext.h"
20#include "rsScriptC.h"
21#include "rsMatrix4x4.h"
22#include "rsMatrix3x3.h"
23#include "rsMatrix2x2.h"
24
25#include "rsdCore.h"
26#include "rsdRuntime.h"
27
28
29using namespace android;
30using namespace android::renderscript;
31
32
33static float SC_exp10(float v) {
34 return pow(10.f, v);
35}
36
37static float SC_fract(float v, int *iptr) {
38 int i = (int)floor(v);
39 iptr[0] = i;
40 return fmin(v - i, 0x1.fffffep-1f);
41}
42
43static float SC_log2(float v) {
44 return log10(v) / log10(2.f);
45}
46
47static float SC_mad(float v1, float v2, float v3) {
48 return v1 * v2 + v3;
49}
50
51#if 0
52static float SC_pown(float v, int p) {
53 return powf(v, (float)p);
54}
55
56static float SC_powr(float v, float p) {
57 return powf(v, p);
58}
59#endif
60
61float SC_rootn(float v, int r) {
62 return pow(v, 1.f / r);
63}
64
65float SC_rsqrt(float v) {
66 return 1.f / sqrtf(v);
67}
68
69float SC_sincos(float v, float *cosptr) {
70 *cosptr = cosf(v);
71 return sinf(v);
72}
73
74//////////////////////////////////////////////////////////////////////////////
75// Integer
76//////////////////////////////////////////////////////////////////////////////
77
78
79static uint32_t SC_abs_i32(int32_t v) {return abs(v);}
80static uint16_t SC_abs_i16(int16_t v) {return (uint16_t)abs(v);}
81static uint8_t SC_abs_i8(int8_t v) {return (uint8_t)abs(v);}
82
83static uint32_t SC_clz_u32(uint32_t v) {return __builtin_clz(v);}
84static uint16_t SC_clz_u16(uint16_t v) {return (uint16_t)__builtin_clz(v);}
85static uint8_t SC_clz_u8(uint8_t v) {return (uint8_t)__builtin_clz(v);}
86static int32_t SC_clz_i32(int32_t v) {return (int32_t)__builtin_clz((uint32_t)v);}
87static int16_t SC_clz_i16(int16_t v) {return (int16_t)__builtin_clz(v);}
88static int8_t SC_clz_i8(int8_t v) {return (int8_t)__builtin_clz(v);}
89
90static uint32_t SC_max_u32(uint32_t v, uint32_t v2) {return rsMax(v, v2);}
91static uint16_t SC_max_u16(uint16_t v, uint16_t v2) {return rsMax(v, v2);}
92static uint8_t SC_max_u8(uint8_t v, uint8_t v2) {return rsMax(v, v2);}
93static int32_t SC_max_i32(int32_t v, int32_t v2) {return rsMax(v, v2);}
94static int16_t SC_max_i16(int16_t v, int16_t v2) {return rsMax(v, v2);}
95static int8_t SC_max_i8(int8_t v, int8_t v2) {return rsMax(v, v2);}
96
97static uint32_t SC_min_u32(uint32_t v, uint32_t v2) {return rsMin(v, v2);}
98static uint16_t SC_min_u16(uint16_t v, uint16_t v2) {return rsMin(v, v2);}
99static uint8_t SC_min_u8(uint8_t v, uint8_t v2) {return rsMin(v, v2);}
100static int32_t SC_min_i32(int32_t v, int32_t v2) {return rsMin(v, v2);}
101static int16_t SC_min_i16(int16_t v, int16_t v2) {return rsMin(v, v2);}
102static int8_t SC_min_i8(int8_t v, int8_t v2) {return rsMin(v, v2);}
103
104//////////////////////////////////////////////////////////////////////////////
105// Float util
106//////////////////////////////////////////////////////////////////////////////
107
108static float SC_clamp_f32(float amount, float low, float high) {
109 return amount < low ? low : (amount > high ? high : amount);
110}
111
112static float SC_degrees(float radians) {
113 return radians * (180.f / M_PI);
114}
115
116static float SC_max_f32(float v, float v2) {
117 return rsMax(v, v2);
118}
119
120static float SC_min_f32(float v, float v2) {
121 return rsMin(v, v2);
122}
123
124static float SC_mix_f32(float start, float stop, float amount) {
125 //LOGE("lerpf %f %f %f", start, stop, amount);
126 return start + (stop - start) * amount;
127}
128
129static float SC_radians(float degrees) {
130 return degrees * (M_PI / 180.f);
131}
132
133static float SC_step_f32(float edge, float v) {
134 if (v < edge) return 0.f;
135 return 1.f;
136}
137
138static float SC_sign_f32(float value) {
139 if (value > 0) return 1.f;
140 if (value < 0) return -1.f;
141 return value;
142}
143
144static void SC_MatrixLoadIdentity_4x4(Matrix4x4 *m) {
145 m->loadIdentity();
146}
147static void SC_MatrixLoadIdentity_3x3(Matrix3x3 *m) {
148 m->loadIdentity();
149}
150static void SC_MatrixLoadIdentity_2x2(Matrix2x2 *m) {
151 m->loadIdentity();
152}
153
154static void SC_MatrixLoad_4x4_f(Matrix4x4 *m, const float *f) {
155 m->load(f);
156}
157static void SC_MatrixLoad_3x3_f(Matrix3x3 *m, const float *f) {
158 m->load(f);
159}
160static void SC_MatrixLoad_2x2_f(Matrix2x2 *m, const float *f) {
161 m->load(f);
162}
163
164static void SC_MatrixLoad_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *s) {
165 m->load(s);
166}
167static void SC_MatrixLoad_4x4_3x3(Matrix4x4 *m, const Matrix3x3 *s) {
168 m->load(s);
169}
170static void SC_MatrixLoad_4x4_2x2(Matrix4x4 *m, const Matrix2x2 *s) {
171 m->load(s);
172}
173static void SC_MatrixLoad_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *s) {
174 m->load(s);
175}
176static void SC_MatrixLoad_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *s) {
177 m->load(s);
178}
179
180static void SC_MatrixLoadRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
181 m->loadRotate(rot, x, y, z);
182}
183static void SC_MatrixLoadScale(Matrix4x4 *m, float x, float y, float z) {
184 m->loadScale(x, y, z);
185}
186static void SC_MatrixLoadTranslate(Matrix4x4 *m, float x, float y, float z) {
187 m->loadTranslate(x, y, z);
188}
189static void SC_MatrixRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
190 m->rotate(rot, x, y, z);
191}
192static void SC_MatrixScale(Matrix4x4 *m, float x, float y, float z) {
193 m->scale(x, y, z);
194}
195static void SC_MatrixTranslate(Matrix4x4 *m, float x, float y, float z) {
196 m->translate(x, y, z);
197}
198
199static void SC_MatrixLoadMultiply_4x4_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *lhs, const Matrix4x4 *rhs) {
200 m->loadMultiply(lhs, rhs);
201}
202static void SC_MatrixLoadMultiply_3x3_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *lhs, const Matrix3x3 *rhs) {
203 m->loadMultiply(lhs, rhs);
204}
205static void SC_MatrixLoadMultiply_2x2_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *lhs, const Matrix2x2 *rhs) {
206 m->loadMultiply(lhs, rhs);
207}
208
209static void SC_MatrixMultiply_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *rhs) {
210 m->multiply(rhs);
211}
212static void SC_MatrixMultiply_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *rhs) {
213 m->multiply(rhs);
214}
215static void SC_MatrixMultiply_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *rhs) {
216 m->multiply(rhs);
217}
218
219static void SC_MatrixLoadOrtho(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
220 m->loadOrtho(l, r, b, t, n, f);
221}
222static void SC_MatrixLoadFrustum(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
223 m->loadFrustum(l, r, b, t, n, f);
224}
225static void SC_MatrixLoadPerspective(Matrix4x4 *m, float fovy, float aspect, float near, float far) {
226 m->loadPerspective(fovy, aspect, near, far);
227}
228
229static bool SC_MatrixInverse_4x4(Matrix4x4 *m) {
230 return m->inverse();
231}
232static bool SC_MatrixInverseTranspose_4x4(Matrix4x4 *m) {
233 return m->inverseTranspose();
234}
235static void SC_MatrixTranspose_4x4(Matrix4x4 *m) {
236 m->transpose();
237}
238static void SC_MatrixTranspose_3x3(Matrix3x3 *m) {
239 m->transpose();
240}
241static void SC_MatrixTranspose_2x2(Matrix2x2 *m) {
242 m->transpose();
243}
244
245static float SC_randf(float max) {
246 float r = (float)rand();
247 r *= max;
Jason Samse2b33042011-04-22 14:19:42 -0700248 r /= RAND_MAX;
249 return r;
Jason Samsfcf72312011-04-20 15:09:01 -0700250}
251
252static float SC_randf2(float min, float max) {
253 float r = (float)rand();
Jason Samse2b33042011-04-22 14:19:42 -0700254 r /= RAND_MAX;
Jason Samsfcf72312011-04-20 15:09:01 -0700255 r = r * (max - min) + min;
Jason Samse2b33042011-04-22 14:19:42 -0700256 return r;
Jason Samsfcf72312011-04-20 15:09:01 -0700257}
258
259static int SC_randi(int max) {
260 return (int)SC_randf(max);
261}
262
263static int SC_randi2(int min, int max) {
264 return (int)SC_randf2(min, max);
265}
266
267static float SC_frac(float v) {
268 int i = (int)floor(v);
269 return fmin(v - i, 0x1.fffffep-1f);
270}
271
272
Jason Sams71767c52011-06-21 16:42:30 -0700273static int32_t SC_AtomicCas(volatile int32_t *ptr, int32_t expectedValue, int32_t newValue) {
274 int32_t prev;
275
276 do {
277 int32_t ret = android_atomic_release_cas(expectedValue, newValue, ptr);
278 if (!ret) {
279 // The android cas return 0 if it wrote the value. This means the
280 // previous value was the expected value and we can return.
281 return expectedValue;
282 }
283 // We didn't write the value and need to load the "previous" value.
284 prev = *ptr;
285
286 // A race condition exists where the expected value could appear after our cas failed
287 // above. In this case loop until we have a legit previous value or the
288 // write passes.
289 } while (prev == expectedValue);
290 return prev;
291}
292
293
294static int32_t SC_AtomicInc(volatile int32_t *ptr) {
295 return android_atomic_inc(ptr);
296}
297
298static int32_t SC_AtomicDec(volatile int32_t *ptr) {
299 return android_atomic_dec(ptr);
300}
301
302static int32_t SC_AtomicAdd(volatile int32_t *ptr, int32_t value) {
303 return android_atomic_add(value, ptr);
304}
305
306static int32_t SC_AtomicSub(volatile int32_t *ptr, int32_t value) {
307 int32_t prev, status;
308 do {
309 prev = *ptr;
310 status = android_atomic_release_cas(prev, prev - value, ptr);
Glenn Kastene80a4cc2011-12-15 09:51:17 -0800311 } while (CC_UNLIKELY(status != 0));
Jason Sams71767c52011-06-21 16:42:30 -0700312 return prev;
313}
314
315static int32_t SC_AtomicAnd(volatile int32_t *ptr, int32_t value) {
316 return android_atomic_and(value, ptr);
317}
318
319static int32_t SC_AtomicOr(volatile int32_t *ptr, int32_t value) {
320 return android_atomic_or(value, ptr);
321}
322
323static int32_t SC_AtomicXor(volatile int32_t *ptr, int32_t value) {
324 int32_t prev, status;
325 do {
326 prev = *ptr;
327 status = android_atomic_release_cas(prev, prev ^ value, ptr);
Glenn Kastene80a4cc2011-12-15 09:51:17 -0800328 } while (CC_UNLIKELY(status != 0));
Jason Sams71767c52011-06-21 16:42:30 -0700329 return prev;
330}
331
332static int32_t SC_AtomicMin(volatile int32_t *ptr, int32_t value) {
333 int32_t prev, status;
334 do {
335 prev = *ptr;
336 int32_t n = rsMin(value, prev);
337 status = android_atomic_release_cas(prev, n, ptr);
Glenn Kastene80a4cc2011-12-15 09:51:17 -0800338 } while (CC_UNLIKELY(status != 0));
Jason Sams71767c52011-06-21 16:42:30 -0700339 return prev;
340}
341
342static int32_t SC_AtomicMax(volatile int32_t *ptr, int32_t value) {
343 int32_t prev, status;
344 do {
345 prev = *ptr;
346 int32_t n = rsMax(value, prev);
347 status = android_atomic_release_cas(prev, n, ptr);
Glenn Kastene80a4cc2011-12-15 09:51:17 -0800348 } while (CC_UNLIKELY(status != 0));
Jason Sams71767c52011-06-21 16:42:30 -0700349 return prev;
350}
351
352
353
Jason Samsfcf72312011-04-20 15:09:01 -0700354//////////////////////////////////////////////////////////////////////////////
355// Class implementation
356//////////////////////////////////////////////////////////////////////////////
357
358// llvm name mangling ref
359// <builtin-type> ::= v # void
360// ::= b # bool
361// ::= c # char
362// ::= a # signed char
363// ::= h # unsigned char
364// ::= s # short
365// ::= t # unsigned short
366// ::= i # int
367// ::= j # unsigned int
368// ::= l # long
369// ::= m # unsigned long
370// ::= x # long long, __int64
371// ::= y # unsigned long long, __int64
372// ::= f # float
373// ::= d # double
374
375static RsdSymbolTable gSyms[] = {
376 { "_Z4acosf", (void *)&acosf, true },
377 { "_Z5acoshf", (void *)&acoshf, true },
378 { "_Z4asinf", (void *)&asinf, true },
379 { "_Z5asinhf", (void *)&asinhf, true },
380 { "_Z4atanf", (void *)&atanf, true },
381 { "_Z5atan2ff", (void *)&atan2f, true },
382 { "_Z5atanhf", (void *)&atanhf, true },
383 { "_Z4cbrtf", (void *)&cbrtf, true },
384 { "_Z4ceilf", (void *)&ceilf, true },
385 { "_Z8copysignff", (void *)&copysignf, true },
386 { "_Z3cosf", (void *)&cosf, true },
387 { "_Z4coshf", (void *)&coshf, true },
388 { "_Z4erfcf", (void *)&erfcf, true },
389 { "_Z3erff", (void *)&erff, true },
390 { "_Z3expf", (void *)&expf, true },
391 { "_Z4exp2f", (void *)&exp2f, true },
392 { "_Z5exp10f", (void *)&SC_exp10, true },
393 { "_Z5expm1f", (void *)&expm1f, true },
394 { "_Z4fabsf", (void *)&fabsf, true },
395 { "_Z4fdimff", (void *)&fdimf, true },
396 { "_Z5floorf", (void *)&floorf, true },
397 { "_Z3fmafff", (void *)&fmaf, true },
398 { "_Z4fmaxff", (void *)&fmaxf, true },
399 { "_Z4fminff", (void *)&fminf, true }, // float fmin(float, float)
400 { "_Z4fmodff", (void *)&fmodf, true },
401 { "_Z5fractfPf", (void *)&SC_fract, true },
402 { "_Z5frexpfPi", (void *)&frexpf, true },
403 { "_Z5hypotff", (void *)&hypotf, true },
404 { "_Z5ilogbf", (void *)&ilogbf, true },
405 { "_Z5ldexpfi", (void *)&ldexpf, true },
406 { "_Z6lgammaf", (void *)&lgammaf, true },
407 { "_Z6lgammafPi", (void *)&lgammaf_r, true },
408 { "_Z3logf", (void *)&logf, true },
409 { "_Z4log2f", (void *)&SC_log2, true },
410 { "_Z5log10f", (void *)&log10f, true },
411 { "_Z5log1pf", (void *)&log1pf, true },
412 { "_Z4logbf", (void *)&logbf, true },
413 { "_Z3madfff", (void *)&SC_mad, true },
414 { "_Z4modffPf", (void *)&modff, true },
415 //{ "_Z3nanj", (void *)&SC_nan, true },
416 { "_Z9nextafterff", (void *)&nextafterf, true },
417 { "_Z3powff", (void *)&powf, true },
418 { "_Z9remainderff", (void *)&remainderf, true },
419 { "_Z6remquoffPi", (void *)&remquof, true },
420 { "_Z4rintf", (void *)&rintf, true },
421 { "_Z5rootnfi", (void *)&SC_rootn, true },
422 { "_Z5roundf", (void *)&roundf, true },
423 { "_Z5rsqrtf", (void *)&SC_rsqrt, true },
424 { "_Z3sinf", (void *)&sinf, true },
425 { "_Z6sincosfPf", (void *)&SC_sincos, true },
426 { "_Z4sinhf", (void *)&sinhf, true },
427 { "_Z4sqrtf", (void *)&sqrtf, true },
428 { "_Z3tanf", (void *)&tanf, true },
429 { "_Z4tanhf", (void *)&tanhf, true },
430 { "_Z6tgammaf", (void *)&tgammaf, true },
431 { "_Z5truncf", (void *)&truncf, true },
432
433 { "_Z3absi", (void *)&SC_abs_i32, true },
434 { "_Z3abss", (void *)&SC_abs_i16, true },
435 { "_Z3absc", (void *)&SC_abs_i8, true },
436 { "_Z3clzj", (void *)&SC_clz_u32, true },
437 { "_Z3clzt", (void *)&SC_clz_u16, true },
438 { "_Z3clzh", (void *)&SC_clz_u8, true },
439 { "_Z3clzi", (void *)&SC_clz_i32, true },
440 { "_Z3clzs", (void *)&SC_clz_i16, true },
441 { "_Z3clzc", (void *)&SC_clz_i8, true },
442 { "_Z3maxjj", (void *)&SC_max_u32, true },
443 { "_Z3maxtt", (void *)&SC_max_u16, true },
444 { "_Z3maxhh", (void *)&SC_max_u8, true },
445 { "_Z3maxii", (void *)&SC_max_i32, true },
446 { "_Z3maxss", (void *)&SC_max_i16, true },
447 { "_Z3maxcc", (void *)&SC_max_i8, true },
448 { "_Z3minjj", (void *)&SC_min_u32, true },
449 { "_Z3mintt", (void *)&SC_min_u16, true },
450 { "_Z3minhh", (void *)&SC_min_u8, true },
451 { "_Z3minii", (void *)&SC_min_i32, true },
452 { "_Z3minss", (void *)&SC_min_i16, true },
453 { "_Z3mincc", (void *)&SC_min_i8, true },
454
455 { "_Z5clampfff", (void *)&SC_clamp_f32, true },
456 { "_Z7degreesf", (void *)&SC_degrees, true },
457 { "_Z3maxff", (void *)&SC_max_f32, true },
458 { "_Z3minff", (void *)&SC_min_f32, true },
459 { "_Z3mixfff", (void *)&SC_mix_f32, true },
460 { "_Z7radiansf", (void *)&SC_radians, true },
461 { "_Z4stepff", (void *)&SC_step_f32, true },
462 //{ "smoothstep", (void *)&, true },
463 { "_Z4signf", (void *)&SC_sign_f32, true },
464
465 // matrix
466 { "_Z20rsMatrixLoadIdentityP12rs_matrix4x4", (void *)&SC_MatrixLoadIdentity_4x4, true },
467 { "_Z20rsMatrixLoadIdentityP12rs_matrix3x3", (void *)&SC_MatrixLoadIdentity_3x3, true },
468 { "_Z20rsMatrixLoadIdentityP12rs_matrix2x2", (void *)&SC_MatrixLoadIdentity_2x2, true },
469
470 { "_Z12rsMatrixLoadP12rs_matrix4x4PKf", (void *)&SC_MatrixLoad_4x4_f, true },
471 { "_Z12rsMatrixLoadP12rs_matrix3x3PKf", (void *)&SC_MatrixLoad_3x3_f, true },
472 { "_Z12rsMatrixLoadP12rs_matrix2x2PKf", (void *)&SC_MatrixLoad_2x2_f, true },
473
474 { "_Z12rsMatrixLoadP12rs_matrix4x4PKS_", (void *)&SC_MatrixLoad_4x4_4x4, true },
475 { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix3x3", (void *)&SC_MatrixLoad_4x4_3x3, true },
476 { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix2x2", (void *)&SC_MatrixLoad_4x4_2x2, true },
477 { "_Z12rsMatrixLoadP12rs_matrix3x3PKS_", (void *)&SC_MatrixLoad_3x3_3x3, true },
478 { "_Z12rsMatrixLoadP12rs_matrix2x2PKS_", (void *)&SC_MatrixLoad_2x2_2x2, true },
479
480 { "_Z18rsMatrixLoadRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadRotate, true },
481 { "_Z17rsMatrixLoadScaleP12rs_matrix4x4fff", (void *)&SC_MatrixLoadScale, true },
482 { "_Z21rsMatrixLoadTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixLoadTranslate, true },
483 { "_Z14rsMatrixRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixRotate, true },
484 { "_Z13rsMatrixScaleP12rs_matrix4x4fff", (void *)&SC_MatrixScale, true },
485 { "_Z17rsMatrixTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixTranslate, true },
486
487 { "_Z20rsMatrixLoadMultiplyP12rs_matrix4x4PKS_S2_", (void *)&SC_MatrixLoadMultiply_4x4_4x4_4x4, true },
488 { "_Z16rsMatrixMultiplyP12rs_matrix4x4PKS_", (void *)&SC_MatrixMultiply_4x4_4x4, true },
489 { "_Z20rsMatrixLoadMultiplyP12rs_matrix3x3PKS_S2_", (void *)&SC_MatrixLoadMultiply_3x3_3x3_3x3, true },
490 { "_Z16rsMatrixMultiplyP12rs_matrix3x3PKS_", (void *)&SC_MatrixMultiply_3x3_3x3, true },
491 { "_Z20rsMatrixLoadMultiplyP12rs_matrix2x2PKS_S2_", (void *)&SC_MatrixLoadMultiply_2x2_2x2_2x2, true },
492 { "_Z16rsMatrixMultiplyP12rs_matrix2x2PKS_", (void *)&SC_MatrixMultiply_2x2_2x2, true },
493
494 { "_Z17rsMatrixLoadOrthoP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadOrtho, true },
495 { "_Z19rsMatrixLoadFrustumP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadFrustum, true },
496 { "_Z23rsMatrixLoadPerspectiveP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadPerspective, true },
497
498 { "_Z15rsMatrixInverseP12rs_matrix4x4", (void *)&SC_MatrixInverse_4x4, true },
499 { "_Z24rsMatrixInverseTransposeP12rs_matrix4x4", (void *)&SC_MatrixInverseTranspose_4x4, true },
500 { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_4x4, true },
501 { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_3x3, true },
502 { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_2x2, true },
503
504 // RS Math
505 { "_Z6rsRandi", (void *)&SC_randi, true },
506 { "_Z6rsRandii", (void *)&SC_randi2, true },
507 { "_Z6rsRandf", (void *)&SC_randf, true },
508 { "_Z6rsRandff", (void *)&SC_randf2, true },
509 { "_Z6rsFracf", (void *)&SC_frac, true },
510
Jason Sams71767c52011-06-21 16:42:30 -0700511 // Atomics
512 { "_Z11rsAtomicIncPVi", (void *)&SC_AtomicInc, true },
513 { "_Z11rsAtomicIncPVj", (void *)&SC_AtomicInc, true },
514 { "_Z11rsAtomicDecPVi", (void *)&SC_AtomicDec, true },
515 { "_Z11rsAtomicDecPVj", (void *)&SC_AtomicDec, true },
516 { "_Z11rsAtomicAddPVii", (void *)&SC_AtomicAdd, true },
517 { "_Z11rsAtomicAddPVjj", (void *)&SC_AtomicAdd, true },
518 { "_Z11rsAtomicSubPVii", (void *)&SC_AtomicSub, true },
519 { "_Z11rsAtomicSubPVjj", (void *)&SC_AtomicSub, true },
520 { "_Z11rsAtomicAndPVii", (void *)&SC_AtomicAnd, true },
521 { "_Z11rsAtomicAndPVjj", (void *)&SC_AtomicAnd, true },
522 { "_Z10rsAtomicOrPVii", (void *)&SC_AtomicOr, true },
523 { "_Z10rsAtomicOrPVjj", (void *)&SC_AtomicOr, true },
524 { "_Z11rsAtomicXorPVii", (void *)&SC_AtomicXor, true },
525 { "_Z11rsAtomicXorPVjj", (void *)&SC_AtomicXor, true },
526 { "_Z11rsAtomicMinPVii", (void *)&SC_AtomicMin, true },
527 { "_Z11rsAtomicMinPVjj", (void *)&SC_AtomicMin, true },
528 { "_Z11rsAtomicMaxPVii", (void *)&SC_AtomicMax, true },
529 { "_Z11rsAtomicMaxPVjj", (void *)&SC_AtomicMax, true },
530 { "_Z11rsAtomicCasPViii", (void *)&SC_AtomicCas, true },
531 { "_Z11rsAtomicCasPVjjj", (void *)&SC_AtomicCas, true },
532
Jason Samsfcf72312011-04-20 15:09:01 -0700533 { NULL, NULL, false }
534};
535
536const RsdSymbolTable * rsdLookupSymbolMath(const char *sym) {
537 const RsdSymbolTable *syms = gSyms;
538
539 while (syms->mPtr) {
540 if (!strcmp(syms->mName, sym)) {
541 return syms;
542 }
543 syms++;
544 }
545 return NULL;
546}
547