blob: 2f9f410f9b9c7d366d5664893fde324137f1480c [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"
28
29#include <time.h>
30
31using namespace android;
32using namespace android::renderscript;
33
34#define GET_TLS() ScriptTLSStruct * tls = \
Jason Samsbe8ac6a2011-04-21 11:46:50 -070035 (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
Jason Samsfcf72312011-04-20 15:09:01 -070036 Context * rsc = tls->mContext; \
37 ScriptC * sc = (ScriptC *) tls->mScript
38
39
40
41//////////////////////////////////////////////////////////////////////////////
42// Allocation
43//////////////////////////////////////////////////////////////////////////////
44
45static uint32_t SC_allocGetDimX(Allocation *a) {
Jason Samsfcf72312011-04-20 15:09:01 -070046 return a->mHal.state.dimensionX;
47}
48
49static uint32_t SC_allocGetDimY(Allocation *a) {
50 return a->mHal.state.dimensionY;
51}
52
53static uint32_t SC_allocGetDimZ(Allocation *a) {
54 return a->mHal.state.dimensionZ;
55}
56
57static uint32_t SC_allocGetDimLOD(Allocation *a) {
58 return a->mHal.state.hasMipmaps;
59}
60
61static uint32_t SC_allocGetDimFaces(Allocation *a) {
62 return a->mHal.state.hasFaces;
63}
64
65static const void * SC_getElementAtX(Allocation *a, uint32_t x) {
66 const uint8_t *p = (const uint8_t *)a->getPtr();
67 return &p[a->mHal.state.elementSizeBytes * x];
68}
69
70static const void * SC_getElementAtXY(Allocation *a, uint32_t x, uint32_t y) {
71 const uint8_t *p = (const uint8_t *)a->getPtr();
72 return &p[a->mHal.state.elementSizeBytes * (x + y * a->mHal.state.dimensionX)];
73}
74
75static const void * SC_getElementAtXYZ(Allocation *a, uint32_t x, uint32_t y, uint32_t z) {
76 const uint8_t *p = (const uint8_t *)a->getPtr();
77 return &p[a->mHal.state.elementSizeBytes * (x + y * a->mHal.state.dimensionX +
78 z * a->mHal.state.dimensionX * a->mHal.state.dimensionY)];
79}
80
81static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
82 GET_TLS();
83 rsrAllocationSyncAll(rsc, sc, a, source);
84}
85
86static void SC_AllocationSyncAll(Allocation *a) {
87 GET_TLS();
88 rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT);
89}
90
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -070091static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
92 uint32_t dstOff,
93 uint32_t dstMip,
94 uint32_t count,
95 Allocation *srcAlloc,
96 uint32_t srcOff, uint32_t srcMip) {
97 GET_TLS();
Alex Sakhartchouk8650c322011-06-16 11:05:13 -070098 rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
99 srcAlloc, srcOff, srcMip);
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700100}
101
102static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
103 uint32_t dstXoff, uint32_t dstYoff,
104 uint32_t dstMip, uint32_t dstFace,
105 uint32_t width, uint32_t height,
106 Allocation *srcAlloc,
107 uint32_t srcXoff, uint32_t srcYoff,
108 uint32_t srcMip, uint32_t srcFace) {
109 GET_TLS();
Alex Sakhartchouk8650c322011-06-16 11:05:13 -0700110 rsrAllocationCopy2DRange(rsc, dstAlloc,
111 dstXoff, dstYoff, dstMip, dstFace,
112 width, height,
113 srcAlloc,
114 srcXoff, srcYoff, srcMip, srcFace);
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700115}
116
117
Jason Samsfcf72312011-04-20 15:09:01 -0700118const Allocation * SC_getAllocation(const void *ptr) {
119 GET_TLS();
120 return rsrGetAllocation(rsc, sc, ptr);
121}
122
123
124//////////////////////////////////////////////////////////////////////////////
125// Context
126//////////////////////////////////////////////////////////////////////////////
127
128static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
129 GET_TLS();
130 rsrBindTexture(rsc, sc, pf, slot, a);
131}
132
133static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
134 GET_TLS();
135 rsrBindSampler(rsc, sc, pf, slot, s);
136}
137
138static void SC_BindProgramStore(ProgramStore *ps) {
139 GET_TLS();
140 rsrBindProgramStore(rsc, sc, ps);
141}
142
143static void SC_BindProgramFragment(ProgramFragment *pf) {
144 GET_TLS();
145 rsrBindProgramFragment(rsc, sc, pf);
146}
147
148static void SC_BindProgramVertex(ProgramVertex *pv) {
149 GET_TLS();
150 rsrBindProgramVertex(rsc, sc, pv);
151}
152
153static void SC_BindProgramRaster(ProgramRaster *pr) {
154 GET_TLS();
155 rsrBindProgramRaster(rsc, sc, pr);
156}
157
158static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
159 GET_TLS();
160 rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot);
161}
162
163static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
164 GET_TLS();
165 rsrBindFrameBufferObjectDepthTarget(rsc, sc, a);
166}
167
168static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
169 GET_TLS();
170 rsrClearFrameBufferObjectColorTarget(rsc, sc, slot);
171}
172
173static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
174 GET_TLS();
175 rsrClearFrameBufferObjectDepthTarget(rsc, sc);
176}
177
178static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
179 GET_TLS();
180 rsrClearFrameBufferObjectTargets(rsc, sc);
181}
182
183
184//////////////////////////////////////////////////////////////////////////////
185// VP
186//////////////////////////////////////////////////////////////////////////////
187
188static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
189 GET_TLS();
190 rsrVpLoadProjectionMatrix(rsc, sc, m);
191}
192
193static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
194 GET_TLS();
195 rsrVpLoadModelMatrix(rsc, sc, m);
196}
197
198static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
199 GET_TLS();
200 rsrVpLoadTextureMatrix(rsc, sc, m);
201}
202
203static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
204 GET_TLS();
205 rsrPfConstantColor(rsc, sc, pf, r, g, b, a);
206}
207
208static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
209 GET_TLS();
210 rsrVpGetProjectionMatrix(rsc, sc, m);
211}
212
213
214//////////////////////////////////////////////////////////////////////////////
215// Drawing
216//////////////////////////////////////////////////////////////////////////////
217
218static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
219 float x2, float y2, float z2, float u2, float v2,
220 float x3, float y3, float z3, float u3, float v3,
221 float x4, float y4, float z4, float u4, float v4) {
222 GET_TLS();
223 rsrDrawQuadTexCoords(rsc, sc,
224 x1, y1, z1, u1, v1,
225 x2, y2, z2, u2, v2,
226 x3, y3, z3, u3, v3,
227 x4, y4, z4, u4, v4);
228}
229
230static void SC_DrawQuad(float x1, float y1, float z1,
231 float x2, float y2, float z2,
232 float x3, float y3, float z3,
233 float x4, float y4, float z4) {
234 GET_TLS();
235 rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
236}
237
238static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
239 GET_TLS();
240 rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h);
241}
242
243static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
244 GET_TLS();
245 rsrDrawRect(rsc, sc, x1, y1, x2, y2, z);
246}
247
248static void SC_DrawMesh(Mesh *m) {
249 GET_TLS();
250 rsrDrawMesh(rsc, sc, m);
251}
252
253static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
254 GET_TLS();
255 rsrDrawMeshPrimitive(rsc, sc, m, primIndex);
256}
257
258static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
259 GET_TLS();
260 rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len);
261}
262
263static void SC_MeshComputeBoundingBox(Mesh *m,
264 float *minX, float *minY, float *minZ,
265 float *maxX, float *maxY, float *maxZ) {
266 GET_TLS();
267 rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ);
268}
269
270
271
272//////////////////////////////////////////////////////////////////////////////
273//
274//////////////////////////////////////////////////////////////////////////////
275
276
277static void SC_Color(float r, float g, float b, float a) {
278 GET_TLS();
279 rsrColor(rsc, sc, r, g, b, a);
280}
281
282static void SC_Finish() {
283 GET_TLS();
284 rsrFinish(rsc, sc);
285}
286
287static void SC_ClearColor(float r, float g, float b, float a) {
288 GET_TLS();
289 rsrClearColor(rsc, sc, r, g, b, a);
290}
291
292static void SC_ClearDepth(float v) {
293 GET_TLS();
294 rsrClearDepth(rsc, sc, v);
295}
296
297static uint32_t SC_GetWidth() {
298 GET_TLS();
299 return rsrGetWidth(rsc, sc);
300}
301
302static uint32_t SC_GetHeight() {
303 GET_TLS();
304 return rsrGetHeight(rsc, sc);
305}
306
307static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
308 GET_TLS();
309 rsrDrawTextAlloc(rsc, sc, a, x, y);
310}
311
312static void SC_DrawText(const char *text, int x, int y) {
313 GET_TLS();
314 rsrDrawText(rsc, sc, text, x, y);
315}
316
317static void SC_MeasureTextAlloc(Allocation *a,
318 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
319 GET_TLS();
320 rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom);
321}
322
323static void SC_MeasureText(const char *text,
324 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
325 GET_TLS();
326 rsrMeasureText(rsc, sc, text, left, right, top, bottom);
327}
328
329static void SC_BindFont(Font *f) {
330 GET_TLS();
331 rsrBindFont(rsc, sc, f);
332}
333
334static void SC_FontColor(float r, float g, float b, float a) {
335 GET_TLS();
336 rsrFontColor(rsc, sc, r, g, b, a);
337}
338
339
340
341//////////////////////////////////////////////////////////////////////////////
342//
343//////////////////////////////////////////////////////////////////////////////
344
345static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
346 GET_TLS();
347 rsrSetObject(rsc, sc, dst, src);
348}
349
350static void SC_ClearObject(ObjectBase **dst) {
351 GET_TLS();
352 rsrClearObject(rsc, sc, dst);
353}
354
355static bool SC_IsObject(const ObjectBase *src) {
356 GET_TLS();
357 return rsrIsObject(rsc, sc, src);
358}
359
360
361
362
363static const Allocation * SC_GetAllocation(const void *ptr) {
364 GET_TLS();
365 return rsrGetAllocation(rsc, sc, ptr);
366}
367
368static void SC_ForEach(Script *target,
369 Allocation *in,
370 Allocation *out,
371 const void *usr,
372 const RsScriptCall *call) {
373 GET_TLS();
374 rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
375}
376
377static void SC_ForEach2(Script *target,
378 Allocation *in,
379 Allocation *out,
380 const void *usr,
381 const RsScriptCall *call) {
382 GET_TLS();
383 rsrForEach(rsc, sc, target, in, out, usr, 0, call);
384}
385
386
387
388//////////////////////////////////////////////////////////////////////////////
389// Time routines
390//////////////////////////////////////////////////////////////////////////////
391
392static float SC_GetDt() {
393 GET_TLS();
394 return rsrGetDt(rsc, sc);
395}
396
397time_t SC_Time(time_t *timer) {
398 GET_TLS();
399 return rsrTime(rsc, sc, timer);
400}
401
402tm* SC_LocalTime(tm *local, time_t *timer) {
403 GET_TLS();
404 return rsrLocalTime(rsc, sc, local, timer);
405}
406
407int64_t SC_UptimeMillis() {
408 GET_TLS();
409 return rsrUptimeMillis(rsc, sc);
410}
411
412int64_t SC_UptimeNanos() {
413 GET_TLS();
414 return rsrUptimeNanos(rsc, sc);
415}
416
417//////////////////////////////////////////////////////////////////////////////
418// Message routines
419//////////////////////////////////////////////////////////////////////////////
420
421static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
422 GET_TLS();
423 return rsrToClient(rsc, sc, cmdID, data, len);
424}
425
426static uint32_t SC_ToClient(int cmdID) {
427 GET_TLS();
428 return rsrToClient(rsc, sc, cmdID, NULL, 0);
429}
430
431static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
432 GET_TLS();
433 return rsrToClientBlocking(rsc, sc, cmdID, data, len);
434}
435
436static uint32_t SC_ToClientBlocking(int cmdID) {
437 GET_TLS();
438 return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
439}
440
441int SC_divsi3(int a, int b) {
442 return a / b;
443}
444
445int SC_modsi3(int a, int b) {
446 return a % b;
447}
448
449unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
450 return a / b;
451}
452
453unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
454 return a % b;
455}
456
457static void SC_debugF(const char *s, float f) {
458 LOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
459}
460static void SC_debugFv2(const char *s, float f1, float f2) {
461 LOGD("%s {%f, %f}", s, f1, f2);
462}
463static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
464 LOGD("%s {%f, %f, %f}", s, f1, f2, f3);
465}
466static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
467 LOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
468}
469static void SC_debugD(const char *s, double d) {
470 LOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
471}
472static void SC_debugFM4v4(const char *s, const float *f) {
473 LOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
474 LOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
475 LOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
476 LOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
477}
478static void SC_debugFM3v3(const char *s, const float *f) {
479 LOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
480 LOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
481 LOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
482}
483static void SC_debugFM2v2(const char *s, const float *f) {
484 LOGD("%s {%f, %f", s, f[0], f[2]);
485 LOGD("%s %f, %f}",s, f[1], f[3]);
486}
487
488static void SC_debugI32(const char *s, int32_t i) {
489 LOGD("%s %i 0x%x", s, i, i);
490}
491static void SC_debugU32(const char *s, uint32_t i) {
492 LOGD("%s %u 0x%x", s, i, i);
493}
494static void SC_debugLL64(const char *s, long long ll) {
495 LOGD("%s %lld 0x%llx", s, ll, ll);
496}
497static void SC_debugULL64(const char *s, unsigned long long ll) {
498 LOGD("%s %llu 0x%llx", s, ll, ll);
499}
500
501static void SC_debugP(const char *s, const void *p) {
502 LOGD("%s %p", s, p);
503}
504
505
506//////////////////////////////////////////////////////////////////////////////
507// Stub implementation
508//////////////////////////////////////////////////////////////////////////////
509
510// llvm name mangling ref
511// <builtin-type> ::= v # void
512// ::= b # bool
513// ::= c # char
514// ::= a # signed char
515// ::= h # unsigned char
516// ::= s # short
517// ::= t # unsigned short
518// ::= i # int
519// ::= j # unsigned int
520// ::= l # long
521// ::= m # unsigned long
522// ::= x # long long, __int64
523// ::= y # unsigned long long, __int64
524// ::= f # float
525// ::= d # double
526
527static RsdSymbolTable gSyms[] = {
Jason Samsfcf72312011-04-20 15:09:01 -0700528 { "memset", (void *)&memset, true },
529 { "memcpy", (void *)&memcpy, true },
530
531 // Refcounting
532 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
533 { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
534 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
535
536 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
537 { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
538 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
539
540 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
541 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
542 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
543
544 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
545 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
546 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
547
548 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
549 { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
550 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
551
552 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
553 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
554 { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
555
556 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
557 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
558 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
559
560 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
561 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
562 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
563
564 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
565 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
566 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
567
568 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
569 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
570 { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
571
572 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
573 { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
574 { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
575
576 // Allocation ops
577 { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX, true },
578 { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY, true },
579 { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ, true },
580 { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD, true },
581 { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces, true },
582
583 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX, true },
584 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY, true },
585 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ, true },
586
587 { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation, true },
588
589 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
590 { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
591 { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700592 { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700593 { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
594
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -0700595 { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
596 { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
Jason Samsfcf72312011-04-20 15:09:01 -0700597
598 // Messaging
599
600 { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
601 { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
602 { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
603 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
604
605 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
606 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
607 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
608 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
609 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
610 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
611
612 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
613 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
614 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
615
616 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
617
618 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
619
620 { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
621 { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
622
623
624 { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
625 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
626 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
627 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
628
629 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
630 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
631 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
632 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
633
634 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
635 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
636
637 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
638 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
639 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
640 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
641
642 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
643 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
644
645 { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
646 { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
647 { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
648 { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
649 { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
650
651 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach, false },
652 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach2, false },
653
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