blob: 38bd48fbaa9ed0f2bac3b42b84a1e74c73b0e5ba [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
17#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix4x4.h"
20#include "rsMatrix3x3.h"
21#include "rsMatrix2x2.h"
22#include "rsRuntime.h"
23
24#include "utils/Timers.h"
25#include "rsdCore.h"
26
27#include "rsdRuntime.h"
Jason Samsf15ed012011-10-31 13:23:43 -070028#include "rsdPath.h"
Jason Samsfcf72312011-04-20 15:09:01 -070029
30#include <time.h>
31
32using namespace android;
33using namespace android::renderscript;
34
35#define GET_TLS() ScriptTLSStruct * tls = \
Jason Samsbe8ac6a2011-04-21 11:46:50 -070036 (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
Jason Samsfcf72312011-04-20 15:09:01 -070037 Context * rsc = tls->mContext; \
38 ScriptC * sc = (ScriptC *) tls->mScript
39
40
41
42//////////////////////////////////////////////////////////////////////////////
43// Allocation
44//////////////////////////////////////////////////////////////////////////////
45
Jason Samsfcf72312011-04-20 15:09:01 -070046
47static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
48 GET_TLS();
49 rsrAllocationSyncAll(rsc, sc, a, source);
50}
51
52static void SC_AllocationSyncAll(Allocation *a) {
53 GET_TLS();
54 rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT);
55}
56
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -070057static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
58 uint32_t dstOff,
59 uint32_t dstMip,
60 uint32_t count,
61 Allocation *srcAlloc,
62 uint32_t srcOff, uint32_t srcMip) {
63 GET_TLS();
Alex Sakhartchouk8650c322011-06-16 11:05:13 -070064 rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
65 srcAlloc, srcOff, srcMip);
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -070066}
67
68static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
69 uint32_t dstXoff, uint32_t dstYoff,
70 uint32_t dstMip, uint32_t dstFace,
71 uint32_t width, uint32_t height,
72 Allocation *srcAlloc,
73 uint32_t srcXoff, uint32_t srcYoff,
74 uint32_t srcMip, uint32_t srcFace) {
75 GET_TLS();
Alex Sakhartchouk8650c322011-06-16 11:05:13 -070076 rsrAllocationCopy2DRange(rsc, dstAlloc,
77 dstXoff, dstYoff, dstMip, dstFace,
78 width, height,
79 srcAlloc,
80 srcXoff, srcYoff, srcMip, srcFace);
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -070081}
82
83
Jason Samsfcf72312011-04-20 15:09:01 -070084//////////////////////////////////////////////////////////////////////////////
85// Context
86//////////////////////////////////////////////////////////////////////////////
87
88static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
89 GET_TLS();
90 rsrBindTexture(rsc, sc, pf, slot, a);
91}
92
Alex Sakhartchouk33680ff2012-01-10 10:16:52 -080093static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
94 GET_TLS();
95 rsrBindConstant(rsc, sc, pv, slot, a);
96}
97
98static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
99 GET_TLS();
100 rsrBindConstant(rsc, sc, pf, slot, a);
101}
102
Jason Samsfcf72312011-04-20 15:09:01 -0700103static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
104 GET_TLS();
105 rsrBindSampler(rsc, sc, pf, slot, s);
106}
107
108static void SC_BindProgramStore(ProgramStore *ps) {
109 GET_TLS();
110 rsrBindProgramStore(rsc, sc, ps);
111}
112
113static void SC_BindProgramFragment(ProgramFragment *pf) {
114 GET_TLS();
115 rsrBindProgramFragment(rsc, sc, pf);
116}
117
118static void SC_BindProgramVertex(ProgramVertex *pv) {
119 GET_TLS();
120 rsrBindProgramVertex(rsc, sc, pv);
121}
122
123static void SC_BindProgramRaster(ProgramRaster *pr) {
124 GET_TLS();
125 rsrBindProgramRaster(rsc, sc, pr);
126}
127
128static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
129 GET_TLS();
130 rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot);
131}
132
133static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
134 GET_TLS();
135 rsrBindFrameBufferObjectDepthTarget(rsc, sc, a);
136}
137
138static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
139 GET_TLS();
140 rsrClearFrameBufferObjectColorTarget(rsc, sc, slot);
141}
142
143static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
144 GET_TLS();
145 rsrClearFrameBufferObjectDepthTarget(rsc, sc);
146}
147
148static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
149 GET_TLS();
150 rsrClearFrameBufferObjectTargets(rsc, sc);
151}
152
153
154//////////////////////////////////////////////////////////////////////////////
155// VP
156//////////////////////////////////////////////////////////////////////////////
157
158static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
159 GET_TLS();
160 rsrVpLoadProjectionMatrix(rsc, sc, m);
161}
162
163static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
164 GET_TLS();
165 rsrVpLoadModelMatrix(rsc, sc, m);
166}
167
168static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
169 GET_TLS();
170 rsrVpLoadTextureMatrix(rsc, sc, m);
171}
172
173static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
174 GET_TLS();
175 rsrPfConstantColor(rsc, sc, pf, r, g, b, a);
176}
177
178static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
179 GET_TLS();
180 rsrVpGetProjectionMatrix(rsc, sc, m);
181}
182
183
184//////////////////////////////////////////////////////////////////////////////
185// Drawing
186//////////////////////////////////////////////////////////////////////////////
187
188static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
189 float x2, float y2, float z2, float u2, float v2,
190 float x3, float y3, float z3, float u3, float v3,
191 float x4, float y4, float z4, float u4, float v4) {
192 GET_TLS();
193 rsrDrawQuadTexCoords(rsc, sc,
194 x1, y1, z1, u1, v1,
195 x2, y2, z2, u2, v2,
196 x3, y3, z3, u3, v3,
197 x4, y4, z4, u4, v4);
198}
199
200static void SC_DrawQuad(float x1, float y1, float z1,
201 float x2, float y2, float z2,
202 float x3, float y3, float z3,
203 float x4, float y4, float z4) {
204 GET_TLS();
205 rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
206}
207
208static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
209 GET_TLS();
210 rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h);
211}
212
213static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
214 GET_TLS();
215 rsrDrawRect(rsc, sc, x1, y1, x2, y2, z);
216}
217
Jason Samsf15ed012011-10-31 13:23:43 -0700218static void SC_DrawPath(Path *p) {
219 GET_TLS();
220 //rsrDrawPath(rsc, sc, p);
221 rsdPathDraw(rsc, p);
222}
223
Jason Samsfcf72312011-04-20 15:09:01 -0700224static void SC_DrawMesh(Mesh *m) {
225 GET_TLS();
226 rsrDrawMesh(rsc, sc, m);
227}
228
229static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
230 GET_TLS();
231 rsrDrawMeshPrimitive(rsc, sc, m, primIndex);
232}
233
234static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
235 GET_TLS();
236 rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len);
237}
238
239static void SC_MeshComputeBoundingBox(Mesh *m,
240 float *minX, float *minY, float *minZ,
241 float *maxX, float *maxY, float *maxZ) {
242 GET_TLS();
243 rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ);
244}
245
246
247
248//////////////////////////////////////////////////////////////////////////////
249//
250//////////////////////////////////////////////////////////////////////////////
251
252
253static void SC_Color(float r, float g, float b, float a) {
254 GET_TLS();
255 rsrColor(rsc, sc, r, g, b, a);
256}
257
258static void SC_Finish() {
259 GET_TLS();
260 rsrFinish(rsc, sc);
261}
262
263static void SC_ClearColor(float r, float g, float b, float a) {
264 GET_TLS();
265 rsrClearColor(rsc, sc, r, g, b, a);
266}
267
268static void SC_ClearDepth(float v) {
269 GET_TLS();
270 rsrClearDepth(rsc, sc, v);
271}
272
273static uint32_t SC_GetWidth() {
274 GET_TLS();
275 return rsrGetWidth(rsc, sc);
276}
277
278static uint32_t SC_GetHeight() {
279 GET_TLS();
280 return rsrGetHeight(rsc, sc);
281}
282
283static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
284 GET_TLS();
285 rsrDrawTextAlloc(rsc, sc, a, x, y);
286}
287
288static void SC_DrawText(const char *text, int x, int y) {
289 GET_TLS();
290 rsrDrawText(rsc, sc, text, x, y);
291}
292
293static void SC_MeasureTextAlloc(Allocation *a,
294 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
295 GET_TLS();
296 rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom);
297}
298
299static void SC_MeasureText(const char *text,
300 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
301 GET_TLS();
302 rsrMeasureText(rsc, sc, text, left, right, top, bottom);
303}
304
305static void SC_BindFont(Font *f) {
306 GET_TLS();
307 rsrBindFont(rsc, sc, f);
308}
309
310static void SC_FontColor(float r, float g, float b, float a) {
311 GET_TLS();
312 rsrFontColor(rsc, sc, r, g, b, a);
313}
314
315
316
317//////////////////////////////////////////////////////////////////////////////
318//
319//////////////////////////////////////////////////////////////////////////////
320
321static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
322 GET_TLS();
323 rsrSetObject(rsc, sc, dst, src);
324}
325
326static void SC_ClearObject(ObjectBase **dst) {
327 GET_TLS();
328 rsrClearObject(rsc, sc, dst);
329}
330
331static bool SC_IsObject(const ObjectBase *src) {
332 GET_TLS();
333 return rsrIsObject(rsc, sc, src);
334}
335
336
337
338
339static const Allocation * SC_GetAllocation(const void *ptr) {
340 GET_TLS();
341 return rsrGetAllocation(rsc, sc, ptr);
342}
343
Jason Samscf57dec2011-07-25 12:58:37 -0700344static void SC_ForEach_SAA(Script *target,
345 Allocation *in,
346 Allocation *out) {
347 GET_TLS();
348 rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL);
349}
350
351static void SC_ForEach_SAAU(Script *target,
352 Allocation *in,
353 Allocation *out,
354 const void *usr) {
Jason Samsfcf72312011-04-20 15:09:01 -0700355 GET_TLS();
356 rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
357}
358
Jason Samscf57dec2011-07-25 12:58:37 -0700359static void SC_ForEach_SAAUS(Script *target,
360 Allocation *in,
361 Allocation *out,
362 const void *usr,
363 const RsScriptCall *call) {
Jason Samsfcf72312011-04-20 15:09:01 -0700364 GET_TLS();
365 rsrForEach(rsc, sc, target, in, out, usr, 0, call);
366}
367
Jason Samscf57dec2011-07-25 12:58:37 -0700368static void SC_ForEach_SAAUL(Script *target,
369 Allocation *in,
370 Allocation *out,
371 const void *usr,
372 uint32_t usrLen) {
373 GET_TLS();
374 rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL);
375}
376
377static void SC_ForEach_SAAULS(Script *target,
378 Allocation *in,
379 Allocation *out,
380 const void *usr,
381 uint32_t usrLen,
382 const RsScriptCall *call) {
383 GET_TLS();
384 rsrForEach(rsc, sc, target, in, out, usr, usrLen, call);
385}
386
Jason Samsfcf72312011-04-20 15:09:01 -0700387
388
389//////////////////////////////////////////////////////////////////////////////
390// Time routines
391//////////////////////////////////////////////////////////////////////////////
392
393static float SC_GetDt() {
394 GET_TLS();
395 return rsrGetDt(rsc, sc);
396}
397
398time_t SC_Time(time_t *timer) {
399 GET_TLS();
400 return rsrTime(rsc, sc, timer);
401}
402
403tm* SC_LocalTime(tm *local, time_t *timer) {
404 GET_TLS();
405 return rsrLocalTime(rsc, sc, local, timer);
406}
407
408int64_t SC_UptimeMillis() {
409 GET_TLS();
410 return rsrUptimeMillis(rsc, sc);
411}
412
413int64_t SC_UptimeNanos() {
414 GET_TLS();
415 return rsrUptimeNanos(rsc, sc);
416}
417
418//////////////////////////////////////////////////////////////////////////////
419// Message routines
420//////////////////////////////////////////////////////////////////////////////
421
422static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
423 GET_TLS();
424 return rsrToClient(rsc, sc, cmdID, data, len);
425}
426
427static uint32_t SC_ToClient(int cmdID) {
428 GET_TLS();
429 return rsrToClient(rsc, sc, cmdID, NULL, 0);
430}
431
432static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
433 GET_TLS();
434 return rsrToClientBlocking(rsc, sc, cmdID, data, len);
435}
436
437static uint32_t SC_ToClientBlocking(int cmdID) {
438 GET_TLS();
439 return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
440}
441
442int SC_divsi3(int a, int b) {
443 return a / b;
444}
445
446int SC_modsi3(int a, int b) {
447 return a % b;
448}
449
450unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
451 return a / b;
452}
453
454unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
455 return a % b;
456}
457
458static void SC_debugF(const char *s, float f) {
Steve Block5baa3a62011-12-20 16:23:08 +0000459 ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
Jason Samsfcf72312011-04-20 15:09:01 -0700460}
461static void SC_debugFv2(const char *s, float f1, float f2) {
Steve Block5baa3a62011-12-20 16:23:08 +0000462 ALOGD("%s {%f, %f}", s, f1, f2);
Jason Samsfcf72312011-04-20 15:09:01 -0700463}
464static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
Steve Block5baa3a62011-12-20 16:23:08 +0000465 ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
Jason Samsfcf72312011-04-20 15:09:01 -0700466}
467static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
Steve Block5baa3a62011-12-20 16:23:08 +0000468 ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
Jason Samsfcf72312011-04-20 15:09:01 -0700469}
470static void SC_debugD(const char *s, double d) {
Steve Block5baa3a62011-12-20 16:23:08 +0000471 ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
Jason Samsfcf72312011-04-20 15:09:01 -0700472}
473static void SC_debugFM4v4(const char *s, const float *f) {
Steve Block5baa3a62011-12-20 16:23:08 +0000474 ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
475 ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
476 ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
477 ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
Jason Samsfcf72312011-04-20 15:09:01 -0700478}
479static void SC_debugFM3v3(const char *s, const float *f) {
Steve Block5baa3a62011-12-20 16:23:08 +0000480 ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
481 ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
482 ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
Jason Samsfcf72312011-04-20 15:09:01 -0700483}
484static void SC_debugFM2v2(const char *s, const float *f) {
Steve Block5baa3a62011-12-20 16:23:08 +0000485 ALOGD("%s {%f, %f", s, f[0], f[2]);
486 ALOGD("%s %f, %f}",s, f[1], f[3]);
Jason Samsfcf72312011-04-20 15:09:01 -0700487}
488
489static void SC_debugI32(const char *s, int32_t i) {
Steve Block5baa3a62011-12-20 16:23:08 +0000490 ALOGD("%s %i 0x%x", s, i, i);
Jason Samsfcf72312011-04-20 15:09:01 -0700491}
492static void SC_debugU32(const char *s, uint32_t i) {
Steve Block5baa3a62011-12-20 16:23:08 +0000493 ALOGD("%s %u 0x%x", s, i, i);
Jason Samsfcf72312011-04-20 15:09:01 -0700494}
495static void SC_debugLL64(const char *s, long long ll) {
Steve Block5baa3a62011-12-20 16:23:08 +0000496 ALOGD("%s %lld 0x%llx", s, ll, ll);
Jason Samsfcf72312011-04-20 15:09:01 -0700497}
498static void SC_debugULL64(const char *s, unsigned long long ll) {
Steve Block5baa3a62011-12-20 16:23:08 +0000499 ALOGD("%s %llu 0x%llx", s, ll, ll);
Jason Samsfcf72312011-04-20 15:09:01 -0700500}
501
502static void SC_debugP(const char *s, const void *p) {
Steve Block5baa3a62011-12-20 16:23:08 +0000503 ALOGD("%s %p", s, p);
Jason Samsfcf72312011-04-20 15:09:01 -0700504}
505
506
507//////////////////////////////////////////////////////////////////////////////
508// Stub implementation
509//////////////////////////////////////////////////////////////////////////////
510
511// llvm name mangling ref
512// <builtin-type> ::= v # void
513// ::= b # bool
514// ::= c # char
515// ::= a # signed char
516// ::= h # unsigned char
517// ::= s # short
518// ::= t # unsigned short
519// ::= i # int
520// ::= j # unsigned int
521// ::= l # long
522// ::= m # unsigned long
523// ::= x # long long, __int64
524// ::= y # unsigned long long, __int64
525// ::= f # float
526// ::= d # double
527
528static RsdSymbolTable gSyms[] = {
Jason Samsfcf72312011-04-20 15:09:01 -0700529 { "memset", (void *)&memset, true },
530 { "memcpy", (void *)&memcpy, true },
531
532 // Refcounting
533 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
534 { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
535 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
536
537 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
538 { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
539 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
540
541 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
542 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
543 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
544
545 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
546 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
547 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
548
549 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
550 { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
551 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
552
Jason Samsf15ed012011-10-31 13:23:43 -0700553 { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
554 { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
555 { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
556
Jason Samsfcf72312011-04-20 15:09:01 -0700557 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
558 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
559 { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
560
561 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
562 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
563 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
564
565 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
566 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
567 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
568
569 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
570 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
571 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
572
573 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
574 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
575 { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
576
577 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
578 { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
579 { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
580
581 // Allocation ops
Jason Samsfcf72312011-04-20 15:09:01 -0700582 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
583 { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
584 { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700585 { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700586 { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
587
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700588 { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
589 { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700590
591 // Messaging
592
593 { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
594 { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
595 { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
596 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
597
598 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
599 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
600 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
601 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
602 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
603 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
Alex Sakhartchouk33680ff2012-01-10 10:16:52 -0800604 { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
605 { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700606
607 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
608 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
609 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
610
611 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
612
613 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
614
615 { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
616 { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
617
618
619 { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
620 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
621 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
622 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
623
624 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
625 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
626 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
627 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
628
Jason Samsf15ed012011-10-31 13:23:43 -0700629 { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
630
Jason Samsfcf72312011-04-20 15:09:01 -0700631 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
632 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
633
634 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
635 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
636 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
637 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
638
639 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
640 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
641
642 { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
643 { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
644 { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
645 { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
646 { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
647
Jason Samscf57dec2011-07-25 12:58:37 -0700648 { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, false },
649 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, false },
650 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK16rs_script_call_t", (void *)&SC_ForEach_SAAUS, false },
651 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, false },
652 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK16rs_script_call_t", (void *)&SC_ForEach_SAAULS, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700653
654 // time
655 { "_Z6rsTimePi", (void *)&SC_Time, true },
656 { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
657 { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
658 { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
659 { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
660
661 // misc
662 { "_Z5colorffff", (void *)&SC_Color, false },
663 { "_Z9rsgFinishv", (void *)&SC_Finish, false },
664
665 // Debug
666 { "_Z7rsDebugPKcf", (void *)&SC_debugF, true },
667 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true },
668 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true },
669 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true },
670 { "_Z7rsDebugPKcd", (void *)&SC_debugD, true },
671 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true },
672 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true },
673 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true },
674 { "_Z7rsDebugPKci", (void *)&SC_debugI32, true },
675 { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true },
676 // Both "long" and "unsigned long" need to be redirected to their
677 // 64-bit counterparts, since we have hacked Slang to use 64-bit
678 // for "long" on Arm (to be similar to Java).
679 { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true },
680 { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true },
681 { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true },
682 { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true },
683 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
684
685 { NULL, NULL, false }
686};
687
688
689void* rsdLookupRuntimeStub(void* pContext, char const* name) {
690 ScriptC *s = (ScriptC *)pContext;
691 if (!strcmp(name, "__isThreadable")) {
692 return (void*) s->mHal.info.isThreadable;
693 } else if (!strcmp(name, "__clearThreadable")) {
694 s->mHal.info.isThreadable = false;
695 return NULL;
696 }
697
698 RsdSymbolTable *syms = gSyms;
699 const RsdSymbolTable *sym = rsdLookupSymbolMath(name);
700
701 if (!sym) {
702 while (syms->mPtr) {
703 if (!strcmp(syms->mName, name)) {
704 sym = syms;
705 }
706 syms++;
707 }
708 }
709
710 if (sym) {
711 s->mHal.info.isThreadable &= sym->threadable;
712 return sym->mPtr;
713 }
714 LOGE("ScriptC sym lookup failed for %s", name);
715 return NULL;
716}
717
718