Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 "rsMatrix.h" |
| 20 | |
Joe Onorato | 9c4e4ca | 2009-08-09 11:39:02 -0700 | [diff] [blame] | 21 | #include "utils/Timers.h" |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 22 | |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 23 | #include <time.h> |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 24 | |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 25 | using namespace android; |
| 26 | using namespace android::renderscript; |
| 27 | |
| 28 | #define GET_TLS() Context::ScriptTLSStruct * tls = \ |
| 29 | (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \ |
| 30 | Context * rsc = tls->mContext; \ |
| 31 | ScriptC * sc = (ScriptC *) tls->mScript |
| 32 | |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 33 | |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 34 | ////////////////////////////////////////////////////////////////////////////// |
| 35 | // Math routines |
| 36 | ////////////////////////////////////////////////////////////////////////////// |
| 37 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 38 | static float SC_sinf_fast(float x) { |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 39 | const float A = 1.0f / (2.0f * M_PI); |
| 40 | const float B = -16.0f; |
| 41 | const float C = 8.0f; |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 42 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 43 | // scale angle for easy argument reduction |
| 44 | x *= A; |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 45 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 46 | if (fabsf(x) >= 0.5f) { |
| 47 | // argument reduction |
| 48 | x = x - ceilf(x + 0.5f) + 1.0f; |
| 49 | } |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 50 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 51 | const float y = B * x * fabsf(x) + C * x; |
| 52 | return 0.2215f * (y * fabsf(y) - y) + y; |
| 53 | } |
| 54 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 55 | static float SC_cosf_fast(float x) { |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 56 | x += float(M_PI / 2); |
| 57 | |
| 58 | const float A = 1.0f / (2.0f * M_PI); |
| 59 | const float B = -16.0f; |
| 60 | const float C = 8.0f; |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 61 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 62 | // scale angle for easy argument reduction |
| 63 | x *= A; |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 64 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 65 | if (fabsf(x) >= 0.5f) { |
| 66 | // argument reduction |
| 67 | x = x - ceilf(x + 0.5f) + 1.0f; |
| 68 | } |
Jason Sams | a57c0a7 | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 69 | |
Romain Guy | 2275d63 | 2009-08-18 11:39:17 -0700 | [diff] [blame] | 70 | const float y = B * x * fabsf(x) + C * x; |
| 71 | return 0.2215f * (y * fabsf(y) - y) + y; |
| 72 | } |
| 73 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 74 | static float SC_randf(float max) { |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 75 | float r = (float)rand(); |
Jason Sams | 366c9c8 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 76 | r *= max; |
| 77 | return r / RAND_MAX; |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 80 | static float SC_randf2(float min, float max) { |
Romain Guy | 39dbc80 | 2009-07-31 11:20:59 -0700 | [diff] [blame] | 81 | float r = (float)rand(); |
Jason Sams | 366c9c8 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 82 | r = r * (max - min) + min; |
| 83 | return r / RAND_MAX; |
Romain Guy | 39dbc80 | 2009-07-31 11:20:59 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 86 | static int SC_randi(int max) { |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 87 | return (int)SC_randf(max); |
| 88 | } |
| 89 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 90 | static int SC_randi2(int min, int max) { |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 91 | return (int)SC_randf2(min, max); |
| 92 | } |
| 93 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 94 | static float SC_frac(float v) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 95 | int i = (int)floor(v); |
| 96 | return fmin(v - i, 0x1.fffffep-1f); |
| 97 | } |
| 98 | |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 99 | ////////////////////////////////////////////////////////////////////////////// |
| 100 | // Time routines |
| 101 | ////////////////////////////////////////////////////////////////////////////// |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 102 | |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 103 | static time_t SC_time(time_t *timer) { |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 104 | GET_TLS(); |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 105 | return time(timer); |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 108 | static tm* SC_localtime(tm *local, time_t *timer) { |
Romain Guy | 98e10fd | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 109 | GET_TLS(); |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 110 | if (!local) { |
| 111 | return NULL; |
| 112 | } |
Jason Sams | e5ffb87 | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 113 | |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 114 | // The native localtime function is not thread-safe, so we |
| 115 | // have to apply locking for proper behavior in RenderScript. |
| 116 | pthread_mutex_lock(&rsc->gLibMutex); |
| 117 | tm *tmp = localtime(timer); |
| 118 | memcpy(local, tmp, sizeof(*tmp)); |
| 119 | pthread_mutex_unlock(&rsc->gLibMutex); |
| 120 | return local; |
Romain Guy | 39dbc80 | 2009-07-31 11:20:59 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 123 | static int64_t SC_uptimeMillis() { |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 124 | return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC)); |
| 125 | } |
| 126 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 127 | static int64_t SC_uptimeNanos() { |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 128 | return systemTime(SYSTEM_TIME_MONOTONIC); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 131 | static float SC_getDt() { |
Joe Onorato | 9c4e4ca | 2009-08-09 11:39:02 -0700 | [diff] [blame] | 132 | GET_TLS(); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 133 | int64_t l = sc->mEnviroment.mLastDtTime; |
| 134 | sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC); |
| 135 | return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9; |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 138 | ////////////////////////////////////////////////////////////////////////////// |
| 139 | // |
| 140 | ////////////////////////////////////////////////////////////////////////////// |
| 141 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 142 | static uint32_t SC_allocGetDimX(RsAllocation va) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 143 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 144 | CHECK_OBJ(a); |
| 145 | //LOGE("SC_allocGetDimX a=%p type=%p", a, a->getType()); |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 146 | return a->getType()->getDimX(); |
| 147 | } |
| 148 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 149 | static uint32_t SC_allocGetDimY(RsAllocation va) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 150 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 151 | CHECK_OBJ(a); |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 152 | return a->getType()->getDimY(); |
| 153 | } |
| 154 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 155 | static uint32_t SC_allocGetDimZ(RsAllocation va) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 156 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 157 | CHECK_OBJ(a); |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 158 | return a->getType()->getDimZ(); |
| 159 | } |
| 160 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 161 | static uint32_t SC_allocGetDimLOD(RsAllocation va) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 162 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 163 | CHECK_OBJ(a); |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 164 | return a->getType()->getDimLOD(); |
| 165 | } |
| 166 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 167 | static uint32_t SC_allocGetDimFaces(RsAllocation va) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 168 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 169 | CHECK_OBJ(a); |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 170 | return a->getType()->getDimFaces(); |
| 171 | } |
| 172 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 173 | static const void * SC_getElementAtX(RsAllocation va, uint32_t x) { |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 174 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 175 | CHECK_OBJ(a); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 176 | const Type *t = a->getType(); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 177 | CHECK_OBJ(t); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 178 | const uint8_t *p = (const uint8_t *)a->getPtr(); |
| 179 | return &p[t->getElementSizeBytes() * x]; |
| 180 | } |
| 181 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 182 | static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y) { |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 183 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 184 | CHECK_OBJ(a); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 185 | const Type *t = a->getType(); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 186 | CHECK_OBJ(t); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 187 | const uint8_t *p = (const uint8_t *)a->getPtr(); |
| 188 | return &p[t->getElementSizeBytes() * (x + y*t->getDimX())]; |
| 189 | } |
| 190 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 191 | static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z) { |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 192 | const Allocation *a = static_cast<const Allocation *>(va); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 193 | CHECK_OBJ(a); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 194 | const Type *t = a->getType(); |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 195 | CHECK_OBJ(t); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 196 | const uint8_t *p = (const uint8_t *)a->getPtr(); |
| 197 | return &p[t->getElementSizeBytes() * (x + y*t->getDimX())]; |
| 198 | } |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 199 | |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 200 | static void SC_setObject(void **vdst, void * vsrc) { |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 201 | //LOGE("SC_setObject %p,%p %p", vdst, *vdst, vsrc); |
| 202 | if (vsrc) { |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 203 | CHECK_OBJ(vsrc); |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 204 | static_cast<ObjectBase *>(vsrc)->incSysRef(); |
| 205 | } |
| 206 | if (vdst[0]) { |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 207 | CHECK_OBJ(vdst[0]); |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 208 | static_cast<ObjectBase *>(vdst[0])->decSysRef(); |
| 209 | } |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 210 | *vdst = vsrc; |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 211 | //LOGE("SC_setObject *"); |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 212 | } |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 213 | |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 214 | static void SC_clearObject(void **vdst) { |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 215 | //LOGE("SC_clearObject %p,%p", vdst, *vdst); |
| 216 | if (vdst[0]) { |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 217 | CHECK_OBJ(vdst[0]); |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 218 | static_cast<ObjectBase *>(vdst[0])->decSysRef(); |
| 219 | } |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 220 | *vdst = NULL; |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 221 | //LOGE("SC_clearObject *"); |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 222 | } |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 223 | |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 224 | static bool SC_isObject(RsAllocation vsrc) { |
| 225 | return vsrc != NULL; |
| 226 | } |
| 227 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 228 | static void SC_debugF(const char *s, float f) { |
| 229 | LOGE("%s %f, 0x%08x", s, f, *((int *) (&f))); |
Jason Sams | c9d43db | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 230 | } |
Jason Sams | 7dce6bc | 2010-08-06 16:22:50 -0700 | [diff] [blame] | 231 | static void SC_debugFv2(const char *s, float f1, float f2) { |
| 232 | LOGE("%s {%f, %f}", s, f1, f2); |
Romain Guy | 370ed15 | 2009-08-20 17:08:33 -0700 | [diff] [blame] | 233 | } |
Jason Sams | 7dce6bc | 2010-08-06 16:22:50 -0700 | [diff] [blame] | 234 | static void SC_debugFv3(const char *s, float f1, float f2, float f3) { |
| 235 | LOGE("%s {%f, %f, %f}", s, f1, f2, f3); |
Jason Sams | c9d43db | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 236 | } |
Jason Sams | 7dce6bc | 2010-08-06 16:22:50 -0700 | [diff] [blame] | 237 | static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) { |
| 238 | LOGE("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 239 | } |
Stephen Hines | df09719 | 2010-10-15 12:47:49 -0700 | [diff] [blame] | 240 | static void SC_debugD(const char *s, double d) { |
| 241 | LOGE("%s %f, 0x%08llx", s, d, *((long long *) (&d))); |
| 242 | } |
Jason Sams | 7dce6bc | 2010-08-06 16:22:50 -0700 | [diff] [blame] | 243 | static void SC_debugFM4v4(const char *s, const float *f) { |
| 244 | LOGE("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]); |
| 245 | LOGE("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]); |
| 246 | LOGE("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]); |
| 247 | LOGE("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]); |
| 248 | } |
| 249 | static void SC_debugFM3v3(const char *s, const float *f) { |
| 250 | LOGE("%s {%f, %f, %f", s, f[0], f[3], f[6]); |
| 251 | LOGE("%s %f, %f, %f", s, f[1], f[4], f[7]); |
| 252 | LOGE("%s %f, %f, %f}",s, f[2], f[5], f[8]); |
| 253 | } |
| 254 | static void SC_debugFM2v2(const char *s, const float *f) { |
| 255 | LOGE("%s {%f, %f", s, f[0], f[2]); |
| 256 | LOGE("%s %f, %f}",s, f[1], f[3]); |
| 257 | } |
| 258 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 259 | static void SC_debugI32(const char *s, int32_t i) { |
| 260 | LOGE("%s %i 0x%x", s, i, i); |
Romain Guy | 370ed15 | 2009-08-20 17:08:33 -0700 | [diff] [blame] | 261 | } |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 262 | static void SC_debugU32(const char *s, uint32_t i) { |
Stephen Hines | df09719 | 2010-10-15 12:47:49 -0700 | [diff] [blame] | 263 | LOGE("%s %u 0x%x", s, i, i); |
| 264 | } |
| 265 | static void SC_debugLL64(const char *s, long long ll) { |
| 266 | LOGE("%s %lld 0x%llx", s, ll, ll); |
| 267 | } |
| 268 | static void SC_debugULL64(const char *s, unsigned long long ll) { |
| 269 | LOGE("%s %llu 0x%llx", s, ll, ll); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 270 | } |
Romain Guy | 370ed15 | 2009-08-20 17:08:33 -0700 | [diff] [blame] | 271 | |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 272 | static void SC_debugP(const char *s, const void *p) { |
| 273 | LOGE("%s %p", s, p); |
| 274 | } |
| 275 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 276 | static uint32_t SC_toClient2(int cmdID, void *data, int len) { |
Jason Sams | 8c401ef | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 277 | GET_TLS(); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 278 | //LOGE("SC_toClient %i %i %i", cmdID, len); |
Jason Sams | aad4bc5 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 279 | return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, false); |
Jason Sams | 8c401ef | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 282 | static uint32_t SC_toClient(int cmdID) { |
Jason Sams | 3a27c95 | 2009-10-07 18:14:01 -0700 | [diff] [blame] | 283 | GET_TLS(); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 284 | //LOGE("SC_toClient %i", cmdID); |
Jason Sams | aad4bc5 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 285 | return rsc->sendMessageToClient(NULL, RS_MESSAGE_TO_CLIENT_USER, cmdID, 0, false); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 288 | static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len) { |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 289 | GET_TLS(); |
| 290 | //LOGE("SC_toClientBlocking %i %i", cmdID, len); |
Jason Sams | aad4bc5 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 291 | return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, true); |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 294 | static uint32_t SC_toClientBlocking(int cmdID) { |
Jason Sams | ef5867a | 2010-07-28 11:17:53 -0700 | [diff] [blame] | 295 | GET_TLS(); |
| 296 | //LOGE("SC_toClientBlocking %i", cmdID); |
Jason Sams | aad4bc5 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 297 | return rsc->sendMessageToClient(NULL, RS_MESSAGE_TO_CLIENT_USER, cmdID, 0, true); |
Jason Sams | 3a27c95 | 2009-10-07 18:14:01 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 300 | int SC_divsi3(int a, int b) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 301 | return a / b; |
| 302 | } |
Jason Sams | 3a27c95 | 2009-10-07 18:14:01 -0700 | [diff] [blame] | 303 | |
Bryan Mawhinney | cb082a3 | 2010-11-11 14:33:12 +0000 | [diff] [blame] | 304 | int SC_modsi3(int a, int b) { |
| 305 | return a % b; |
| 306 | } |
| 307 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 308 | int SC_getAllocation(const void *ptr) { |
Jason Sams | ce92d4b | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 309 | GET_TLS(); |
| 310 | const Allocation *alloc = sc->ptrToAllocation(ptr); |
| 311 | return (int)alloc; |
| 312 | } |
| 313 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 314 | void SC_allocationMarkDirty(RsAllocation a) { |
Alex Sakhartchouk | 1e5168d | 2010-09-01 16:34:48 -0700 | [diff] [blame] | 315 | Allocation *alloc = static_cast<Allocation *>(a); |
| 316 | alloc->sendDirty(); |
| 317 | } |
Jason Sams | ce92d4b | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 318 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 319 | void SC_ForEach(RsScript vs, |
| 320 | RsAllocation vin, |
| 321 | RsAllocation vout, |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 322 | const void *usr) { |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 323 | GET_TLS(); |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 324 | const Allocation *ain = static_cast<const Allocation *>(vin); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 325 | Allocation *aout = static_cast<Allocation *>(vout); |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 326 | Script *s = static_cast<Script *>(vs); |
| 327 | s->runForEach(rsc, ain, aout, usr); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 330 | void SC_ForEach2(RsScript vs, |
| 331 | RsAllocation vin, |
| 332 | RsAllocation vout, |
| 333 | const void *usr, |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 334 | const RsScriptCall *call) { |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 335 | GET_TLS(); |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 336 | const Allocation *ain = static_cast<const Allocation *>(vin); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 337 | Allocation *aout = static_cast<Allocation *>(vout); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 338 | Script *s = static_cast<Script *>(vs); |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 339 | s->runForEach(rsc, ain, aout, usr, call); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 342 | ////////////////////////////////////////////////////////////////////////////// |
| 343 | // Class implementation |
| 344 | ////////////////////////////////////////////////////////////////////////////// |
| 345 | |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 346 | // llvm name mangling ref |
| 347 | // <builtin-type> ::= v # void |
| 348 | // ::= b # bool |
| 349 | // ::= c # char |
| 350 | // ::= a # signed char |
| 351 | // ::= h # unsigned char |
| 352 | // ::= s # short |
| 353 | // ::= t # unsigned short |
| 354 | // ::= i # int |
| 355 | // ::= j # unsigned int |
| 356 | // ::= l # long |
| 357 | // ::= m # unsigned long |
| 358 | // ::= x # long long, __int64 |
| 359 | // ::= y # unsigned long long, __int64 |
| 360 | // ::= f # float |
| 361 | // ::= d # double |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 362 | |
Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 363 | static ScriptCState::SymbolTable_t gSyms[] = { |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 364 | { "__divsi3", (void *)&SC_divsi3, true }, |
Bryan Mawhinney | cb082a3 | 2010-11-11 14:33:12 +0000 | [diff] [blame] | 365 | { "__modsi3", (void *)&SC_modsi3, true }, |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 366 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 367 | // allocation |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 368 | { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX, true }, |
| 369 | { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY, true }, |
| 370 | { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ, true }, |
| 371 | { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD, true }, |
| 372 | { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces, true }, |
| 373 | { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation, true }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 374 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 375 | { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX, true }, |
| 376 | { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY, true }, |
| 377 | { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ, true }, |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 378 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 379 | { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_setObject, true }, |
| 380 | { "_Z13rsClearObjectP10rs_element", (void *)&SC_clearObject, true }, |
| 381 | { "_Z10rsIsObject10rs_element", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 382 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 383 | { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_setObject, true }, |
| 384 | { "_Z13rsClearObjectP7rs_type", (void *)&SC_clearObject, true }, |
| 385 | { "_Z10rsIsObject7rs_type", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 386 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 387 | { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_setObject, true }, |
| 388 | { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_clearObject, true }, |
| 389 | { "_Z10rsIsObject13rs_allocation", (void *)&SC_isObject, true }, |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 390 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 391 | { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_setObject, true }, |
| 392 | { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_clearObject, true }, |
| 393 | { "_Z10rsIsObject10rs_sampler", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 394 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 395 | { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_setObject, true }, |
| 396 | { "_Z13rsClearObjectP9rs_script", (void *)&SC_clearObject, true }, |
| 397 | { "_Z10rsIsObject9rs_script", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 398 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 399 | { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_setObject, true }, |
| 400 | { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_clearObject, true }, |
| 401 | { "_Z10rsIsObject7rs_mesh", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 402 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 403 | { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_setObject, true }, |
| 404 | { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_clearObject, true }, |
| 405 | { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 406 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 407 | { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_setObject, true }, |
| 408 | { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_clearObject, true }, |
| 409 | { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 410 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 411 | { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_setObject, true }, |
| 412 | { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_clearObject, true }, |
| 413 | { "_Z10rsIsObject17rs_program_raster", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 414 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 415 | { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_setObject, true }, |
| 416 | { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_clearObject, true }, |
| 417 | { "_Z10rsIsObject16rs_program_store", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 418 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 419 | { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_setObject, true }, |
| 420 | { "_Z13rsClearObjectP7rs_font", (void *)&SC_clearObject, true }, |
| 421 | { "_Z10rsIsObject7rs_font", (void *)&SC_isObject, true }, |
Jason Sams | f24d7d0 | 2010-09-17 13:17:17 -0700 | [diff] [blame] | 422 | |
| 423 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 424 | { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_allocationMarkDirty, true }, |
Alex Sakhartchouk | 1e5168d | 2010-09-01 16:34:48 -0700 | [diff] [blame] | 425 | |
Jason Sams | c093685 | 2010-08-16 12:41:48 -0700 | [diff] [blame] | 426 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 427 | // Debug |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 428 | { "_Z7rsDebugPKcf", (void *)&SC_debugF, true }, |
| 429 | { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true }, |
| 430 | { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true }, |
| 431 | { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true }, |
| 432 | { "_Z7rsDebugPKcd", (void *)&SC_debugD, true }, |
| 433 | { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true }, |
| 434 | { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true }, |
| 435 | { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true }, |
| 436 | { "_Z7rsDebugPKci", (void *)&SC_debugI32, true }, |
| 437 | { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true }, |
Stephen Hines | df09719 | 2010-10-15 12:47:49 -0700 | [diff] [blame] | 438 | // Both "long" and "unsigned long" need to be redirected to their |
| 439 | // 64-bit counterparts, since we have hacked Slang to use 64-bit |
| 440 | // for "long" on Arm (to be similar to Java). |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 441 | { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true }, |
| 442 | { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true }, |
| 443 | { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true }, |
| 444 | { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true }, |
| 445 | { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 446 | |
| 447 | // RS Math |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 448 | { "_Z6rsRandi", (void *)&SC_randi, true }, |
| 449 | { "_Z6rsRandii", (void *)&SC_randi2, true }, |
| 450 | { "_Z6rsRandf", (void *)&SC_randf, true }, |
| 451 | { "_Z6rsRandff", (void *)&SC_randf2, true }, |
| 452 | { "_Z6rsFracf", (void *)&SC_frac, true }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 453 | |
| 454 | // time |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame^] | 455 | { "_Z6rsTimePi", (void *)&SC_time, true }, |
| 456 | { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_localtime, true }, |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 457 | { "_Z14rsUptimeMillisv", (void*)&SC_uptimeMillis, true }, |
| 458 | { "_Z13rsUptimeNanosv", (void*)&SC_uptimeNanos, true }, |
| 459 | { "_Z7rsGetDtv", (void*)&SC_getDt, false }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 460 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 461 | { "_Z14rsSendToClienti", (void *)&SC_toClient, false }, |
| 462 | { "_Z14rsSendToClientiPKvj", (void *)&SC_toClient2, false }, |
| 463 | { "_Z22rsSendToClientBlockingi", (void *)&SC_toClientBlocking, false }, |
| 464 | { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_toClientBlocking2, false }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 465 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 466 | { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach, false }, |
| 467 | //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2, true }, |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 468 | |
| 469 | //////////////////////////////////////////////////////////////////// |
| 470 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 471 | //{ "sinf_fast", (void *)&SC_sinf_fast, true }, |
| 472 | //{ "cosf_fast", (void *)&SC_cosf_fast, true }, |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 473 | |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 474 | { NULL, NULL, false } |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 475 | }; |
| 476 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 477 | const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym) { |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 478 | ScriptCState::SymbolTable_t *syms = gSyms; |
| 479 | |
| 480 | while (syms->mPtr) { |
| 481 | if (!strcmp(syms->mName, sym)) { |
| 482 | return syms; |
| 483 | } |
| 484 | syms++; |
| 485 | } |
| 486 | return NULL; |
| 487 | } |