rsdRuntimeStubs.cpp revision d6f1f46b2929ed56c73ba32357cde31b82972fbe
1/*
2 * Copyright (C) 2011-2012 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 "rsdCore.h"
25#include "rsdBcc.h"
26
27#include "rsdPath.h"
28#include "rsdAllocation.h"
29#include "rsdShaderCache.h"
30#include "rsdVertexArray.h"
31
32#include <time.h>
33
34using namespace android;
35using namespace android::renderscript;
36
37typedef float float2 __attribute__((ext_vector_type(2)));
38typedef float float3 __attribute__((ext_vector_type(3)));
39typedef float float4 __attribute__((ext_vector_type(4)));
40typedef double double2 __attribute__((ext_vector_type(2)));
41typedef double double3 __attribute__((ext_vector_type(3)));
42typedef double double4 __attribute__((ext_vector_type(4)));
43typedef char char2 __attribute__((ext_vector_type(2)));
44typedef char char3 __attribute__((ext_vector_type(3)));
45typedef char char4 __attribute__((ext_vector_type(4)));
46typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
47typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
48typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
49typedef short short2 __attribute__((ext_vector_type(2)));
50typedef short short3 __attribute__((ext_vector_type(3)));
51typedef short short4 __attribute__((ext_vector_type(4)));
52typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
53typedef unsigned short ushort3 __attribute__((ext_vector_type(3)));
54typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
55typedef int32_t int2 __attribute__((ext_vector_type(2)));
56typedef int32_t int3 __attribute__((ext_vector_type(3)));
57typedef int32_t int4 __attribute__((ext_vector_type(4)));
58typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
59typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
60typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
61typedef long long long2 __attribute__((ext_vector_type(2)));
62typedef long long long3 __attribute__((ext_vector_type(3)));
63typedef long long long4 __attribute__((ext_vector_type(4)));
64typedef unsigned long long ulong2 __attribute__((ext_vector_type(2)));
65typedef unsigned long long ulong3 __attribute__((ext_vector_type(3)));
66typedef unsigned long long ulong4 __attribute__((ext_vector_type(4)));
67
68typedef uint8_t uchar;
69typedef uint16_t ushort;
70typedef uint32_t uint;
71#ifndef RS_SERVER
72typedef uint64_t ulong;
73#endif
74
75#ifdef RS_COMPATIBILITY_LIB
76#define OPAQUETYPE(t) \
77    typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t;
78
79OPAQUETYPE(rs_element)
80OPAQUETYPE(rs_type)
81OPAQUETYPE(rs_allocation)
82OPAQUETYPE(rs_sampler)
83OPAQUETYPE(rs_script)
84OPAQUETYPE(rs_script_call)
85#undef OPAQUETYPE
86
87typedef struct {
88    int tm_sec;     ///< seconds
89    int tm_min;     ///< minutes
90    int tm_hour;    ///< hours
91    int tm_mday;    ///< day of the month
92    int tm_mon;     ///< month
93    int tm_year;    ///< year
94    int tm_wday;    ///< day of the week
95    int tm_yday;    ///< day of the year
96    int tm_isdst;   ///< daylight savings time
97} rs_tm;
98#endif
99
100//////////////////////////////////////////////////////////////////////////////
101// Allocation
102//////////////////////////////////////////////////////////////////////////////
103
104
105static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
106    Context *rsc = RsdCpuReference::getTlsContext();
107    rsrAllocationSyncAll(rsc, a, source);
108}
109
110static void SC_AllocationSyncAll(Allocation *a) {
111    Context *rsc = RsdCpuReference::getTlsContext();
112    rsrAllocationSyncAll(rsc, a, RS_ALLOCATION_USAGE_SCRIPT);
113}
114
115static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
116                                     uint32_t dstOff,
117                                     uint32_t dstMip,
118                                     uint32_t count,
119                                     Allocation *srcAlloc,
120                                     uint32_t srcOff, uint32_t srcMip) {
121    Context *rsc = RsdCpuReference::getTlsContext();
122    rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
123                             srcAlloc, srcOff, srcMip);
124}
125
126static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
127                                     uint32_t dstXoff, uint32_t dstYoff,
128                                     uint32_t dstMip, uint32_t dstFace,
129                                     uint32_t width, uint32_t height,
130                                     Allocation *srcAlloc,
131                                     uint32_t srcXoff, uint32_t srcYoff,
132                                     uint32_t srcMip, uint32_t srcFace) {
133    Context *rsc = RsdCpuReference::getTlsContext();
134    rsrAllocationCopy2DRange(rsc, dstAlloc,
135                             dstXoff, dstYoff, dstMip, dstFace,
136                             width, height,
137                             srcAlloc,
138                             srcXoff, srcYoff, srcMip, srcFace);
139}
140
141#ifndef RS_COMPATIBILITY_LIB
142static void SC_AllocationIoSend(Allocation *alloc) {
143    Context *rsc = RsdCpuReference::getTlsContext();
144    rsdAllocationIoSend(rsc, alloc);
145}
146
147
148static void SC_AllocationIoReceive(Allocation *alloc) {
149    Context *rsc = RsdCpuReference::getTlsContext();
150    rsdAllocationIoReceive(rsc, alloc);
151}
152
153
154
155//////////////////////////////////////////////////////////////////////////////
156// Context
157//////////////////////////////////////////////////////////////////////////////
158
159static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
160    Context *rsc = RsdCpuReference::getTlsContext();
161    rsrBindTexture(rsc, pf, slot, a);
162}
163
164static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
165    Context *rsc = RsdCpuReference::getTlsContext();
166    rsrBindConstant(rsc, pv, slot, a);
167}
168
169static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
170    Context *rsc = RsdCpuReference::getTlsContext();
171    rsrBindConstant(rsc, pf, slot, a);
172}
173
174static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
175    Context *rsc = RsdCpuReference::getTlsContext();
176    rsrBindSampler(rsc, pf, slot, s);
177}
178
179static void SC_BindProgramStore(ProgramStore *ps) {
180    Context *rsc = RsdCpuReference::getTlsContext();
181    rsrBindProgramStore(rsc, ps);
182}
183
184static void SC_BindProgramFragment(ProgramFragment *pf) {
185    Context *rsc = RsdCpuReference::getTlsContext();
186    rsrBindProgramFragment(rsc, pf);
187}
188
189static void SC_BindProgramVertex(ProgramVertex *pv) {
190    Context *rsc = RsdCpuReference::getTlsContext();
191    rsrBindProgramVertex(rsc, pv);
192}
193
194static void SC_BindProgramRaster(ProgramRaster *pr) {
195    Context *rsc = RsdCpuReference::getTlsContext();
196    rsrBindProgramRaster(rsc, pr);
197}
198
199static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
200    Context *rsc = RsdCpuReference::getTlsContext();
201    rsrBindFrameBufferObjectColorTarget(rsc, a, slot);
202}
203
204static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
205    Context *rsc = RsdCpuReference::getTlsContext();
206    rsrBindFrameBufferObjectDepthTarget(rsc, a);
207}
208
209static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
210    Context *rsc = RsdCpuReference::getTlsContext();
211    rsrClearFrameBufferObjectColorTarget(rsc, slot);
212}
213
214static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
215    Context *rsc = RsdCpuReference::getTlsContext();
216    rsrClearFrameBufferObjectDepthTarget(rsc);
217}
218
219static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
220    Context *rsc = RsdCpuReference::getTlsContext();
221    rsrClearFrameBufferObjectTargets(rsc);
222}
223
224
225//////////////////////////////////////////////////////////////////////////////
226// VP
227//////////////////////////////////////////////////////////////////////////////
228
229static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
230    Context *rsc = RsdCpuReference::getTlsContext();
231    rsrVpLoadProjectionMatrix(rsc, m);
232}
233
234static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
235    Context *rsc = RsdCpuReference::getTlsContext();
236    rsrVpLoadModelMatrix(rsc, m);
237}
238
239static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
240    Context *rsc = RsdCpuReference::getTlsContext();
241    rsrVpLoadTextureMatrix(rsc, m);
242}
243
244static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
245    Context *rsc = RsdCpuReference::getTlsContext();
246    rsrPfConstantColor(rsc, pf, r, g, b, a);
247}
248
249static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
250    Context *rsc = RsdCpuReference::getTlsContext();
251    rsrVpGetProjectionMatrix(rsc, m);
252}
253
254
255//////////////////////////////////////////////////////////////////////////////
256// Drawing
257//////////////////////////////////////////////////////////////////////////////
258
259static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
260                                 float x2, float y2, float z2, float u2, float v2,
261                                 float x3, float y3, float z3, float u3, float v3,
262                                 float x4, float y4, float z4, float u4, float v4) {
263    Context *rsc = RsdCpuReference::getTlsContext();
264
265    if (!rsc->setupCheck()) {
266        return;
267    }
268
269    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
270    if (!dc->gl.shaderCache->setup(rsc)) {
271        return;
272    }
273
274    //ALOGE("Quad");
275    //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
276    //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
277    //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
278    //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
279
280    float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
281    const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
282
283    RsdVertexArray::Attrib attribs[2];
284    attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
285    attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
286
287    RsdVertexArray va(attribs, 2);
288    va.setup(rsc);
289
290    RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
291}
292
293static void SC_DrawQuad(float x1, float y1, float z1,
294                        float x2, float y2, float z2,
295                        float x3, float y3, float z3,
296                        float x4, float y4, float z4) {
297    SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
298                         x2, y2, z2, 1, 1,
299                         x3, y3, z3, 1, 0,
300                         x4, y4, z4, 0, 0);
301}
302
303static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
304    Context *rsc = RsdCpuReference::getTlsContext();
305
306    ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
307    rsc->setProgramVertex(rsc->getDefaultProgramVertex());
308    //rsc->setupCheck();
309
310    //GLint crop[4] = {0, h, w, -h};
311
312    float sh = rsc->getHeight();
313
314    SC_DrawQuad(x,   sh - y,     z,
315                x+w, sh - y,     z,
316                x+w, sh - (y+h), z,
317                x,   sh - (y+h), z);
318    rsc->setProgramVertex((ProgramVertex *)tmp.get());
319}
320
321static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
322    SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
323}
324
325static void SC_DrawPath(Path *p) {
326    Context *rsc = RsdCpuReference::getTlsContext();
327    rsdPathDraw(rsc, p);
328}
329
330static void SC_DrawMesh(Mesh *m) {
331    Context *rsc = RsdCpuReference::getTlsContext();
332    rsrDrawMesh(rsc, m);
333}
334
335static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
336    Context *rsc = RsdCpuReference::getTlsContext();
337    rsrDrawMeshPrimitive(rsc, m, primIndex);
338}
339
340static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
341    Context *rsc = RsdCpuReference::getTlsContext();
342    rsrDrawMeshPrimitiveRange(rsc, m, primIndex, start, len);
343}
344
345static void SC_MeshComputeBoundingBox(Mesh *m,
346                               float *minX, float *minY, float *minZ,
347                               float *maxX, float *maxY, float *maxZ) {
348    Context *rsc = RsdCpuReference::getTlsContext();
349    rsrMeshComputeBoundingBox(rsc, m, minX, minY, minZ, maxX, maxY, maxZ);
350}
351
352
353
354//////////////////////////////////////////////////////////////////////////////
355//
356//////////////////////////////////////////////////////////////////////////////
357
358
359static void SC_Color(float r, float g, float b, float a) {
360    Context *rsc = RsdCpuReference::getTlsContext();
361    rsrColor(rsc, r, g, b, a);
362}
363
364static void SC_Finish() {
365    Context *rsc = RsdCpuReference::getTlsContext();
366    rsdGLFinish(rsc);
367}
368
369static void SC_ClearColor(float r, float g, float b, float a) {
370    Context *rsc = RsdCpuReference::getTlsContext();
371    rsrPrepareClear(rsc);
372    rsdGLClearColor(rsc, r, g, b, a);
373}
374
375static void SC_ClearDepth(float v) {
376    Context *rsc = RsdCpuReference::getTlsContext();
377    rsrPrepareClear(rsc);
378    rsdGLClearDepth(rsc, v);
379}
380
381static uint32_t SC_GetWidth() {
382    Context *rsc = RsdCpuReference::getTlsContext();
383    return rsrGetWidth(rsc);
384}
385
386static uint32_t SC_GetHeight() {
387    Context *rsc = RsdCpuReference::getTlsContext();
388    return rsrGetHeight(rsc);
389}
390
391static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
392    Context *rsc = RsdCpuReference::getTlsContext();
393    rsrDrawTextAlloc(rsc, a, x, y);
394}
395
396static void SC_DrawText(const char *text, int x, int y) {
397    Context *rsc = RsdCpuReference::getTlsContext();
398    rsrDrawText(rsc, text, x, y);
399}
400
401static void SC_MeasureTextAlloc(Allocation *a,
402                         int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
403    Context *rsc = RsdCpuReference::getTlsContext();
404    rsrMeasureTextAlloc(rsc, a, left, right, top, bottom);
405}
406
407static void SC_MeasureText(const char *text,
408                    int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
409    Context *rsc = RsdCpuReference::getTlsContext();
410    rsrMeasureText(rsc, text, left, right, top, bottom);
411}
412
413static void SC_BindFont(Font *f) {
414    Context *rsc = RsdCpuReference::getTlsContext();
415    rsrBindFont(rsc, f);
416}
417
418static void SC_FontColor(float r, float g, float b, float a) {
419    Context *rsc = RsdCpuReference::getTlsContext();
420    rsrFontColor(rsc, r, g, b, a);
421}
422#endif
423
424
425//////////////////////////////////////////////////////////////////////////////
426//
427//////////////////////////////////////////////////////////////////////////////
428
429static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
430    Context *rsc = RsdCpuReference::getTlsContext();
431    rsrSetObject(rsc, dst, src);
432}
433
434static void SC_ClearObject(ObjectBase **dst) {
435    Context *rsc = RsdCpuReference::getTlsContext();
436    rsrClearObject(rsc, dst);
437}
438
439static bool SC_IsObject(const ObjectBase *src) {
440    Context *rsc = RsdCpuReference::getTlsContext();
441    return rsrIsObject(rsc, src);
442}
443
444
445
446
447static const Allocation * SC_GetAllocation(const void *ptr) {
448    Context *rsc = RsdCpuReference::getTlsContext();
449    const Script *sc = RsdCpuReference::getTlsScript();
450    return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
451}
452
453static void SC_ForEach_SAA(Script *target,
454                            Allocation *in,
455                            Allocation *out) {
456    Context *rsc = RsdCpuReference::getTlsContext();
457    rsrForEach(rsc, target, in, out, NULL, 0, NULL);
458}
459
460static void SC_ForEach_SAAU(Script *target,
461                            Allocation *in,
462                            Allocation *out,
463                            const void *usr) {
464    Context *rsc = RsdCpuReference::getTlsContext();
465    rsrForEach(rsc, target, in, out, usr, 0, NULL);
466}
467
468static void SC_ForEach_SAAUS(Script *target,
469                             Allocation *in,
470                             Allocation *out,
471                             const void *usr,
472                             const RsScriptCall *call) {
473    Context *rsc = RsdCpuReference::getTlsContext();
474    rsrForEach(rsc, target, in, out, usr, 0, call);
475}
476
477static void SC_ForEach_SAAUL(Script *target,
478                             Allocation *in,
479                             Allocation *out,
480                             const void *usr,
481                             uint32_t usrLen) {
482    Context *rsc = RsdCpuReference::getTlsContext();
483    rsrForEach(rsc, target, in, out, usr, usrLen, NULL);
484}
485
486static void SC_ForEach_SAAULS(Script *target,
487                              Allocation *in,
488                              Allocation *out,
489                              const void *usr,
490                              uint32_t usrLen,
491                              const RsScriptCall *call) {
492    Context *rsc = RsdCpuReference::getTlsContext();
493    rsrForEach(rsc, target, in, out, usr, usrLen, call);
494}
495
496
497
498//////////////////////////////////////////////////////////////////////////////
499// Time routines
500//////////////////////////////////////////////////////////////////////////////
501
502static float SC_GetDt() {
503    Context *rsc = RsdCpuReference::getTlsContext();
504    const Script *sc = RsdCpuReference::getTlsScript();
505    return rsrGetDt(rsc, sc);
506}
507
508#ifndef RS_COMPATIBILITY_LIB
509time_t SC_Time(time_t *timer) {
510    Context *rsc = RsdCpuReference::getTlsContext();
511    return rsrTime(rsc, timer);
512}
513#else
514static int SC_Time(int *timer) {
515    Context *rsc = RsdCpuReference::getTlsContext();
516    return rsrTime(rsc, (long*)timer);
517}
518#endif
519
520tm* SC_LocalTime(tm *local, time_t *timer) {
521    Context *rsc = RsdCpuReference::getTlsContext();
522    return rsrLocalTime(rsc, local, timer);
523}
524
525int64_t SC_UptimeMillis() {
526    Context *rsc = RsdCpuReference::getTlsContext();
527    return rsrUptimeMillis(rsc);
528}
529
530int64_t SC_UptimeNanos() {
531    Context *rsc = RsdCpuReference::getTlsContext();
532    return rsrUptimeNanos(rsc);
533}
534
535//////////////////////////////////////////////////////////////////////////////
536// Message routines
537//////////////////////////////////////////////////////////////////////////////
538
539static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
540    Context *rsc = RsdCpuReference::getTlsContext();
541    return rsrToClient(rsc, cmdID, data, len);
542}
543
544static uint32_t SC_ToClient(int cmdID) {
545    Context *rsc = RsdCpuReference::getTlsContext();
546    return rsrToClient(rsc, cmdID, NULL, 0);
547}
548
549static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
550    Context *rsc = RsdCpuReference::getTlsContext();
551    return rsrToClientBlocking(rsc, cmdID, data, len);
552}
553
554static uint32_t SC_ToClientBlocking(int cmdID) {
555    Context *rsc = RsdCpuReference::getTlsContext();
556    return rsrToClientBlocking(rsc, cmdID, NULL, 0);
557}
558
559
560static void * ElementAt1D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x) {
561    Context *rsc = RsdCpuReference::getTlsContext();
562    const Type *t = a->getType();
563    const Element *e = t->getElement();
564
565    char buf[256];
566    if (x >= t->getLODDimX(0)) {
567        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
568        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
569        return NULL;
570    }
571
572    if (vecSize != e->getVectorSize()) {
573        sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
574        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
575        return NULL;
576    }
577
578    if (dt != e->getType()) {
579        sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
580        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
581        return NULL;
582    }
583
584    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
585    const uint32_t eSize = e->getSizeBytes();
586    return &p[(eSize * x)];
587}
588
589static void * ElementAt2D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y) {
590    Context *rsc = RsdCpuReference::getTlsContext();
591    const Type *t = a->getType();
592    const Element *e = t->getElement();
593
594    char buf[256];
595    if (x >= t->getLODDimX(0)) {
596        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
597        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
598        return NULL;
599    }
600
601    if (y >= t->getLODDimY(0)) {
602        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
603        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
604        return NULL;
605    }
606
607    if (vecSize != e->getVectorSize()) {
608        sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
609        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
610        return NULL;
611    }
612
613    if (dt != e->getType()) {
614        sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
615        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
616        return NULL;
617    }
618
619    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
620    const uint32_t eSize = e->getSizeBytes();
621    const uint32_t stride = a->mHal.drvState.lod[0].stride;
622    return &p[(eSize * x) + (y * stride)];
623}
624
625static void * ElementAt3D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y, uint32_t z) {
626    Context *rsc = RsdCpuReference::getTlsContext();
627    const Type *t = a->getType();
628    const Element *e = t->getElement();
629
630    char buf[256];
631    if (x >= t->getLODDimX(0)) {
632        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
633        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
634        return NULL;
635    }
636
637    if (y >= t->getLODDimY(0)) {
638        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
639        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
640        return NULL;
641    }
642
643    if (z >= t->getLODDimZ(0)) {
644        sprintf(buf, "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0));
645        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
646        return NULL;
647    }
648
649    if (vecSize != e->getVectorSize()) {
650        sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
651        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
652        return NULL;
653    }
654
655    if (dt != e->getType()) {
656        sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
657        rsc->setError(RS_ERROR_FATAL_UNKNOWN, buf);
658        return NULL;
659    }
660
661    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
662    const uint32_t eSize = e->getSizeBytes();
663    const uint32_t stride = a->mHal.drvState.lod[0].stride;
664    return &p[(eSize * x) + (y * stride)];
665}
666
667#define ELEMENT_AT(T, DT, VS)                                               \
668    static void SC_SetElementAt1_##T(Allocation *a, T val, uint32_t x) {           \
669        void *r = ElementAt1D(a, DT, VS, x);                            \
670        if (r != NULL) ((T *)r)[0] = val;                               \
671        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
672    }                                                                   \
673    static void SC_SetElementAt2_##T(Allocation * a, T val, uint32_t x, uint32_t y) { \
674        void *r = ElementAt2D(a, DT, VS, x, y);            \
675        if (r != NULL) ((T *)r)[0] = val;                               \
676        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
677    }                                                                   \
678    static void SC_SetElementAt3_##T(Allocation * a, T val, uint32_t x, uint32_t y, uint32_t z) { \
679        void *r = ElementAt3D(a, DT, VS, x, y, z);         \
680        if (r != NULL) ((T *)r)[0] = val;                               \
681        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
682    }                                                                   \
683    static T SC_GetElementAt1_##T(Allocation * a, uint32_t x) {                  \
684        void *r = ElementAt1D(a, DT, VS, x);               \
685        if (r != NULL) return ((T *)r)[0];                              \
686        ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
687        return 0;                                                       \
688    }                                                                   \
689    static T SC_GetElementAt2_##T(Allocation * a, uint32_t x, uint32_t y) {      \
690        void *r = ElementAt2D(a, DT, VS, x, y);            \
691        if (r != NULL) return ((T *)r)[0];                              \
692        ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
693        return 0;                                                       \
694    }                                                                   \
695    static T SC_GetElementAt3_##T(Allocation * a, uint32_t x, uint32_t y, uint32_t z) { \
696        void *r = ElementAt3D(a, DT, VS, x, y, z);         \
697        if (r != NULL) return ((T *)r)[0];                              \
698        ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
699        return 0;                                                       \
700    }
701
702ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1)
703ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2)
704ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3)
705ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4)
706ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1)
707ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2)
708ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3)
709ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4)
710ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1)
711ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2)
712ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3)
713ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4)
714ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1)
715ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2)
716ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3)
717ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4)
718ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1)
719ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2)
720ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3)
721ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4)
722ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1)
723ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2)
724ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3)
725ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4)
726ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1)
727ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2)
728ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3)
729ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4)
730ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1)
731ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2)
732ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3)
733ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4)
734ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1)
735ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2)
736ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3)
737ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4)
738ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1)
739ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2)
740ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3)
741ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4)
742
743#undef ELEMENT_AT
744
745//////////////////////////////////////////////////////////////////////////////
746// Stub implementation
747//////////////////////////////////////////////////////////////////////////////
748
749// llvm name mangling ref
750//  <builtin-type> ::= v  # void
751//                 ::= b  # bool
752//                 ::= c  # char
753//                 ::= a  # signed char
754//                 ::= h  # unsigned char
755//                 ::= s  # short
756//                 ::= t  # unsigned short
757//                 ::= i  # int
758//                 ::= j  # unsigned int
759//                 ::= l  # long
760//                 ::= m  # unsigned long
761//                 ::= x  # long long, __int64
762//                 ::= y  # unsigned long long, __int64
763//                 ::= f  # float
764//                 ::= d  # double
765
766static RsdCpuReference::CpuSymbol gSyms[] = {
767    // Debug runtime
768    { "_Z20rsGetElementAt_uchar13rs_allocationcj", (void *)&SC_GetElementAt1_uchar, true },
769    { "_Z21rsGetElementAt_uchar213rs_allocationj", (void *)&SC_GetElementAt1_uchar2, true },
770    { "_Z21rsGetElementAt_uchar313rs_allocationj", (void *)&SC_GetElementAt1_uchar3, true },
771    { "_Z21rsGetElementAt_uchar413rs_allocationj", (void *)&SC_GetElementAt1_uchar4, true },
772    { "_Z20rsGetElementAt_uchar13rs_allocationjj", (void *)&SC_GetElementAt2_uchar, true },
773    { "_Z21rsGetElementAt_uchar213rs_allocationjj", (void *)&SC_GetElementAt2_uchar2, true },
774    { "_Z21rsGetElementAt_uchar313rs_allocationjj", (void *)&SC_GetElementAt2_uchar3, true },
775    { "_Z21rsGetElementAt_uchar413rs_allocationjj", (void *)&SC_GetElementAt2_uchar4, true },
776    { "_Z20rsGetElementAt_uchar13rs_allocationjjj", (void *)&SC_GetElementAt3_uchar, true },
777    { "_Z21rsGetElementAt_uchar213rs_allocationjjj", (void *)&SC_GetElementAt3_uchar2, true },
778    { "_Z21rsGetElementAt_uchar313rs_allocationjjj", (void *)&SC_GetElementAt3_uchar3, true },
779    { "_Z21rsGetElementAt_uchar413rs_allocationjjj", (void *)&SC_GetElementAt3_uchar4, true },
780
781    { "_Z19rsGetElementAt_char13rs_allocationj", (void *)&SC_GetElementAt1_char, true },
782    { "_Z20rsGetElementAt_char213rs_allocationj", (void *)&SC_GetElementAt1_char2, true },
783    { "_Z20rsGetElementAt_char313rs_allocationj", (void *)&SC_GetElementAt1_char3, true },
784    { "_Z20rsGetElementAt_char413rs_allocationj", (void *)&SC_GetElementAt1_char4, true },
785    { "_Z19rsGetElementAt_char13rs_allocationjj", (void *)&SC_GetElementAt2_char, true },
786    { "_Z20rsGetElementAt_char213rs_allocationjj", (void *)&SC_GetElementAt2_char2, true },
787    { "_Z20rsGetElementAt_char313rs_allocationjj", (void *)&SC_GetElementAt2_char3, true },
788    { "_Z20rsGetElementAt_char413rs_allocationjj", (void *)&SC_GetElementAt2_char4, true },
789    { "_Z19rsGetElementAt_char13rs_allocationjjj", (void *)&SC_GetElementAt3_char, true },
790    { "_Z20rsGetElementAt_char213rs_allocationjjj", (void *)&SC_GetElementAt3_char2, true },
791    { "_Z20rsGetElementAt_char313rs_allocationjjj", (void *)&SC_GetElementAt3_char3, true },
792    { "_Z20rsGetElementAt_char413rs_allocationjjj", (void *)&SC_GetElementAt3_char4, true },
793
794    { "_Z21rsGetElementAt_ushort13rs_allocationcj", (void *)&SC_GetElementAt1_ushort, true },
795    { "_Z22rsGetElementAt_ushort213rs_allocationj", (void *)&SC_GetElementAt1_ushort2, true },
796    { "_Z22rsGetElementAt_ushort313rs_allocationj", (void *)&SC_GetElementAt1_ushort3, true },
797    { "_Z22rsGetElementAt_ushort413rs_allocationj", (void *)&SC_GetElementAt1_ushort4, true },
798    { "_Z21rsGetElementAt_ushort13rs_allocationjj", (void *)&SC_GetElementAt2_ushort, true },
799    { "_Z22rsGetElementAt_ushort213rs_allocationjj", (void *)&SC_GetElementAt2_ushort2, true },
800    { "_Z22rsGetElementAt_ushort313rs_allocationjj", (void *)&SC_GetElementAt2_ushort3, true },
801    { "_Z22rsGetElementAt_ushort413rs_allocationjj", (void *)&SC_GetElementAt2_ushort4, true },
802    { "_Z21rsGetElementAt_ushort13rs_allocationjjj", (void *)&SC_GetElementAt3_ushort, true },
803    { "_Z22rsGetElementAt_ushort213rs_allocationjjj", (void *)&SC_GetElementAt3_ushort2, true },
804    { "_Z22rsGetElementAt_ushort313rs_allocationjjj", (void *)&SC_GetElementAt3_ushort3, true },
805    { "_Z22rsGetElementAt_ushort413rs_allocationjjj", (void *)&SC_GetElementAt3_ushort4, true },
806
807    { "_Z20rsGetElementAt_short13rs_allocationj", (void *)&SC_GetElementAt1_short, true },
808    { "_Z21rsGetElementAt_short213rs_allocationj", (void *)&SC_GetElementAt1_short2, true },
809    { "_Z21rsGetElementAt_short313rs_allocationj", (void *)&SC_GetElementAt1_short3, true },
810    { "_Z21rsGetElementAt_short413rs_allocationj", (void *)&SC_GetElementAt1_short4, true },
811    { "_Z20rsGetElementAt_short13rs_allocationjj", (void *)&SC_GetElementAt2_short, true },
812    { "_Z21rsGetElementAt_short213rs_allocationjj", (void *)&SC_GetElementAt2_short2, true },
813    { "_Z21rsGetElementAt_short313rs_allocationjj", (void *)&SC_GetElementAt2_short3, true },
814    { "_Z21rsGetElementAt_short413rs_allocationjj", (void *)&SC_GetElementAt2_short4, true },
815    { "_Z20rsGetElementAt_short13rs_allocationjjj", (void *)&SC_GetElementAt3_short, true },
816    { "_Z21rsGetElementAt_short213rs_allocationjjj", (void *)&SC_GetElementAt3_short2, true },
817    { "_Z21rsGetElementAt_short313rs_allocationjjj", (void *)&SC_GetElementAt3_short3, true },
818    { "_Z21rsGetElementAt_short413rs_allocationjjj", (void *)&SC_GetElementAt3_short4, true },
819
820    { "_Z19rsGetElementAt_uint13rs_allocationcj", (void *)&SC_GetElementAt1_uint, true },
821    { "_Z20rsGetElementAt_uint213rs_allocationj", (void *)&SC_GetElementAt1_uint2, true },
822    { "_Z20rsGetElementAt_uint313rs_allocationj", (void *)&SC_GetElementAt1_uint3, true },
823    { "_Z20rsGetElementAt_uint413rs_allocationj", (void *)&SC_GetElementAt1_uint4, true },
824    { "_Z19rsGetElementAt_uint13rs_allocationjj", (void *)&SC_GetElementAt2_uint, true },
825    { "_Z20rsGetElementAt_uint213rs_allocationjj", (void *)&SC_GetElementAt2_uint2, true },
826    { "_Z20rsGetElementAt_uint313rs_allocationjj", (void *)&SC_GetElementAt2_uint3, true },
827    { "_Z20rsGetElementAt_uint413rs_allocationjj", (void *)&SC_GetElementAt2_uint4, true },
828    { "_Z19rsGetElementAt_uint13rs_allocationjjj", (void *)&SC_GetElementAt3_uint, true },
829    { "_Z20rsGetElementAt_uint213rs_allocationjjj", (void *)&SC_GetElementAt3_uint2, true },
830    { "_Z20rsGetElementAt_uint313rs_allocationjjj", (void *)&SC_GetElementAt3_uint3, true },
831    { "_Z20rsGetElementAt_uint413rs_allocationjjj", (void *)&SC_GetElementAt3_uint4, true },
832
833    { "_Z18rsGetElementAt_int13rs_allocationj", (void *)&SC_GetElementAt1_int, true },
834    { "_Z19rsGetElementAt_int213rs_allocationj", (void *)&SC_GetElementAt1_int2, true },
835    { "_Z19rsGetElementAt_int313rs_allocationj", (void *)&SC_GetElementAt1_int3, true },
836    { "_Z19rsGetElementAt_int413rs_allocationj", (void *)&SC_GetElementAt1_int4, true },
837    { "_Z18rsGetElementAt_int13rs_allocationjj", (void *)&SC_GetElementAt2_int, true },
838    { "_Z19rsGetElementAt_int213rs_allocationjj", (void *)&SC_GetElementAt2_int2, true },
839    { "_Z19rsGetElementAt_int313rs_allocationjj", (void *)&SC_GetElementAt2_int3, true },
840    { "_Z19rsGetElementAt_int413rs_allocationjj", (void *)&SC_GetElementAt2_int4, true },
841    { "_Z18rsGetElementAt_int13rs_allocationjjj", (void *)&SC_GetElementAt3_int, true },
842    { "_Z19rsGetElementAt_int213rs_allocationjjj", (void *)&SC_GetElementAt3_int2, true },
843    { "_Z19rsGetElementAt_int313rs_allocationjjj", (void *)&SC_GetElementAt3_int3, true },
844    { "_Z19rsGetElementAt_int413rs_allocationjjj", (void *)&SC_GetElementAt3_int4, true },
845
846    { "_Z20rsGetElementAt_ulong13rs_allocationcj", (void *)&SC_GetElementAt1_ulong, true },
847    { "_Z21rsGetElementAt_ulong213rs_allocationj", (void *)&SC_GetElementAt1_ulong2, true },
848    { "_Z21rsGetElementAt_ulong313rs_allocationj", (void *)&SC_GetElementAt1_ulong3, true },
849    { "_Z21rsGetElementAt_ulong413rs_allocationj", (void *)&SC_GetElementAt1_ulong4, true },
850    { "_Z20rsGetElementAt_ulong13rs_allocationjj", (void *)&SC_GetElementAt2_ulong, true },
851    { "_Z21rsGetElementAt_ulong213rs_allocationjj", (void *)&SC_GetElementAt2_ulong2, true },
852    { "_Z21rsGetElementAt_ulong313rs_allocationjj", (void *)&SC_GetElementAt2_ulong3, true },
853    { "_Z21rsGetElementAt_ulong413rs_allocationjj", (void *)&SC_GetElementAt2_ulong4, true },
854    { "_Z20rsGetElementAt_ulong13rs_allocationjjj", (void *)&SC_GetElementAt3_ulong, true },
855    { "_Z21rsGetElementAt_ulong213rs_allocationjjj", (void *)&SC_GetElementAt3_ulong2, true },
856    { "_Z21rsGetElementAt_ulong313rs_allocationjjj", (void *)&SC_GetElementAt3_ulong3, true },
857    { "_Z21rsGetElementAt_ulong413rs_allocationjjj", (void *)&SC_GetElementAt3_ulong4, true },
858
859    { "_Z19rsGetElementAt_long13rs_allocationj", (void *)&SC_GetElementAt1_long, true },
860    { "_Z20rsGetElementAt_long213rs_allocationj", (void *)&SC_GetElementAt1_long2, true },
861    { "_Z20rsGetElementAt_long313rs_allocationj", (void *)&SC_GetElementAt1_long3, true },
862    { "_Z20rsGetElementAt_long413rs_allocationj", (void *)&SC_GetElementAt1_long4, true },
863    { "_Z19rsGetElementAt_long13rs_allocationjj", (void *)&SC_GetElementAt2_long, true },
864    { "_Z20rsGetElementAt_long213rs_allocationjj", (void *)&SC_GetElementAt2_long2, true },
865    { "_Z20rsGetElementAt_long313rs_allocationjj", (void *)&SC_GetElementAt2_long3, true },
866    { "_Z20rsGetElementAt_long413rs_allocationjj", (void *)&SC_GetElementAt2_long4, true },
867    { "_Z19rsGetElementAt_long13rs_allocationjjj", (void *)&SC_GetElementAt3_long, true },
868    { "_Z20rsGetElementAt_long213rs_allocationjjj", (void *)&SC_GetElementAt3_long2, true },
869    { "_Z20rsGetElementAt_long313rs_allocationjjj", (void *)&SC_GetElementAt3_long3, true },
870    { "_Z20rsGetElementAt_long413rs_allocationjjj", (void *)&SC_GetElementAt3_long4, true },
871
872    { "_Z20rsGetElementAt_float13rs_allocationcj", (void *)&SC_GetElementAt1_float, true },
873    { "_Z21rsGetElementAt_float213rs_allocationj", (void *)&SC_GetElementAt1_float2, true },
874    { "_Z21rsGetElementAt_float313rs_allocationj", (void *)&SC_GetElementAt1_float3, true },
875    { "_Z21rsGetElementAt_float413rs_allocationj", (void *)&SC_GetElementAt1_float4, true },
876    { "_Z20rsGetElementAt_float13rs_allocationjj", (void *)&SC_GetElementAt2_float, true },
877    { "_Z21rsGetElementAt_float213rs_allocationjj", (void *)&SC_GetElementAt2_float2, true },
878    { "_Z21rsGetElementAt_float313rs_allocationjj", (void *)&SC_GetElementAt2_float3, true },
879    { "_Z21rsGetElementAt_float413rs_allocationjj", (void *)&SC_GetElementAt2_float4, true },
880    { "_Z20rsGetElementAt_float13rs_allocationjjj", (void *)&SC_GetElementAt3_float, true },
881    { "_Z21rsGetElementAt_float213rs_allocationjjj", (void *)&SC_GetElementAt3_float2, true },
882    { "_Z21rsGetElementAt_float313rs_allocationjjj", (void *)&SC_GetElementAt3_float3, true },
883    { "_Z21rsGetElementAt_float413rs_allocationjjj", (void *)&SC_GetElementAt3_float4, true },
884
885    { "_Z21rsGetElementAt_double13rs_allocationcj", (void *)&SC_GetElementAt1_double, true },
886    { "_Z22rsGetElementAt_double213rs_allocationj", (void *)&SC_GetElementAt1_double2, true },
887    { "_Z22rsGetElementAt_double313rs_allocationj", (void *)&SC_GetElementAt1_double3, true },
888    { "_Z22rsGetElementAt_double413rs_allocationj", (void *)&SC_GetElementAt1_double4, true },
889    { "_Z21rsGetElementAt_double13rs_allocationjj", (void *)&SC_GetElementAt2_double, true },
890    { "_Z22rsGetElementAt_double213rs_allocationjj", (void *)&SC_GetElementAt2_double2, true },
891    { "_Z22rsGetElementAt_double313rs_allocationjj", (void *)&SC_GetElementAt2_double3, true },
892    { "_Z22rsGetElementAt_double413rs_allocationjj", (void *)&SC_GetElementAt2_double4, true },
893    { "_Z21rsGetElementAt_double13rs_allocationjjj", (void *)&SC_GetElementAt3_double, true },
894    { "_Z22rsGetElementAt_double213rs_allocationjjj", (void *)&SC_GetElementAt3_double2, true },
895    { "_Z22rsGetElementAt_double313rs_allocationjjj", (void *)&SC_GetElementAt3_double3, true },
896    { "_Z22rsGetElementAt_double413rs_allocationjjj", (void *)&SC_GetElementAt3_double4, true },
897
898
899
900    { "_Z20rsSetElementAt_uchar13rs_allocationhj", (void *)&SC_SetElementAt1_uchar, true },
901    { "_Z21rsSetElementAt_uchar213rs_allocationDv2_hj", (void *)&SC_SetElementAt1_uchar2, true },
902    { "_Z21rsSetElementAt_uchar313rs_allocationDv3_hj", (void *)&SC_SetElementAt1_uchar3, true },
903    { "_Z21rsSetElementAt_uchar413rs_allocationDv4_hj", (void *)&SC_SetElementAt1_uchar4, true },
904    { "_Z20rsSetElementAt_uchar13rs_allocationhjj", (void *)&SC_SetElementAt2_uchar, true },
905    { "_Z21rsSetElementAt_uchar213rs_allocationDv2_hjj", (void *)&SC_SetElementAt2_uchar2, true },
906    { "_Z21rsSetElementAt_uchar313rs_allocationDv3_hjj", (void *)&SC_SetElementAt2_uchar3, true },
907    { "_Z21rsSetElementAt_uchar413rs_allocationDv4_hjj", (void *)&SC_SetElementAt2_uchar4, true },
908    { "_Z20rsSetElementAt_uchar13rs_allocationhjjj", (void *)&SC_SetElementAt3_uchar, true },
909    { "_Z21rsSetElementAt_uchar213rs_allocationDv2_hjjj", (void *)&SC_SetElementAt3_uchar2, true },
910    { "_Z21rsSetElementAt_uchar313rs_allocationDv3_hjjj", (void *)&SC_SetElementAt3_uchar3, true },
911    { "_Z21rsSetElementAt_uchar413rs_allocationDv4_hjjj", (void *)&SC_SetElementAt3_uchar4, true },
912
913    { "_Z19rsSetElementAt_char13rs_allocationcj", (void *)&SC_SetElementAt1_char, true },
914    { "_Z20rsSetElementAt_char213rs_allocationDv2_cj", (void *)&SC_SetElementAt1_char2, true },
915    { "_Z20rsSetElementAt_char313rs_allocationDv3_cj", (void *)&SC_SetElementAt1_char3, true },
916    { "_Z20rsSetElementAt_char413rs_allocationDv4_cj", (void *)&SC_SetElementAt1_char4, true },
917    { "_Z19rsSetElementAt_char13rs_allocationcjj", (void *)&SC_SetElementAt2_char, true },
918    { "_Z20rsSetElementAt_char213rs_allocationDv2_cjj", (void *)&SC_SetElementAt2_char2, true },
919    { "_Z20rsSetElementAt_char313rs_allocationDv3_cjj", (void *)&SC_SetElementAt2_char3, true },
920    { "_Z20rsSetElementAt_char413rs_allocationDv4_cjj", (void *)&SC_SetElementAt2_char4, true },
921    { "_Z19rsSetElementAt_char13rs_allocationcjjj", (void *)&SC_SetElementAt3_char, true },
922    { "_Z20rsSetElementAt_char213rs_allocationDv2_cjjj", (void *)&SC_SetElementAt3_char2, true },
923    { "_Z20rsSetElementAt_char313rs_allocationDv3_cjjj", (void *)&SC_SetElementAt3_char3, true },
924    { "_Z20rsSetElementAt_char413rs_allocationDv4_cjjj", (void *)&SC_SetElementAt3_char4, true },
925
926    { "_Z21rsSetElementAt_ushort13rs_allocationht", (void *)&SC_SetElementAt1_ushort, true },
927    { "_Z22rsSetElementAt_ushort213rs_allocationDv2_tj", (void *)&SC_SetElementAt1_ushort2, true },
928    { "_Z22rsSetElementAt_ushort313rs_allocationDv3_tj", (void *)&SC_SetElementAt1_ushort3, true },
929    { "_Z22rsSetElementAt_ushort413rs_allocationDv4_tj", (void *)&SC_SetElementAt1_ushort4, true },
930    { "_Z21rsSetElementAt_ushort13rs_allocationtjj", (void *)&SC_SetElementAt2_ushort, true },
931    { "_Z22rsSetElementAt_ushort213rs_allocationDv2_tjj", (void *)&SC_SetElementAt2_ushort2, true },
932    { "_Z22rsSetElementAt_ushort313rs_allocationDv3_tjj", (void *)&SC_SetElementAt2_ushort3, true },
933    { "_Z22rsSetElementAt_ushort413rs_allocationDv4_tjj", (void *)&SC_SetElementAt2_ushort4, true },
934    { "_Z21rsSetElementAt_ushort13rs_allocationtjjj", (void *)&SC_SetElementAt3_ushort, true },
935    { "_Z22rsSetElementAt_ushort213rs_allocationDv2_tjjj", (void *)&SC_SetElementAt3_ushort2, true },
936    { "_Z22rsSetElementAt_ushort313rs_allocationDv3_tjjj", (void *)&SC_SetElementAt3_ushort3, true },
937    { "_Z22rsSetElementAt_ushort413rs_allocationDv4_tjjj", (void *)&SC_SetElementAt3_ushort4, true },
938
939    { "_Z20rsSetElementAt_short13rs_allocationsj", (void *)&SC_SetElementAt1_short, true },
940    { "_Z21rsSetElementAt_short213rs_allocationDv2_sj", (void *)&SC_SetElementAt1_short2, true },
941    { "_Z21rsSetElementAt_short313rs_allocationDv3_sj", (void *)&SC_SetElementAt1_short3, true },
942    { "_Z21rsSetElementAt_short413rs_allocationDv4_sj", (void *)&SC_SetElementAt1_short4, true },
943    { "_Z20rsSetElementAt_short13rs_allocationsjj", (void *)&SC_SetElementAt2_short, true },
944    { "_Z21rsSetElementAt_short213rs_allocationDv2_sjj", (void *)&SC_SetElementAt2_short2, true },
945    { "_Z21rsSetElementAt_short313rs_allocationDv3_sjj", (void *)&SC_SetElementAt2_short3, true },
946    { "_Z21rsSetElementAt_short413rs_allocationDv4_sjj", (void *)&SC_SetElementAt2_short4, true },
947    { "_Z20rsSetElementAt_short13rs_allocationsjjj", (void *)&SC_SetElementAt3_short, true },
948    { "_Z21rsSetElementAt_short213rs_allocationDv2_sjjj", (void *)&SC_SetElementAt3_short2, true },
949    { "_Z21rsSetElementAt_short313rs_allocationDv3_sjjj", (void *)&SC_SetElementAt3_short3, true },
950    { "_Z21rsSetElementAt_short413rs_allocationDv4_sjjj", (void *)&SC_SetElementAt3_short4, true },
951
952    { "_Z19rsSetElementAt_uint13rs_allocationjj", (void *)&SC_SetElementAt1_uint, true },
953    { "_Z20rsSetElementAt_uint213rs_allocationDv2_jj", (void *)&SC_SetElementAt1_uint2, true },
954    { "_Z20rsSetElementAt_uint313rs_allocationDv3_jj", (void *)&SC_SetElementAt1_uint3, true },
955    { "_Z20rsSetElementAt_uint413rs_allocationDv4_jj", (void *)&SC_SetElementAt1_uint4, true },
956    { "_Z19rsSetElementAt_uint13rs_allocationjjj", (void *)&SC_SetElementAt2_uint, true },
957    { "_Z20rsSetElementAt_uint213rs_allocationDv2_jjj", (void *)&SC_SetElementAt2_uint2, true },
958    { "_Z20rsSetElementAt_uint313rs_allocationDv3_jjj", (void *)&SC_SetElementAt2_uint3, true },
959    { "_Z20rsSetElementAt_uint413rs_allocationDv4_jjj", (void *)&SC_SetElementAt2_uint4, true },
960    { "_Z19rsSetElementAt_uint13rs_allocationjjjj", (void *)&SC_SetElementAt3_uint, true },
961    { "_Z20rsSetElementAt_uint213rs_allocationDv2_jjjj", (void *)&SC_SetElementAt3_uint2, true },
962    { "_Z20rsSetElementAt_uint313rs_allocationDv3_jjjj", (void *)&SC_SetElementAt3_uint3, true },
963    { "_Z20rsSetElementAt_uint413rs_allocationDv4_jjjj", (void *)&SC_SetElementAt3_uint4, true },
964
965    { "_Z19rsSetElementAt_int13rs_allocationij", (void *)&SC_SetElementAt1_int, true },
966    { "_Z19rsSetElementAt_int213rs_allocationDv2_ij", (void *)&SC_SetElementAt1_int2, true },
967    { "_Z19rsSetElementAt_int313rs_allocationDv3_ij", (void *)&SC_SetElementAt1_int3, true },
968    { "_Z19rsSetElementAt_int413rs_allocationDv4_ij", (void *)&SC_SetElementAt1_int4, true },
969    { "_Z18rsSetElementAt_int13rs_allocationijj", (void *)&SC_SetElementAt2_int, true },
970    { "_Z19rsSetElementAt_int213rs_allocationDv2_ijj", (void *)&SC_SetElementAt2_int2, true },
971    { "_Z19rsSetElementAt_int313rs_allocationDv3_ijj", (void *)&SC_SetElementAt2_int3, true },
972    { "_Z19rsSetElementAt_int413rs_allocationDv4_ijj", (void *)&SC_SetElementAt2_int4, true },
973    { "_Z18rsSetElementAt_int13rs_allocationijjj", (void *)&SC_SetElementAt3_int, true },
974    { "_Z19rsSetElementAt_int213rs_allocationDv2_ijjj", (void *)&SC_SetElementAt3_int2, true },
975    { "_Z19rsSetElementAt_int313rs_allocationDv3_ijjj", (void *)&SC_SetElementAt3_int3, true },
976    { "_Z19rsSetElementAt_int413rs_allocationDv4_ijjj", (void *)&SC_SetElementAt3_int4, true },
977
978    { "_Z20rsSetElementAt_ulong13rs_allocationmt", (void *)&SC_SetElementAt1_ulong, true },
979    { "_Z21rsSetElementAt_ulong213rs_allocationDv2_mj", (void *)&SC_SetElementAt1_ulong2, true },
980    { "_Z21rsSetElementAt_ulong313rs_allocationDv3_mj", (void *)&SC_SetElementAt1_ulong3, true },
981    { "_Z21rsSetElementAt_ulong413rs_allocationDv4_mj", (void *)&SC_SetElementAt1_ulong4, true },
982    { "_Z20rsSetElementAt_ulong13rs_allocationmjj", (void *)&SC_SetElementAt2_ulong, true },
983    { "_Z21rsSetElementAt_ulong213rs_allocationDv2_mjj", (void *)&SC_SetElementAt2_ulong2, true },
984    { "_Z21rsSetElementAt_ulong313rs_allocationDv3_mjj", (void *)&SC_SetElementAt2_ulong3, true },
985    { "_Z21rsSetElementAt_ulong413rs_allocationDv4_mjj", (void *)&SC_SetElementAt2_ulong4, true },
986    { "_Z20rsSetElementAt_ulong13rs_allocationmjjj", (void *)&SC_SetElementAt3_ulong, true },
987    { "_Z21rsSetElementAt_ulong213rs_allocationDv2_mjjj", (void *)&SC_SetElementAt3_ulong2, true },
988    { "_Z21rsSetElementAt_ulong313rs_allocationDv3_mjjj", (void *)&SC_SetElementAt3_ulong3, true },
989    { "_Z21rsSetElementAt_ulong413rs_allocationDv4_mjjj", (void *)&SC_SetElementAt3_ulong4, true },
990
991    { "_Z19rsSetElementAt_long13rs_allocationlj", (void *)&SC_SetElementAt1_long, true },
992    { "_Z20rsSetElementAt_long213rs_allocationDv2_lj", (void *)&SC_SetElementAt1_long2, true },
993    { "_Z20rsSetElementAt_long313rs_allocationDv3_lj", (void *)&SC_SetElementAt1_long3, true },
994    { "_Z20rsSetElementAt_long413rs_allocationDv4_lj", (void *)&SC_SetElementAt1_long4, true },
995    { "_Z19rsSetElementAt_long13rs_allocationljj", (void *)&SC_SetElementAt2_long, true },
996    { "_Z20rsSetElementAt_long213rs_allocationDv2_ljj", (void *)&SC_SetElementAt2_long2, true },
997    { "_Z20rsSetElementAt_long313rs_allocationDv3_ljj", (void *)&SC_SetElementAt2_long3, true },
998    { "_Z20rsSetElementAt_long413rs_allocationDv4_ljj", (void *)&SC_SetElementAt2_long4, true },
999    { "_Z19rsSetElementAt_long13rs_allocationljjj", (void *)&SC_SetElementAt3_long, true },
1000    { "_Z20rsSetElementAt_long213rs_allocationDv2_ljjj", (void *)&SC_SetElementAt3_long2, true },
1001    { "_Z20rsSetElementAt_long313rs_allocationDv3_ljjj", (void *)&SC_SetElementAt3_long3, true },
1002    { "_Z20rsSetElementAt_long413rs_allocationDv4_ljjj", (void *)&SC_SetElementAt3_long4, true },
1003
1004    { "_Z20rsSetElementAt_float13rs_allocationft", (void *)&SC_SetElementAt1_float, true },
1005    { "_Z21rsSetElementAt_float213rs_allocationDv2_fj", (void *)&SC_SetElementAt1_float2, true },
1006    { "_Z21rsSetElementAt_float313rs_allocationDv3_fj", (void *)&SC_SetElementAt1_float3, true },
1007    { "_Z21rsSetElementAt_float413rs_allocationDv4_fj", (void *)&SC_SetElementAt1_float4, true },
1008    { "_Z20rsSetElementAt_float13rs_allocationfjj", (void *)&SC_SetElementAt2_float, true },
1009    { "_Z21rsSetElementAt_float213rs_allocationDv2_fjj", (void *)&SC_SetElementAt2_float2, true },
1010    { "_Z21rsSetElementAt_float313rs_allocationDv3_fjj", (void *)&SC_SetElementAt2_float3, true },
1011    { "_Z21rsSetElementAt_float413rs_allocationDv4_fjj", (void *)&SC_SetElementAt2_float4, true },
1012    { "_Z20rsSetElementAt_float13rs_allocationfjjj", (void *)&SC_SetElementAt3_float, true },
1013    { "_Z21rsSetElementAt_float213rs_allocationDv2_fjjj", (void *)&SC_SetElementAt3_float2, true },
1014    { "_Z21rsSetElementAt_float313rs_allocationDv3_fjjj", (void *)&SC_SetElementAt3_float3, true },
1015    { "_Z21rsSetElementAt_float413rs_allocationDv4_fjjj", (void *)&SC_SetElementAt3_float4, true },
1016
1017    { "_Z21rsSetElementAt_double13rs_allocationdt", (void *)&SC_SetElementAt1_double, true },
1018    { "_Z22rsSetElementAt_double213rs_allocationDv2_dj", (void *)&SC_SetElementAt1_double2, true },
1019    { "_Z22rsSetElementAt_double313rs_allocationDv3_dj", (void *)&SC_SetElementAt1_double3, true },
1020    { "_Z22rsSetElementAt_double413rs_allocationDv4_dj", (void *)&SC_SetElementAt1_double4, true },
1021    { "_Z21rsSetElementAt_double13rs_allocationdjj", (void *)&SC_SetElementAt2_double, true },
1022    { "_Z22rsSetElementAt_double213rs_allocationDv2_djj", (void *)&SC_SetElementAt2_double2, true },
1023    { "_Z22rsSetElementAt_double313rs_allocationDv3_djj", (void *)&SC_SetElementAt2_double3, true },
1024    { "_Z22rsSetElementAt_double413rs_allocationDv4_djj", (void *)&SC_SetElementAt2_double4, true },
1025    { "_Z21rsSetElementAt_double13rs_allocationdjjj", (void *)&SC_SetElementAt3_double, true },
1026    { "_Z22rsSetElementAt_double213rs_allocationDv2_djjj", (void *)&SC_SetElementAt3_double2, true },
1027    { "_Z22rsSetElementAt_double313rs_allocationDv3_djjj", (void *)&SC_SetElementAt3_double3, true },
1028    { "_Z22rsSetElementAt_double413rs_allocationDv4_djjj", (void *)&SC_SetElementAt3_double4, true },
1029
1030
1031    // Refcounting
1032    { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
1033    { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
1034    { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
1035
1036    { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
1037    { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
1038    { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
1039
1040    { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
1041    { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
1042    { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
1043
1044    { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
1045    { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
1046    { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
1047
1048    { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
1049    { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
1050    { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
1051
1052    { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
1053    { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
1054    { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
1055
1056    { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
1057    { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
1058    { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
1059
1060    { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
1061    { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
1062    { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
1063
1064    { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
1065    { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
1066    { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
1067
1068    { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
1069    { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
1070    { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
1071
1072    { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
1073    { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
1074    { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
1075
1076    { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
1077    { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
1078    { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
1079
1080    // Allocation ops
1081    { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
1082    { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
1083    { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
1084    { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
1085    { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
1086#ifndef RS_COMPATIBILITY_LIB
1087    { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
1088    { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
1089#endif
1090    { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
1091    { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
1092
1093    // Messaging
1094
1095    { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
1096    { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
1097    { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
1098    { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
1099#ifndef RS_COMPATIBILITY_LIB
1100    { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
1101    { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
1102    { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
1103    { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
1104    { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
1105    { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
1106    { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
1107    { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
1108
1109    { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
1110    { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
1111    { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
1112
1113    { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
1114
1115    { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
1116
1117    { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
1118    { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
1119
1120
1121    { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
1122    { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
1123    { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
1124    { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
1125
1126    { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
1127    { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
1128    { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
1129    { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
1130
1131    { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
1132
1133    { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
1134    { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
1135
1136    { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
1137    { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
1138    { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
1139    { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
1140
1141    { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
1142    { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
1143
1144    { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
1145    { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
1146    { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
1147    { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
1148    { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
1149#endif // RS_COMPATIBILITY_LIB
1150
1151    { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
1152    { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
1153    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
1154    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
1155    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
1156
1157    // time
1158    { "_Z6rsTimePi", (void *)&SC_Time, true },
1159    { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
1160    { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
1161    { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
1162    { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
1163
1164    // misc
1165#ifndef RS_COMPATIBILITY_LIB
1166    { "_Z5colorffff", (void *)&SC_Color, false },
1167    { "_Z9rsgFinishv", (void *)&SC_Finish, false },
1168#endif
1169
1170    { NULL, NULL, false }
1171};
1172
1173#ifdef RS_COMPATIBILITY_LIB
1174
1175//////////////////////////////////////////////////////////////////////////////
1176// Compatibility Library entry points
1177//////////////////////////////////////////////////////////////////////////////
1178
1179bool rsIsObject(rs_element src) {
1180    return SC_IsObject((ObjectBase*)src.p);
1181}
1182
1183#define CLEAR_SET_OBJ(t) \
1184    void __attribute__((overloadable)) rsClearObject(t *dst) { \
1185    return SC_ClearObject((ObjectBase**) dst); \
1186    } \
1187    void __attribute__((overloadable)) rsSetObject(t *dst, t src) { \
1188    return SC_SetObject((ObjectBase**) dst, (ObjectBase*) src.p); \
1189    }
1190
1191CLEAR_SET_OBJ(rs_element)
1192CLEAR_SET_OBJ(rs_type)
1193CLEAR_SET_OBJ(rs_allocation)
1194CLEAR_SET_OBJ(rs_sampler)
1195CLEAR_SET_OBJ(rs_script)
1196#undef CLEAR_SET_OBJ
1197
1198const Allocation * rsGetAllocation(const void *ptr) {
1199    return SC_GetAllocation(ptr);
1200}
1201
1202void __attribute__((overloadable)) rsForEach(rs_script script,
1203                                             rs_allocation in,
1204                                             rs_allocation out,
1205                                             const void *usr,
1206                                             const rs_script_call *call) {
1207    return SC_ForEach_SAAUS((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p, usr, (RsScriptCall*)call);
1208}
1209
1210void __attribute__((overloadable)) rsForEach(rs_script script,
1211                                             rs_allocation in,
1212                                             rs_allocation out,
1213                                             const void *usr,
1214                                             uint32_t usrLen,
1215                                             const rs_script_call *call) {
1216    return SC_ForEach_SAAULS((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p, usr, usrLen, (RsScriptCall*)call);
1217}
1218
1219int rsTime(int *timer) {
1220    return SC_Time(timer);
1221}
1222
1223rs_tm* rsLocaltime(rs_tm* local, const int *timer) {
1224    return (rs_tm*)(SC_LocalTime((tm*)local, (long*)timer));
1225}
1226
1227int64_t rsUptimeMillis() {
1228    Context *rsc = RsdCpuReference::getTlsContext();
1229    return rsrUptimeMillis(rsc);
1230}
1231
1232uint32_t rsSendToClientBlocking2(int cmdID, void *data, int len) {
1233    Context *rsc = RsdCpuReference::getTlsContext();
1234    return rsrToClientBlocking(rsc, cmdID, data, len);
1235}
1236
1237uint32_t rsSendToClientBlocking(int cmdID) {
1238    Context *rsc = RsdCpuReference::getTlsContext();
1239    return rsrToClientBlocking(rsc, cmdID, NULL, 0);
1240}
1241
1242static void SC_debugF(const char *s, float f) {
1243    ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
1244}
1245static void SC_debugFv2(const char *s, float f1, float f2) {
1246    ALOGD("%s {%f, %f}", s, f1, f2);
1247}
1248static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
1249    ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
1250}
1251static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
1252    ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
1253}
1254static void SC_debugF2(const char *s, float2 f) {
1255    ALOGD("%s {%f, %f}", s, f.x, f.y);
1256}
1257static void SC_debugF3(const char *s, float3 f) {
1258    ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
1259}
1260static void SC_debugF4(const char *s, float4 f) {
1261    ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
1262}
1263static void SC_debugD(const char *s, double d) {
1264    ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
1265}
1266static void SC_debugFM4v4(const char *s, const float *f) {
1267    ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
1268    ALOGD("%s  %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
1269    ALOGD("%s  %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
1270    ALOGD("%s  %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
1271}
1272static void SC_debugFM3v3(const char *s, const float *f) {
1273    ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
1274    ALOGD("%s  %f, %f, %f", s, f[1], f[4], f[7]);
1275    ALOGD("%s  %f, %f, %f}",s, f[2], f[5], f[8]);
1276}
1277static void SC_debugFM2v2(const char *s, const float *f) {
1278    ALOGD("%s {%f, %f", s, f[0], f[2]);
1279    ALOGD("%s  %f, %f}",s, f[1], f[3]);
1280}
1281static void SC_debugI8(const char *s, char c) {
1282    ALOGD("%s %hhd  0x%hhx", s, c, (unsigned char)c);
1283}
1284static void SC_debugC2(const char *s, char2 c) {
1285    ALOGD("%s {%hhd, %hhd}  0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
1286}
1287static void SC_debugC3(const char *s, char3 c) {
1288    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);
1289}
1290static void SC_debugC4(const char *s, char4 c) {
1291    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);
1292}
1293static void SC_debugU8(const char *s, unsigned char c) {
1294    ALOGD("%s %hhu  0x%hhx", s, c, c);
1295}
1296static void SC_debugUC2(const char *s, uchar2 c) {
1297    ALOGD("%s {%hhu, %hhu}  0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
1298}
1299static void SC_debugUC3(const char *s, uchar3 c) {
1300    ALOGD("%s {%hhu, %hhu, %hhu}  0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1301}
1302static void SC_debugUC4(const char *s, uchar4 c) {
1303    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);
1304}
1305static void SC_debugI16(const char *s, short c) {
1306    ALOGD("%s %hd  0x%hx", s, c, c);
1307}
1308static void SC_debugS2(const char *s, short2 c) {
1309    ALOGD("%s {%hd, %hd}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1310}
1311static void SC_debugS3(const char *s, short3 c) {
1312    ALOGD("%s {%hd, %hd, %hd}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1313}
1314static void SC_debugS4(const char *s, short4 c) {
1315    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);
1316}
1317static void SC_debugU16(const char *s, unsigned short c) {
1318    ALOGD("%s %hu  0x%hx", s, c, c);
1319}
1320static void SC_debugUS2(const char *s, ushort2 c) {
1321    ALOGD("%s {%hu, %hu}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1322}
1323static void SC_debugUS3(const char *s, ushort3 c) {
1324    ALOGD("%s {%hu, %hu, %hu}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1325}
1326static void SC_debugUS4(const char *s, ushort4 c) {
1327    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);
1328}
1329static void SC_debugI32(const char *s, int32_t i) {
1330    ALOGD("%s %d  0x%x", s, i, i);
1331}
1332static void SC_debugI2(const char *s, int2 i) {
1333    ALOGD("%s {%d, %d}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1334}
1335static void SC_debugI3(const char *s, int3 i) {
1336    ALOGD("%s {%d, %d, %d}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1337}
1338static void SC_debugI4(const char *s, int4 i) {
1339    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);
1340}
1341static void SC_debugU32(const char *s, uint32_t i) {
1342    ALOGD("%s %u  0x%x", s, i, i);
1343}
1344static void SC_debugUI2(const char *s, uint2 i) {
1345    ALOGD("%s {%u, %u}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1346}
1347static void SC_debugUI3(const char *s, uint3 i) {
1348    ALOGD("%s {%u, %u, %u}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1349}
1350static void SC_debugUI4(const char *s, uint4 i) {
1351    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);
1352}
1353static void SC_debugLL64(const char *s, long long ll) {
1354    ALOGD("%s %lld  0x%llx", s, ll, ll);
1355}
1356static void SC_debugL2(const char *s, long2 ll) {
1357    ALOGD("%s {%lld, %lld}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
1358}
1359static void SC_debugL3(const char *s, long3 ll) {
1360    ALOGD("%s {%lld, %lld, %lld}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
1361}
1362static void SC_debugL4(const char *s, long4 ll) {
1363    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);
1364}
1365static void SC_debugULL64(const char *s, unsigned long long ll) {
1366    ALOGD("%s %llu  0x%llx", s, ll, ll);
1367}
1368static void SC_debugUL2(const char *s, ulong2 ll) {
1369    ALOGD("%s {%llu, %llu}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
1370}
1371static void SC_debugUL3(const char *s, ulong3 ll) {
1372    ALOGD("%s {%llu, %llu, %llu}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
1373}
1374static void SC_debugUL4(const char *s, ulong4 ll) {
1375    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);
1376}
1377static void SC_debugP(const char *s, const void *p) {
1378    ALOGD("%s %p", s, p);
1379}
1380
1381// TODO: allocation ops, messaging, time
1382
1383void rsDebug(const char *s, float f) {
1384    SC_debugF(s, f);
1385}
1386
1387void rsDebug(const char *s, float f1, float f2) {
1388    SC_debugFv2(s, f1, f2);
1389}
1390
1391void rsDebug(const char *s, float f1, float f2, float f3) {
1392    SC_debugFv3(s, f1, f2, f3);
1393}
1394
1395void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
1396    SC_debugFv4(s, f1, f2, f3, f4);
1397}
1398
1399void rsDebug(const char *s, float2 f) {
1400    SC_debugF2(s, f);
1401}
1402
1403void rsDebug(const char *s, float3 f) {
1404    SC_debugF3(s, f);
1405}
1406
1407void rsDebug(const char *s, float4 f) {
1408    SC_debugF4(s, f);
1409}
1410
1411void rsDebug(const char *s, double d) {
1412    SC_debugD(s, d);
1413}
1414
1415void rsDebug(const char *s, rs_matrix4x4 *m) {
1416    SC_debugFM4v4(s, (float *) m);
1417}
1418
1419void rsDebug(const char *s, rs_matrix3x3 *m) {
1420    SC_debugFM3v3(s, (float *) m);
1421}
1422
1423void rsDebug(const char *s, rs_matrix2x2 *m) {
1424    SC_debugFM2v2(s, (float *) m);
1425}
1426
1427void rsDebug(const char *s, char c) {
1428    SC_debugI8(s, c);
1429}
1430
1431void rsDebug(const char *s, char2 c) {
1432    SC_debugC2(s, c);
1433}
1434
1435void rsDebug(const char *s, char3 c) {
1436    SC_debugC3(s, c);
1437}
1438
1439void rsDebug(const char *s, char4 c) {
1440    SC_debugC4(s, c);
1441}
1442
1443void rsDebug(const char *s, unsigned char c) {
1444    SC_debugU8(s, c);
1445}
1446
1447void rsDebug(const char *s, uchar2 c) {
1448    SC_debugUC2(s, c);
1449}
1450
1451void rsDebug(const char *s, uchar3 c) {
1452    SC_debugUC3(s, c);
1453}
1454
1455void rsDebug(const char *s, uchar4 c) {
1456    SC_debugUC4(s, c);
1457}
1458
1459void rsDebug(const char *s, short c) {
1460    SC_debugI16(s, c);
1461}
1462
1463void rsDebug(const char *s, short2 c) {
1464    SC_debugS2(s, c);
1465}
1466
1467void rsDebug(const char *s, short3 c) {
1468    SC_debugS3(s, c);
1469}
1470
1471void rsDebug(const char *s, short4 c) {
1472    SC_debugS4(s, c);
1473}
1474
1475void rsDebug(const char *s, unsigned short c) {
1476    SC_debugU16(s, c);
1477}
1478
1479void rsDebug(const char *s, ushort2 c) {
1480    SC_debugUS2(s, c);
1481}
1482
1483void rsDebug(const char *s, ushort3 c) {
1484    SC_debugUS3(s, c);
1485}
1486
1487void rsDebug(const char *s, ushort4 c) {
1488    SC_debugUS4(s, c);
1489}
1490
1491void rsDebug(const char *s, int c) {
1492    SC_debugI32(s, c);
1493}
1494
1495void rsDebug(const char *s, int2 c) {
1496    SC_debugI2(s, c);
1497}
1498
1499void rsDebug(const char *s, int3 c) {
1500    SC_debugI3(s, c);
1501}
1502
1503void rsDebug(const char *s, int4 c) {
1504    SC_debugI4(s, c);
1505}
1506
1507void rsDebug(const char *s, unsigned int c) {
1508    SC_debugU32(s, c);
1509}
1510
1511void rsDebug(const char *s, uint2 c) {
1512    SC_debugUI2(s, c);
1513}
1514
1515void rsDebug(const char *s, uint3 c) {
1516    SC_debugUI3(s, c);
1517}
1518
1519void rsDebug(const char *s, uint4 c) {
1520    SC_debugUI4(s, c);
1521}
1522
1523void rsDebug(const char *s, long c) {
1524    SC_debugLL64(s, c);
1525}
1526
1527void rsDebug(const char *s, long long c) {
1528    SC_debugLL64(s, c);
1529}
1530
1531void rsDebug(const char *s, long2 c) {
1532    SC_debugL2(s, c);
1533}
1534
1535void rsDebug(const char *s, long3 c) {
1536    SC_debugL3(s, c);
1537}
1538
1539void rsDebug(const char *s, long4 c) {
1540    SC_debugL4(s, c);
1541}
1542
1543void rsDebug(const char *s, unsigned long c) {
1544    SC_debugULL64(s, c);
1545}
1546
1547void rsDebug(const char *s, unsigned long long c) {
1548    SC_debugULL64(s, c);
1549}
1550
1551void rsDebug(const char *s, ulong2 c) {
1552    SC_debugUL2(s, c);
1553}
1554
1555void rsDebug(const char *s, ulong3 c) {
1556    SC_debugUL3(s, c);
1557}
1558
1559void rsDebug(const char *s, ulong4 c) {
1560    SC_debugUL4(s, c);
1561}
1562
1563void rsDebug(const char *s, const void *p) {
1564    SC_debugP(s, p);
1565}
1566#endif // RS_COMPATIBILITY_LIB
1567
1568extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
1569    ScriptC *s = (ScriptC *)pContext;
1570    const RsdCpuReference::CpuSymbol *syms = gSyms;
1571    const RsdCpuReference::CpuSymbol *sym = NULL;
1572
1573    if (!sym) {
1574        while (syms->fnPtr) {
1575            if (!strcmp(syms->name, name)) {
1576                return syms;
1577            }
1578            syms++;
1579        }
1580    }
1581
1582    return NULL;
1583}
1584
1585
1586