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