rsdRuntimeStubs.cpp revision a5d9bef6b53ba394087c7c7b9cc60d3aaa7f121b
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 enum {
88    // Empty to avoid conflicting definitions with RsAllocationCubemapFace
89} rs_allocation_cubemap_face;
90
91typedef struct {
92    int tm_sec;     ///< seconds
93    int tm_min;     ///< minutes
94    int tm_hour;    ///< hours
95    int tm_mday;    ///< day of the month
96    int tm_mon;     ///< month
97    int tm_year;    ///< year
98    int tm_wday;    ///< day of the week
99    int tm_yday;    ///< day of the year
100    int tm_isdst;   ///< daylight savings time
101} rs_tm;
102#endif
103
104//////////////////////////////////////////////////////////////////////////////
105// Allocation
106//////////////////////////////////////////////////////////////////////////////
107
108
109static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
110    Context *rsc = RsdCpuReference::getTlsContext();
111    rsrAllocationSyncAll(rsc, a, source);
112}
113
114static void SC_AllocationSyncAll(Allocation *a) {
115    Context *rsc = RsdCpuReference::getTlsContext();
116    rsrAllocationSyncAll(rsc, a, RS_ALLOCATION_USAGE_SCRIPT);
117}
118
119static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
120                                     uint32_t dstOff,
121                                     uint32_t dstMip,
122                                     uint32_t count,
123                                     Allocation *srcAlloc,
124                                     uint32_t srcOff, uint32_t srcMip) {
125    Context *rsc = RsdCpuReference::getTlsContext();
126    rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
127                             srcAlloc, srcOff, srcMip);
128}
129
130static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
131                                     uint32_t dstXoff, uint32_t dstYoff,
132                                     uint32_t dstMip, uint32_t dstFace,
133                                     uint32_t width, uint32_t height,
134                                     Allocation *srcAlloc,
135                                     uint32_t srcXoff, uint32_t srcYoff,
136                                     uint32_t srcMip, uint32_t srcFace) {
137    Context *rsc = RsdCpuReference::getTlsContext();
138    rsrAllocationCopy2DRange(rsc, dstAlloc,
139                             dstXoff, dstYoff, dstMip, dstFace,
140                             width, height,
141                             srcAlloc,
142                             srcXoff, srcYoff, srcMip, srcFace);
143}
144
145static void SC_AllocationIoSend(Allocation *alloc) {
146    Context *rsc = RsdCpuReference::getTlsContext();
147    rsrAllocationIoSend(rsc, alloc);
148}
149
150
151static void SC_AllocationIoReceive(Allocation *alloc) {
152    Context *rsc = RsdCpuReference::getTlsContext();
153    rsrAllocationIoReceive(rsc, alloc);
154}
155
156#ifndef RS_COMPATIBILITY_LIB
157
158//////////////////////////////////////////////////////////////////////////////
159// Context
160//////////////////////////////////////////////////////////////////////////////
161
162static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
163    Context *rsc = RsdCpuReference::getTlsContext();
164    rsrBindTexture(rsc, pf, slot, a);
165}
166
167static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
168    Context *rsc = RsdCpuReference::getTlsContext();
169    rsrBindConstant(rsc, pv, slot, a);
170}
171
172static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
173    Context *rsc = RsdCpuReference::getTlsContext();
174    rsrBindConstant(rsc, pf, slot, a);
175}
176
177static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
178    Context *rsc = RsdCpuReference::getTlsContext();
179    rsrBindSampler(rsc, pf, slot, s);
180}
181
182static void SC_BindProgramStore(ProgramStore *ps) {
183    Context *rsc = RsdCpuReference::getTlsContext();
184    rsrBindProgramStore(rsc, ps);
185}
186
187static void SC_BindProgramFragment(ProgramFragment *pf) {
188    Context *rsc = RsdCpuReference::getTlsContext();
189    rsrBindProgramFragment(rsc, pf);
190}
191
192static void SC_BindProgramVertex(ProgramVertex *pv) {
193    Context *rsc = RsdCpuReference::getTlsContext();
194    rsrBindProgramVertex(rsc, pv);
195}
196
197static void SC_BindProgramRaster(ProgramRaster *pr) {
198    Context *rsc = RsdCpuReference::getTlsContext();
199    rsrBindProgramRaster(rsc, pr);
200}
201
202static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
203    Context *rsc = RsdCpuReference::getTlsContext();
204    rsrBindFrameBufferObjectColorTarget(rsc, a, slot);
205}
206
207static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
208    Context *rsc = RsdCpuReference::getTlsContext();
209    rsrBindFrameBufferObjectDepthTarget(rsc, a);
210}
211
212static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
213    Context *rsc = RsdCpuReference::getTlsContext();
214    rsrClearFrameBufferObjectColorTarget(rsc, slot);
215}
216
217static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
218    Context *rsc = RsdCpuReference::getTlsContext();
219    rsrClearFrameBufferObjectDepthTarget(rsc);
220}
221
222static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
223    Context *rsc = RsdCpuReference::getTlsContext();
224    rsrClearFrameBufferObjectTargets(rsc);
225}
226
227
228//////////////////////////////////////////////////////////////////////////////
229// VP
230//////////////////////////////////////////////////////////////////////////////
231
232static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
233    Context *rsc = RsdCpuReference::getTlsContext();
234    rsrVpLoadProjectionMatrix(rsc, m);
235}
236
237static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
238    Context *rsc = RsdCpuReference::getTlsContext();
239    rsrVpLoadModelMatrix(rsc, m);
240}
241
242static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
243    Context *rsc = RsdCpuReference::getTlsContext();
244    rsrVpLoadTextureMatrix(rsc, m);
245}
246
247static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
248    Context *rsc = RsdCpuReference::getTlsContext();
249    rsrPfConstantColor(rsc, pf, r, g, b, a);
250}
251
252static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
253    Context *rsc = RsdCpuReference::getTlsContext();
254    rsrVpGetProjectionMatrix(rsc, m);
255}
256
257
258//////////////////////////////////////////////////////////////////////////////
259// Drawing
260//////////////////////////////////////////////////////////////////////////////
261
262static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
263                                 float x2, float y2, float z2, float u2, float v2,
264                                 float x3, float y3, float z3, float u3, float v3,
265                                 float x4, float y4, float z4, float u4, float v4) {
266    Context *rsc = RsdCpuReference::getTlsContext();
267
268    if (!rsc->setupCheck()) {
269        return;
270    }
271
272    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
273    if (!dc->gl.shaderCache->setup(rsc)) {
274        return;
275    }
276
277    //ALOGE("Quad");
278    //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
279    //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
280    //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
281    //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
282
283    float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
284    const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
285
286    RsdVertexArray::Attrib attribs[2];
287    attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
288    attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
289
290    RsdVertexArray va(attribs, 2);
291    va.setup(rsc);
292
293    RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
294}
295
296static void SC_DrawQuad(float x1, float y1, float z1,
297                        float x2, float y2, float z2,
298                        float x3, float y3, float z3,
299                        float x4, float y4, float z4) {
300    SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
301                         x2, y2, z2, 1, 1,
302                         x3, y3, z3, 1, 0,
303                         x4, y4, z4, 0, 0);
304}
305
306static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
307    Context *rsc = RsdCpuReference::getTlsContext();
308
309    ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
310    rsc->setProgramVertex(rsc->getDefaultProgramVertex());
311    //rsc->setupCheck();
312
313    //GLint crop[4] = {0, h, w, -h};
314
315    float sh = rsc->getHeight();
316
317    SC_DrawQuad(x,   sh - y,     z,
318                x+w, sh - y,     z,
319                x+w, sh - (y+h), z,
320                x,   sh - (y+h), z);
321    rsc->setProgramVertex((ProgramVertex *)tmp.get());
322}
323
324static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
325    SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
326}
327
328static void SC_DrawPath(Path *p) {
329    Context *rsc = RsdCpuReference::getTlsContext();
330    rsdPathDraw(rsc, p);
331}
332
333static void SC_DrawMesh(Mesh *m) {
334    Context *rsc = RsdCpuReference::getTlsContext();
335    rsrDrawMesh(rsc, m);
336}
337
338static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
339    Context *rsc = RsdCpuReference::getTlsContext();
340    rsrDrawMeshPrimitive(rsc, m, primIndex);
341}
342
343static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
344    Context *rsc = RsdCpuReference::getTlsContext();
345    rsrDrawMeshPrimitiveRange(rsc, m, primIndex, start, len);
346}
347
348static void SC_MeshComputeBoundingBox(Mesh *m,
349                               float *minX, float *minY, float *minZ,
350                               float *maxX, float *maxY, float *maxZ) {
351    Context *rsc = RsdCpuReference::getTlsContext();
352    rsrMeshComputeBoundingBox(rsc, m, minX, minY, minZ, maxX, maxY, maxZ);
353}
354
355
356
357//////////////////////////////////////////////////////////////////////////////
358//
359//////////////////////////////////////////////////////////////////////////////
360
361
362static void SC_Color(float r, float g, float b, float a) {
363    Context *rsc = RsdCpuReference::getTlsContext();
364    rsrColor(rsc, r, g, b, a);
365}
366
367static void SC_Finish() {
368    Context *rsc = RsdCpuReference::getTlsContext();
369    rsdGLFinish(rsc);
370}
371
372static void SC_ClearColor(float r, float g, float b, float a) {
373    Context *rsc = RsdCpuReference::getTlsContext();
374    rsrPrepareClear(rsc);
375    rsdGLClearColor(rsc, r, g, b, a);
376}
377
378static void SC_ClearDepth(float v) {
379    Context *rsc = RsdCpuReference::getTlsContext();
380    rsrPrepareClear(rsc);
381    rsdGLClearDepth(rsc, v);
382}
383
384static uint32_t SC_GetWidth() {
385    Context *rsc = RsdCpuReference::getTlsContext();
386    return rsrGetWidth(rsc);
387}
388
389static uint32_t SC_GetHeight() {
390    Context *rsc = RsdCpuReference::getTlsContext();
391    return rsrGetHeight(rsc);
392}
393
394static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
395    Context *rsc = RsdCpuReference::getTlsContext();
396    rsrDrawTextAlloc(rsc, a, x, y);
397}
398
399static void SC_DrawText(const char *text, int x, int y) {
400    Context *rsc = RsdCpuReference::getTlsContext();
401    rsrDrawText(rsc, text, x, y);
402}
403
404static void SC_MeasureTextAlloc(Allocation *a,
405                         int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
406    Context *rsc = RsdCpuReference::getTlsContext();
407    rsrMeasureTextAlloc(rsc, a, left, right, top, bottom);
408}
409
410static void SC_MeasureText(const char *text,
411                    int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
412    Context *rsc = RsdCpuReference::getTlsContext();
413    rsrMeasureText(rsc, text, left, right, top, bottom);
414}
415
416static void SC_BindFont(Font *f) {
417    Context *rsc = RsdCpuReference::getTlsContext();
418    rsrBindFont(rsc, f);
419}
420
421static void SC_FontColor(float r, float g, float b, float a) {
422    Context *rsc = RsdCpuReference::getTlsContext();
423    rsrFontColor(rsc, r, g, b, a);
424}
425#endif
426
427
428//////////////////////////////////////////////////////////////////////////////
429//
430//////////////////////////////////////////////////////////////////////////////
431
432static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
433    Context *rsc = RsdCpuReference::getTlsContext();
434    rsrSetObject(rsc, dst, src);
435}
436
437static void SC_ClearObject(ObjectBase **dst) {
438    Context *rsc = RsdCpuReference::getTlsContext();
439    rsrClearObject(rsc, dst);
440}
441
442static bool SC_IsObject(const ObjectBase *src) {
443    Context *rsc = RsdCpuReference::getTlsContext();
444    return rsrIsObject(rsc, src);
445}
446
447
448
449
450static const Allocation * SC_GetAllocation(const void *ptr) {
451    Context *rsc = RsdCpuReference::getTlsContext();
452    const Script *sc = RsdCpuReference::getTlsScript();
453    return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
454}
455
456static void SC_ForEach_SAA(Script *target,
457                            Allocation *in,
458                            Allocation *out) {
459    Context *rsc = RsdCpuReference::getTlsContext();
460    rsrForEach(rsc, target, in, out, NULL, 0, NULL);
461}
462
463static void SC_ForEach_SAAU(Script *target,
464                            Allocation *in,
465                            Allocation *out,
466                            const void *usr) {
467    Context *rsc = RsdCpuReference::getTlsContext();
468    rsrForEach(rsc, target, in, out, usr, 0, NULL);
469}
470
471static void SC_ForEach_SAAUS(Script *target,
472                             Allocation *in,
473                             Allocation *out,
474                             const void *usr,
475                             const RsScriptCall *call) {
476    Context *rsc = RsdCpuReference::getTlsContext();
477    rsrForEach(rsc, target, in, out, usr, 0, call);
478}
479
480static void SC_ForEach_SAAUL(Script *target,
481                             Allocation *in,
482                             Allocation *out,
483                             const void *usr,
484                             uint32_t usrLen) {
485    Context *rsc = RsdCpuReference::getTlsContext();
486    rsrForEach(rsc, target, in, out, usr, usrLen, NULL);
487}
488
489static void SC_ForEach_SAAULS(Script *target,
490                              Allocation *in,
491                              Allocation *out,
492                              const void *usr,
493                              uint32_t usrLen,
494                              const RsScriptCall *call) {
495    Context *rsc = RsdCpuReference::getTlsContext();
496    rsrForEach(rsc, target, in, out, usr, usrLen, call);
497}
498
499
500
501//////////////////////////////////////////////////////////////////////////////
502// Time routines
503//////////////////////////////////////////////////////////////////////////////
504
505static float SC_GetDt() {
506    Context *rsc = RsdCpuReference::getTlsContext();
507    const Script *sc = RsdCpuReference::getTlsScript();
508    return rsrGetDt(rsc, sc);
509}
510
511#ifndef RS_COMPATIBILITY_LIB
512time_t SC_Time(time_t *timer) {
513    Context *rsc = RsdCpuReference::getTlsContext();
514    return rsrTime(rsc, timer);
515}
516#else
517static int SC_Time(int *timer) {
518    Context *rsc = RsdCpuReference::getTlsContext();
519    return rsrTime(rsc, (long*)timer);
520}
521#endif
522
523tm* SC_LocalTime(tm *local, time_t *timer) {
524    Context *rsc = RsdCpuReference::getTlsContext();
525    return rsrLocalTime(rsc, local, timer);
526}
527
528int64_t SC_UptimeMillis() {
529    Context *rsc = RsdCpuReference::getTlsContext();
530    return rsrUptimeMillis(rsc);
531}
532
533int64_t SC_UptimeNanos() {
534    Context *rsc = RsdCpuReference::getTlsContext();
535    return rsrUptimeNanos(rsc);
536}
537
538//////////////////////////////////////////////////////////////////////////////
539// Message routines
540//////////////////////////////////////////////////////////////////////////////
541
542static uint32_t SC_ToClient2(int cmdID, const void *data, uint32_t len) {
543    Context *rsc = RsdCpuReference::getTlsContext();
544    return rsrToClient(rsc, cmdID, data, len);
545}
546
547static uint32_t SC_ToClient(int cmdID) {
548    Context *rsc = RsdCpuReference::getTlsContext();
549    return rsrToClient(rsc, cmdID, (const void *)NULL, 0);
550}
551
552static uint32_t SC_ToClientBlocking2(int cmdID, const void *data, uint32_t len) {
553    Context *rsc = RsdCpuReference::getTlsContext();
554    return rsrToClientBlocking(rsc, cmdID, data, len);
555}
556
557static uint32_t SC_ToClientBlocking(int cmdID) {
558    Context *rsc = RsdCpuReference::getTlsContext();
559    return rsrToClientBlocking(rsc, cmdID, (const void *)NULL, 0);
560}
561
562
563static void * ElementAt1D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x) {
564    Context *rsc = RsdCpuReference::getTlsContext();
565    const Type *t = a->getType();
566    const Element *e = t->getElement();
567
568    char buf[256];
569    if (x >= t->getLODDimX(0)) {
570        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
571        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
572        return NULL;
573    }
574
575    if (vecSize > 0) {
576        if (vecSize != e->getVectorSize()) {
577            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
578            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
579            return NULL;
580        }
581
582        if (dt != e->getType()) {
583            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
584            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
585            return NULL;
586        }
587    }
588
589    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
590    const uint32_t eSize = e->getSizeBytes();
591    return &p[(eSize * x)];
592}
593
594static void * ElementAt2D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y) {
595    Context *rsc = RsdCpuReference::getTlsContext();
596    const Type *t = a->getType();
597    const Element *e = t->getElement();
598
599    char buf[256];
600    if (x >= t->getLODDimX(0)) {
601        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
602        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
603        return NULL;
604    }
605
606    if (y >= t->getLODDimY(0)) {
607        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
608        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
609        return NULL;
610    }
611
612    if (vecSize > 0) {
613        if (vecSize != e->getVectorSize()) {
614            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
615            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
616            return NULL;
617        }
618
619        if (dt != e->getType()) {
620            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
621            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
622            return NULL;
623        }
624    }
625
626    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
627    const uint32_t eSize = e->getSizeBytes();
628    const uint32_t stride = a->mHal.drvState.lod[0].stride;
629    return &p[(eSize * x) + (y * stride)];
630}
631
632static void * ElementAt3D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y, uint32_t z) {
633    Context *rsc = RsdCpuReference::getTlsContext();
634    const Type *t = a->getType();
635    const Element *e = t->getElement();
636
637    char buf[256];
638    if (x >= t->getLODDimX(0)) {
639        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
640        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
641        return NULL;
642    }
643
644    if (y >= t->getLODDimY(0)) {
645        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
646        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
647        return NULL;
648    }
649
650    if (z >= t->getLODDimZ(0)) {
651        sprintf(buf, "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0));
652        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
653        return NULL;
654    }
655
656    if (vecSize > 0) {
657        if (vecSize != e->getVectorSize()) {
658            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
659            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
660            return NULL;
661        }
662
663        if (dt != e->getType()) {
664            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
665            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
666            return NULL;
667        }
668    }
669
670    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
671    const uint32_t eSize = e->getSizeBytes();
672    const uint32_t stride = a->mHal.drvState.lod[0].stride;
673    return &p[(eSize * x) + (y * stride)];
674}
675
676static const void * SC_GetElementAt1D(Allocation *a, uint32_t x) {
677    return ElementAt1D(a, RS_TYPE_UNSIGNED_8, 0, x);
678}
679static const void * SC_GetElementAt2D(Allocation *a, uint32_t x, uint32_t y) {
680    return ElementAt2D(a, RS_TYPE_UNSIGNED_8, 0, x, y);
681}
682static const void * SC_GetElementAt3D(Allocation *a, uint32_t x, uint32_t y, uint32_t z) {
683    return ElementAt3D(a, RS_TYPE_UNSIGNED_8, 0, x, y, z);
684}
685
686static void SC_SetElementAt1D(Allocation *a, const void *ptr, uint32_t x) {
687    const Type *t = a->getType();
688    const Element *e = t->getElement();
689    void *tmp = ElementAt1D(a, RS_TYPE_UNSIGNED_8, 0, x);
690    if (tmp != NULL) {
691        memcpy(tmp, ptr, e->getSizeBytes());
692    }
693}
694static void SC_SetElementAt2D(Allocation *a, const void *ptr, uint32_t x, uint32_t y) {
695    const Type *t = a->getType();
696    const Element *e = t->getElement();
697    void *tmp = ElementAt2D(a, RS_TYPE_UNSIGNED_8, 0, x, y);
698    if (tmp != NULL) {
699        memcpy(tmp, ptr, e->getSizeBytes());
700    }
701}
702static void SC_SetElementAt3D(Allocation *a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
703    const Type *t = a->getType();
704    const Element *e = t->getElement();
705    void *tmp = ElementAt3D(a, RS_TYPE_UNSIGNED_8, 0, x, y, z);
706    if (tmp != NULL) {
707        memcpy(tmp, ptr, e->getSizeBytes());
708    }
709}
710
711#define ELEMENT_AT(T, DT, VS)                                               \
712    static void SC_SetElementAt1_##T(Allocation *a, const T *val, uint32_t x) {           \
713        void *r = ElementAt1D(a, DT, VS, x);                            \
714        if (r != NULL) ((T *)r)[0] = *val;                               \
715        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
716    }                                                                   \
717    static void SC_SetElementAt2_##T(Allocation * a, const T * val, uint32_t x, uint32_t y) { \
718        void *r = ElementAt2D(a, DT, VS, x, y);            \
719        if (r != NULL) ((T *)r)[0] = *val;                               \
720        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
721    }                                                                   \
722    static void SC_SetElementAt3_##T(Allocation * a, const T * val, uint32_t x, uint32_t y, uint32_t z) { \
723        void *r = ElementAt3D(a, DT, VS, x, y, z);         \
724        if (r != NULL) ((T *)r)[0] = *val;                               \
725        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
726    }                                                                   \
727    static void SC_GetElementAt1_##T(Allocation * a, T *val, uint32_t x) {                  \
728        void *r = ElementAt1D(a, DT, VS, x);               \
729        if (r != NULL) *val = ((T *)r)[0];                              \
730        else ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
731    }                                                                   \
732    static void SC_GetElementAt2_##T(Allocation * a, T *val, uint32_t x, uint32_t y) {      \
733        void *r = ElementAt2D(a, DT, VS, x, y);            \
734        if (r != NULL) *val = ((T *)r)[0];                              \
735        else ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
736    }                                                                   \
737    static void SC_GetElementAt3_##T(Allocation * a, T *val, uint32_t x, uint32_t y, uint32_t z) { \
738        void *r = ElementAt3D(a, DT, VS, x, y, z);         \
739        if (r != NULL) *val = ((T *)r)[0];                              \
740        else ALOGE("Error from %s", __PRETTY_FUNCTION__);                    \
741    }
742
743ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1)
744ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2)
745ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3)
746ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4)
747ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1)
748ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2)
749ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3)
750ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4)
751ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1)
752ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2)
753ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3)
754ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4)
755ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1)
756ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2)
757ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3)
758ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4)
759ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1)
760ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2)
761ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3)
762ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4)
763ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1)
764ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2)
765ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3)
766ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4)
767ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1)
768ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2)
769ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3)
770ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4)
771ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1)
772ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2)
773ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3)
774ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4)
775ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1)
776ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2)
777ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3)
778ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4)
779ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1)
780ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2)
781ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3)
782ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4)
783
784#undef ELEMENT_AT
785
786//////////////////////////////////////////////////////////////////////////////
787// Stub implementation
788//////////////////////////////////////////////////////////////////////////////
789
790// llvm name mangling ref
791//  <builtin-type> ::= v  # void
792//                 ::= b  # bool
793//                 ::= c  # char
794//                 ::= a  # signed char
795//                 ::= h  # unsigned char
796//                 ::= s  # short
797//                 ::= t  # unsigned short
798//                 ::= i  # int
799//                 ::= j  # unsigned int
800//                 ::= l  # long
801//                 ::= m  # unsigned long
802//                 ::= x  # long long, __int64
803//                 ::= y  # unsigned long long, __int64
804//                 ::= f  # float
805//                 ::= d  # double
806
807static RsdCpuReference::CpuSymbol gSyms[] = {
808    // Debug runtime
809    { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_GetElementAt1D, true },
810    { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_GetElementAt2D, true },
811    { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_GetElementAt3D, true },
812    { "_Z14rsSetElementAt13rs_allocationPKvj", (void *)&SC_SetElementAt1D, true },
813    { "_Z14rsSetElementAt13rs_allocationPKvjj", (void *)&SC_SetElementAt2D, true },
814    { "_Z14rsSetElementAt13rs_allocationPKvjjj", (void *)&SC_SetElementAt3D, true },
815
816
817    { "_Z20rsGetElementAt_uchar13rs_allocationPhj", (void *)&SC_GetElementAt1_uchar, true },
818    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hj", (void *)&SC_GetElementAt1_uchar2, true },
819    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hj", (void *)&SC_GetElementAt1_uchar3, true },
820    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hj", (void *)&SC_GetElementAt1_uchar4, true },
821    { "_Z20rsGetElementAt_uchar13rs_allocationPhjj", (void *)&SC_GetElementAt2_uchar, true },
822    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjj", (void *)&SC_GetElementAt2_uchar2, true },
823    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjj", (void *)&SC_GetElementAt2_uchar3, true },
824    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjj", (void *)&SC_GetElementAt2_uchar4, true },
825    { "_Z20rsGetElementAt_uchar13rs_allocationPhjjj", (void *)&SC_GetElementAt3_uchar, true },
826    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjjj", (void *)&SC_GetElementAt3_uchar2, true },
827    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjjj", (void *)&SC_GetElementAt3_uchar3, true },
828    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjjj", (void *)&SC_GetElementAt3_uchar4, true },
829
830    { "_Z19rsGetElementAt_char13rs_allocationPcj", (void *)&SC_GetElementAt1_char, true },
831    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cj", (void *)&SC_GetElementAt1_char2, true },
832    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cj", (void *)&SC_GetElementAt1_char3, true },
833    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cj", (void *)&SC_GetElementAt1_char4, true },
834    { "_Z19rsGetElementAt_char13rs_allocationPcjj", (void *)&SC_GetElementAt2_char, true },
835    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjj", (void *)&SC_GetElementAt2_char2, true },
836    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjj", (void *)&SC_GetElementAt2_char3, true },
837    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjj", (void *)&SC_GetElementAt2_char4, true },
838    { "_Z19rsGetElementAt_char13rs_allocationPcjjj", (void *)&SC_GetElementAt3_char, true },
839    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjjj", (void *)&SC_GetElementAt3_char2, true },
840    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjjj", (void *)&SC_GetElementAt3_char3, true },
841    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjjj", (void *)&SC_GetElementAt3_char4, true },
842
843    { "_Z21rsGetElementAt_ushort13rs_allocationPtj", (void *)&SC_GetElementAt1_ushort, true },
844    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tj", (void *)&SC_GetElementAt1_ushort2, true },
845    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tj", (void *)&SC_GetElementAt1_ushort3, true },
846    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tj", (void *)&SC_GetElementAt1_ushort4, true },
847    { "_Z21rsGetElementAt_ushort13rs_allocationPtjj", (void *)&SC_GetElementAt2_ushort, true },
848    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjj", (void *)&SC_GetElementAt2_ushort2, true },
849    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjj", (void *)&SC_GetElementAt2_ushort3, true },
850    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjj", (void *)&SC_GetElementAt2_ushort4, true },
851    { "_Z21rsGetElementAt_ushort13rs_allocationPtjjj", (void *)&SC_GetElementAt3_ushort, true },
852    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjjj", (void *)&SC_GetElementAt3_ushort2, true },
853    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjjj", (void *)&SC_GetElementAt3_ushort3, true },
854    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjjj", (void *)&SC_GetElementAt3_ushort4, true },
855
856    { "_Z20rsGetElementAt_short13rs_allocationPsj", (void *)&SC_GetElementAt1_short, true },
857    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sj", (void *)&SC_GetElementAt1_short2, true },
858    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sj", (void *)&SC_GetElementAt1_short3, true },
859    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sj", (void *)&SC_GetElementAt1_short4, true },
860    { "_Z20rsGetElementAt_short13rs_allocationPsjj", (void *)&SC_GetElementAt2_short, true },
861    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjj", (void *)&SC_GetElementAt2_short2, true },
862    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjj", (void *)&SC_GetElementAt2_short3, true },
863    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjj", (void *)&SC_GetElementAt2_short4, true },
864    { "_Z20rsGetElementAt_short13rs_allocationPsjjj", (void *)&SC_GetElementAt3_short, true },
865    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjjj", (void *)&SC_GetElementAt3_short2, true },
866    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjjj", (void *)&SC_GetElementAt3_short3, true },
867    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjjj", (void *)&SC_GetElementAt3_short4, true },
868
869    { "_Z19rsGetElementAt_uint13rs_allocationPjj", (void *)&SC_GetElementAt1_uint, true },
870    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jj", (void *)&SC_GetElementAt1_uint2, true },
871    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jj", (void *)&SC_GetElementAt1_uint3, true },
872    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jj", (void *)&SC_GetElementAt1_uint4, true },
873    { "_Z19rsGetElementAt_uint13rs_allocationPjjj", (void *)&SC_GetElementAt2_uint, true },
874    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjj", (void *)&SC_GetElementAt2_uint2, true },
875    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjj", (void *)&SC_GetElementAt2_uint3, true },
876    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjj", (void *)&SC_GetElementAt2_uint4, true },
877    { "_Z19rsGetElementAt_uint13rs_allocationPjjjj", (void *)&SC_GetElementAt3_uint, true },
878    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjjj", (void *)&SC_GetElementAt3_uint2, true },
879    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjjj", (void *)&SC_GetElementAt3_uint3, true },
880    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjjj", (void *)&SC_GetElementAt3_uint4, true },
881
882    { "_Z18rsGetElementAt_int13rs_allocationPij", (void *)&SC_GetElementAt1_int, true },
883    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ij", (void *)&SC_GetElementAt1_int2, true },
884    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ij", (void *)&SC_GetElementAt1_int3, true },
885    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ij", (void *)&SC_GetElementAt1_int4, true },
886    { "_Z18rsGetElementAt_int13rs_allocationPijj", (void *)&SC_GetElementAt2_int, true },
887    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijj", (void *)&SC_GetElementAt2_int2, true },
888    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijj", (void *)&SC_GetElementAt2_int3, true },
889    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijj", (void *)&SC_GetElementAt2_int4, true },
890    { "_Z18rsGetElementAt_int13rs_allocationPijjj", (void *)&SC_GetElementAt3_int, true },
891    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijjj", (void *)&SC_GetElementAt3_int2, true },
892    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijjj", (void *)&SC_GetElementAt3_int3, true },
893    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijjj", (void *)&SC_GetElementAt3_int4, true },
894
895    { "_Z20rsGetElementAt_ulong13rs_allocationPmj", (void *)&SC_GetElementAt1_ulong, true },
896    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mj", (void *)&SC_GetElementAt1_ulong2, true },
897    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mj", (void *)&SC_GetElementAt1_ulong3, true },
898    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mj", (void *)&SC_GetElementAt1_ulong4, true },
899    { "_Z20rsGetElementAt_ulong13rs_allocationPmjj", (void *)&SC_GetElementAt2_ulong, true },
900    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjj", (void *)&SC_GetElementAt2_ulong2, true },
901    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjj", (void *)&SC_GetElementAt2_ulong3, true },
902    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjj", (void *)&SC_GetElementAt2_ulong4, true },
903    { "_Z20rsGetElementAt_ulong13rs_allocationPmjjj", (void *)&SC_GetElementAt3_ulong, true },
904    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjjj", (void *)&SC_GetElementAt3_ulong2, true },
905    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjjj", (void *)&SC_GetElementAt3_ulong3, true },
906    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjjj", (void *)&SC_GetElementAt3_ulong4, true },
907
908    { "_Z19rsGetElementAt_long13rs_allocationPlj", (void *)&SC_GetElementAt1_long, true },
909    { "_Z20rsGetElementAt_long213rs_allocationPDv2_lj", (void *)&SC_GetElementAt1_long2, true },
910    { "_Z20rsGetElementAt_long313rs_allocationPDv3_lj", (void *)&SC_GetElementAt1_long3, true },
911    { "_Z20rsGetElementAt_long413rs_allocationPDv4_lj", (void *)&SC_GetElementAt1_long4, true },
912    { "_Z19rsGetElementAt_long13rs_allocationPljj", (void *)&SC_GetElementAt2_long, true },
913    { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljj", (void *)&SC_GetElementAt2_long2, true },
914    { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljj", (void *)&SC_GetElementAt2_long3, true },
915    { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljj", (void *)&SC_GetElementAt2_long4, true },
916    { "_Z19rsGetElementAt_long13rs_allocationPljjj", (void *)&SC_GetElementAt3_long, true },
917    { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljjj", (void *)&SC_GetElementAt3_long2, true },
918    { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljjj", (void *)&SC_GetElementAt3_long3, true },
919    { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljjj", (void *)&SC_GetElementAt3_long4, true },
920
921    { "_Z20rsGetElementAt_float13rs_allocationPfj", (void *)&SC_GetElementAt1_float, true },
922    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fj", (void *)&SC_GetElementAt1_float2, true },
923    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fj", (void *)&SC_GetElementAt1_float3, true },
924    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fj", (void *)&SC_GetElementAt1_float4, true },
925    { "_Z20rsGetElementAt_float13rs_allocationPfjj", (void *)&SC_GetElementAt2_float, true },
926    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjj", (void *)&SC_GetElementAt2_float2, true },
927    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjj", (void *)&SC_GetElementAt2_float3, true },
928    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjj", (void *)&SC_GetElementAt2_float4, true },
929    { "_Z20rsGetElementAt_float13rs_allocationPfjjj", (void *)&SC_GetElementAt3_float, true },
930    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjjj", (void *)&SC_GetElementAt3_float2, true },
931    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjjj", (void *)&SC_GetElementAt3_float3, true },
932    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjjj", (void *)&SC_GetElementAt3_float4, true },
933
934    { "_Z21rsGetElementAt_double13rs_allocationPdj", (void *)&SC_GetElementAt1_double, true },
935    { "_Z22rsGetElementAt_double213rs_allocationPDv2_dj", (void *)&SC_GetElementAt1_double2, true },
936    { "_Z22rsGetElementAt_double313rs_allocationPDv3_dj", (void *)&SC_GetElementAt1_double3, true },
937    { "_Z22rsGetElementAt_double413rs_allocationPDv4_dj", (void *)&SC_GetElementAt1_double4, true },
938    { "_Z21rsGetElementAt_double13rs_allocationPdjj", (void *)&SC_GetElementAt2_double, true },
939    { "_Z22rsGetElementAt_double213rs_allocationPDv2_djj", (void *)&SC_GetElementAt2_double2, true },
940    { "_Z22rsGetElementAt_double313rs_allocationPDv3_djj", (void *)&SC_GetElementAt2_double3, true },
941    { "_Z22rsGetElementAt_double413rs_allocationPDv4_djj", (void *)&SC_GetElementAt2_double4, true },
942    { "_Z21rsGetElementAt_double13rs_allocationPdjjj", (void *)&SC_GetElementAt3_double, true },
943    { "_Z22rsGetElementAt_double213rs_allocationPDv2_djjj", (void *)&SC_GetElementAt3_double2, true },
944    { "_Z22rsGetElementAt_double313rs_allocationPDv3_djjj", (void *)&SC_GetElementAt3_double3, true },
945    { "_Z22rsGetElementAt_double413rs_allocationPDv4_djjj", (void *)&SC_GetElementAt3_double4, true },
946
947
948
949    { "_Z20rsSetElementAt_uchar13rs_allocationPKhj", (void *)&SC_SetElementAt1_uchar, true },
950    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hj", (void *)&SC_SetElementAt1_uchar2, true },
951    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hj", (void *)&SC_SetElementAt1_uchar3, true },
952    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hj", (void *)&SC_SetElementAt1_uchar4, true },
953    { "_Z20rsSetElementAt_uchar13rs_allocationPKhjj", (void *)&SC_SetElementAt2_uchar, true },
954    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjj", (void *)&SC_SetElementAt2_uchar2, true },
955    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjj", (void *)&SC_SetElementAt2_uchar3, true },
956    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjj", (void *)&SC_SetElementAt2_uchar4, true },
957    { "_Z20rsSetElementAt_uchar13rs_allocationPKhjjj", (void *)&SC_SetElementAt3_uchar, true },
958    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjjj", (void *)&SC_SetElementAt3_uchar2, true },
959    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjjj", (void *)&SC_SetElementAt3_uchar3, true },
960    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjjj", (void *)&SC_SetElementAt3_uchar4, true },
961
962    { "_Z19rsSetElementAt_char13rs_allocationPKcj", (void *)&SC_SetElementAt1_char, true },
963    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cj", (void *)&SC_SetElementAt1_char2, true },
964    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cj", (void *)&SC_SetElementAt1_char3, true },
965    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cj", (void *)&SC_SetElementAt1_char4, true },
966    { "_Z19rsSetElementAt_char13rs_allocationPKcjj", (void *)&SC_SetElementAt2_char, true },
967    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjj", (void *)&SC_SetElementAt2_char2, true },
968    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjj", (void *)&SC_SetElementAt2_char3, true },
969    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjj", (void *)&SC_SetElementAt2_char4, true },
970    { "_Z19rsSetElementAt_char13rs_allocationPKcjjj", (void *)&SC_SetElementAt3_char, true },
971    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjjj", (void *)&SC_SetElementAt3_char2, true },
972    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjjj", (void *)&SC_SetElementAt3_char3, true },
973    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjjj", (void *)&SC_SetElementAt3_char4, true },
974
975    { "_Z21rsSetElementAt_ushort13rs_allocationPKht", (void *)&SC_SetElementAt1_ushort, true },
976    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tj", (void *)&SC_SetElementAt1_ushort2, true },
977    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tj", (void *)&SC_SetElementAt1_ushort3, true },
978    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tj", (void *)&SC_SetElementAt1_ushort4, true },
979    { "_Z21rsSetElementAt_ushort13rs_allocationPKtjj", (void *)&SC_SetElementAt2_ushort, true },
980    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjj", (void *)&SC_SetElementAt2_ushort2, true },
981    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjj", (void *)&SC_SetElementAt2_ushort3, true },
982    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjj", (void *)&SC_SetElementAt2_ushort4, true },
983    { "_Z21rsSetElementAt_ushort13rs_allocationPKtjjj", (void *)&SC_SetElementAt3_ushort, true },
984    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjjj", (void *)&SC_SetElementAt3_ushort2, true },
985    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjjj", (void *)&SC_SetElementAt3_ushort3, true },
986    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjjj", (void *)&SC_SetElementAt3_ushort4, true },
987
988    { "_Z20rsSetElementAt_short13rs_allocationPKsj", (void *)&SC_SetElementAt1_short, true },
989    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sj", (void *)&SC_SetElementAt1_short2, true },
990    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sj", (void *)&SC_SetElementAt1_short3, true },
991    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sj", (void *)&SC_SetElementAt1_short4, true },
992    { "_Z20rsSetElementAt_short13rs_allocationPKsjj", (void *)&SC_SetElementAt2_short, true },
993    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjj", (void *)&SC_SetElementAt2_short2, true },
994    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjj", (void *)&SC_SetElementAt2_short3, true },
995    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjj", (void *)&SC_SetElementAt2_short4, true },
996    { "_Z20rsSetElementAt_short13rs_allocationPKsjjj", (void *)&SC_SetElementAt3_short, true },
997    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjjj", (void *)&SC_SetElementAt3_short2, true },
998    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjjj", (void *)&SC_SetElementAt3_short3, true },
999    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjjj", (void *)&SC_SetElementAt3_short4, true },
1000
1001    { "_Z19rsSetElementAt_uint13rs_allocationPKjj", (void *)&SC_SetElementAt1_uint, true },
1002    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jj", (void *)&SC_SetElementAt1_uint2, true },
1003    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jj", (void *)&SC_SetElementAt1_uint3, true },
1004    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jj", (void *)&SC_SetElementAt1_uint4, true },
1005    { "_Z19rsSetElementAt_uint13rs_allocationPKjjj", (void *)&SC_SetElementAt2_uint, true },
1006    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjj", (void *)&SC_SetElementAt2_uint2, true },
1007    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjj", (void *)&SC_SetElementAt2_uint3, true },
1008    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjj", (void *)&SC_SetElementAt2_uint4, true },
1009    { "_Z19rsSetElementAt_uint13rs_allocationPKjjjj", (void *)&SC_SetElementAt3_uint, true },
1010    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjjj", (void *)&SC_SetElementAt3_uint2, true },
1011    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjjj", (void *)&SC_SetElementAt3_uint3, true },
1012    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjjj", (void *)&SC_SetElementAt3_uint4, true },
1013
1014    { "_Z18rsSetElementAt_int13rs_allocationPKij", (void *)&SC_SetElementAt1_int, true },
1015    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ij", (void *)&SC_SetElementAt1_int2, true },
1016    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ij", (void *)&SC_SetElementAt1_int3, true },
1017    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ij", (void *)&SC_SetElementAt1_int4, true },
1018    { "_Z18rsSetElementAt_int13rs_allocationPKijj", (void *)&SC_SetElementAt2_int, true },
1019    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijj", (void *)&SC_SetElementAt2_int2, true },
1020    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijj", (void *)&SC_SetElementAt2_int3, true },
1021    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijj", (void *)&SC_SetElementAt2_int4, true },
1022    { "_Z18rsSetElementAt_int13rs_allocationPKijjj", (void *)&SC_SetElementAt3_int, true },
1023    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijjj", (void *)&SC_SetElementAt3_int2, true },
1024    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijjj", (void *)&SC_SetElementAt3_int3, true },
1025    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijjj", (void *)&SC_SetElementAt3_int4, true },
1026
1027    { "_Z20rsSetElementAt_ulong13rs_allocationPKmt", (void *)&SC_SetElementAt1_ulong, true },
1028    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mj", (void *)&SC_SetElementAt1_ulong2, true },
1029    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mj", (void *)&SC_SetElementAt1_ulong3, true },
1030    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mj", (void *)&SC_SetElementAt1_ulong4, true },
1031    { "_Z20rsSetElementAt_ulong13rs_allocationPKmjj", (void *)&SC_SetElementAt2_ulong, true },
1032    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjj", (void *)&SC_SetElementAt2_ulong2, true },
1033    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjj", (void *)&SC_SetElementAt2_ulong3, true },
1034    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjj", (void *)&SC_SetElementAt2_ulong4, true },
1035    { "_Z20rsSetElementAt_ulong13rs_allocationPKmjjj", (void *)&SC_SetElementAt3_ulong, true },
1036    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjjj", (void *)&SC_SetElementAt3_ulong2, true },
1037    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjjj", (void *)&SC_SetElementAt3_ulong3, true },
1038    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjjj", (void *)&SC_SetElementAt3_ulong4, true },
1039
1040    { "_Z19rsSetElementAt_long13rs_allocationPKlj", (void *)&SC_SetElementAt1_long, true },
1041    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_lj", (void *)&SC_SetElementAt1_long2, true },
1042    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_lj", (void *)&SC_SetElementAt1_long3, true },
1043    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_lj", (void *)&SC_SetElementAt1_long4, true },
1044    { "_Z19rsSetElementAt_long13rs_allocationPKljj", (void *)&SC_SetElementAt2_long, true },
1045    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljj", (void *)&SC_SetElementAt2_long2, true },
1046    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljj", (void *)&SC_SetElementAt2_long3, true },
1047    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljj", (void *)&SC_SetElementAt2_long4, true },
1048    { "_Z19rsSetElementAt_long13rs_allocationPKljjj", (void *)&SC_SetElementAt3_long, true },
1049    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljjj", (void *)&SC_SetElementAt3_long2, true },
1050    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljjj", (void *)&SC_SetElementAt3_long3, true },
1051    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljjj", (void *)&SC_SetElementAt3_long4, true },
1052
1053    { "_Z20rsSetElementAt_float13rs_allocationPKft", (void *)&SC_SetElementAt1_float, true },
1054    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fj", (void *)&SC_SetElementAt1_float2, true },
1055    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fj", (void *)&SC_SetElementAt1_float3, true },
1056    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fj", (void *)&SC_SetElementAt1_float4, true },
1057    { "_Z20rsSetElementAt_float13rs_allocationPKfjj", (void *)&SC_SetElementAt2_float, true },
1058    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjj", (void *)&SC_SetElementAt2_float2, true },
1059    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjj", (void *)&SC_SetElementAt2_float3, true },
1060    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjj", (void *)&SC_SetElementAt2_float4, true },
1061    { "_Z20rsSetElementAt_float13rs_allocationPKfjjj", (void *)&SC_SetElementAt3_float, true },
1062    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjjj", (void *)&SC_SetElementAt3_float2, true },
1063    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjjj", (void *)&SC_SetElementAt3_float3, true },
1064    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjjj", (void *)&SC_SetElementAt3_float4, true },
1065
1066    { "_Z21rsSetElementAt_double13rs_allocationPKdt", (void *)&SC_SetElementAt1_double, true },
1067    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_dj", (void *)&SC_SetElementAt1_double2, true },
1068    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_dj", (void *)&SC_SetElementAt1_double3, true },
1069    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_dj", (void *)&SC_SetElementAt1_double4, true },
1070    { "_Z21rsSetElementAt_double13rs_allocationPKdjj", (void *)&SC_SetElementAt2_double, true },
1071    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djj", (void *)&SC_SetElementAt2_double2, true },
1072    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djj", (void *)&SC_SetElementAt2_double3, true },
1073    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djj", (void *)&SC_SetElementAt2_double4, true },
1074    { "_Z21rsSetElementAt_double13rs_allocationPKdjjj", (void *)&SC_SetElementAt3_double, true },
1075    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djjj", (void *)&SC_SetElementAt3_double2, true },
1076    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djjj", (void *)&SC_SetElementAt3_double3, true },
1077    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djjj", (void *)&SC_SetElementAt3_double4, true },
1078
1079
1080    // Refcounting
1081    { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
1082    { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
1083    { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
1084
1085    { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
1086    { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
1087    { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
1088
1089    { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
1090    { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
1091    { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
1092
1093    { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
1094    { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
1095    { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
1096
1097    { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
1098    { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
1099    { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
1100
1101    { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
1102    { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
1103    { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
1104
1105    { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
1106    { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
1107    { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
1108
1109    { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
1110    { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
1111    { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
1112
1113    { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
1114    { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
1115    { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
1116
1117    { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
1118    { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
1119    { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
1120
1121    { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
1122    { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
1123    { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
1124
1125    { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
1126    { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
1127    { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
1128
1129    // Allocation ops
1130    { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
1131    { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
1132    { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
1133    { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
1134    { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
1135#ifndef RS_COMPATIBILITY_LIB
1136    { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
1137    { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
1138#endif
1139    { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
1140    { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
1141
1142    // Messaging
1143
1144    { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
1145    { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
1146    { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
1147    { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
1148#ifndef RS_COMPATIBILITY_LIB
1149    { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
1150    { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
1151    { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
1152    { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
1153    { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
1154    { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
1155    { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
1156    { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
1157
1158    { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
1159    { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
1160    { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
1161
1162    { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
1163
1164    { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
1165
1166    { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
1167    { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
1168
1169
1170    { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
1171    { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
1172    { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
1173    { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
1174
1175    { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
1176    { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
1177    { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
1178    { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
1179
1180    { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
1181
1182    { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
1183    { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
1184
1185    { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
1186    { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
1187    { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
1188    { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
1189
1190    { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
1191    { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
1192
1193    { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
1194    { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
1195    { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
1196    { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
1197    { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
1198#endif // RS_COMPATIBILITY_LIB
1199
1200    { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
1201    { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
1202    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
1203    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
1204    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
1205
1206    // time
1207    { "_Z6rsTimePi", (void *)&SC_Time, true },
1208    { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
1209    { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
1210    { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
1211    { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
1212
1213    // misc
1214#ifndef RS_COMPATIBILITY_LIB
1215    { "_Z5colorffff", (void *)&SC_Color, false },
1216    { "_Z9rsgFinishv", (void *)&SC_Finish, false },
1217#endif
1218
1219    { NULL, NULL, false }
1220};
1221
1222#ifdef RS_COMPATIBILITY_LIB
1223
1224//////////////////////////////////////////////////////////////////////////////
1225// Compatibility Library entry points
1226//////////////////////////////////////////////////////////////////////////////
1227
1228#define IS_CLEAR_SET_OBJ(t) \
1229    bool rsIsObject(t src) { \
1230        return SC_IsObject((ObjectBase*)src.p); \
1231    } \
1232    void __attribute__((overloadable)) rsClearObject(t *dst) { \
1233        return SC_ClearObject((ObjectBase**) dst); \
1234    } \
1235    void __attribute__((overloadable)) rsSetObject(t *dst, t src) { \
1236        return SC_SetObject((ObjectBase**) dst, (ObjectBase*) src.p); \
1237    }
1238
1239IS_CLEAR_SET_OBJ(rs_element)
1240IS_CLEAR_SET_OBJ(rs_type)
1241IS_CLEAR_SET_OBJ(rs_allocation)
1242IS_CLEAR_SET_OBJ(rs_sampler)
1243IS_CLEAR_SET_OBJ(rs_script)
1244#undef IS_CLEAR_SET_OBJ
1245
1246const Allocation * rsGetAllocation(const void *ptr) {
1247    return SC_GetAllocation(ptr);
1248}
1249
1250void __attribute__((overloadable)) rsAllocationIoSend(rs_allocation a) {
1251    SC_AllocationIoSend((Allocation *)a.p);
1252}
1253
1254void __attribute__((overloadable)) rsAllocationIoReceive(rs_allocation a) {
1255    SC_AllocationIoReceive((Allocation *)a.p);
1256}
1257
1258
1259void __attribute__((overloadable)) rsAllocationCopy1DRange(
1260        rs_allocation dstAlloc,
1261        uint32_t dstOff, uint32_t dstMip, uint32_t count,
1262        rs_allocation srcAlloc,
1263        uint32_t srcOff, uint32_t srcMip) {
1264    SC_AllocationCopy1DRange((Allocation *)dstAlloc.p, dstOff, dstMip, count,
1265                             (Allocation *)srcAlloc.p, srcOff, srcMip);
1266}
1267
1268void __attribute__((overloadable)) rsAllocationCopy2DRange(
1269        rs_allocation dstAlloc,
1270        uint32_t dstXoff, uint32_t dstYoff,
1271        uint32_t dstMip, rs_allocation_cubemap_face dstFace,
1272        uint32_t width, uint32_t height,
1273        rs_allocation srcAlloc,
1274        uint32_t srcXoff, uint32_t srcYoff,
1275        uint32_t srcMip, rs_allocation_cubemap_face srcFace) {
1276    SC_AllocationCopy2DRange((Allocation *)dstAlloc.p, dstXoff, dstYoff,
1277                             dstMip, dstFace, width, height,
1278                             (Allocation *)srcAlloc.p, srcXoff, srcYoff,
1279                             srcMip, srcFace);
1280}
1281
1282void __attribute__((overloadable)) rsForEach(rs_script script,
1283                                             rs_allocation in,
1284                                             rs_allocation out,
1285                                             const void *usr,
1286                                             const rs_script_call *call) {
1287    return SC_ForEach_SAAUS((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p, usr, (RsScriptCall*)call);
1288}
1289
1290void __attribute__((overloadable)) rsForEach(rs_script script,
1291                                             rs_allocation in,
1292                                             rs_allocation out) {
1293    return SC_ForEach_SAA((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p);
1294}
1295
1296void __attribute__((overloadable)) rsForEach(rs_script script,
1297                                             rs_allocation in,
1298                                             rs_allocation out,
1299                                             const void *usr,
1300                                             uint32_t usrLen) {
1301    return SC_ForEach_SAAUL((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p, usr, usrLen);
1302}
1303
1304void __attribute__((overloadable)) rsForEach(rs_script script,
1305                                             rs_allocation in,
1306                                             rs_allocation out,
1307                                             const void *usr,
1308                                             uint32_t usrLen,
1309                                             const rs_script_call *call) {
1310    return SC_ForEach_SAAULS((Script *)script.p, (Allocation*)in.p, (Allocation*)out.p, usr, usrLen, (RsScriptCall*)call);
1311}
1312
1313int rsTime(int *timer) {
1314    return SC_Time(timer);
1315}
1316
1317rs_tm* rsLocaltime(rs_tm* local, const int *timer) {
1318    return (rs_tm*)(SC_LocalTime((tm*)local, (long*)timer));
1319}
1320
1321int64_t rsUptimeMillis() {
1322    Context *rsc = RsdCpuReference::getTlsContext();
1323    return rsrUptimeMillis(rsc);
1324}
1325
1326uint32_t rsSendToClient(int cmdID) {
1327    return SC_ToClient(cmdID);
1328}
1329
1330uint32_t rsSendToClient(int cmdID, const void *data, uint32_t len) {
1331    return SC_ToClient2(cmdID, data, len);
1332}
1333
1334uint32_t rsSendToClientBlocking(int cmdID) {
1335    return SC_ToClientBlocking(cmdID);
1336}
1337
1338uint32_t rsSendToClientBlocking(int cmdID, const void *data, uint32_t len) {
1339    return SC_ToClientBlocking2(cmdID, data, len);
1340}
1341
1342static void SC_debugF(const char *s, float f) {
1343    ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
1344}
1345static void SC_debugFv2(const char *s, float f1, float f2) {
1346    ALOGD("%s {%f, %f}", s, f1, f2);
1347}
1348static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
1349    ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
1350}
1351static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
1352    ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
1353}
1354static void SC_debugF2(const char *s, float2 f) {
1355    ALOGD("%s {%f, %f}", s, f.x, f.y);
1356}
1357static void SC_debugF3(const char *s, float3 f) {
1358    ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
1359}
1360static void SC_debugF4(const char *s, float4 f) {
1361    ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
1362}
1363static void SC_debugD(const char *s, double d) {
1364    ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
1365}
1366static void SC_debugFM4v4(const char *s, const float *f) {
1367    ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
1368    ALOGD("%s  %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
1369    ALOGD("%s  %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
1370    ALOGD("%s  %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
1371}
1372static void SC_debugFM3v3(const char *s, const float *f) {
1373    ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
1374    ALOGD("%s  %f, %f, %f", s, f[1], f[4], f[7]);
1375    ALOGD("%s  %f, %f, %f}",s, f[2], f[5], f[8]);
1376}
1377static void SC_debugFM2v2(const char *s, const float *f) {
1378    ALOGD("%s {%f, %f", s, f[0], f[2]);
1379    ALOGD("%s  %f, %f}",s, f[1], f[3]);
1380}
1381static void SC_debugI8(const char *s, char c) {
1382    ALOGD("%s %hhd  0x%hhx", s, c, (unsigned char)c);
1383}
1384static void SC_debugC2(const char *s, char2 c) {
1385    ALOGD("%s {%hhd, %hhd}  0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
1386}
1387static void SC_debugC3(const char *s, char3 c) {
1388    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);
1389}
1390static void SC_debugC4(const char *s, char4 c) {
1391    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);
1392}
1393static void SC_debugU8(const char *s, unsigned char c) {
1394    ALOGD("%s %hhu  0x%hhx", s, c, c);
1395}
1396static void SC_debugUC2(const char *s, uchar2 c) {
1397    ALOGD("%s {%hhu, %hhu}  0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
1398}
1399static void SC_debugUC3(const char *s, uchar3 c) {
1400    ALOGD("%s {%hhu, %hhu, %hhu}  0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1401}
1402static void SC_debugUC4(const char *s, uchar4 c) {
1403    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);
1404}
1405static void SC_debugI16(const char *s, short c) {
1406    ALOGD("%s %hd  0x%hx", s, c, c);
1407}
1408static void SC_debugS2(const char *s, short2 c) {
1409    ALOGD("%s {%hd, %hd}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1410}
1411static void SC_debugS3(const char *s, short3 c) {
1412    ALOGD("%s {%hd, %hd, %hd}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1413}
1414static void SC_debugS4(const char *s, short4 c) {
1415    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);
1416}
1417static void SC_debugU16(const char *s, unsigned short c) {
1418    ALOGD("%s %hu  0x%hx", s, c, c);
1419}
1420static void SC_debugUS2(const char *s, ushort2 c) {
1421    ALOGD("%s {%hu, %hu}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1422}
1423static void SC_debugUS3(const char *s, ushort3 c) {
1424    ALOGD("%s {%hu, %hu, %hu}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1425}
1426static void SC_debugUS4(const char *s, ushort4 c) {
1427    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);
1428}
1429static void SC_debugI32(const char *s, int32_t i) {
1430    ALOGD("%s %d  0x%x", s, i, i);
1431}
1432static void SC_debugI2(const char *s, int2 i) {
1433    ALOGD("%s {%d, %d}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1434}
1435static void SC_debugI3(const char *s, int3 i) {
1436    ALOGD("%s {%d, %d, %d}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1437}
1438static void SC_debugI4(const char *s, int4 i) {
1439    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);
1440}
1441static void SC_debugU32(const char *s, uint32_t i) {
1442    ALOGD("%s %u  0x%x", s, i, i);
1443}
1444static void SC_debugUI2(const char *s, uint2 i) {
1445    ALOGD("%s {%u, %u}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1446}
1447static void SC_debugUI3(const char *s, uint3 i) {
1448    ALOGD("%s {%u, %u, %u}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1449}
1450static void SC_debugUI4(const char *s, uint4 i) {
1451    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);
1452}
1453static void SC_debugLL64(const char *s, long long ll) {
1454    ALOGD("%s %lld  0x%llx", s, ll, ll);
1455}
1456static void SC_debugL2(const char *s, long2 ll) {
1457    ALOGD("%s {%lld, %lld}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
1458}
1459static void SC_debugL3(const char *s, long3 ll) {
1460    ALOGD("%s {%lld, %lld, %lld}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
1461}
1462static void SC_debugL4(const char *s, long4 ll) {
1463    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);
1464}
1465static void SC_debugULL64(const char *s, unsigned long long ll) {
1466    ALOGD("%s %llu  0x%llx", s, ll, ll);
1467}
1468static void SC_debugUL2(const char *s, ulong2 ll) {
1469    ALOGD("%s {%llu, %llu}  0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
1470}
1471static void SC_debugUL3(const char *s, ulong3 ll) {
1472    ALOGD("%s {%llu, %llu, %llu}  0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
1473}
1474static void SC_debugUL4(const char *s, ulong4 ll) {
1475    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);
1476}
1477static void SC_debugP(const char *s, const void *p) {
1478    ALOGD("%s %p", s, p);
1479}
1480
1481// TODO: allocation ops, messaging, time
1482
1483void rsDebug(const char *s, float f) {
1484    SC_debugF(s, f);
1485}
1486
1487void rsDebug(const char *s, float f1, float f2) {
1488    SC_debugFv2(s, f1, f2);
1489}
1490
1491void rsDebug(const char *s, float f1, float f2, float f3) {
1492    SC_debugFv3(s, f1, f2, f3);
1493}
1494
1495void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
1496    SC_debugFv4(s, f1, f2, f3, f4);
1497}
1498
1499void rsDebug(const char *s, const float2 *f) {
1500    SC_debugF2(s, *f);
1501}
1502
1503void rsDebug(const char *s, const float3 *f) {
1504    SC_debugF3(s, *f);
1505}
1506
1507void rsDebug(const char *s, const float4 *f) {
1508    SC_debugF4(s, *f);
1509}
1510
1511void rsDebug(const char *s, double d) {
1512    SC_debugD(s, d);
1513}
1514
1515void rsDebug(const char *s, const rs_matrix4x4 *m) {
1516    SC_debugFM4v4(s, (float *) m);
1517}
1518
1519void rsDebug(const char *s, const rs_matrix3x3 *m) {
1520    SC_debugFM3v3(s, (float *) m);
1521}
1522
1523void rsDebug(const char *s, const rs_matrix2x2 *m) {
1524    SC_debugFM2v2(s, (float *) m);
1525}
1526
1527void rsDebug(const char *s, char c) {
1528    SC_debugI8(s, c);
1529}
1530
1531void rsDebug(const char *s, const char2 *c) {
1532    SC_debugC2(s, *c);
1533}
1534
1535void rsDebug(const char *s, const char3 *c) {
1536    SC_debugC3(s, *c);
1537}
1538
1539void rsDebug(const char *s, const char4 *c) {
1540    SC_debugC4(s, *c);
1541}
1542
1543void rsDebug(const char *s, unsigned char c) {
1544    SC_debugU8(s, c);
1545}
1546
1547void rsDebug(const char *s, const uchar2 *c) {
1548    SC_debugUC2(s, *c);
1549}
1550
1551void rsDebug(const char *s, const uchar3 *c) {
1552    SC_debugUC3(s, *c);
1553}
1554
1555void rsDebug(const char *s, const uchar4 *c) {
1556    SC_debugUC4(s, *c);
1557}
1558
1559void rsDebug(const char *s, short c) {
1560    SC_debugI16(s, c);
1561}
1562
1563void rsDebug(const char *s, const short2 *c) {
1564    SC_debugS2(s, *c);
1565}
1566
1567void rsDebug(const char *s, const short3 *c) {
1568    SC_debugS3(s, *c);
1569}
1570
1571void rsDebug(const char *s, const short4 *c) {
1572    SC_debugS4(s, *c);
1573}
1574
1575void rsDebug(const char *s, unsigned short c) {
1576    SC_debugU16(s, c);
1577}
1578
1579void rsDebug(const char *s, const ushort2 *c) {
1580    SC_debugUS2(s, *c);
1581}
1582
1583void rsDebug(const char *s, const ushort3 *c) {
1584    SC_debugUS3(s, *c);
1585}
1586
1587void rsDebug(const char *s, const ushort4 *c) {
1588    SC_debugUS4(s, *c);
1589}
1590
1591void rsDebug(const char *s, int c) {
1592    SC_debugI32(s, c);
1593}
1594
1595void rsDebug(const char *s, const int2 *c) {
1596    SC_debugI2(s, *c);
1597}
1598
1599void rsDebug(const char *s, const int3 *c) {
1600    SC_debugI3(s, *c);
1601}
1602
1603void rsDebug(const char *s, const int4 *c) {
1604    SC_debugI4(s, *c);
1605}
1606
1607void rsDebug(const char *s, unsigned int c) {
1608    SC_debugU32(s, c);
1609}
1610
1611void rsDebug(const char *s, const uint2 *c) {
1612    SC_debugUI2(s, *c);
1613}
1614
1615void rsDebug(const char *s, const uint3 *c) {
1616    SC_debugUI3(s, *c);
1617}
1618
1619void rsDebug(const char *s, const uint4 *c) {
1620    SC_debugUI4(s, *c);
1621}
1622
1623void rsDebug(const char *s, long c) {
1624    SC_debugLL64(s, c);
1625}
1626
1627void rsDebug(const char *s, long long c) {
1628    SC_debugLL64(s, c);
1629}
1630
1631void rsDebug(const char *s, const long2 *c) {
1632    SC_debugL2(s, *c);
1633}
1634
1635void rsDebug(const char *s, const long3 *c) {
1636    SC_debugL3(s, *c);
1637}
1638
1639void rsDebug(const char *s, const long4 *c) {
1640    SC_debugL4(s, *c);
1641}
1642
1643void rsDebug(const char *s, unsigned long c) {
1644    SC_debugULL64(s, c);
1645}
1646
1647void rsDebug(const char *s, unsigned long long c) {
1648    SC_debugULL64(s, c);
1649}
1650
1651void rsDebug(const char *s, const ulong2 *c) {
1652    SC_debugUL2(s, *c);
1653}
1654
1655void rsDebug(const char *s, const ulong3 *c) {
1656    SC_debugUL3(s, *c);
1657}
1658
1659void rsDebug(const char *s, const ulong4 *c) {
1660    SC_debugUL4(s, *c);
1661}
1662
1663// FIXME: We need to export these function signatures for the compatibility
1664// library. The C++ name mangling that LLVM uses for ext_vector_type requires
1665// different versions for "long" vs. "long long". Note that the called
1666// functions are still using the appropriate 64-bit sizes.
1667typedef long l2 __attribute__((ext_vector_type(2)));
1668typedef long l3 __attribute__((ext_vector_type(3)));
1669typedef long l4 __attribute__((ext_vector_type(4)));
1670typedef unsigned long ul2 __attribute__((ext_vector_type(2)));
1671typedef unsigned long ul3 __attribute__((ext_vector_type(3)));
1672typedef unsigned long ul4 __attribute__((ext_vector_type(4)));
1673
1674void rsDebug(const char *s, const l2 *c) {
1675    SC_debugL2(s, *(const long2 *)c);
1676}
1677
1678void rsDebug(const char *s, const l3 *c) {
1679    SC_debugL3(s, *(const long3 *)c);
1680}
1681
1682void rsDebug(const char *s, const l4 *c) {
1683    SC_debugL4(s, *(const long4 *)c);
1684}
1685
1686void rsDebug(const char *s, const ul2 *c) {
1687    SC_debugUL2(s, *(const ulong2 *)c);
1688}
1689
1690void rsDebug(const char *s, const ul3 *c) {
1691    SC_debugUL3(s, *(const ulong3 *)c);
1692}
1693
1694void rsDebug(const char *s, const ul4 *c) {
1695    SC_debugUL4(s, *(const ulong4 *)c);
1696}
1697
1698void rsDebug(const char *s, const void *p) {
1699    SC_debugP(s, p);
1700}
1701#endif // RS_COMPATIBILITY_LIB
1702
1703extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
1704    ScriptC *s = (ScriptC *)pContext;
1705    const RsdCpuReference::CpuSymbol *syms = gSyms;
1706    const RsdCpuReference::CpuSymbol *sym = NULL;
1707
1708    if (!sym) {
1709        while (syms->fnPtr) {
1710            if (!strcmp(syms->name, name)) {
1711                return syms;
1712            }
1713            syms++;
1714        }
1715    }
1716
1717    return NULL;
1718}
1719
1720
1721