• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 "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 #include "rsdBcc.h"
27 
28 #include "rsdRuntime.h"
29 #include "rsdPath.h"
30 #include "rsdAllocation.h"
31 #include "rsdShaderCache.h"
32 #include "rsdVertexArray.h"
33 
34 #include <time.h>
35 
36 using namespace android;
37 using namespace android::renderscript;
38 
39 #define GET_TLS()  ScriptTLSStruct * tls = \
40     (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
41     Context * rsc = tls->mContext; \
42     ScriptC * sc = (ScriptC *) tls->mScript
43 
44 typedef float float2 __attribute__((ext_vector_type(2)));
45 typedef float float3 __attribute__((ext_vector_type(3)));
46 typedef float float4 __attribute__((ext_vector_type(4)));
47 typedef char char2 __attribute__((ext_vector_type(2)));
48 typedef char char3 __attribute__((ext_vector_type(3)));
49 typedef char char4 __attribute__((ext_vector_type(4)));
50 typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
51 typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
52 typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
53 typedef short short2 __attribute__((ext_vector_type(2)));
54 typedef short short3 __attribute__((ext_vector_type(3)));
55 typedef short short4 __attribute__((ext_vector_type(4)));
56 typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
57 typedef unsigned short ushort3 __attribute__((ext_vector_type(3)));
58 typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
59 typedef int32_t int2 __attribute__((ext_vector_type(2)));
60 typedef int32_t int3 __attribute__((ext_vector_type(3)));
61 typedef int32_t int4 __attribute__((ext_vector_type(4)));
62 typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
63 typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
64 typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
65 typedef long long long2 __attribute__((ext_vector_type(2)));
66 typedef long long long3 __attribute__((ext_vector_type(3)));
67 typedef long long long4 __attribute__((ext_vector_type(4)));
68 typedef unsigned long long ulong2 __attribute__((ext_vector_type(2)));
69 typedef unsigned long long ulong3 __attribute__((ext_vector_type(3)));
70 typedef unsigned long long ulong4 __attribute__((ext_vector_type(4)));
71 
72 
73 //////////////////////////////////////////////////////////////////////////////
74 // Allocation
75 //////////////////////////////////////////////////////////////////////////////
76 
77 
SC_AllocationSyncAll2(Allocation * a,RsAllocationUsageType source)78 static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
79     GET_TLS();
80     rsrAllocationSyncAll(rsc, sc, a, source);
81 }
82 
SC_AllocationSyncAll(Allocation * a)83 static void SC_AllocationSyncAll(Allocation *a) {
84     GET_TLS();
85     rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT);
86 }
87 
SC_AllocationCopy1DRange(Allocation * dstAlloc,uint32_t dstOff,uint32_t dstMip,uint32_t count,Allocation * srcAlloc,uint32_t srcOff,uint32_t srcMip)88 static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
89                                      uint32_t dstOff,
90                                      uint32_t dstMip,
91                                      uint32_t count,
92                                      Allocation *srcAlloc,
93                                      uint32_t srcOff, uint32_t srcMip) {
94     GET_TLS();
95     rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
96                              srcAlloc, srcOff, srcMip);
97 }
98 
SC_AllocationCopy2DRange(Allocation * dstAlloc,uint32_t dstXoff,uint32_t dstYoff,uint32_t dstMip,uint32_t dstFace,uint32_t width,uint32_t height,Allocation * srcAlloc,uint32_t srcXoff,uint32_t srcYoff,uint32_t srcMip,uint32_t srcFace)99 static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
100                                      uint32_t dstXoff, uint32_t dstYoff,
101                                      uint32_t dstMip, uint32_t dstFace,
102                                      uint32_t width, uint32_t height,
103                                      Allocation *srcAlloc,
104                                      uint32_t srcXoff, uint32_t srcYoff,
105                                      uint32_t srcMip, uint32_t srcFace) {
106     GET_TLS();
107     rsrAllocationCopy2DRange(rsc, dstAlloc,
108                              dstXoff, dstYoff, dstMip, dstFace,
109                              width, height,
110                              srcAlloc,
111                              srcXoff, srcYoff, srcMip, srcFace);
112 }
113 
SC_AllocationIoSend(Allocation * alloc)114 static void SC_AllocationIoSend(Allocation *alloc) {
115     GET_TLS();
116     rsdAllocationIoSend(rsc, alloc);
117 }
118 
119 
SC_AllocationIoReceive(Allocation * alloc)120 static void SC_AllocationIoReceive(Allocation *alloc) {
121     GET_TLS();
122     rsdAllocationIoReceive(rsc, alloc);
123 }
124 
125 
126 
127 //////////////////////////////////////////////////////////////////////////////
128 // Context
129 //////////////////////////////////////////////////////////////////////////////
130 
SC_BindTexture(ProgramFragment * pf,uint32_t slot,Allocation * a)131 static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
132     GET_TLS();
133     rsrBindTexture(rsc, sc, pf, slot, a);
134 }
135 
SC_BindVertexConstant(ProgramVertex * pv,uint32_t slot,Allocation * a)136 static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
137     GET_TLS();
138     rsrBindConstant(rsc, sc, pv, slot, a);
139 }
140 
SC_BindFragmentConstant(ProgramFragment * pf,uint32_t slot,Allocation * a)141 static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
142     GET_TLS();
143     rsrBindConstant(rsc, sc, pf, slot, a);
144 }
145 
SC_BindSampler(ProgramFragment * pf,uint32_t slot,Sampler * s)146 static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
147     GET_TLS();
148     rsrBindSampler(rsc, sc, pf, slot, s);
149 }
150 
SC_BindProgramStore(ProgramStore * ps)151 static void SC_BindProgramStore(ProgramStore *ps) {
152     GET_TLS();
153     rsrBindProgramStore(rsc, sc, ps);
154 }
155 
SC_BindProgramFragment(ProgramFragment * pf)156 static void SC_BindProgramFragment(ProgramFragment *pf) {
157     GET_TLS();
158     rsrBindProgramFragment(rsc, sc, pf);
159 }
160 
SC_BindProgramVertex(ProgramVertex * pv)161 static void SC_BindProgramVertex(ProgramVertex *pv) {
162     GET_TLS();
163     rsrBindProgramVertex(rsc, sc, pv);
164 }
165 
SC_BindProgramRaster(ProgramRaster * pr)166 static void SC_BindProgramRaster(ProgramRaster *pr) {
167     GET_TLS();
168     rsrBindProgramRaster(rsc, sc, pr);
169 }
170 
SC_BindFrameBufferObjectColorTarget(Allocation * a,uint32_t slot)171 static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
172     GET_TLS();
173     rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot);
174 }
175 
SC_BindFrameBufferObjectDepthTarget(Allocation * a)176 static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
177     GET_TLS();
178     rsrBindFrameBufferObjectDepthTarget(rsc, sc, a);
179 }
180 
SC_ClearFrameBufferObjectColorTarget(uint32_t slot)181 static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
182     GET_TLS();
183     rsrClearFrameBufferObjectColorTarget(rsc, sc, slot);
184 }
185 
SC_ClearFrameBufferObjectDepthTarget(Context *,Script *)186 static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
187     GET_TLS();
188     rsrClearFrameBufferObjectDepthTarget(rsc, sc);
189 }
190 
SC_ClearFrameBufferObjectTargets(Context *,Script *)191 static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
192     GET_TLS();
193     rsrClearFrameBufferObjectTargets(rsc, sc);
194 }
195 
196 
197 //////////////////////////////////////////////////////////////////////////////
198 // VP
199 //////////////////////////////////////////////////////////////////////////////
200 
SC_VpLoadProjectionMatrix(const rsc_Matrix * m)201 static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
202     GET_TLS();
203     rsrVpLoadProjectionMatrix(rsc, sc, m);
204 }
205 
SC_VpLoadModelMatrix(const rsc_Matrix * m)206 static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
207     GET_TLS();
208     rsrVpLoadModelMatrix(rsc, sc, m);
209 }
210 
SC_VpLoadTextureMatrix(const rsc_Matrix * m)211 static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
212     GET_TLS();
213     rsrVpLoadTextureMatrix(rsc, sc, m);
214 }
215 
SC_PfConstantColor(ProgramFragment * pf,float r,float g,float b,float a)216 static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
217     GET_TLS();
218     rsrPfConstantColor(rsc, sc, pf, r, g, b, a);
219 }
220 
SC_VpGetProjectionMatrix(rsc_Matrix * m)221 static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
222     GET_TLS();
223     rsrVpGetProjectionMatrix(rsc, sc, m);
224 }
225 
226 
227 //////////////////////////////////////////////////////////////////////////////
228 // Drawing
229 //////////////////////////////////////////////////////////////////////////////
230 
SC_DrawQuadTexCoords(float x1,float y1,float z1,float u1,float v1,float x2,float y2,float z2,float u2,float v2,float x3,float y3,float z3,float u3,float v3,float x4,float y4,float z4,float u4,float v4)231 static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
232                                  float x2, float y2, float z2, float u2, float v2,
233                                  float x3, float y3, float z3, float u3, float v3,
234                                  float x4, float y4, float z4, float u4, float v4) {
235     GET_TLS();
236 
237     if (!rsc->setupCheck()) {
238         return;
239     }
240 
241     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
242     if (!dc->gl.shaderCache->setup(rsc)) {
243         return;
244     }
245 
246     //ALOGE("Quad");
247     //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
248     //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
249     //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
250     //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
251 
252     float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
253     const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
254 
255     RsdVertexArray::Attrib attribs[2];
256     attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
257     attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
258 
259     RsdVertexArray va(attribs, 2);
260     va.setup(rsc);
261 
262     RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
263 }
264 
SC_DrawQuad(float x1,float y1,float z1,float x2,float y2,float z2,float x3,float y3,float z3,float x4,float y4,float z4)265 static void SC_DrawQuad(float x1, float y1, float z1,
266                         float x2, float y2, float z2,
267                         float x3, float y3, float z3,
268                         float x4, float y4, float z4) {
269     GET_TLS();
270     SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
271                          x2, y2, z2, 1, 1,
272                          x3, y3, z3, 1, 0,
273                          x4, y4, z4, 0, 0);
274 }
275 
SC_DrawSpriteScreenspace(float x,float y,float z,float w,float h)276 static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
277     GET_TLS();
278 
279     ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
280     rsc->setProgramVertex(rsc->getDefaultProgramVertex());
281     //rsc->setupCheck();
282 
283     //GLint crop[4] = {0, h, w, -h};
284 
285     float sh = rsc->getHeight();
286 
287     SC_DrawQuad(x,   sh - y,     z,
288                 x+w, sh - y,     z,
289                 x+w, sh - (y+h), z,
290                 x,   sh - (y+h), z);
291     rsc->setProgramVertex((ProgramVertex *)tmp.get());
292 }
293 
SC_DrawRect(float x1,float y1,float x2,float y2,float z)294 static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
295     GET_TLS();
296 
297     SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
298 
299 }
300 
SC_DrawPath(Path * p)301 static void SC_DrawPath(Path *p) {
302     GET_TLS();
303     //rsrDrawPath(rsc, sc, p);
304     rsdPathDraw(rsc, p);
305 }
306 
SC_DrawMesh(Mesh * m)307 static void SC_DrawMesh(Mesh *m) {
308     GET_TLS();
309     rsrDrawMesh(rsc, sc, m);
310 }
311 
SC_DrawMeshPrimitive(Mesh * m,uint32_t primIndex)312 static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
313     GET_TLS();
314     rsrDrawMeshPrimitive(rsc, sc, m, primIndex);
315 }
316 
SC_DrawMeshPrimitiveRange(Mesh * m,uint32_t primIndex,uint32_t start,uint32_t len)317 static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
318     GET_TLS();
319     rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len);
320 }
321 
SC_MeshComputeBoundingBox(Mesh * m,float * minX,float * minY,float * minZ,float * maxX,float * maxY,float * maxZ)322 static void SC_MeshComputeBoundingBox(Mesh *m,
323                                float *minX, float *minY, float *minZ,
324                                float *maxX, float *maxY, float *maxZ) {
325     GET_TLS();
326     rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ);
327 }
328 
329 
330 
331 //////////////////////////////////////////////////////////////////////////////
332 //
333 //////////////////////////////////////////////////////////////////////////////
334 
335 
SC_Color(float r,float g,float b,float a)336 static void SC_Color(float r, float g, float b, float a) {
337     GET_TLS();
338     rsrColor(rsc, sc, r, g, b, a);
339 }
340 
SC_Finish()341 static void SC_Finish() {
342     GET_TLS();
343     rsdGLFinish(rsc);
344 }
345 
SC_ClearColor(float r,float g,float b,float a)346 static void SC_ClearColor(float r, float g, float b, float a) {
347     GET_TLS();
348     rsrPrepareClear(rsc, sc);
349     rsdGLClearColor(rsc, r, g, b, a);
350 }
351 
SC_ClearDepth(float v)352 static void SC_ClearDepth(float v) {
353     GET_TLS();
354     rsrPrepareClear(rsc, sc);
355     rsdGLClearDepth(rsc, v);
356 }
357 
SC_GetWidth()358 static uint32_t SC_GetWidth() {
359     GET_TLS();
360     return rsrGetWidth(rsc, sc);
361 }
362 
SC_GetHeight()363 static uint32_t SC_GetHeight() {
364     GET_TLS();
365     return rsrGetHeight(rsc, sc);
366 }
367 
SC_DrawTextAlloc(Allocation * a,int x,int y)368 static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
369     GET_TLS();
370     rsrDrawTextAlloc(rsc, sc, a, x, y);
371 }
372 
SC_DrawText(const char * text,int x,int y)373 static void SC_DrawText(const char *text, int x, int y) {
374     GET_TLS();
375     rsrDrawText(rsc, sc, text, x, y);
376 }
377 
SC_MeasureTextAlloc(Allocation * a,int32_t * left,int32_t * right,int32_t * top,int32_t * bottom)378 static void SC_MeasureTextAlloc(Allocation *a,
379                          int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
380     GET_TLS();
381     rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom);
382 }
383 
SC_MeasureText(const char * text,int32_t * left,int32_t * right,int32_t * top,int32_t * bottom)384 static void SC_MeasureText(const char *text,
385                     int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
386     GET_TLS();
387     rsrMeasureText(rsc, sc, text, left, right, top, bottom);
388 }
389 
SC_BindFont(Font * f)390 static void SC_BindFont(Font *f) {
391     GET_TLS();
392     rsrBindFont(rsc, sc, f);
393 }
394 
SC_FontColor(float r,float g,float b,float a)395 static void SC_FontColor(float r, float g, float b, float a) {
396     GET_TLS();
397     rsrFontColor(rsc, sc, r, g, b, a);
398 }
399 
400 
401 
402 //////////////////////////////////////////////////////////////////////////////
403 //
404 //////////////////////////////////////////////////////////////////////////////
405 
SC_SetObject(ObjectBase ** dst,ObjectBase * src)406 static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
407     GET_TLS();
408     rsrSetObject(rsc, sc, dst, src);
409 }
410 
SC_ClearObject(ObjectBase ** dst)411 static void SC_ClearObject(ObjectBase **dst) {
412     GET_TLS();
413     rsrClearObject(rsc, sc, dst);
414 }
415 
SC_IsObject(const ObjectBase * src)416 static bool SC_IsObject(const ObjectBase *src) {
417     GET_TLS();
418     return rsrIsObject(rsc, sc, src);
419 }
420 
421 
422 
423 
SC_GetAllocation(const void * ptr)424 static const Allocation * SC_GetAllocation(const void *ptr) {
425     GET_TLS();
426     return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
427 }
428 
SC_ForEach_SAA(Script * target,Allocation * in,Allocation * out)429 static void SC_ForEach_SAA(Script *target,
430                             Allocation *in,
431                             Allocation *out) {
432     GET_TLS();
433     rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL);
434 }
435 
SC_ForEach_SAAU(Script * target,Allocation * in,Allocation * out,const void * usr)436 static void SC_ForEach_SAAU(Script *target,
437                             Allocation *in,
438                             Allocation *out,
439                             const void *usr) {
440     GET_TLS();
441     rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
442 }
443 
SC_ForEach_SAAUS(Script * target,Allocation * in,Allocation * out,const void * usr,const RsScriptCall * call)444 static void SC_ForEach_SAAUS(Script *target,
445                              Allocation *in,
446                              Allocation *out,
447                              const void *usr,
448                              const RsScriptCall *call) {
449     GET_TLS();
450     rsrForEach(rsc, sc, target, in, out, usr, 0, call);
451 }
452 
SC_ForEach_SAAUL(Script * target,Allocation * in,Allocation * out,const void * usr,uint32_t usrLen)453 static void SC_ForEach_SAAUL(Script *target,
454                              Allocation *in,
455                              Allocation *out,
456                              const void *usr,
457                              uint32_t usrLen) {
458     GET_TLS();
459     rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL);
460 }
461 
SC_ForEach_SAAULS(Script * target,Allocation * in,Allocation * out,const void * usr,uint32_t usrLen,const RsScriptCall * call)462 static void SC_ForEach_SAAULS(Script *target,
463                               Allocation *in,
464                               Allocation *out,
465                               const void *usr,
466                               uint32_t usrLen,
467                               const RsScriptCall *call) {
468     GET_TLS();
469     rsrForEach(rsc, sc, target, in, out, usr, usrLen, call);
470 }
471 
472 
473 
474 //////////////////////////////////////////////////////////////////////////////
475 // Time routines
476 //////////////////////////////////////////////////////////////////////////////
477 
SC_GetDt()478 static float SC_GetDt() {
479     GET_TLS();
480     return rsrGetDt(rsc, sc);
481 }
482 
SC_Time(time_t * timer)483 time_t SC_Time(time_t *timer) {
484     GET_TLS();
485     return rsrTime(rsc, sc, timer);
486 }
487 
SC_LocalTime(tm * local,time_t * timer)488 tm* SC_LocalTime(tm *local, time_t *timer) {
489     GET_TLS();
490     return rsrLocalTime(rsc, sc, local, timer);
491 }
492 
SC_UptimeMillis()493 int64_t SC_UptimeMillis() {
494     GET_TLS();
495     return rsrUptimeMillis(rsc, sc);
496 }
497 
SC_UptimeNanos()498 int64_t SC_UptimeNanos() {
499     GET_TLS();
500     return rsrUptimeNanos(rsc, sc);
501 }
502 
503 //////////////////////////////////////////////////////////////////////////////
504 // Message routines
505 //////////////////////////////////////////////////////////////////////////////
506 
SC_ToClient2(int cmdID,void * data,int len)507 static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
508     GET_TLS();
509     return rsrToClient(rsc, sc, cmdID, data, len);
510 }
511 
SC_ToClient(int cmdID)512 static uint32_t SC_ToClient(int cmdID) {
513     GET_TLS();
514     return rsrToClient(rsc, sc, cmdID, NULL, 0);
515 }
516 
SC_ToClientBlocking2(int cmdID,void * data,int len)517 static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
518     GET_TLS();
519     return rsrToClientBlocking(rsc, sc, cmdID, data, len);
520 }
521 
SC_ToClientBlocking(int cmdID)522 static uint32_t SC_ToClientBlocking(int cmdID) {
523     GET_TLS();
524     return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
525 }
526 
SC_divsi3(int a,int b)527 int SC_divsi3(int a, int b) {
528     return a / b;
529 }
530 
SC_modsi3(int a,int b)531 int SC_modsi3(int a, int b) {
532     return a % b;
533 }
534 
SC_udivsi3(unsigned int a,unsigned int b)535 unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
536     return a / b;
537 }
538 
SC_umodsi3(unsigned int a,unsigned int b)539 unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
540     return a % b;
541 }
542 
SC_debugF(const char * s,float f)543 static void SC_debugF(const char *s, float f) {
544     ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
545 }
SC_debugFv2(const char * s,float f1,float f2)546 static void SC_debugFv2(const char *s, float f1, float f2) {
547     ALOGD("%s {%f, %f}", s, f1, f2);
548 }
SC_debugFv3(const char * s,float f1,float f2,float f3)549 static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
550     ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
551 }
SC_debugFv4(const char * s,float f1,float f2,float f3,float f4)552 static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
553     ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
554 }
SC_debugF2(const char * s,float2 f)555 static void SC_debugF2(const char *s, float2 f) {
556     ALOGD("%s {%f, %f}", s, f.x, f.y);
557 }
SC_debugF3(const char * s,float3 f)558 static void SC_debugF3(const char *s, float3 f) {
559     ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
560 }
SC_debugF4(const char * s,float4 f)561 static void SC_debugF4(const char *s, float4 f) {
562     ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
563 }
SC_debugD(const char * s,double d)564 static void SC_debugD(const char *s, double d) {
565     ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
566 }
SC_debugFM4v4(const char * s,const float * f)567 static void SC_debugFM4v4(const char *s, const float *f) {
568     ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
569     ALOGD("%s  %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
570     ALOGD("%s  %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
571     ALOGD("%s  %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
572 }
SC_debugFM3v3(const char * s,const float * f)573 static void SC_debugFM3v3(const char *s, const float *f) {
574     ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
575     ALOGD("%s  %f, %f, %f", s, f[1], f[4], f[7]);
576     ALOGD("%s  %f, %f, %f}",s, f[2], f[5], f[8]);
577 }
SC_debugFM2v2(const char * s,const float * f)578 static void SC_debugFM2v2(const char *s, const float *f) {
579     ALOGD("%s {%f, %f", s, f[0], f[2]);
580     ALOGD("%s  %f, %f}",s, f[1], f[3]);
581 }
SC_debugI8(const char * s,char c)582 static void SC_debugI8(const char *s, char c) {
583     ALOGD("%s %hhd  0x%hhx", s, c, (unsigned char)c);
584 }
SC_debugC2(const char * s,char2 c)585 static void SC_debugC2(const char *s, char2 c) {
586     ALOGD("%s {%hhd, %hhd}  0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
587 }
SC_debugC3(const char * s,char3 c)588 static void SC_debugC3(const char *s, char3 c) {
589     ALOGD("%s {%hhd, %hhd, %hhd}  0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, (unsigned char)c.x, (unsigned char)c.y, (unsigned char)c.z);
590 }
SC_debugC4(const char * s,char4 c)591 static void SC_debugC4(const char *s, char4 c) {
592     ALOGD("%s {%hhd, %hhd, %hhd, %hhd}  0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.w, (unsigned char)c.x, (unsigned char)c.y, (unsigned char)c.z, (unsigned char)c.w);
593 }
SC_debugU8(const char * s,unsigned char c)594 static void SC_debugU8(const char *s, unsigned char c) {
595     ALOGD("%s %hhu  0x%hhx", s, c, c);
596 }
SC_debugUC2(const char * s,uchar2 c)597 static void SC_debugUC2(const char *s, uchar2 c) {
598     ALOGD("%s {%hhu, %hhu}  0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
599 }
SC_debugUC3(const char * s,uchar3 c)600 static void SC_debugUC3(const char *s, uchar3 c) {
601     ALOGD("%s {%hhu, %hhu, %hhu}  0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
602 }
SC_debugUC4(const char * s,uchar4 c)603 static void SC_debugUC4(const char *s, uchar4 c) {
604     ALOGD("%s {%hhu, %hhu, %hhu, %hhu}  0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
605 }
SC_debugI16(const char * s,short c)606 static void SC_debugI16(const char *s, short c) {
607     ALOGD("%s %hd  0x%hx", s, c, c);
608 }
SC_debugS2(const char * s,short2 c)609 static void SC_debugS2(const char *s, short2 c) {
610     ALOGD("%s {%hd, %hd}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
611 }
SC_debugS3(const char * s,short3 c)612 static void SC_debugS3(const char *s, short3 c) {
613     ALOGD("%s {%hd, %hd, %hd}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
614 }
SC_debugS4(const char * s,short4 c)615 static void SC_debugS4(const char *s, short4 c) {
616     ALOGD("%s {%hd, %hd, %hd, %hd}  0x%hx 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
617 }
SC_debugU16(const char * s,unsigned short c)618 static void SC_debugU16(const char *s, unsigned short c) {
619     ALOGD("%s %hu  0x%hx", s, c, c);
620 }
SC_debugUS2(const char * s,ushort2 c)621 static void SC_debugUS2(const char *s, ushort2 c) {
622     ALOGD("%s {%hu, %hu}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
623 }
SC_debugUS3(const char * s,ushort3 c)624 static void SC_debugUS3(const char *s, ushort3 c) {
625     ALOGD("%s {%hu, %hu, %hu}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
626 }
SC_debugUS4(const char * s,ushort4 c)627 static void SC_debugUS4(const char *s, ushort4 c) {
628     ALOGD("%s {%hu, %hu, %hu, %hu}  0x%hx 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
629 }
SC_debugI32(const char * s,int32_t i)630 static void SC_debugI32(const char *s, int32_t i) {
631     ALOGD("%s %d  0x%x", s, i, i);
632 }
SC_debugI2(const char * s,int2 i)633 static void SC_debugI2(const char *s, int2 i) {
634     ALOGD("%s {%d, %d}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
635 }
SC_debugI3(const char * s,int3 i)636 static void SC_debugI3(const char *s, int3 i) {
637     ALOGD("%s {%d, %d, %d}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
638 }
SC_debugI4(const char * s,int4 i)639 static void SC_debugI4(const char *s, int4 i) {
640     ALOGD("%s {%d, %d, %d, %d}  0x%x 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.w, i.x, i.y, i.z, i.w);
641 }
SC_debugU32(const char * s,uint32_t i)642 static void SC_debugU32(const char *s, uint32_t i) {
643     ALOGD("%s %u  0x%x", s, i, i);
644 }
SC_debugUI2(const char * s,uint2 i)645 static void SC_debugUI2(const char *s, uint2 i) {
646     ALOGD("%s {%u, %u}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
647 }
SC_debugUI3(const char * s,uint3 i)648 static void SC_debugUI3(const char *s, uint3 i) {
649     ALOGD("%s {%u, %u, %u}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
650 }
SC_debugUI4(const char * s,uint4 i)651 static void SC_debugUI4(const char *s, uint4 i) {
652     ALOGD("%s {%u, %u, %u, %u}  0x%x 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.w, i.x, i.y, i.z, i.w);
653 }
SC_debugLL64(const char * s,long long ll)654 static void SC_debugLL64(const char *s, long long ll) {
655     ALOGD("%s %lld  0x%llx", s, ll, ll);
656 }
SC_debugL2(const char * s,long2 ll)657 static void SC_debugL2(const char *s, long2 ll) {
658     ALOGD("%s {%lld, %lld}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
659 }
SC_debugL3(const char * s,long3 ll)660 static void SC_debugL3(const char *s, long3 ll) {
661     ALOGD("%s {%lld, %lld, %lld}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
662 }
SC_debugL4(const char * s,long4 ll)663 static void SC_debugL4(const char *s, long4 ll) {
664     ALOGD("%s {%lld, %lld, %lld, %lld}  0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w);
665 }
SC_debugULL64(const char * s,unsigned long long ll)666 static void SC_debugULL64(const char *s, unsigned long long ll) {
667     ALOGD("%s %llu  0x%llx", s, ll, ll);
668 }
SC_debugUL2(const char * s,ulong2 ll)669 static void SC_debugUL2(const char *s, ulong2 ll) {
670     ALOGD("%s {%llu, %llu}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
671 }
SC_debugUL3(const char * s,ulong3 ll)672 static void SC_debugUL3(const char *s, ulong3 ll) {
673     ALOGD("%s {%llu, %llu, %llu}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
674 }
SC_debugUL4(const char * s,ulong4 ll)675 static void SC_debugUL4(const char *s, ulong4 ll) {
676     ALOGD("%s {%llu, %llu, %llu, %llu}  0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w);
677 }
SC_debugP(const char * s,const void * p)678 static void SC_debugP(const char *s, const void *p) {
679     ALOGD("%s %p", s, p);
680 }
681 
682 
683 //////////////////////////////////////////////////////////////////////////////
684 // Stub implementation
685 //////////////////////////////////////////////////////////////////////////////
686 
687 // llvm name mangling ref
688 //  <builtin-type> ::= v  # void
689 //                 ::= b  # bool
690 //                 ::= c  # char
691 //                 ::= a  # signed char
692 //                 ::= h  # unsigned char
693 //                 ::= s  # short
694 //                 ::= t  # unsigned short
695 //                 ::= i  # int
696 //                 ::= j  # unsigned int
697 //                 ::= l  # long
698 //                 ::= m  # unsigned long
699 //                 ::= x  # long long, __int64
700 //                 ::= y  # unsigned long long, __int64
701 //                 ::= f  # float
702 //                 ::= d  # double
703 
704 static RsdSymbolTable gSyms[] = {
705     { "memset", (void *)&memset, true },
706     { "memcpy", (void *)&memcpy, true },
707 
708     // Refcounting
709     { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
710     { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
711     { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
712 
713     { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
714     { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
715     { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
716 
717     { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
718     { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
719     { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
720 
721     { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
722     { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
723     { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
724 
725     { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
726     { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
727     { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
728 
729     { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
730     { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
731     { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
732 
733     { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
734     { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
735     { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
736 
737     { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
738     { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
739     { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
740 
741     { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
742     { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
743     { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
744 
745     { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
746     { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
747     { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
748 
749     { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
750     { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
751     { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
752 
753     { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
754     { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
755     { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
756 
757     // Allocation ops
758     { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
759     { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
760     { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
761     { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
762     { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
763     { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
764     { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
765     { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
766     { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
767 
768     // Messaging
769 
770     { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
771     { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
772     { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
773     { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
774 
775     { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
776     { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
777     { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
778     { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
779     { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
780     { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
781     { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
782     { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
783 
784     { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
785     { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
786     { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
787 
788     { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
789 
790     { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
791 
792     { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
793     { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
794 
795 
796     { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
797     { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
798     { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
799     { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
800 
801     { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
802     { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
803     { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
804     { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
805 
806     { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
807 
808     { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
809     { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
810 
811     { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
812     { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
813     { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
814     { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
815 
816     { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
817     { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
818 
819     { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
820     { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
821     { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
822     { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
823     { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
824 
825     { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
826     { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
827     { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
828     { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
829     { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
830 
831     // time
832     { "_Z6rsTimePi", (void *)&SC_Time, true },
833     { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
834     { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
835     { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
836     { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
837 
838     // misc
839     { "_Z5colorffff", (void *)&SC_Color, false },
840     { "_Z9rsgFinishv", (void *)&SC_Finish, false },
841 
842     // Debug
843     { "_Z7rsDebugPKcf", (void *)&SC_debugF, true },
844     { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true },
845     { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true },
846     { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true },
847     { "_Z7rsDebugPKcDv2_f", (void *)&SC_debugF2, true },
848     { "_Z7rsDebugPKcDv3_f", (void *)&SC_debugF3, true },
849     { "_Z7rsDebugPKcDv4_f", (void *)&SC_debugF4, true },
850     { "_Z7rsDebugPKcd", (void *)&SC_debugD, true },
851     { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true },
852     { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true },
853     { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true },
854     { "_Z7rsDebugPKcc", (void *)&SC_debugI8, true },
855     { "_Z7rsDebugPKcDv2_c", (void *)&SC_debugC2, true },
856     { "_Z7rsDebugPKcDv3_c", (void *)&SC_debugC3, true },
857     { "_Z7rsDebugPKcDv4_c", (void *)&SC_debugC4, true },
858     { "_Z7rsDebugPKch", (void *)&SC_debugU8, true },
859     { "_Z7rsDebugPKcDv2_h", (void *)&SC_debugUC2, true },
860     { "_Z7rsDebugPKcDv3_h", (void *)&SC_debugUC3, true },
861     { "_Z7rsDebugPKcDv4_h", (void *)&SC_debugUC4, true },
862     { "_Z7rsDebugPKcs", (void *)&SC_debugI16, true },
863     { "_Z7rsDebugPKcDv2_s", (void *)&SC_debugS2, true },
864     { "_Z7rsDebugPKcDv3_s", (void *)&SC_debugS3, true },
865     { "_Z7rsDebugPKcDv4_s", (void *)&SC_debugS4, true },
866     { "_Z7rsDebugPKct", (void *)&SC_debugU16, true },
867     { "_Z7rsDebugPKcDv2_t", (void *)&SC_debugUS2, true },
868     { "_Z7rsDebugPKcDv3_t", (void *)&SC_debugUS3, true },
869     { "_Z7rsDebugPKcDv4_t", (void *)&SC_debugUS4, true },
870     { "_Z7rsDebugPKci", (void *)&SC_debugI32, true },
871     { "_Z7rsDebugPKcDv2_i", (void *)&SC_debugI2, true },
872     { "_Z7rsDebugPKcDv3_i", (void *)&SC_debugI3, true },
873     { "_Z7rsDebugPKcDv4_i", (void *)&SC_debugI4, true },
874     { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true },
875     { "_Z7rsDebugPKcDv2_j", (void *)&SC_debugUI2, true },
876     { "_Z7rsDebugPKcDv3_j", (void *)&SC_debugUI3, true },
877     { "_Z7rsDebugPKcDv4_j", (void *)&SC_debugUI4, true },
878     // Both "long" and "unsigned long" need to be redirected to their
879     // 64-bit counterparts, since we have hacked Slang to use 64-bit
880     // for "long" on Arm (to be similar to Java).
881     { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true },
882     { "_Z7rsDebugPKcDv2_l", (void *)&SC_debugL2, true },
883     { "_Z7rsDebugPKcDv3_l", (void *)&SC_debugL3, true },
884     { "_Z7rsDebugPKcDv4_l", (void *)&SC_debugL4, true },
885     { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true },
886     { "_Z7rsDebugPKcDv2_m", (void *)&SC_debugUL2, true },
887     { "_Z7rsDebugPKcDv3_m", (void *)&SC_debugUL3, true },
888     { "_Z7rsDebugPKcDv4_m", (void *)&SC_debugUL4, true },
889     { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true },
890     { "_Z7rsDebugPKcDv2_x", (void *)&SC_debugL2, true },
891     { "_Z7rsDebugPKcDv3_x", (void *)&SC_debugL3, true },
892     { "_Z7rsDebugPKcDv4_x", (void *)&SC_debugL4, true },
893     { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true },
894     { "_Z7rsDebugPKcDv2_y", (void *)&SC_debugUL2, true },
895     { "_Z7rsDebugPKcDv3_y", (void *)&SC_debugUL3, true },
896     { "_Z7rsDebugPKcDv4_y", (void *)&SC_debugUL4, true },
897     { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
898 
899     { NULL, NULL, false }
900 };
901 
902 
rsdLookupRuntimeStub(void * pContext,char const * name)903 void* rsdLookupRuntimeStub(void* pContext, char const* name) {
904     ScriptC *s = (ScriptC *)pContext;
905     RsdSymbolTable *syms = gSyms;
906     const RsdSymbolTable *sym = rsdLookupSymbolMath(name);
907 
908     if (!sym) {
909         while (syms->mPtr) {
910             if (!strcmp(syms->mName, name)) {
911                 sym = syms;
912             }
913             syms++;
914         }
915     }
916 
917     if (sym) {
918         s->mHal.info.isThreadable &= sym->threadable;
919         return sym->mPtr;
920     }
921     ALOGE("ScriptC sym lookup failed for %s", name);
922     return NULL;
923 }
924 
925 
926