blob: c2201bedad5567f82211e06acaaeb56297f2401b [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
93static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
94 GET_TLS();
95 rsrBindSampler(rsc, sc, pf, slot, s);
96}
97
98static void SC_BindProgramStore(ProgramStore *ps) {
99 GET_TLS();
100 rsrBindProgramStore(rsc, sc, ps);
101}
102
103static void SC_BindProgramFragment(ProgramFragment *pf) {
104 GET_TLS();
105 rsrBindProgramFragment(rsc, sc, pf);
106}
107
108static void SC_BindProgramVertex(ProgramVertex *pv) {
109 GET_TLS();
110 rsrBindProgramVertex(rsc, sc, pv);
111}
112
113static void SC_BindProgramRaster(ProgramRaster *pr) {
114 GET_TLS();
115 rsrBindProgramRaster(rsc, sc, pr);
116}
117
118static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
119 GET_TLS();
120 rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot);
121}
122
123static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
124 GET_TLS();
125 rsrBindFrameBufferObjectDepthTarget(rsc, sc, a);
126}
127
128static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
129 GET_TLS();
130 rsrClearFrameBufferObjectColorTarget(rsc, sc, slot);
131}
132
133static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
134 GET_TLS();
135 rsrClearFrameBufferObjectDepthTarget(rsc, sc);
136}
137
138static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
139 GET_TLS();
140 rsrClearFrameBufferObjectTargets(rsc, sc);
141}
142
143
144//////////////////////////////////////////////////////////////////////////////
145// VP
146//////////////////////////////////////////////////////////////////////////////
147
148static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
149 GET_TLS();
150 rsrVpLoadProjectionMatrix(rsc, sc, m);
151}
152
153static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
154 GET_TLS();
155 rsrVpLoadModelMatrix(rsc, sc, m);
156}
157
158static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
159 GET_TLS();
160 rsrVpLoadTextureMatrix(rsc, sc, m);
161}
162
163static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
164 GET_TLS();
165 rsrPfConstantColor(rsc, sc, pf, r, g, b, a);
166}
167
168static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
169 GET_TLS();
170 rsrVpGetProjectionMatrix(rsc, sc, m);
171}
172
173
174//////////////////////////////////////////////////////////////////////////////
175// Drawing
176//////////////////////////////////////////////////////////////////////////////
177
178static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
179 float x2, float y2, float z2, float u2, float v2,
180 float x3, float y3, float z3, float u3, float v3,
181 float x4, float y4, float z4, float u4, float v4) {
182 GET_TLS();
183 rsrDrawQuadTexCoords(rsc, sc,
184 x1, y1, z1, u1, v1,
185 x2, y2, z2, u2, v2,
186 x3, y3, z3, u3, v3,
187 x4, y4, z4, u4, v4);
188}
189
190static void SC_DrawQuad(float x1, float y1, float z1,
191 float x2, float y2, float z2,
192 float x3, float y3, float z3,
193 float x4, float y4, float z4) {
194 GET_TLS();
195 rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
196}
197
198static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
199 GET_TLS();
200 rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h);
201}
202
203static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
204 GET_TLS();
205 rsrDrawRect(rsc, sc, x1, y1, x2, y2, z);
206}
207
Jason Samsf15ed012011-10-31 13:23:43 -0700208static void SC_DrawPath(Path *p) {
209 GET_TLS();
210 //rsrDrawPath(rsc, sc, p);
211 rsdPathDraw(rsc, p);
212}
213
Jason Samsfcf72312011-04-20 15:09:01 -0700214static void SC_DrawMesh(Mesh *m) {
215 GET_TLS();
216 rsrDrawMesh(rsc, sc, m);
217}
218
219static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
220 GET_TLS();
221 rsrDrawMeshPrimitive(rsc, sc, m, primIndex);
222}
223
224static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
225 GET_TLS();
226 rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len);
227}
228
229static void SC_MeshComputeBoundingBox(Mesh *m,
230 float *minX, float *minY, float *minZ,
231 float *maxX, float *maxY, float *maxZ) {
232 GET_TLS();
233 rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ);
234}
235
236
237
238//////////////////////////////////////////////////////////////////////////////
239//
240//////////////////////////////////////////////////////////////////////////////
241
242
243static void SC_Color(float r, float g, float b, float a) {
244 GET_TLS();
245 rsrColor(rsc, sc, r, g, b, a);
246}
247
248static void SC_Finish() {
249 GET_TLS();
250 rsrFinish(rsc, sc);
251}
252
253static void SC_ClearColor(float r, float g, float b, float a) {
254 GET_TLS();
255 rsrClearColor(rsc, sc, r, g, b, a);
256}
257
258static void SC_ClearDepth(float v) {
259 GET_TLS();
260 rsrClearDepth(rsc, sc, v);
261}
262
263static uint32_t SC_GetWidth() {
264 GET_TLS();
265 return rsrGetWidth(rsc, sc);
266}
267
268static uint32_t SC_GetHeight() {
269 GET_TLS();
270 return rsrGetHeight(rsc, sc);
271}
272
273static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
274 GET_TLS();
275 rsrDrawTextAlloc(rsc, sc, a, x, y);
276}
277
278static void SC_DrawText(const char *text, int x, int y) {
279 GET_TLS();
280 rsrDrawText(rsc, sc, text, x, y);
281}
282
283static void SC_MeasureTextAlloc(Allocation *a,
284 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
285 GET_TLS();
286 rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom);
287}
288
289static void SC_MeasureText(const char *text,
290 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
291 GET_TLS();
292 rsrMeasureText(rsc, sc, text, left, right, top, bottom);
293}
294
295static void SC_BindFont(Font *f) {
296 GET_TLS();
297 rsrBindFont(rsc, sc, f);
298}
299
300static void SC_FontColor(float r, float g, float b, float a) {
301 GET_TLS();
302 rsrFontColor(rsc, sc, r, g, b, a);
303}
304
305
306
307//////////////////////////////////////////////////////////////////////////////
308//
309//////////////////////////////////////////////////////////////////////////////
310
311static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
312 GET_TLS();
313 rsrSetObject(rsc, sc, dst, src);
314}
315
316static void SC_ClearObject(ObjectBase **dst) {
317 GET_TLS();
318 rsrClearObject(rsc, sc, dst);
319}
320
321static bool SC_IsObject(const ObjectBase *src) {
322 GET_TLS();
323 return rsrIsObject(rsc, sc, src);
324}
325
326
327
328
329static const Allocation * SC_GetAllocation(const void *ptr) {
330 GET_TLS();
331 return rsrGetAllocation(rsc, sc, ptr);
332}
333
Jason Samscf57dec2011-07-25 12:58:37 -0700334static void SC_ForEach_SAA(Script *target,
335 Allocation *in,
336 Allocation *out) {
337 GET_TLS();
338 rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL);
339}
340
341static void SC_ForEach_SAAU(Script *target,
342 Allocation *in,
343 Allocation *out,
344 const void *usr) {
Jason Samsfcf72312011-04-20 15:09:01 -0700345 GET_TLS();
346 rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
347}
348
Jason Samscf57dec2011-07-25 12:58:37 -0700349static void SC_ForEach_SAAUS(Script *target,
350 Allocation *in,
351 Allocation *out,
352 const void *usr,
353 const RsScriptCall *call) {
Jason Samsfcf72312011-04-20 15:09:01 -0700354 GET_TLS();
355 rsrForEach(rsc, sc, target, in, out, usr, 0, call);
356}
357
Jason Samscf57dec2011-07-25 12:58:37 -0700358static void SC_ForEach_SAAUL(Script *target,
359 Allocation *in,
360 Allocation *out,
361 const void *usr,
362 uint32_t usrLen) {
363 GET_TLS();
364 rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL);
365}
366
367static void SC_ForEach_SAAULS(Script *target,
368 Allocation *in,
369 Allocation *out,
370 const void *usr,
371 uint32_t usrLen,
372 const RsScriptCall *call) {
373 GET_TLS();
374 rsrForEach(rsc, sc, target, in, out, usr, usrLen, call);
375}
376
Jason Samsfcf72312011-04-20 15:09:01 -0700377
378
379//////////////////////////////////////////////////////////////////////////////
380// Time routines
381//////////////////////////////////////////////////////////////////////////////
382
383static float SC_GetDt() {
384 GET_TLS();
385 return rsrGetDt(rsc, sc);
386}
387
388time_t SC_Time(time_t *timer) {
389 GET_TLS();
390 return rsrTime(rsc, sc, timer);
391}
392
393tm* SC_LocalTime(tm *local, time_t *timer) {
394 GET_TLS();
395 return rsrLocalTime(rsc, sc, local, timer);
396}
397
398int64_t SC_UptimeMillis() {
399 GET_TLS();
400 return rsrUptimeMillis(rsc, sc);
401}
402
403int64_t SC_UptimeNanos() {
404 GET_TLS();
405 return rsrUptimeNanos(rsc, sc);
406}
407
408//////////////////////////////////////////////////////////////////////////////
409// Message routines
410//////////////////////////////////////////////////////////////////////////////
411
412static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
413 GET_TLS();
414 return rsrToClient(rsc, sc, cmdID, data, len);
415}
416
417static uint32_t SC_ToClient(int cmdID) {
418 GET_TLS();
419 return rsrToClient(rsc, sc, cmdID, NULL, 0);
420}
421
422static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
423 GET_TLS();
424 return rsrToClientBlocking(rsc, sc, cmdID, data, len);
425}
426
427static uint32_t SC_ToClientBlocking(int cmdID) {
428 GET_TLS();
429 return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
430}
431
432int SC_divsi3(int a, int b) {
433 return a / b;
434}
435
436int SC_modsi3(int a, int b) {
437 return a % b;
438}
439
440unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
441 return a / b;
442}
443
444unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
445 return a % b;
446}
447
448static void SC_debugF(const char *s, float f) {
449 LOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
450}
451static void SC_debugFv2(const char *s, float f1, float f2) {
452 LOGD("%s {%f, %f}", s, f1, f2);
453}
454static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
455 LOGD("%s {%f, %f, %f}", s, f1, f2, f3);
456}
457static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
458 LOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
459}
460static void SC_debugD(const char *s, double d) {
461 LOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
462}
463static void SC_debugFM4v4(const char *s, const float *f) {
464 LOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
465 LOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
466 LOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
467 LOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
468}
469static void SC_debugFM3v3(const char *s, const float *f) {
470 LOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
471 LOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
472 LOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
473}
474static void SC_debugFM2v2(const char *s, const float *f) {
475 LOGD("%s {%f, %f", s, f[0], f[2]);
476 LOGD("%s %f, %f}",s, f[1], f[3]);
477}
478
479static void SC_debugI32(const char *s, int32_t i) {
480 LOGD("%s %i 0x%x", s, i, i);
481}
482static void SC_debugU32(const char *s, uint32_t i) {
483 LOGD("%s %u 0x%x", s, i, i);
484}
485static void SC_debugLL64(const char *s, long long ll) {
486 LOGD("%s %lld 0x%llx", s, ll, ll);
487}
488static void SC_debugULL64(const char *s, unsigned long long ll) {
489 LOGD("%s %llu 0x%llx", s, ll, ll);
490}
491
492static void SC_debugP(const char *s, const void *p) {
493 LOGD("%s %p", s, p);
494}
495
496
497//////////////////////////////////////////////////////////////////////////////
498// Stub implementation
499//////////////////////////////////////////////////////////////////////////////
500
501// llvm name mangling ref
502// <builtin-type> ::= v # void
503// ::= b # bool
504// ::= c # char
505// ::= a # signed char
506// ::= h # unsigned char
507// ::= s # short
508// ::= t # unsigned short
509// ::= i # int
510// ::= j # unsigned int
511// ::= l # long
512// ::= m # unsigned long
513// ::= x # long long, __int64
514// ::= y # unsigned long long, __int64
515// ::= f # float
516// ::= d # double
517
518static RsdSymbolTable gSyms[] = {
Jason Samsfcf72312011-04-20 15:09:01 -0700519 { "memset", (void *)&memset, true },
520 { "memcpy", (void *)&memcpy, true },
521
522 // Refcounting
523 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
524 { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
525 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
526
527 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
528 { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
529 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
530
531 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
532 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
533 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
534
535 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
536 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
537 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
538
539 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
540 { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
541 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
542
Jason Samsf15ed012011-10-31 13:23:43 -0700543 { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
544 { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
545 { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
546
Jason Samsfcf72312011-04-20 15:09:01 -0700547 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
548 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
549 { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
550
551 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
552 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
553 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
554
555 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
556 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
557 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
558
559 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
560 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
561 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
562
563 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
564 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
565 { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
566
567 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
568 { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
569 { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
570
571 // Allocation ops
Jason Samsfcf72312011-04-20 15:09:01 -0700572 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
573 { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
574 { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700575 { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700576 { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
577
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700578 { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
579 { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700580
581 // Messaging
582
583 { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
584 { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
585 { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
586 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
587
588 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
589 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
590 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
591 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
592 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
593 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
594
595 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
596 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
597 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
598
599 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
600
601 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
602
603 { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
604 { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
605
606
607 { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
608 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
609 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
610 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
611
612 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
613 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
614 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
615 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
616
Jason Samsf15ed012011-10-31 13:23:43 -0700617 { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
618
Jason Samsfcf72312011-04-20 15:09:01 -0700619 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
620 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
621
622 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
623 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
624 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
625 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
626
627 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
628 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
629
630 { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
631 { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
632 { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
633 { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
634 { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
635
Jason Samscf57dec2011-07-25 12:58:37 -0700636 { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, false },
637 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, false },
638 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK16rs_script_call_t", (void *)&SC_ForEach_SAAUS, false },
639 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, false },
640 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK16rs_script_call_t", (void *)&SC_ForEach_SAAULS, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700641
642 // time
643 { "_Z6rsTimePi", (void *)&SC_Time, true },
644 { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
645 { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
646 { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
647 { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
648
649 // misc
650 { "_Z5colorffff", (void *)&SC_Color, false },
651 { "_Z9rsgFinishv", (void *)&SC_Finish, false },
652
653 // Debug
654 { "_Z7rsDebugPKcf", (void *)&SC_debugF, true },
655 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true },
656 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true },
657 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true },
658 { "_Z7rsDebugPKcd", (void *)&SC_debugD, true },
659 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true },
660 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true },
661 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true },
662 { "_Z7rsDebugPKci", (void *)&SC_debugI32, true },
663 { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true },
664 // Both "long" and "unsigned long" need to be redirected to their
665 // 64-bit counterparts, since we have hacked Slang to use 64-bit
666 // for "long" on Arm (to be similar to Java).
667 { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true },
668 { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true },
669 { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true },
670 { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true },
671 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
672
673 { NULL, NULL, false }
674};
675
676
677void* rsdLookupRuntimeStub(void* pContext, char const* name) {
678 ScriptC *s = (ScriptC *)pContext;
679 if (!strcmp(name, "__isThreadable")) {
680 return (void*) s->mHal.info.isThreadable;
681 } else if (!strcmp(name, "__clearThreadable")) {
682 s->mHal.info.isThreadable = false;
683 return NULL;
684 }
685
686 RsdSymbolTable *syms = gSyms;
687 const RsdSymbolTable *sym = rsdLookupSymbolMath(name);
688
689 if (!sym) {
690 while (syms->mPtr) {
691 if (!strcmp(syms->mName, name)) {
692 sym = syms;
693 }
694 syms++;
695 }
696 }
697
698 if (sym) {
699 s->mHal.info.isThreadable &= sym->threadable;
700 return sym->mPtr;
701 }
702 LOGE("ScriptC sym lookup failed for %s", name);
703 return NULL;
704}
705
706