blob: 22fd421934d80e9228d71fb06ee620e221236910 [file] [log] [blame]
Jason Samsc97bb882009-07-20 14:31:06 -07001/*
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 Onorato3370ec92009-08-09 11:39:02 -070021#include "utils/Timers.h"
Jason Samsc97bb882009-07-20 14:31:06 -070022
Romain Guy584a3752009-07-30 18:45:01 -070023#include <time.h>
Romain Guy584a3752009-07-30 18:45:01 -070024
Jason Samsc97bb882009-07-20 14:31:06 -070025using namespace android;
26using 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 Sams4d339932010-05-11 14:03:58 -070033
Jason Samsc97bb882009-07-20 14:31:06 -070034//////////////////////////////////////////////////////////////////////////////
35// Math routines
36//////////////////////////////////////////////////////////////////////////////
37
Romain Guycac80a62009-08-18 11:39:17 -070038static float SC_sinf_fast(float x)
39{
40 const float A = 1.0f / (2.0f * M_PI);
41 const float B = -16.0f;
42 const float C = 8.0f;
Jason Samsea84a7c2009-09-04 14:42:41 -070043
Romain Guycac80a62009-08-18 11:39:17 -070044 // scale angle for easy argument reduction
45 x *= A;
Jason Samsea84a7c2009-09-04 14:42:41 -070046
Romain Guycac80a62009-08-18 11:39:17 -070047 if (fabsf(x) >= 0.5f) {
48 // argument reduction
49 x = x - ceilf(x + 0.5f) + 1.0f;
50 }
Jason Samsea84a7c2009-09-04 14:42:41 -070051
Romain Guycac80a62009-08-18 11:39:17 -070052 const float y = B * x * fabsf(x) + C * x;
53 return 0.2215f * (y * fabsf(y) - y) + y;
54}
55
56static float SC_cosf_fast(float x)
57{
58 x += float(M_PI / 2);
59
60 const float A = 1.0f / (2.0f * M_PI);
61 const float B = -16.0f;
62 const float C = 8.0f;
Jason Samsea84a7c2009-09-04 14:42:41 -070063
Romain Guycac80a62009-08-18 11:39:17 -070064 // scale angle for easy argument reduction
65 x *= A;
Jason Samsea84a7c2009-09-04 14:42:41 -070066
Romain Guycac80a62009-08-18 11:39:17 -070067 if (fabsf(x) >= 0.5f) {
68 // argument reduction
69 x = x - ceilf(x + 0.5f) + 1.0f;
70 }
Jason Samsea84a7c2009-09-04 14:42:41 -070071
Romain Guycac80a62009-08-18 11:39:17 -070072 const float y = B * x * fabsf(x) + C * x;
73 return 0.2215f * (y * fabsf(y) - y) + y;
74}
75
Jason Samsd79b2e92010-05-19 17:22:57 -070076
Jason Samsc97bb882009-07-20 14:31:06 -070077static float SC_randf(float max)
78{
79 float r = (float)rand();
80 return r / RAND_MAX * max;
81}
82
Romain Guy8839ca52009-07-31 11:20:59 -070083static float SC_randf2(float min, float max)
84{
85 float r = (float)rand();
86 return r / RAND_MAX * (max - min) + min;
87}
88
Jason Samsd79b2e92010-05-19 17:22:57 -070089static int SC_randi(int max)
90{
91 return (int)SC_randf(max);
92}
93
94static int SC_randi2(int min, int max)
95{
96 return (int)SC_randf2(min, max);
97}
98
Jason Sams4d339932010-05-11 14:03:58 -070099static float SC_frac(float v)
100{
101 int i = (int)floor(v);
102 return fmin(v - i, 0x1.fffffep-1f);
103}
104
Romain Guy584a3752009-07-30 18:45:01 -0700105//////////////////////////////////////////////////////////////////////////////
106// Time routines
107//////////////////////////////////////////////////////////////////////////////
Jason Samsc97bb882009-07-20 14:31:06 -0700108
Joe Onorato3370ec92009-08-09 11:39:02 -0700109static int32_t SC_second()
Romain Guy584a3752009-07-30 18:45:01 -0700110{
111 GET_TLS();
112
113 time_t rawtime;
114 time(&rawtime);
115
Romain Guybaed7272009-11-11 15:36:06 -0800116 struct tm *timeinfo;
117 timeinfo = localtime(&rawtime);
118 return timeinfo->tm_sec;
Romain Guy584a3752009-07-30 18:45:01 -0700119}
120
Joe Onorato3370ec92009-08-09 11:39:02 -0700121static int32_t SC_minute()
Romain Guy584a3752009-07-30 18:45:01 -0700122{
123 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700124
Romain Guy584a3752009-07-30 18:45:01 -0700125 time_t rawtime;
126 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700127
Romain Guybaed7272009-11-11 15:36:06 -0800128 struct tm *timeinfo;
129 timeinfo = localtime(&rawtime);
130 return timeinfo->tm_min;
Jason Sams1bada8c2009-08-09 17:01:55 -0700131}
Romain Guy584a3752009-07-30 18:45:01 -0700132
Joe Onorato3370ec92009-08-09 11:39:02 -0700133static int32_t SC_hour()
Romain Guy584a3752009-07-30 18:45:01 -0700134{
135 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700136
Romain Guy584a3752009-07-30 18:45:01 -0700137 time_t rawtime;
138 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700139
Romain Guybaed7272009-11-11 15:36:06 -0800140 struct tm *timeinfo;
141 timeinfo = localtime(&rawtime);
142 return timeinfo->tm_hour;
Romain Guy8839ca52009-07-31 11:20:59 -0700143}
144
Joe Onorato3370ec92009-08-09 11:39:02 -0700145static int32_t SC_day()
Romain Guy8839ca52009-07-31 11:20:59 -0700146{
147 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700148
Romain Guy8839ca52009-07-31 11:20:59 -0700149 time_t rawtime;
150 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700151
Romain Guybaed7272009-11-11 15:36:06 -0800152 struct tm *timeinfo;
153 timeinfo = localtime(&rawtime);
154 return timeinfo->tm_mday;
Jason Sams1bada8c2009-08-09 17:01:55 -0700155}
Jason Samsc97bb882009-07-20 14:31:06 -0700156
Joe Onorato3370ec92009-08-09 11:39:02 -0700157static int32_t SC_month()
Romain Guy8839ca52009-07-31 11:20:59 -0700158{
159 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700160
Romain Guy8839ca52009-07-31 11:20:59 -0700161 time_t rawtime;
162 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700163
Romain Guybaed7272009-11-11 15:36:06 -0800164 struct tm *timeinfo;
165 timeinfo = localtime(&rawtime);
166 return timeinfo->tm_mon;
Jason Sams1bada8c2009-08-09 17:01:55 -0700167}
Romain Guy8839ca52009-07-31 11:20:59 -0700168
Joe Onorato3370ec92009-08-09 11:39:02 -0700169static int32_t SC_year()
Romain Guy8839ca52009-07-31 11:20:59 -0700170{
171 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700172
Romain Guy8839ca52009-07-31 11:20:59 -0700173 time_t rawtime;
174 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700175
Romain Guybaed7272009-11-11 15:36:06 -0800176 struct tm *timeinfo;
177 timeinfo = localtime(&rawtime);
178 return timeinfo->tm_year;
Romain Guy8839ca52009-07-31 11:20:59 -0700179}
180
Jason Sams17966512010-07-28 11:17:53 -0700181static int64_t SC_uptimeMillis()
Jason Samsd79b2e92010-05-19 17:22:57 -0700182{
183 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
184}
185
Jason Samsf0690c42010-07-29 17:31:14 -0700186static int64_t SC_uptimeNanos()
Jason Samsd79b2e92010-05-19 17:22:57 -0700187{
Jason Samsf0690c42010-07-29 17:31:14 -0700188 return systemTime(SYSTEM_TIME_MONOTONIC);
Jason Samsd79b2e92010-05-19 17:22:57 -0700189}
190
Jason Sams17966512010-07-28 11:17:53 -0700191static float SC_getDt()
Joe Onorato3370ec92009-08-09 11:39:02 -0700192{
193 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700194 int64_t l = sc->mEnviroment.mLastDtTime;
195 sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
196 return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
Jason Samsc97bb882009-07-20 14:31:06 -0700197}
198
199
Jason Samsc97bb882009-07-20 14:31:06 -0700200//////////////////////////////////////////////////////////////////////////////
201//
202//////////////////////////////////////////////////////////////////////////////
203
Jason Sams4d339932010-05-11 14:03:58 -0700204static uint32_t SC_allocGetDimX(RsAllocation va)
205{
206 GET_TLS();
207 const Allocation *a = static_cast<const Allocation *>(va);
208 //LOGE("SC_allocGetDimX a=%p", a);
209 //LOGE(" type=%p", a->getType());
210 return a->getType()->getDimX();
211}
212
213static uint32_t SC_allocGetDimY(RsAllocation va)
214{
215 GET_TLS();
216 const Allocation *a = static_cast<const Allocation *>(va);
217 return a->getType()->getDimY();
218}
219
220static uint32_t SC_allocGetDimZ(RsAllocation va)
221{
222 GET_TLS();
223 const Allocation *a = static_cast<const Allocation *>(va);
224 return a->getType()->getDimZ();
225}
226
227static uint32_t SC_allocGetDimLOD(RsAllocation va)
228{
229 GET_TLS();
230 const Allocation *a = static_cast<const Allocation *>(va);
231 return a->getType()->getDimLOD();
232}
233
234static uint32_t SC_allocGetDimFaces(RsAllocation va)
235{
236 GET_TLS();
237 const Allocation *a = static_cast<const Allocation *>(va);
238 return a->getType()->getDimFaces();
239}
240
Jason Sams02f62aa2010-08-16 12:41:48 -0700241static const void * SC_getElementAtX(RsAllocation va, uint32_t x)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700242{
243 const Allocation *a = static_cast<const Allocation *>(va);
244 const Type *t = a->getType();
245 const uint8_t *p = (const uint8_t *)a->getPtr();
246 return &p[t->getElementSizeBytes() * x];
247}
248
Jason Sams02f62aa2010-08-16 12:41:48 -0700249static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700250{
251 const Allocation *a = static_cast<const Allocation *>(va);
252 const Type *t = a->getType();
253 const uint8_t *p = (const uint8_t *)a->getPtr();
254 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
255}
256
Jason Sams02f62aa2010-08-16 12:41:48 -0700257static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700258{
259 const Allocation *a = static_cast<const Allocation *>(va);
260 const Type *t = a->getType();
261 const uint8_t *p = (const uint8_t *)a->getPtr();
262 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
263}
Jason Sams4d339932010-05-11 14:03:58 -0700264
Jason Sams02f62aa2010-08-16 12:41:48 -0700265static void SC_setObject(void **vdst, void * vsrc) {
Jason Sams4fd8bb42010-09-17 13:17:17 -0700266 //LOGE("SC_setObject %p,%p %p", vdst, *vdst, vsrc);
267 if (vsrc) {
268 static_cast<ObjectBase *>(vsrc)->incSysRef();
269 }
270 if (vdst[0]) {
271 static_cast<ObjectBase *>(vdst[0])->decSysRef();
272 }
Jason Sams02f62aa2010-08-16 12:41:48 -0700273 *vdst = vsrc;
Jason Sams4fd8bb42010-09-17 13:17:17 -0700274 //LOGE("SC_setObject *");
Jason Sams02f62aa2010-08-16 12:41:48 -0700275}
276static void SC_clearObject(void **vdst) {
Jason Sams4fd8bb42010-09-17 13:17:17 -0700277 //LOGE("SC_clearObject %p,%p", vdst, *vdst);
278 if (vdst[0]) {
279 static_cast<ObjectBase *>(vdst[0])->decSysRef();
280 }
Jason Sams02f62aa2010-08-16 12:41:48 -0700281 *vdst = NULL;
Jason Sams4fd8bb42010-09-17 13:17:17 -0700282 //LOGE("SC_clearObject *");
Jason Sams02f62aa2010-08-16 12:41:48 -0700283}
284static bool SC_isObject(RsAllocation vsrc) {
285 return vsrc != NULL;
286}
287
288
Jason Samsc97bb882009-07-20 14:31:06 -0700289
Jason Samsd79b2e92010-05-19 17:22:57 -0700290static void SC_debugF(const char *s, float f) {
291 LOGE("%s %f, 0x%08x", s, f, *((int *) (&f)));
Jason Samsb0ec1b42009-07-28 12:02:16 -0700292}
Jason Samsd64188a2010-08-06 16:22:50 -0700293static void SC_debugFv2(const char *s, float f1, float f2) {
294 LOGE("%s {%f, %f}", s, f1, f2);
Romain Guyd22fff72009-08-20 17:08:33 -0700295}
Jason Samsd64188a2010-08-06 16:22:50 -0700296static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
297 LOGE("%s {%f, %f, %f}", s, f1, f2, f3);
Jason Samsb0ec1b42009-07-28 12:02:16 -0700298}
Jason Samsd64188a2010-08-06 16:22:50 -0700299static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
300 LOGE("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
Jason Samsd79b2e92010-05-19 17:22:57 -0700301}
Jason Samsd64188a2010-08-06 16:22:50 -0700302static void SC_debugFM4v4(const char *s, const float *f) {
303 LOGE("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
304 LOGE("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
305 LOGE("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
306 LOGE("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
307}
308static void SC_debugFM3v3(const char *s, const float *f) {
309 LOGE("%s {%f, %f, %f", s, f[0], f[3], f[6]);
310 LOGE("%s %f, %f, %f", s, f[1], f[4], f[7]);
311 LOGE("%s %f, %f, %f}",s, f[2], f[5], f[8]);
312}
313static void SC_debugFM2v2(const char *s, const float *f) {
314 LOGE("%s {%f, %f", s, f[0], f[2]);
315 LOGE("%s %f, %f}",s, f[1], f[3]);
316}
317
Jason Samsd79b2e92010-05-19 17:22:57 -0700318static void SC_debugI32(const char *s, int32_t i) {
319 LOGE("%s %i 0x%x", s, i, i);
Romain Guyd22fff72009-08-20 17:08:33 -0700320}
Jason Sams17966512010-07-28 11:17:53 -0700321static void SC_debugU32(const char *s, uint32_t i) {
322 LOGE("%s %i 0x%x", s, i, i);
323}
Romain Guyd22fff72009-08-20 17:08:33 -0700324
Jason Sams8e6c17f2010-07-19 15:38:19 -0700325static void SC_debugP(const char *s, const void *p) {
326 LOGE("%s %p", s, p);
327}
328
Jason Sams17966512010-07-28 11:17:53 -0700329static uint32_t SC_toClient2(int cmdID, void *data, int len)
Jason Sams516c3192009-10-06 13:58:47 -0700330{
331 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700332 //LOGE("SC_toClient %i %i %i", cmdID, len);
333 return rsc->sendMessageToClient(data, cmdID, len, false);
Jason Sams516c3192009-10-06 13:58:47 -0700334}
335
Jason Sams17966512010-07-28 11:17:53 -0700336static uint32_t SC_toClient(int cmdID)
Jason Samsbd2197f2009-10-07 18:14:01 -0700337{
338 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700339 //LOGE("SC_toClient %i", cmdID);
340 return rsc->sendMessageToClient(NULL, cmdID, 0, false);
341}
342
343static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len)
344{
345 GET_TLS();
346 //LOGE("SC_toClientBlocking %i %i", cmdID, len);
347 return rsc->sendMessageToClient(data, cmdID, len, true);
348}
349
350static uint32_t SC_toClientBlocking(int cmdID)
351{
352 GET_TLS();
353 //LOGE("SC_toClientBlocking %i", cmdID);
354 return rsc->sendMessageToClient(NULL, cmdID, 0, true);
Jason Samsbd2197f2009-10-07 18:14:01 -0700355}
356
Jason Sams4d339932010-05-11 14:03:58 -0700357int SC_divsi3(int a, int b)
358{
359 return a / b;
360}
Jason Samsbd2197f2009-10-07 18:14:01 -0700361
Jason Sams1de0b872010-05-17 14:55:34 -0700362int SC_getAllocation(const void *ptr)
363{
364 GET_TLS();
365 const Allocation *alloc = sc->ptrToAllocation(ptr);
366 return (int)alloc;
367}
368
Alex Sakhartchouk8e954662010-09-01 16:34:48 -0700369void SC_allocationMarkDirty(RsAllocation a)
370{
371 Allocation *alloc = static_cast<Allocation *>(a);
372 alloc->sendDirty();
373}
Jason Sams1de0b872010-05-17 14:55:34 -0700374
Jason Sams8f8a5722010-07-15 17:11:13 -0700375void SC_ForEach(RsScript vs,
376 RsAllocation vin,
377 RsAllocation vout,
378 const void *usr)
Jason Samsf17bccc2010-05-28 18:23:22 -0700379{
380 GET_TLS();
Jason Sams8f8a5722010-07-15 17:11:13 -0700381 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsf17bccc2010-05-28 18:23:22 -0700382 Allocation *aout = static_cast<Allocation *>(vout);
Jason Sams8f8a5722010-07-15 17:11:13 -0700383 Script *s = static_cast<Script *>(vs);
384 s->runForEach(rsc, ain, aout, usr);
Jason Samsf17bccc2010-05-28 18:23:22 -0700385}
386
Jason Sams8f8a5722010-07-15 17:11:13 -0700387void SC_ForEach2(RsScript vs,
388 RsAllocation vin,
389 RsAllocation vout,
390 const void *usr,
391 const RsScriptCall *call)
Jason Samsf17bccc2010-05-28 18:23:22 -0700392{
393 GET_TLS();
Jason Sams8f8a5722010-07-15 17:11:13 -0700394 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsf17bccc2010-05-28 18:23:22 -0700395 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsf17bccc2010-05-28 18:23:22 -0700396 Script *s = static_cast<Script *>(vs);
Jason Sams8f8a5722010-07-15 17:11:13 -0700397 s->runForEach(rsc, ain, aout, usr, call);
Jason Samsf17bccc2010-05-28 18:23:22 -0700398}
399
Jason Samsc97bb882009-07-20 14:31:06 -0700400//////////////////////////////////////////////////////////////////////////////
401// Class implementation
402//////////////////////////////////////////////////////////////////////////////
403
Jason Sams4d339932010-05-11 14:03:58 -0700404// llvm name mangling ref
405// <builtin-type> ::= v # void
406// ::= b # bool
407// ::= c # char
408// ::= a # signed char
409// ::= h # unsigned char
410// ::= s # short
411// ::= t # unsigned short
412// ::= i # int
413// ::= j # unsigned int
414// ::= l # long
415// ::= m # unsigned long
416// ::= x # long long, __int64
417// ::= y # unsigned long long, __int64
418// ::= f # float
419// ::= d # double
Jason Samsc97bb882009-07-20 14:31:06 -0700420
Jason Sams536923d2010-05-18 13:35:45 -0700421static ScriptCState::SymbolTable_t gSyms[] = {
Jason Sams4d339932010-05-11 14:03:58 -0700422 { "__divsi3", (void *)&SC_divsi3 },
423
Jason Samsd79b2e92010-05-19 17:22:57 -0700424 // allocation
Jason Sams17966512010-07-28 11:17:53 -0700425 { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX },
426 { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY },
427 { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ },
428 { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD },
429 { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces },
430 { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation },
Jason Samsd79b2e92010-05-19 17:22:57 -0700431
Jason Sams8e6c17f2010-07-19 15:38:19 -0700432 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX },
433 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY },
434 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ },
435
Jason Sams4fd8bb42010-09-17 13:17:17 -0700436 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_setObject },
437 { "_Z13rsClearObjectP10rs_element", (void *)&SC_clearObject },
438 { "_Z10rsIsObject10rs_element", (void *)&SC_isObject },
439
440 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_setObject },
441 { "_Z13rsClearObjectP7rs_type", (void *)&SC_clearObject },
442 { "_Z10rsIsObject7rs_type", (void *)&SC_isObject },
443
444 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_setObject },
Jason Sams02f62aa2010-08-16 12:41:48 -0700445 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_clearObject },
446 { "_Z10rsIsObject13rs_allocation", (void *)&SC_isObject },
447
Jason Sams4fd8bb42010-09-17 13:17:17 -0700448 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_setObject },
449 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_clearObject },
450 { "_Z10rsIsObject10rs_sampler", (void *)&SC_isObject },
451
452 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_setObject },
453 { "_Z13rsClearObjectP9rs_script", (void *)&SC_clearObject },
454 { "_Z10rsIsObject9rs_script", (void *)&SC_isObject },
455
456 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_setObject },
457 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_clearObject },
458 { "_Z10rsIsObject7rs_mesh", (void *)&SC_isObject },
459
460 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_setObject },
461 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_clearObject },
462 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_isObject },
463
464 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_setObject },
465 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_clearObject },
466 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_isObject },
467
468 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_setObject },
469 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_clearObject },
470 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_isObject },
471
472 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_setObject },
473 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_clearObject },
474 { "_Z10rsIsObject16rs_program_store", (void *)&SC_isObject },
475
476 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_setObject },
477 { "_Z13rsClearObjectP7rs_font", (void *)&SC_clearObject },
478 { "_Z10rsIsObject7rs_font", (void *)&SC_isObject },
479
480
Alex Sakhartchouk8e954662010-09-01 16:34:48 -0700481 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_allocationMarkDirty },
482
Jason Sams02f62aa2010-08-16 12:41:48 -0700483
Jason Samsd79b2e92010-05-19 17:22:57 -0700484 // Debug
485 { "_Z7rsDebugPKcf", (void *)&SC_debugF },
Jason Samsd64188a2010-08-06 16:22:50 -0700486 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2 },
487 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3 },
488 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4 },
489 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4 },
490 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3 },
491 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700492 { "_Z7rsDebugPKci", (void *)&SC_debugI32 },
Jason Sams17966512010-07-28 11:17:53 -0700493 { "_Z7rsDebugPKcj", (void *)&SC_debugU32 },
Jason Sams8e6c17f2010-07-19 15:38:19 -0700494 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP },
Jason Samsd79b2e92010-05-19 17:22:57 -0700495
496 // RS Math
497 { "_Z6rsRandi", (void *)&SC_randi },
498 { "_Z6rsRandii", (void *)&SC_randi2 },
499 { "_Z6rsRandf", (void *)&SC_randf },
500 { "_Z6rsRandff", (void *)&SC_randf2 },
501 { "_Z6rsFracf", (void *)&SC_frac },
502
503 // time
Jason Samsf0690c42010-07-29 17:31:14 -0700504 { "_Z8rsSecondv", (void *)&SC_second },
505 { "_Z8rsMinutev", (void *)&SC_minute },
506 { "_Z6rsHourv", (void *)&SC_hour },
507 { "_Z5rsDayv", (void *)&SC_day },
508 { "_Z7rsMonthv", (void *)&SC_month },
509 { "_Z6rsYearv", (void *)&SC_year },
510 { "_Z14rsUptimeMillisv", (void*)&SC_uptimeMillis },
511 { "_Z13rsUptimeNanosv", (void*)&SC_uptimeNanos },
512 { "_Z7rsGetDtv", (void*)&SC_getDt },
Jason Samsd79b2e92010-05-19 17:22:57 -0700513
Jason Sams17966512010-07-28 11:17:53 -0700514 { "_Z14rsSendToClienti", (void *)&SC_toClient },
515 { "_Z14rsSendToClientiPKvj", (void *)&SC_toClient2 },
516 { "_Z22rsSendToClientBlockingi", (void *)&SC_toClientBlocking },
517 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_toClientBlocking2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700518
Jason Sams8f8a5722010-07-15 17:11:13 -0700519 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach },
520 //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700521
522////////////////////////////////////////////////////////////////////
523
Jason Sams4d339932010-05-11 14:03:58 -0700524 //{ "sinf_fast", (void *)&SC_sinf_fast },
525 //{ "cosf_fast", (void *)&SC_cosf_fast },
Jason Samsc97bb882009-07-20 14:31:06 -0700526
Jason Sams4d339932010-05-11 14:03:58 -0700527 { NULL, NULL }
Jason Samsc97bb882009-07-20 14:31:06 -0700528};
529
530const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym)
531{
532 ScriptCState::SymbolTable_t *syms = gSyms;
533
534 while (syms->mPtr) {
535 if (!strcmp(syms->mName, sym)) {
536 return syms;
537 }
538 syms++;
539 }
540 return NULL;
541}
542