rsdRuntimeStubs.cpp revision 709a1894c9c265433dc657878cba7b1be2514040
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 int16_t short2 __attribute__((ext_vector_type(2)));
50typedef int16_t short3 __attribute__((ext_vector_type(3)));
51typedef int16_t short4 __attribute__((ext_vector_type(4)));
52typedef uint16_t ushort2 __attribute__((ext_vector_type(2)));
53typedef uint16_t ushort3 __attribute__((ext_vector_type(3)));
54typedef uint16_t 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 int64_t long2 __attribute__((ext_vector_type(2)));
62typedef int64_t long3 __attribute__((ext_vector_type(3)));
63typedef int64_t long4 __attribute__((ext_vector_type(4)));
64typedef uint64_t ulong2 __attribute__((ext_vector_type(2)));
65typedef uint64_t ulong3 __attribute__((ext_vector_type(3)));
66typedef uint64_t 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#ifndef __LP64__
76#define OPAQUETYPE(t) \
77    typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t;
78#else
79#define OPAQUETYPE(t) \
80    typedef struct { const void* p; const void* r; const void* v1; const void* v2; } t;
81#endif
82
83OPAQUETYPE(rs_element)
84OPAQUETYPE(rs_type)
85OPAQUETYPE(rs_allocation)
86OPAQUETYPE(rs_sampler)
87OPAQUETYPE(rs_script)
88OPAQUETYPE(rs_script_call)
89
90OPAQUETYPE(rs_program_fragment);
91OPAQUETYPE(rs_program_store);
92OPAQUETYPE(rs_program_vertex);
93OPAQUETYPE(rs_program_raster);
94
95OPAQUETYPE(rs_mesh);
96OPAQUETYPE(rs_font);
97OPAQUETYPE(rs_path);
98
99#undef OPAQUETYPE
100
101typedef enum {
102    // Empty to avoid conflicting definitions with RsAllocationCubemapFace
103} rs_allocation_cubemap_face;
104
105typedef struct {
106    int tm_sec;     ///< seconds
107    int tm_min;     ///< minutes
108    int tm_hour;    ///< hours
109    int tm_mday;    ///< day of the month
110    int tm_mon;     ///< month
111    int tm_year;    ///< year
112    int tm_wday;    ///< day of the week
113    int tm_yday;    ///< day of the year
114    int tm_isdst;   ///< daylight savings time
115} rs_tm;
116
117//////////////////////////////////////////////////////////////////////////////
118// Allocation
119//////////////////////////////////////////////////////////////////////////////
120
121
122static void SC_AllocationSyncAll2(android::renderscript::rs_allocation a, RsAllocationUsageType source) {
123    Context *rsc = RsdCpuReference::getTlsContext();
124    rsrAllocationSyncAll(rsc, (Allocation*)a.p, source);
125}
126
127static void SC_AllocationSyncAll(android::renderscript::rs_allocation a) {
128    Context *rsc = RsdCpuReference::getTlsContext();
129    rsrAllocationSyncAll(rsc, (Allocation*)a.p, RS_ALLOCATION_USAGE_SCRIPT);
130}
131
132#ifndef RS_COMPATIBILITY_LIB
133
134static void SC_AllocationCopy1DRange(::rs_allocation dstAlloc,
135                                     uint32_t dstOff,
136                                     uint32_t dstMip,
137                                     uint32_t count,
138                                     ::rs_allocation srcAlloc,
139                                     uint32_t srcOff, uint32_t srcMip) {
140    Context *rsc = RsdCpuReference::getTlsContext();
141    rsrAllocationCopy1DRange(rsc, (Allocation*)dstAlloc.p, dstOff, dstMip, count,
142                             (Allocation*)srcAlloc.p, srcOff, srcMip);
143}
144
145static void SC_AllocationCopy2DRange(::rs_allocation dstAlloc,
146                                     uint32_t dstXoff, uint32_t dstYoff,
147                                     uint32_t dstMip, uint32_t dstFace,
148                                     uint32_t width, uint32_t height,
149                                     ::rs_allocation srcAlloc,
150                                     uint32_t srcXoff, uint32_t srcYoff,
151                                     uint32_t srcMip, uint32_t srcFace) {
152    Context *rsc = RsdCpuReference::getTlsContext();
153    rsrAllocationCopy2DRange(rsc, (Allocation*)dstAlloc.p,
154                             dstXoff, dstYoff, dstMip, dstFace,
155                             width, height,
156                             (Allocation*)srcAlloc.p,
157                             srcXoff, srcYoff, srcMip, srcFace);
158}
159
160static void SC_AllocationIoSend(::rs_allocation alloc) {
161    Context *rsc = RsdCpuReference::getTlsContext();
162    rsrAllocationIoSend(rsc, (Allocation*)alloc.p);
163}
164
165
166static void SC_AllocationIoReceive(::rs_allocation alloc) {
167    Context *rsc = RsdCpuReference::getTlsContext();
168    rsrAllocationIoReceive(rsc, (Allocation*)alloc.p);
169}
170
171#else
172
173static void SC_AllocationCopy1DRange(::rs_allocation dstAlloc,
174                                     uint32_t dstOff,
175                                     uint32_t dstMip,
176                                     uint32_t count,
177                                     ::rs_allocation srcAlloc,
178                                     uint32_t srcOff, uint32_t srcMip) {
179    Context *rsc = RsdCpuReference::getTlsContext();
180    rsrAllocationCopy1DRange(rsc, (Allocation*)dstAlloc.p, dstOff, dstMip, count,
181                             (Allocation*)srcAlloc.p, srcOff, srcMip);
182}
183
184static void SC_AllocationCopy2DRange(::rs_allocation dstAlloc,
185                                     uint32_t dstXoff, uint32_t dstYoff,
186                                     uint32_t dstMip, uint32_t dstFace,
187                                     uint32_t width, uint32_t height,
188                                     ::rs_allocation srcAlloc,
189                                     uint32_t srcXoff, uint32_t srcYoff,
190                                     uint32_t srcMip, uint32_t srcFace) {
191    Context *rsc = RsdCpuReference::getTlsContext();
192    rsrAllocationCopy2DRange(rsc, (Allocation*)dstAlloc.p,
193                             dstXoff, dstYoff, dstMip, dstFace,
194                             width, height,
195                             (Allocation*)srcAlloc.p,
196                             srcXoff, srcYoff, srcMip, srcFace);
197}
198
199static void SC_AllocationIoSend(::rs_allocation alloc) {
200    Context *rsc = RsdCpuReference::getTlsContext();
201    rsrAllocationIoSend(rsc, (Allocation *) alloc.p);
202}
203
204
205static void SC_AllocationIoReceive(::rs_allocation alloc) {
206    Context *rsc = RsdCpuReference::getTlsContext();
207    rsrAllocationIoReceive(rsc, (Allocation *) alloc.p);
208}
209
210#endif
211
212#ifndef RS_COMPATIBILITY_LIB
213
214//////////////////////////////////////////////////////////////////////////////
215// Context
216//////////////////////////////////////////////////////////////////////////////
217
218static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
219    Context *rsc = RsdCpuReference::getTlsContext();
220    rsrBindTexture(rsc, pf, slot, a);
221}
222
223static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
224    Context *rsc = RsdCpuReference::getTlsContext();
225    rsrBindConstant(rsc, pv, slot, a);
226}
227
228static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
229    Context *rsc = RsdCpuReference::getTlsContext();
230    rsrBindConstant(rsc, pf, slot, a);
231}
232
233static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
234    Context *rsc = RsdCpuReference::getTlsContext();
235    rsrBindSampler(rsc, pf, slot, s);
236}
237
238static void SC_BindProgramStore(ProgramStore *ps) {
239    Context *rsc = RsdCpuReference::getTlsContext();
240    rsrBindProgramStore(rsc, ps);
241}
242
243static void SC_BindProgramFragment(ProgramFragment *pf) {
244    Context *rsc = RsdCpuReference::getTlsContext();
245    rsrBindProgramFragment(rsc, pf);
246}
247
248static void SC_BindProgramVertex(ProgramVertex *pv) {
249    Context *rsc = RsdCpuReference::getTlsContext();
250    rsrBindProgramVertex(rsc, pv);
251}
252
253static void SC_BindProgramRaster(ProgramRaster *pr) {
254    Context *rsc = RsdCpuReference::getTlsContext();
255    rsrBindProgramRaster(rsc, pr);
256}
257
258static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
259    Context *rsc = RsdCpuReference::getTlsContext();
260    rsrBindFrameBufferObjectColorTarget(rsc, a, slot);
261}
262
263static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
264    Context *rsc = RsdCpuReference::getTlsContext();
265    rsrBindFrameBufferObjectDepthTarget(rsc, a);
266}
267
268static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
269    Context *rsc = RsdCpuReference::getTlsContext();
270    rsrClearFrameBufferObjectColorTarget(rsc, slot);
271}
272
273static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
274    Context *rsc = RsdCpuReference::getTlsContext();
275    rsrClearFrameBufferObjectDepthTarget(rsc);
276}
277
278static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
279    Context *rsc = RsdCpuReference::getTlsContext();
280    rsrClearFrameBufferObjectTargets(rsc);
281}
282
283
284//////////////////////////////////////////////////////////////////////////////
285// VP
286//////////////////////////////////////////////////////////////////////////////
287
288static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
289    Context *rsc = RsdCpuReference::getTlsContext();
290    rsrVpLoadProjectionMatrix(rsc, m);
291}
292
293static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
294    Context *rsc = RsdCpuReference::getTlsContext();
295    rsrVpLoadModelMatrix(rsc, m);
296}
297
298static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
299    Context *rsc = RsdCpuReference::getTlsContext();
300    rsrVpLoadTextureMatrix(rsc, m);
301}
302
303static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
304    Context *rsc = RsdCpuReference::getTlsContext();
305    rsrPfConstantColor(rsc, pf, r, g, b, a);
306}
307
308static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
309    Context *rsc = RsdCpuReference::getTlsContext();
310    rsrVpGetProjectionMatrix(rsc, m);
311}
312
313
314//////////////////////////////////////////////////////////////////////////////
315// Drawing
316//////////////////////////////////////////////////////////////////////////////
317
318static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
319                                 float x2, float y2, float z2, float u2, float v2,
320                                 float x3, float y3, float z3, float u3, float v3,
321                                 float x4, float y4, float z4, float u4, float v4) {
322    Context *rsc = RsdCpuReference::getTlsContext();
323
324    if (!rsc->setupCheck()) {
325        return;
326    }
327
328    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
329    if (!dc->gl.shaderCache->setup(rsc)) {
330        return;
331    }
332
333    //ALOGE("Quad");
334    //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
335    //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
336    //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
337    //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
338
339    float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
340    const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
341
342    RsdVertexArray::Attrib attribs[2];
343    attribs[0].set(GL_FLOAT, 3, 12, false, (size_t)vtx, "ATTRIB_position");
344    attribs[1].set(GL_FLOAT, 2, 8, false, (size_t)tex, "ATTRIB_texture0");
345
346    RsdVertexArray va(attribs, 2);
347    va.setup(rsc);
348
349    RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
350}
351
352static void SC_DrawQuad(float x1, float y1, float z1,
353                        float x2, float y2, float z2,
354                        float x3, float y3, float z3,
355                        float x4, float y4, float z4) {
356    SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
357                         x2, y2, z2, 1, 1,
358                         x3, y3, z3, 1, 0,
359                         x4, y4, z4, 0, 0);
360}
361
362static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
363    Context *rsc = RsdCpuReference::getTlsContext();
364
365    ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
366    rsc->setProgramVertex(rsc->getDefaultProgramVertex());
367    //rsc->setupCheck();
368
369    //GLint crop[4] = {0, h, w, -h};
370
371    float sh = rsc->getHeight();
372
373    SC_DrawQuad(x,   sh - y,     z,
374                x+w, sh - y,     z,
375                x+w, sh - (y+h), z,
376                x,   sh - (y+h), z);
377    rsc->setProgramVertex((ProgramVertex *)tmp.get());
378}
379
380static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
381    SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
382}
383
384static void SC_DrawPath(Path *p) {
385    Context *rsc = RsdCpuReference::getTlsContext();
386    rsdPathDraw(rsc, p);
387}
388
389static void SC_DrawMesh(Mesh *m) {
390    Context *rsc = RsdCpuReference::getTlsContext();
391    rsrDrawMesh(rsc, m);
392}
393
394static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
395    Context *rsc = RsdCpuReference::getTlsContext();
396    rsrDrawMeshPrimitive(rsc, m, primIndex);
397}
398
399static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
400    Context *rsc = RsdCpuReference::getTlsContext();
401    rsrDrawMeshPrimitiveRange(rsc, m, primIndex, start, len);
402}
403
404static void SC_MeshComputeBoundingBox(Mesh *m,
405                               float *minX, float *minY, float *minZ,
406                               float *maxX, float *maxY, float *maxZ) {
407    Context *rsc = RsdCpuReference::getTlsContext();
408    rsrMeshComputeBoundingBox(rsc, m, minX, minY, minZ, maxX, maxY, maxZ);
409}
410
411
412
413//////////////////////////////////////////////////////////////////////////////
414//
415//////////////////////////////////////////////////////////////////////////////
416
417
418static void SC_Color(float r, float g, float b, float a) {
419    Context *rsc = RsdCpuReference::getTlsContext();
420    rsrColor(rsc, r, g, b, a);
421}
422
423static void SC_Finish() {
424    Context *rsc = RsdCpuReference::getTlsContext();
425    rsdGLFinish(rsc);
426}
427
428static void SC_ClearColor(float r, float g, float b, float a) {
429    Context *rsc = RsdCpuReference::getTlsContext();
430    rsrPrepareClear(rsc);
431    rsdGLClearColor(rsc, r, g, b, a);
432}
433
434static void SC_ClearDepth(float v) {
435    Context *rsc = RsdCpuReference::getTlsContext();
436    rsrPrepareClear(rsc);
437    rsdGLClearDepth(rsc, v);
438}
439
440static uint32_t SC_GetWidth() {
441    Context *rsc = RsdCpuReference::getTlsContext();
442    return rsrGetWidth(rsc);
443}
444
445static uint32_t SC_GetHeight() {
446    Context *rsc = RsdCpuReference::getTlsContext();
447    return rsrGetHeight(rsc);
448}
449
450static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
451    Context *rsc = RsdCpuReference::getTlsContext();
452    rsrDrawTextAlloc(rsc, a, x, y);
453}
454
455static void SC_DrawText(const char *text, int x, int y) {
456    Context *rsc = RsdCpuReference::getTlsContext();
457    rsrDrawText(rsc, text, x, y);
458}
459
460static void SC_MeasureTextAlloc(Allocation *a,
461                         int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
462    Context *rsc = RsdCpuReference::getTlsContext();
463    rsrMeasureTextAlloc(rsc, a, left, right, top, bottom);
464}
465
466static void SC_MeasureText(const char *text,
467                    int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
468    Context *rsc = RsdCpuReference::getTlsContext();
469    rsrMeasureText(rsc, text, left, right, top, bottom);
470}
471
472static void SC_BindFont(Font *f) {
473    Context *rsc = RsdCpuReference::getTlsContext();
474    rsrBindFont(rsc, f);
475}
476
477static void SC_FontColor(float r, float g, float b, float a) {
478    Context *rsc = RsdCpuReference::getTlsContext();
479    rsrFontColor(rsc, r, g, b, a);
480}
481#endif
482
483
484//////////////////////////////////////////////////////////////////////////////
485//
486//////////////////////////////////////////////////////////////////////////////
487
488static void SC_ClearObject(rs_object_base *dst) {
489    Context *rsc = RsdCpuReference::getTlsContext();
490    rsrClearObject(rsc, dst);
491}
492
493static void SC_SetObject(rs_object_base *dst, rs_object_base  src) {
494    //    ALOGE("SC_SetObject: dst = %p, src = %p", dst, src.p);
495    //    ALOGE("SC_SetObject: dst[0] = %p", dst[0]);
496    Context *rsc = RsdCpuReference::getTlsContext();
497    rsrSetObject(rsc, dst, (ObjectBase*)src.p);
498}
499
500static bool SC_IsObject(rs_object_base o) {
501    Context *rsc = RsdCpuReference::getTlsContext();
502    return rsrIsObject(rsc, o);
503}
504
505#ifdef __LP64__
506static void SC_SetObject_ByRef(rs_object_base *dst, rs_object_base *src) {
507    //    ALOGE("SC_SetObject2: dst = %p, src = %p", dst, src->p);
508    Context *rsc = RsdCpuReference::getTlsContext();
509    rsrSetObject(rsc, dst, (ObjectBase*)src->p);
510}
511
512static bool SC_IsObject_ByRef(rs_object_base *o) {
513    Context *rsc = RsdCpuReference::getTlsContext();
514    return rsrIsObject(rsc, *o);
515}
516#endif
517
518
519#ifndef RS_COMPATIBILITY_LIB
520#ifndef __LP64__
521
522// i386 has different struct return passing to ARM; emulate with void*
523#ifdef __i386__
524static const void* SC_GetAllocation(const void *ptr) {
525    Context *rsc = RsdCpuReference::getTlsContext();
526    const Script *sc = RsdCpuReference::getTlsScript();
527    Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
528    android::renderscript::rs_allocation obj = {0};
529    alloc->callUpdateCacheObject(rsc, &obj);
530    return (void*)obj.p;
531}
532#else
533// ARMv7/MIPS
534static const android::renderscript::rs_allocation SC_GetAllocation(const void *ptr) {
535    Context *rsc = RsdCpuReference::getTlsContext();
536    const Script *sc = RsdCpuReference::getTlsScript();
537    Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
538    android::renderscript::rs_allocation obj = {0};
539    alloc->callUpdateCacheObject(rsc, &obj);
540    return obj;
541}
542#endif
543#else
544// AArch64/x86_64/MIPS64
545static const android::renderscript::rs_allocation SC_GetAllocation(const void *ptr) {
546    Context *rsc = RsdCpuReference::getTlsContext();
547    const Script *sc = RsdCpuReference::getTlsScript();
548    Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
549    android::renderscript::rs_allocation obj = {0, 0, 0, 0};
550    alloc->callUpdateCacheObject(rsc, &obj);
551    return obj;
552}
553#endif
554#endif
555
556
557#ifndef __LP64__
558static void SC_ForEach_SAA(::rs_script target,
559                           ::rs_allocation in,
560                           ::rs_allocation out);
561#else
562static void SC_ForEach_SAA(android::renderscript::rs_script *target,
563                            android::renderscript::rs_allocation *in,
564                            android::renderscript::rs_allocation *out) {
565    Context *rsc = RsdCpuReference::getTlsContext();
566    rsrForEach(rsc, (Script*)target->p, (Allocation*)in->p, (Allocation*)out->p, NULL, 0, NULL);
567}
568#endif
569
570#ifndef __LP64__
571static void SC_ForEach_SAAU(::rs_script target,
572                            ::rs_allocation in,
573                            ::rs_allocation out,
574                            const void *usr) {
575    Context *rsc = RsdCpuReference::getTlsContext();
576    rsrForEach(rsc, (Script*)target.p, (Allocation*)in.p, (Allocation*)out.p,
577               usr, 0, nullptr);
578}
579#else
580static void SC_ForEach_SAAU(::rs_script *target,
581                            ::rs_allocation *in,
582                            ::rs_allocation *out,
583                            const void *usr) {
584    Context *rsc = RsdCpuReference::getTlsContext();
585    rsrForEach(rsc, (Script*)target->p, (Allocation*)in->p, (Allocation*)out->p, usr, 0, NULL);
586}
587#endif
588
589#ifndef __LP64__
590static void SC_ForEach_SAAUS(::rs_script target,
591                             ::rs_allocation in,
592                             ::rs_allocation out,
593                             const void *usr,
594                             const RsScriptCall *call);
595#else
596static void SC_ForEach_SAAUS(android::renderscript::rs_script *target,
597                             android::renderscript::rs_allocation *in,
598                             android::renderscript::rs_allocation *out,
599                             const void *usr,
600                             const RsScriptCall *call) {
601    Context *rsc = RsdCpuReference::getTlsContext();
602    rsrForEach(rsc, (Script*)target->p, (Allocation*)in->p, (Allocation*)out->p, usr, 0, call);
603}
604#endif
605
606// These functions are only supported in 32-bit.
607#ifndef __LP64__
608static void SC_ForEach_SAAUL(::rs_script target,
609                             ::rs_allocation in,
610                             ::rs_allocation out,
611                             const void *usr,
612                             uint32_t usrLen);
613
614static void SC_ForEach_SAAULS(::rs_script target,
615                              ::rs_allocation in,
616                              ::rs_allocation out,
617                              const void *usr,
618                              uint32_t usrLen,
619                              const RsScriptCall *call);
620#endif
621
622
623//////////////////////////////////////////////////////////////////////////////
624// Time routines
625//////////////////////////////////////////////////////////////////////////////
626
627static float SC_GetDt() {
628    Context *rsc = RsdCpuReference::getTlsContext();
629    const Script *sc = RsdCpuReference::getTlsScript();
630    return rsrGetDt(rsc, sc);
631}
632
633// #if !defined(RS_COMPATIBILITY_LIB) && defined(__LP64__)
634#ifdef __LP64__
635time_t SC_Time(time_t *timer) {
636    Context *rsc = RsdCpuReference::getTlsContext();
637    return rsrTime(rsc, timer);
638}
639#else
640static int SC_Time(int *timer) {
641    Context *rsc = RsdCpuReference::getTlsContext();
642    return rsrTime(rsc, (long*)timer);
643}
644#endif
645
646tm* SC_LocalTime(tm *local, time_t *timer) {
647    Context *rsc = RsdCpuReference::getTlsContext();
648    return rsrLocalTime(rsc, local, timer);
649}
650
651int64_t SC_UptimeMillis() {
652    Context *rsc = RsdCpuReference::getTlsContext();
653    return rsrUptimeMillis(rsc);
654}
655
656int64_t SC_UptimeNanos() {
657    Context *rsc = RsdCpuReference::getTlsContext();
658    return rsrUptimeNanos(rsc);
659}
660
661//////////////////////////////////////////////////////////////////////////////
662// Message routines
663//////////////////////////////////////////////////////////////////////////////
664
665static uint32_t SC_ToClient2(int cmdID, const void *data, uint32_t len) {
666    Context *rsc = RsdCpuReference::getTlsContext();
667    return rsrToClient(rsc, cmdID, data, len);
668}
669
670static uint32_t SC_ToClient(int cmdID) {
671    Context *rsc = RsdCpuReference::getTlsContext();
672    return rsrToClient(rsc, cmdID, (const void *)nullptr, 0);
673}
674
675static uint32_t SC_ToClientBlocking2(int cmdID, const void *data, uint32_t len) {
676    Context *rsc = RsdCpuReference::getTlsContext();
677    return rsrToClientBlocking(rsc, cmdID, data, len);
678}
679
680static uint32_t SC_ToClientBlocking(int cmdID) {
681    Context *rsc = RsdCpuReference::getTlsContext();
682    return rsrToClientBlocking(rsc, cmdID, (const void *)nullptr, 0);
683}
684
685
686static void * ElementAt1D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x) {
687    Context *rsc = RsdCpuReference::getTlsContext();
688    const Type *t = a->getType();
689    const Element *e = t->getElement();
690
691    char buf[256];
692    if (x >= t->getLODDimX(0)) {
693        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
694        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
695        return nullptr;
696    }
697
698    if (vecSize > 0) {
699        if (vecSize != e->getVectorSize()) {
700            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
701            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
702            return nullptr;
703        }
704
705        if (dt != e->getType()) {
706            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
707            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
708            return nullptr;
709        }
710    }
711
712    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
713    const uint32_t eSize = e->getSizeBytes();
714    return &p[(eSize * x)];
715}
716
717static void * ElementAt2D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y) {
718    Context *rsc = RsdCpuReference::getTlsContext();
719    const Type *t = a->getType();
720    const Element *e = t->getElement();
721
722    char buf[256];
723    if (x >= t->getLODDimX(0)) {
724        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
725        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
726        return nullptr;
727    }
728
729    if (y >= t->getLODDimY(0)) {
730        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
731        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
732        return nullptr;
733    }
734
735    if (vecSize > 0) {
736        if (vecSize != e->getVectorSize()) {
737            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
738            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
739            return nullptr;
740        }
741
742        if (dt != e->getType()) {
743            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
744            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
745            return nullptr;
746        }
747    }
748
749    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
750    const uint32_t eSize = e->getSizeBytes();
751    const uint32_t stride = a->mHal.drvState.lod[0].stride;
752    return &p[(eSize * x) + (y * stride)];
753}
754
755static void * ElementAt3D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y, uint32_t z) {
756    Context *rsc = RsdCpuReference::getTlsContext();
757    const Type *t = a->getType();
758    const Element *e = t->getElement();
759
760    char buf[256];
761    if (x >= t->getLODDimX(0)) {
762        sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
763        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
764        return nullptr;
765    }
766
767    if (y >= t->getLODDimY(0)) {
768        sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
769        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
770        return nullptr;
771    }
772
773    if (z >= t->getLODDimZ(0)) {
774        sprintf(buf, "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0));
775        rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
776        return nullptr;
777    }
778
779    if (vecSize > 0) {
780        if (vecSize != e->getVectorSize()) {
781            sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
782            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
783            return nullptr;
784        }
785
786        if (dt != e->getType()) {
787            sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
788            rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
789            return nullptr;
790        }
791    }
792
793    uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
794    const uint32_t eSize = e->getSizeBytes();
795    const uint32_t stride = a->mHal.drvState.lod[0].stride;
796    return &p[(eSize * x) + (y * stride)];
797}
798
799static const void * SC_GetElementAt1D(android::renderscript::rs_allocation a, uint32_t x) {
800    return ElementAt1D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x);
801}
802static const void * SC_GetElementAt2D(android::renderscript::rs_allocation a, uint32_t x, uint32_t y) {
803    return ElementAt2D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x, y);
804}
805static const void * SC_GetElementAt3D(android::renderscript::rs_allocation a, uint32_t x, uint32_t y, uint32_t z) {
806    return ElementAt3D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x, y, z);
807}
808
809static void SC_SetElementAt1D(android::renderscript::rs_allocation a, const void *ptr, uint32_t x) {
810    const Type *t = ((Allocation*)a.p)->getType();
811    const Element *e = t->getElement();
812    void *tmp = ElementAt1D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x);
813    if (tmp != nullptr) {
814        memcpy(tmp, ptr, e->getSizeBytes());
815    }
816}
817static void SC_SetElementAt2D(android::renderscript::rs_allocation a, const void *ptr, uint32_t x, uint32_t y) {
818    const Type *t = ((Allocation*)a.p)->getType();
819    const Element *e = t->getElement();
820    void *tmp = ElementAt2D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x, y);
821    if (tmp != nullptr) {
822        memcpy(tmp, ptr, e->getSizeBytes());
823    }
824}
825static void SC_SetElementAt3D(android::renderscript::rs_allocation a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
826    const Type *t = ((Allocation*)a.p)->getType();
827    const Element *e = t->getElement();
828    void *tmp = ElementAt3D((Allocation*)a.p, RS_TYPE_UNSIGNED_8, 0, x, y, z);
829    if (tmp != nullptr) {
830        memcpy(tmp, ptr, e->getSizeBytes());
831    }
832}
833
834static inline
835android::renderscript::rs_allocation castToARSAlloc(::rs_allocation a) {
836    android::renderscript::rs_allocation cast;
837    cast.p = (const Allocation *) a.p;
838    return cast;
839}
840
841const void *rsGetElementAt(::rs_allocation a, uint32_t x) {
842    return SC_GetElementAt1D(castToARSAlloc(a), x);
843}
844
845const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y) {
846    return SC_GetElementAt2D(castToARSAlloc(a), x, y);
847}
848
849const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y, uint32_t z) {
850    return SC_GetElementAt3D(castToARSAlloc(a), x, y, z);
851}
852
853void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x) {
854    SC_SetElementAt1D(castToARSAlloc(a), ptr, x);
855}
856
857void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y) {
858    SC_SetElementAt2D(castToARSAlloc(a), ptr, x, y);
859}
860
861void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
862    SC_SetElementAt3D(castToARSAlloc(a), ptr, x, y, z);
863}
864
865
866#define ELEMENT_AT(T, DT, VS)                                               \
867    static void SC_SetElementAt1_##T(android::renderscript::rs_allocation a, const T *val, uint32_t x) { \
868        void *r = ElementAt1D((Allocation*)a.p, DT, VS, x);             \
869        if (r != nullptr) ((T *)r)[0] = *val;                           \
870        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
871    }                                                                   \
872    static void SC_SetElementAt2_##T(android::renderscript::rs_allocation a, const T * val, uint32_t x, uint32_t y) { \
873        void *r = ElementAt2D((Allocation*)a.p, DT, VS, x, y);          \
874        if (r != nullptr) ((T *)r)[0] = *val;                           \
875        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
876    }                                                                   \
877    static void SC_SetElementAt3_##T(android::renderscript::rs_allocation a, const T * val, uint32_t x, uint32_t y, uint32_t z) { \
878        void *r = ElementAt3D((Allocation*)a.p, DT, VS, x, y, z);       \
879        if (r != nullptr) ((T *)r)[0] = *val;                           \
880        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
881    }                                                                   \
882    static void SC_GetElementAt1_##T(android::renderscript::rs_allocation a, T *val, uint32_t x) {                  \
883        void *r = ElementAt1D((Allocation*)a.p, DT, VS, x);             \
884        if (r != nullptr) *val = ((T *)r)[0];                           \
885        else ALOGE("Error from %s", __PRETTY_FUNCTION__);               \
886    }                                                                   \
887    static void SC_GetElementAt2_##T(android::renderscript::rs_allocation a, T *val, uint32_t x, uint32_t y) {      \
888        void *r = ElementAt2D((Allocation*)a.p, DT, VS, x, y);           \
889        if (r != nullptr) *val = ((T *)r)[0];                            \
890        else ALOGE("Error from %s", __PRETTY_FUNCTION__);                \
891    }                                                                    \
892    static void SC_GetElementAt3_##T(android::renderscript::rs_allocation a, T *val, uint32_t x, uint32_t y, uint32_t z) { \
893        void *r = ElementAt3D((Allocation*)a.p, DT, VS, x, y, z);        \
894        if (r != nullptr) *val = ((T *)r)[0];                            \
895        else ALOGE("Error from %s", __PRETTY_FUNCTION__);                \
896    } \
897    void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x) { \
898        SC_SetElementAt1_##T(castToARSAlloc(a), val, x); \
899    } \
900    void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y) { \
901        SC_SetElementAt2_##T(castToARSAlloc(a), val, x, y); \
902    } \
903    void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y, uint32_t z) { \
904        SC_SetElementAt3_##T(castToARSAlloc(a), val, x, y, z); \
905    } \
906    void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x) { \
907        SC_GetElementAt1_##T(castToARSAlloc(a), val, x); \
908    } \
909    void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y) { \
910        SC_GetElementAt2_##T(castToARSAlloc(a), val, x, y); \
911    } \
912    void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y, uint32_t z) { \
913        SC_GetElementAt3_##T(castToARSAlloc(a), val, x, y, z); \
914    } \
915
916ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1)
917ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2)
918ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3)
919ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4)
920ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1)
921ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2)
922ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3)
923ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4)
924ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1)
925ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2)
926ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3)
927ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4)
928ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1)
929ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2)
930ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3)
931ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4)
932ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1)
933ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2)
934ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3)
935ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4)
936ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1)
937ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2)
938ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3)
939ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4)
940ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1)
941ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2)
942ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3)
943ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4)
944ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1)
945ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2)
946ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3)
947ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4)
948ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1)
949ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2)
950ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3)
951ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4)
952ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1)
953ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2)
954ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3)
955ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4)
956
957#undef ELEMENT_AT
958
959#ifndef __LP64__
960/*
961 * We miss some symbols for rs{Get,Set}Element_long,ulong variants because 64
962 * bit integer values are 'long' in RS-land but might be 'long long' in the
963 * driver.  Define native_long* and native_ulong* types to be vectors of
964 * 'long' as seen by the driver and define overloaded versions of
965 * rsSetElementAt_* and rsGetElementAt_*.  This should get us the correct
966 * mangled names in the driver.
967 */
968
969typedef long native_long2 __attribute__((ext_vector_type(2)));
970typedef long native_long3 __attribute__((ext_vector_type(3)));
971typedef long native_long4 __attribute__((ext_vector_type(4)));
972typedef unsigned long native_ulong2 __attribute__((ext_vector_type(2)));
973typedef unsigned long native_ulong3 __attribute__((ext_vector_type(3)));
974typedef unsigned long native_ulong4 __attribute__((ext_vector_type(4)));
975
976#define ELEMENT_AT_OVERLOADS(T, U) \
977    void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x) { \
978        SC_SetElementAt1_##T(castToARSAlloc(a), (T *) val, x); \
979    } \
980    void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y) { \
981        SC_SetElementAt2_##T(castToARSAlloc(a), (T *) val, x, y); \
982    } \
983    void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y, uint32_t z) { \
984        SC_SetElementAt3_##T(castToARSAlloc(a), (T *) val, x, y, z); \
985    } \
986    void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x) { \
987        SC_GetElementAt1_##T(castToARSAlloc(a), (T *) val, x); \
988    } \
989    void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y) { \
990        SC_GetElementAt2_##T(castToARSAlloc(a), (T *) val, x, y); \
991    } \
992    void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y, uint32_t z) { \
993        SC_GetElementAt3_##T(castToARSAlloc(a), (T *) val, x, y, z); \
994    } \
995
996ELEMENT_AT_OVERLOADS(long2, native_long2)
997ELEMENT_AT_OVERLOADS(long3, native_long3)
998ELEMENT_AT_OVERLOADS(long4, native_long4)
999ELEMENT_AT_OVERLOADS(ulong, unsigned long)
1000ELEMENT_AT_OVERLOADS(ulong2, native_ulong2)
1001ELEMENT_AT_OVERLOADS(ulong3, native_ulong3)
1002ELEMENT_AT_OVERLOADS(ulong4, native_ulong4)
1003
1004// We also need variants of rs{Get,Set}ElementAt_long that take 'long long *' as
1005// we might have this overloaded variant in old APKs.
1006ELEMENT_AT_OVERLOADS(long, long long)
1007
1008#undef ELEMENT_AT_OVERLOADS
1009#endif
1010
1011
1012//////////////////////////////////////////////////////////////////////////////
1013// Stub implementation
1014//////////////////////////////////////////////////////////////////////////////
1015
1016// llvm name mangling ref
1017//  <builtin-type> ::= v  # void
1018//                 ::= b  # bool
1019//                 ::= c  # char
1020//                 ::= a  # signed char
1021//                 ::= h  # unsigned char
1022//                 ::= s  # short
1023//                 ::= t  # unsigned short
1024//                 ::= i  # int
1025//                 ::= j  # unsigned int
1026//                 ::= l  # long
1027//                 ::= m  # unsigned long
1028//                 ::= x  # long long, __int64
1029//                 ::= y  # unsigned long long, __int64
1030//                 ::= f  # float
1031//                 ::= d  # double
1032
1033static RsdCpuReference::CpuSymbol gSyms[] = {
1034    // Debug runtime
1035    { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_GetElementAt1D, true },
1036    { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_GetElementAt2D, true },
1037    { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_GetElementAt3D, true },
1038    { "_Z14rsSetElementAt13rs_allocationPKvj", (void *)&SC_SetElementAt1D, true },
1039    { "_Z14rsSetElementAt13rs_allocationPKvjj", (void *)&SC_SetElementAt2D, true },
1040    { "_Z14rsSetElementAt13rs_allocationPKvjjj", (void *)&SC_SetElementAt3D, true },
1041
1042
1043    { "_Z20rsGetElementAt_uchar13rs_allocationPhj", (void *)&SC_GetElementAt1_uchar, true },
1044    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hj", (void *)&SC_GetElementAt1_uchar2, true },
1045    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hj", (void *)&SC_GetElementAt1_uchar3, true },
1046    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hj", (void *)&SC_GetElementAt1_uchar4, true },
1047    { "_Z20rsGetElementAt_uchar13rs_allocationPhjj", (void *)&SC_GetElementAt2_uchar, true },
1048    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjj", (void *)&SC_GetElementAt2_uchar2, true },
1049    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjj", (void *)&SC_GetElementAt2_uchar3, true },
1050    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjj", (void *)&SC_GetElementAt2_uchar4, true },
1051    { "_Z20rsGetElementAt_uchar13rs_allocationPhjjj", (void *)&SC_GetElementAt3_uchar, true },
1052    { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjjj", (void *)&SC_GetElementAt3_uchar2, true },
1053    { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjjj", (void *)&SC_GetElementAt3_uchar3, true },
1054    { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjjj", (void *)&SC_GetElementAt3_uchar4, true },
1055
1056    { "_Z19rsGetElementAt_char13rs_allocationPcj", (void *)&SC_GetElementAt1_char, true },
1057    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cj", (void *)&SC_GetElementAt1_char2, true },
1058    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cj", (void *)&SC_GetElementAt1_char3, true },
1059    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cj", (void *)&SC_GetElementAt1_char4, true },
1060    { "_Z19rsGetElementAt_char13rs_allocationPcjj", (void *)&SC_GetElementAt2_char, true },
1061    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjj", (void *)&SC_GetElementAt2_char2, true },
1062    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjj", (void *)&SC_GetElementAt2_char3, true },
1063    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjj", (void *)&SC_GetElementAt2_char4, true },
1064    { "_Z19rsGetElementAt_char13rs_allocationPcjjj", (void *)&SC_GetElementAt3_char, true },
1065    { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjjj", (void *)&SC_GetElementAt3_char2, true },
1066    { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjjj", (void *)&SC_GetElementAt3_char3, true },
1067    { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjjj", (void *)&SC_GetElementAt3_char4, true },
1068
1069    { "_Z21rsGetElementAt_ushort13rs_allocationPtj", (void *)&SC_GetElementAt1_ushort, true },
1070    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tj", (void *)&SC_GetElementAt1_ushort2, true },
1071    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tj", (void *)&SC_GetElementAt1_ushort3, true },
1072    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tj", (void *)&SC_GetElementAt1_ushort4, true },
1073    { "_Z21rsGetElementAt_ushort13rs_allocationPtjj", (void *)&SC_GetElementAt2_ushort, true },
1074    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjj", (void *)&SC_GetElementAt2_ushort2, true },
1075    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjj", (void *)&SC_GetElementAt2_ushort3, true },
1076    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjj", (void *)&SC_GetElementAt2_ushort4, true },
1077    { "_Z21rsGetElementAt_ushort13rs_allocationPtjjj", (void *)&SC_GetElementAt3_ushort, true },
1078    { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjjj", (void *)&SC_GetElementAt3_ushort2, true },
1079    { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjjj", (void *)&SC_GetElementAt3_ushort3, true },
1080    { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjjj", (void *)&SC_GetElementAt3_ushort4, true },
1081
1082    { "_Z20rsGetElementAt_short13rs_allocationPsj", (void *)&SC_GetElementAt1_short, true },
1083    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sj", (void *)&SC_GetElementAt1_short2, true },
1084    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sj", (void *)&SC_GetElementAt1_short3, true },
1085    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sj", (void *)&SC_GetElementAt1_short4, true },
1086    { "_Z20rsGetElementAt_short13rs_allocationPsjj", (void *)&SC_GetElementAt2_short, true },
1087    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjj", (void *)&SC_GetElementAt2_short2, true },
1088    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjj", (void *)&SC_GetElementAt2_short3, true },
1089    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjj", (void *)&SC_GetElementAt2_short4, true },
1090    { "_Z20rsGetElementAt_short13rs_allocationPsjjj", (void *)&SC_GetElementAt3_short, true },
1091    { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjjj", (void *)&SC_GetElementAt3_short2, true },
1092    { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjjj", (void *)&SC_GetElementAt3_short3, true },
1093    { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjjj", (void *)&SC_GetElementAt3_short4, true },
1094
1095    { "_Z19rsGetElementAt_uint13rs_allocationPjj", (void *)&SC_GetElementAt1_uint, true },
1096    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jj", (void *)&SC_GetElementAt1_uint2, true },
1097    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jj", (void *)&SC_GetElementAt1_uint3, true },
1098    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jj", (void *)&SC_GetElementAt1_uint4, true },
1099    { "_Z19rsGetElementAt_uint13rs_allocationPjjj", (void *)&SC_GetElementAt2_uint, true },
1100    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjj", (void *)&SC_GetElementAt2_uint2, true },
1101    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjj", (void *)&SC_GetElementAt2_uint3, true },
1102    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjj", (void *)&SC_GetElementAt2_uint4, true },
1103    { "_Z19rsGetElementAt_uint13rs_allocationPjjjj", (void *)&SC_GetElementAt3_uint, true },
1104    { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjjj", (void *)&SC_GetElementAt3_uint2, true },
1105    { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjjj", (void *)&SC_GetElementAt3_uint3, true },
1106    { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjjj", (void *)&SC_GetElementAt3_uint4, true },
1107
1108    { "_Z18rsGetElementAt_int13rs_allocationPij", (void *)&SC_GetElementAt1_int, true },
1109    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ij", (void *)&SC_GetElementAt1_int2, true },
1110    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ij", (void *)&SC_GetElementAt1_int3, true },
1111    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ij", (void *)&SC_GetElementAt1_int4, true },
1112    { "_Z18rsGetElementAt_int13rs_allocationPijj", (void *)&SC_GetElementAt2_int, true },
1113    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijj", (void *)&SC_GetElementAt2_int2, true },
1114    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijj", (void *)&SC_GetElementAt2_int3, true },
1115    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijj", (void *)&SC_GetElementAt2_int4, true },
1116    { "_Z18rsGetElementAt_int13rs_allocationPijjj", (void *)&SC_GetElementAt3_int, true },
1117    { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijjj", (void *)&SC_GetElementAt3_int2, true },
1118    { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijjj", (void *)&SC_GetElementAt3_int3, true },
1119    { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijjj", (void *)&SC_GetElementAt3_int4, true },
1120
1121    { "_Z20rsGetElementAt_ulong13rs_allocationPmj", (void *)&SC_GetElementAt1_ulong, true },
1122    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mj", (void *)&SC_GetElementAt1_ulong2, true },
1123    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mj", (void *)&SC_GetElementAt1_ulong3, true },
1124    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mj", (void *)&SC_GetElementAt1_ulong4, true },
1125    { "_Z20rsGetElementAt_ulong13rs_allocationPmjj", (void *)&SC_GetElementAt2_ulong, true },
1126    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjj", (void *)&SC_GetElementAt2_ulong2, true },
1127    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjj", (void *)&SC_GetElementAt2_ulong3, true },
1128    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjj", (void *)&SC_GetElementAt2_ulong4, true },
1129    { "_Z20rsGetElementAt_ulong13rs_allocationPmjjj", (void *)&SC_GetElementAt3_ulong, true },
1130    { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjjj", (void *)&SC_GetElementAt3_ulong2, true },
1131    { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjjj", (void *)&SC_GetElementAt3_ulong3, true },
1132    { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjjj", (void *)&SC_GetElementAt3_ulong4, true },
1133
1134    { "_Z19rsGetElementAt_long13rs_allocationPlj", (void *)&SC_GetElementAt1_long, true },
1135    { "_Z20rsGetElementAt_long213rs_allocationPDv2_lj", (void *)&SC_GetElementAt1_long2, true },
1136    { "_Z20rsGetElementAt_long313rs_allocationPDv3_lj", (void *)&SC_GetElementAt1_long3, true },
1137    { "_Z20rsGetElementAt_long413rs_allocationPDv4_lj", (void *)&SC_GetElementAt1_long4, true },
1138    { "_Z19rsGetElementAt_long13rs_allocationPljj", (void *)&SC_GetElementAt2_long, true },
1139    { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljj", (void *)&SC_GetElementAt2_long2, true },
1140    { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljj", (void *)&SC_GetElementAt2_long3, true },
1141    { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljj", (void *)&SC_GetElementAt2_long4, true },
1142    { "_Z19rsGetElementAt_long13rs_allocationPljjj", (void *)&SC_GetElementAt3_long, true },
1143    { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljjj", (void *)&SC_GetElementAt3_long2, true },
1144    { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljjj", (void *)&SC_GetElementAt3_long3, true },
1145    { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljjj", (void *)&SC_GetElementAt3_long4, true },
1146
1147    { "_Z20rsGetElementAt_float13rs_allocationPfj", (void *)&SC_GetElementAt1_float, true },
1148    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fj", (void *)&SC_GetElementAt1_float2, true },
1149    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fj", (void *)&SC_GetElementAt1_float3, true },
1150    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fj", (void *)&SC_GetElementAt1_float4, true },
1151    { "_Z20rsGetElementAt_float13rs_allocationPfjj", (void *)&SC_GetElementAt2_float, true },
1152    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjj", (void *)&SC_GetElementAt2_float2, true },
1153    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjj", (void *)&SC_GetElementAt2_float3, true },
1154    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjj", (void *)&SC_GetElementAt2_float4, true },
1155    { "_Z20rsGetElementAt_float13rs_allocationPfjjj", (void *)&SC_GetElementAt3_float, true },
1156    { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjjj", (void *)&SC_GetElementAt3_float2, true },
1157    { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjjj", (void *)&SC_GetElementAt3_float3, true },
1158    { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjjj", (void *)&SC_GetElementAt3_float4, true },
1159
1160    { "_Z21rsGetElementAt_double13rs_allocationPdj", (void *)&SC_GetElementAt1_double, true },
1161    { "_Z22rsGetElementAt_double213rs_allocationPDv2_dj", (void *)&SC_GetElementAt1_double2, true },
1162    { "_Z22rsGetElementAt_double313rs_allocationPDv3_dj", (void *)&SC_GetElementAt1_double3, true },
1163    { "_Z22rsGetElementAt_double413rs_allocationPDv4_dj", (void *)&SC_GetElementAt1_double4, true },
1164    { "_Z21rsGetElementAt_double13rs_allocationPdjj", (void *)&SC_GetElementAt2_double, true },
1165    { "_Z22rsGetElementAt_double213rs_allocationPDv2_djj", (void *)&SC_GetElementAt2_double2, true },
1166    { "_Z22rsGetElementAt_double313rs_allocationPDv3_djj", (void *)&SC_GetElementAt2_double3, true },
1167    { "_Z22rsGetElementAt_double413rs_allocationPDv4_djj", (void *)&SC_GetElementAt2_double4, true },
1168    { "_Z21rsGetElementAt_double13rs_allocationPdjjj", (void *)&SC_GetElementAt3_double, true },
1169    { "_Z22rsGetElementAt_double213rs_allocationPDv2_djjj", (void *)&SC_GetElementAt3_double2, true },
1170    { "_Z22rsGetElementAt_double313rs_allocationPDv3_djjj", (void *)&SC_GetElementAt3_double3, true },
1171    { "_Z22rsGetElementAt_double413rs_allocationPDv4_djjj", (void *)&SC_GetElementAt3_double4, true },
1172
1173
1174
1175    { "_Z20rsSetElementAt_uchar13rs_allocationPKhj", (void *)&SC_SetElementAt1_uchar, true },
1176    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hj", (void *)&SC_SetElementAt1_uchar2, true },
1177    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hj", (void *)&SC_SetElementAt1_uchar3, true },
1178    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hj", (void *)&SC_SetElementAt1_uchar4, true },
1179    { "_Z20rsSetElementAt_uchar13rs_allocationPKhjj", (void *)&SC_SetElementAt2_uchar, true },
1180    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjj", (void *)&SC_SetElementAt2_uchar2, true },
1181    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjj", (void *)&SC_SetElementAt2_uchar3, true },
1182    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjj", (void *)&SC_SetElementAt2_uchar4, true },
1183    { "_Z20rsSetElementAt_uchar13rs_allocationPKhjjj", (void *)&SC_SetElementAt3_uchar, true },
1184    { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjjj", (void *)&SC_SetElementAt3_uchar2, true },
1185    { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjjj", (void *)&SC_SetElementAt3_uchar3, true },
1186    { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjjj", (void *)&SC_SetElementAt3_uchar4, true },
1187
1188    { "_Z19rsSetElementAt_char13rs_allocationPKcj", (void *)&SC_SetElementAt1_char, true },
1189    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cj", (void *)&SC_SetElementAt1_char2, true },
1190    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cj", (void *)&SC_SetElementAt1_char3, true },
1191    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cj", (void *)&SC_SetElementAt1_char4, true },
1192    { "_Z19rsSetElementAt_char13rs_allocationPKcjj", (void *)&SC_SetElementAt2_char, true },
1193    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjj", (void *)&SC_SetElementAt2_char2, true },
1194    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjj", (void *)&SC_SetElementAt2_char3, true },
1195    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjj", (void *)&SC_SetElementAt2_char4, true },
1196    { "_Z19rsSetElementAt_char13rs_allocationPKcjjj", (void *)&SC_SetElementAt3_char, true },
1197    { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjjj", (void *)&SC_SetElementAt3_char2, true },
1198    { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjjj", (void *)&SC_SetElementAt3_char3, true },
1199    { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjjj", (void *)&SC_SetElementAt3_char4, true },
1200
1201    { "_Z21rsSetElementAt_ushort13rs_allocationPKtj", (void *)&SC_SetElementAt1_ushort, true },
1202    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tj", (void *)&SC_SetElementAt1_ushort2, true },
1203    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tj", (void *)&SC_SetElementAt1_ushort3, true },
1204    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tj", (void *)&SC_SetElementAt1_ushort4, true },
1205    { "_Z21rsSetElementAt_ushort13rs_allocationPKtjj", (void *)&SC_SetElementAt2_ushort, true },
1206    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjj", (void *)&SC_SetElementAt2_ushort2, true },
1207    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjj", (void *)&SC_SetElementAt2_ushort3, true },
1208    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjj", (void *)&SC_SetElementAt2_ushort4, true },
1209    { "_Z21rsSetElementAt_ushort13rs_allocationPKtjjj", (void *)&SC_SetElementAt3_ushort, true },
1210    { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjjj", (void *)&SC_SetElementAt3_ushort2, true },
1211    { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjjj", (void *)&SC_SetElementAt3_ushort3, true },
1212    { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjjj", (void *)&SC_SetElementAt3_ushort4, true },
1213
1214    { "_Z20rsSetElementAt_short13rs_allocationPKsj", (void *)&SC_SetElementAt1_short, true },
1215    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sj", (void *)&SC_SetElementAt1_short2, true },
1216    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sj", (void *)&SC_SetElementAt1_short3, true },
1217    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sj", (void *)&SC_SetElementAt1_short4, true },
1218    { "_Z20rsSetElementAt_short13rs_allocationPKsjj", (void *)&SC_SetElementAt2_short, true },
1219    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjj", (void *)&SC_SetElementAt2_short2, true },
1220    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjj", (void *)&SC_SetElementAt2_short3, true },
1221    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjj", (void *)&SC_SetElementAt2_short4, true },
1222    { "_Z20rsSetElementAt_short13rs_allocationPKsjjj", (void *)&SC_SetElementAt3_short, true },
1223    { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjjj", (void *)&SC_SetElementAt3_short2, true },
1224    { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjjj", (void *)&SC_SetElementAt3_short3, true },
1225    { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjjj", (void *)&SC_SetElementAt3_short4, true },
1226
1227    { "_Z19rsSetElementAt_uint13rs_allocationPKjj", (void *)&SC_SetElementAt1_uint, true },
1228    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jj", (void *)&SC_SetElementAt1_uint2, true },
1229    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jj", (void *)&SC_SetElementAt1_uint3, true },
1230    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jj", (void *)&SC_SetElementAt1_uint4, true },
1231    { "_Z19rsSetElementAt_uint13rs_allocationPKjjj", (void *)&SC_SetElementAt2_uint, true },
1232    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjj", (void *)&SC_SetElementAt2_uint2, true },
1233    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjj", (void *)&SC_SetElementAt2_uint3, true },
1234    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjj", (void *)&SC_SetElementAt2_uint4, true },
1235    { "_Z19rsSetElementAt_uint13rs_allocationPKjjjj", (void *)&SC_SetElementAt3_uint, true },
1236    { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjjj", (void *)&SC_SetElementAt3_uint2, true },
1237    { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjjj", (void *)&SC_SetElementAt3_uint3, true },
1238    { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjjj", (void *)&SC_SetElementAt3_uint4, true },
1239
1240    { "_Z18rsSetElementAt_int13rs_allocationPKij", (void *)&SC_SetElementAt1_int, true },
1241    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ij", (void *)&SC_SetElementAt1_int2, true },
1242    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ij", (void *)&SC_SetElementAt1_int3, true },
1243    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ij", (void *)&SC_SetElementAt1_int4, true },
1244    { "_Z18rsSetElementAt_int13rs_allocationPKijj", (void *)&SC_SetElementAt2_int, true },
1245    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijj", (void *)&SC_SetElementAt2_int2, true },
1246    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijj", (void *)&SC_SetElementAt2_int3, true },
1247    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijj", (void *)&SC_SetElementAt2_int4, true },
1248    { "_Z18rsSetElementAt_int13rs_allocationPKijjj", (void *)&SC_SetElementAt3_int, true },
1249    { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijjj", (void *)&SC_SetElementAt3_int2, true },
1250    { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijjj", (void *)&SC_SetElementAt3_int3, true },
1251    { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijjj", (void *)&SC_SetElementAt3_int4, true },
1252
1253    { "_Z20rsSetElementAt_ulong13rs_allocationPKmj", (void *)&SC_SetElementAt1_ulong, true },
1254    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mj", (void *)&SC_SetElementAt1_ulong2, true },
1255    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mj", (void *)&SC_SetElementAt1_ulong3, true },
1256    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mj", (void *)&SC_SetElementAt1_ulong4, true },
1257    { "_Z20rsSetElementAt_ulong13rs_allocationPKmjj", (void *)&SC_SetElementAt2_ulong, true },
1258    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjj", (void *)&SC_SetElementAt2_ulong2, true },
1259    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjj", (void *)&SC_SetElementAt2_ulong3, true },
1260    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjj", (void *)&SC_SetElementAt2_ulong4, true },
1261    { "_Z20rsSetElementAt_ulong13rs_allocationPKmjjj", (void *)&SC_SetElementAt3_ulong, true },
1262    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjjj", (void *)&SC_SetElementAt3_ulong2, true },
1263    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjjj", (void *)&SC_SetElementAt3_ulong3, true },
1264    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjjj", (void *)&SC_SetElementAt3_ulong4, true },
1265
1266    // Pre-21 compatibility path
1267    { "_Z20rsSetElementAt_ulong13rs_allocationPKyj", (void *)&SC_SetElementAt1_ulong, true },
1268    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yj", (void *)&SC_SetElementAt1_ulong2, true },
1269    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yj", (void *)&SC_SetElementAt1_ulong3, true },
1270    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yj", (void *)&SC_SetElementAt1_ulong4, true },
1271    { "_Z20rsSetElementAt_ulong13rs_allocationPKyjj", (void *)&SC_SetElementAt2_ulong, true },
1272    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yjj", (void *)&SC_SetElementAt2_ulong2, true },
1273    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yjj", (void *)&SC_SetElementAt2_ulong3, true },
1274    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yjj", (void *)&SC_SetElementAt2_ulong4, true },
1275    { "_Z20rsSetElementAt_ulong13rs_allocationPKyjjj", (void *)&SC_SetElementAt3_ulong, true },
1276    { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yjjj", (void *)&SC_SetElementAt3_ulong2, true },
1277    { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yjjj", (void *)&SC_SetElementAt3_ulong3, true },
1278    { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yjjj", (void *)&SC_SetElementAt3_ulong4, true },
1279
1280    { "_Z19rsSetElementAt_long13rs_allocationPKlj", (void *)&SC_SetElementAt1_long, true },
1281    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_lj", (void *)&SC_SetElementAt1_long2, true },
1282    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_lj", (void *)&SC_SetElementAt1_long3, true },
1283    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_lj", (void *)&SC_SetElementAt1_long4, true },
1284    { "_Z19rsSetElementAt_long13rs_allocationPKljj", (void *)&SC_SetElementAt2_long, true },
1285    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljj", (void *)&SC_SetElementAt2_long2, true },
1286    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljj", (void *)&SC_SetElementAt2_long3, true },
1287    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljj", (void *)&SC_SetElementAt2_long4, true },
1288    { "_Z19rsSetElementAt_long13rs_allocationPKljjj", (void *)&SC_SetElementAt3_long, true },
1289    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljjj", (void *)&SC_SetElementAt3_long2, true },
1290    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljjj", (void *)&SC_SetElementAt3_long3, true },
1291    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljjj", (void *)&SC_SetElementAt3_long4, true },
1292
1293    // Pre-21 compatibility path
1294    { "_Z19rsSetElementAt_long13rs_allocationPKxj", (void *)&SC_SetElementAt1_long, true },
1295    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xj", (void *)&SC_SetElementAt1_long2, true },
1296    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xj", (void *)&SC_SetElementAt1_long3, true },
1297    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xj", (void *)&SC_SetElementAt1_long4, true },
1298    { "_Z19rsSetElementAt_long13rs_allocationPKxjj", (void *)&SC_SetElementAt2_long, true },
1299    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xjj", (void *)&SC_SetElementAt2_long2, true },
1300    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xjj", (void *)&SC_SetElementAt2_long3, true },
1301    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xjj", (void *)&SC_SetElementAt2_long4, true },
1302    { "_Z19rsSetElementAt_long13rs_allocationPKxjjj", (void *)&SC_SetElementAt3_long, true },
1303    { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xjjj", (void *)&SC_SetElementAt3_long2, true },
1304    { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xjjj", (void *)&SC_SetElementAt3_long3, true },
1305    { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xjjj", (void *)&SC_SetElementAt3_long4, true },
1306
1307    { "_Z20rsSetElementAt_float13rs_allocationPKfj", (void *)&SC_SetElementAt1_float, true },
1308    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fj", (void *)&SC_SetElementAt1_float2, true },
1309    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fj", (void *)&SC_SetElementAt1_float3, true },
1310    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fj", (void *)&SC_SetElementAt1_float4, true },
1311    { "_Z20rsSetElementAt_float13rs_allocationPKfjj", (void *)&SC_SetElementAt2_float, true },
1312    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjj", (void *)&SC_SetElementAt2_float2, true },
1313    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjj", (void *)&SC_SetElementAt2_float3, true },
1314    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjj", (void *)&SC_SetElementAt2_float4, true },
1315    { "_Z20rsSetElementAt_float13rs_allocationPKfjjj", (void *)&SC_SetElementAt3_float, true },
1316    { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjjj", (void *)&SC_SetElementAt3_float2, true },
1317    { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjjj", (void *)&SC_SetElementAt3_float3, true },
1318    { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjjj", (void *)&SC_SetElementAt3_float4, true },
1319
1320    { "_Z21rsSetElementAt_double13rs_allocationPKdj", (void *)&SC_SetElementAt1_double, true },
1321    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_dj", (void *)&SC_SetElementAt1_double2, true },
1322    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_dj", (void *)&SC_SetElementAt1_double3, true },
1323    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_dj", (void *)&SC_SetElementAt1_double4, true },
1324    { "_Z21rsSetElementAt_double13rs_allocationPKdjj", (void *)&SC_SetElementAt2_double, true },
1325    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djj", (void *)&SC_SetElementAt2_double2, true },
1326    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djj", (void *)&SC_SetElementAt2_double3, true },
1327    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djj", (void *)&SC_SetElementAt2_double4, true },
1328    { "_Z21rsSetElementAt_double13rs_allocationPKdjjj", (void *)&SC_SetElementAt3_double, true },
1329    { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djjj", (void *)&SC_SetElementAt3_double2, true },
1330    { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djjj", (void *)&SC_SetElementAt3_double3, true },
1331    { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djjj", (void *)&SC_SetElementAt3_double4, true },
1332
1333
1334    // Refcounting
1335#ifndef __LP64__
1336    { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
1337    { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
1338
1339    { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
1340    { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
1341
1342    { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
1343    { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
1344
1345    { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
1346    { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
1347
1348    { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
1349    { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
1350#else
1351    { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject_ByRef, true },
1352    { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject_ByRef, true },
1353
1354    { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject_ByRef, true },
1355    { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject_ByRef, true },
1356
1357    { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject_ByRef, true },
1358    { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject_ByRef, true },
1359
1360    { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject_ByRef, true },
1361    { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject_ByRef, true },
1362
1363    { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject_ByRef, true },
1364    { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject_ByRef, true },
1365#endif
1366    { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
1367    { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
1368    { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
1369    { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
1370    { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
1371
1372    { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
1373    { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
1374    { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
1375
1376    { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
1377    { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
1378    { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
1379
1380    { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
1381    { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
1382    { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
1383
1384    { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
1385    { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
1386    { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
1387
1388    { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
1389    { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
1390    { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
1391
1392    { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
1393    { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
1394    { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
1395
1396    { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
1397    { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
1398    { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
1399
1400    // Allocation ops
1401    { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
1402    { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
1403    { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
1404    { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
1405#ifndef RS_COMPATIBILITY_LIB
1406    { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
1407    { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
1408    { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
1409#endif
1410    { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
1411    { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
1412
1413    // Messaging
1414
1415    { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
1416    { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
1417    { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
1418    { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
1419#ifndef RS_COMPATIBILITY_LIB
1420    { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
1421    { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
1422    { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
1423    { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
1424    { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
1425    { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
1426    { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
1427    { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
1428
1429    { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
1430    { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
1431    { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
1432
1433    { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
1434
1435    { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
1436
1437    { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
1438    { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
1439
1440
1441    { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
1442    { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
1443    { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
1444    { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
1445
1446    { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
1447    { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
1448    { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
1449    { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
1450
1451    { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
1452
1453    { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
1454    { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
1455
1456    { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
1457    { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
1458    { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
1459    { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
1460
1461    { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
1462    { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
1463
1464    { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
1465    { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
1466    { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
1467    { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
1468    { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
1469
1470
1471    { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
1472    { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
1473    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
1474
1475    //rsForEach with usrdata is not supported in 64-bit
1476#ifndef __LP64__
1477    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
1478    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
1479#endif
1480#endif // RS_COMPATIBILITY_LIB
1481
1482#ifndef __LP64__
1483    // time
1484    { "_Z6rsTimePi", (void *)&SC_Time, true },
1485    { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
1486#else
1487    // time
1488    { "_Z6rsTimePl", (void *)&SC_Time, true },
1489    { "_Z11rsLocaltimeP5rs_tmPKl", (void *)&SC_LocalTime, true },
1490#endif
1491    { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
1492    { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
1493    { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
1494
1495    // misc
1496#ifndef RS_COMPATIBILITY_LIB
1497    { "_Z5colorffff", (void *)&SC_Color, false },
1498    { "_Z9rsgFinishv", (void *)&SC_Finish, false },
1499#endif
1500
1501    { nullptr, nullptr, false }
1502};
1503
1504#ifndef RS_COMPATIBILITY_LIB
1505
1506typedef struct { unsigned int val; } rs_allocation_usage_type;
1507
1508void rsAllocationMarkDirty(::rs_allocation a) {
1509    return SC_AllocationSyncAll(castToARSAlloc(a));
1510}
1511
1512void rsgAllocationSyncAll(::rs_allocation a) {
1513    return SC_AllocationSyncAll(castToARSAlloc(a));
1514}
1515
1516void rsgAllocationSyncAll(::rs_allocation a,
1517                          unsigned int usage) {
1518    return SC_AllocationSyncAll2(castToARSAlloc(a),
1519                                 (RsAllocationUsageType) usage);
1520}
1521void rsgAllocationSyncAll(::rs_allocation a,
1522                          rs_allocation_usage_type source) {
1523    return SC_AllocationSyncAll2(castToARSAlloc(a),
1524                                 (RsAllocationUsageType) source.val);
1525}
1526
1527void rsgBindProgramFragment(::rs_program_fragment pf) {
1528    return SC_BindProgramFragment((ProgramFragment *) pf.p);
1529}
1530
1531void rsgBindProgramStore(::rs_program_store ps) {
1532    return SC_BindProgramStore((ProgramStore *) ps.p);
1533}
1534
1535void rsgBindProgramVertex(::rs_program_vertex pv) {
1536    return SC_BindProgramVertex((ProgramVertex *) pv.p);
1537}
1538
1539void rsgBindProgramRaster(::rs_program_raster pr) {
1540    return SC_BindProgramRaster((ProgramRaster *) pr.p);
1541}
1542
1543void rsgBindSampler(::rs_program_fragment pf,
1544                    uint32_t slot,
1545                    ::rs_sampler s) {
1546    return SC_BindSampler((ProgramFragment *) pf.p, slot, (Sampler *) s.p);
1547}
1548
1549void rsgBindTexture(::rs_program_fragment pf,
1550                    uint32_t slot,
1551                    ::rs_allocation a) {
1552    return SC_BindTexture((ProgramFragment *) pf.p,
1553                          slot,
1554                          (Allocation *) a.p);
1555}
1556
1557void rsgBindConstant(::rs_program_fragment pf,
1558                     uint32_t slot,
1559                     ::rs_allocation a) {
1560    return SC_BindFragmentConstant((ProgramFragment *) pf.p,
1561                                   slot,
1562                                   (Allocation *) a.p);
1563}
1564
1565void rsgBindConstant(::rs_program_vertex pv,
1566                     uint32_t slot,
1567                     ::rs_allocation a) {
1568    return SC_BindVertexConstant((ProgramVertex *) pv.p,
1569                                 slot,
1570                                 (Allocation *) a.p);
1571}
1572
1573void rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *m) {
1574    return SC_VpLoadProjectionMatrix((const rsc_Matrix *) m);
1575}
1576
1577void rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *m) {
1578    return SC_VpLoadModelMatrix((const rsc_Matrix *) m);
1579}
1580
1581void rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *m) {
1582    return SC_VpLoadTextureMatrix((const rsc_Matrix *) m);
1583}
1584
1585void rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *m) {
1586    return SC_VpGetProjectionMatrix((rsc_Matrix *) m);
1587}
1588
1589void rsgProgramFragmentConstantColor(::rs_program_fragment pf,
1590                                     float r, float g,
1591                                     float b, float a) {
1592
1593    return SC_PfConstantColor((ProgramFragment *) pf.p, r, g, b, a);
1594}
1595
1596uint32_t rsgGetWidth(void) {
1597    return SC_GetWidth();
1598}
1599
1600uint32_t rsgGetHeight(void) {
1601    return SC_GetHeight();
1602}
1603
1604void rsgDrawRect(float x1, float y1, float x2, float y2, float z) {
1605    return SC_DrawRect(x1, y1, x2, y2, z);
1606}
1607
1608void rsgDrawQuad(float x1, float y1, float z1,
1609                 float x2, float y2, float z2,
1610                 float x3, float y3, float z3,
1611                 float x4, float y4, float z4) {
1612
1613    SC_DrawQuad(x1, y1, z1,
1614                x2, y2, z2,
1615                x3, y3, z3,
1616                x4, y4, z4);
1617}
1618
1619void rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
1620                          float x2, float y2, float z2, float u2, float v2,
1621                          float x3, float y3, float z3, float u3, float v3,
1622                          float x4, float y4, float z4, float u4, float v4) {
1623
1624    return rsgDrawQuadTexCoords(x1, y1, z1, u1, v1,
1625                                x2, y2, z2, u2, v2,
1626                                x3, y3, z3, u3, v3,
1627                                x4, y4, z4, u4, v4);
1628}
1629
1630void rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h) {
1631    return SC_DrawSpriteScreenspace(x, y, z, w, h);
1632}
1633
1634void rsgDrawMesh(::rs_mesh ism) {
1635    return SC_DrawMesh((Mesh *) ism.p);
1636}
1637
1638void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex) {
1639    return SC_DrawMeshPrimitive((Mesh *) ism.p, primitiveIndex);
1640}
1641
1642void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex, uint start, uint len) {
1643    return SC_DrawMeshPrimitiveRange((Mesh *) ism.p, primitiveIndex, start, len);
1644}
1645
1646void  rsgMeshComputeBoundingBox(::rs_mesh mesh,
1647                                float *minX, float *minY, float *minZ,
1648                                float *maxX, float *maxY, float *maxZ) {
1649
1650    return SC_MeshComputeBoundingBox((Mesh *) mesh.p,
1651                                minX, minY, minZ,
1652                                maxX, maxY, maxZ);
1653}
1654
1655void rsgDrawPath(::rs_path p) {
1656    return SC_DrawPath((Path *) p.p);
1657}
1658
1659void rsgClearColor(float r, float g, float b, float a) {
1660    return SC_ClearColor(r, g, b, a);
1661}
1662
1663void rsgClearDepth(float value) {
1664    return SC_ClearDepth(value);
1665}
1666
1667void rsgDrawText(const char *text, int x, int y) {
1668    return SC_DrawText(text, x, y);
1669}
1670
1671void rsgDrawText(::rs_allocation a, int x, int y) {
1672    return SC_DrawTextAlloc((Allocation *) a.p, x, y);
1673}
1674
1675void rsgMeasureText(const char *text, int *left, int *right,
1676                    int *top, int *bottom) {
1677    return SC_MeasureText(text, left, right, top, bottom);
1678}
1679
1680void rsgMeasureText(::rs_allocation a, int *left, int *right,
1681                    int *top, int *bottom) {
1682    return SC_MeasureTextAlloc((Allocation *) a.p, left, right, top, bottom);
1683}
1684
1685void rsgBindFont(::rs_font font) {
1686    return SC_BindFont((Font *) font.p);
1687}
1688
1689void rsgFontColor(float r, float g, float b, float a) {
1690    return SC_FontColor(r, g, b, a);
1691}
1692
1693void rsgBindColorTarget(::rs_allocation a, uint slot) {
1694    return SC_BindFrameBufferObjectColorTarget((Allocation *) a.p, slot);
1695}
1696
1697void rsgBindDepthTarget(::rs_allocation a) {
1698    return SC_BindFrameBufferObjectDepthTarget((Allocation *) a.p);
1699}
1700
1701void rsgClearColorTarget(uint slot) {
1702    return SC_ClearFrameBufferObjectColorTarget(slot);
1703}
1704
1705void rsgClearDepthTarget(void) {
1706    return SC_ClearFrameBufferObjectDepthTarget(nullptr, nullptr);
1707}
1708
1709void rsgClearAllRenderTargets(void) {
1710    return SC_ClearFrameBufferObjectTargets(nullptr, nullptr);
1711}
1712
1713void color(float r, float g, float b, float a) {
1714    return SC_Color(r, g, b, a);
1715}
1716
1717void rsgFinish(void) {
1718    return SC_Finish();
1719}
1720
1721#endif
1722
1723//////////////////////////////////////////////////////////////////////////////
1724// Compatibility Library entry points
1725//////////////////////////////////////////////////////////////////////////////
1726
1727#ifndef __LP64__
1728#define IS_CLEAR_SET_OBJ(t, u, v) \
1729    bool rsIsObject(t src) { \
1730        return src.p != nullptr; \
1731    } \
1732    void __attribute__((overloadable)) rsClearObject(t *dst) { \
1733        return SC_ClearObject(reinterpret_cast<rs_object_base *>(dst)); \
1734    } \
1735    void __attribute__((overloadable)) rsSetObject(t *dst, t src) { \
1736        android::renderscript::rs_object_base cast; \
1737        cast.p = (ObjectBase *) src.p; \
1738        return SC_SetObject(reinterpret_cast<rs_object_base *>(dst), cast);\
1739    }
1740#else
1741#define IS_CLEAR_SET_OBJ(t, u, v) \
1742    extern "C" { bool u(t* src) { \
1743        return src->p != nullptr; \
1744    } }\
1745    void __attribute__((overloadable)) rsClearObject(t *dst) { \
1746        return SC_ClearObject(reinterpret_cast<rs_object_base *>(dst)); \
1747    } \
1748    extern "C" {\
1749      void v (t *dst, t *src) { \
1750        return SC_SetObject_ByRef(reinterpret_cast<rs_object_base *>(dst),\
1751                                  reinterpret_cast<rs_object_base *>(src));\
1752    } }
1753#endif
1754
1755IS_CLEAR_SET_OBJ(::rs_element, _Z10rsIsObject10rs_element, _Z11rsSetObjectP10rs_elementS_)
1756IS_CLEAR_SET_OBJ(::rs_type, _Z10rsIsObject7rs_type, _Z11rsSetObjectP7rs_typeS_)
1757IS_CLEAR_SET_OBJ(::rs_allocation, _Z10rsIsObject13rs_allocation, _Z11rsSetObjectP13rs_allocationS_)
1758IS_CLEAR_SET_OBJ(::rs_sampler, _Z10rsIsObject10rs_sampler, _Z11rsSetObjectP10rs_samplerS_)
1759IS_CLEAR_SET_OBJ(::rs_script, _Z10rsIsObject9rs_script, _Z11rsSetObjectP9rs_scriptS_)
1760
1761IS_CLEAR_SET_OBJ(::rs_path, _Z10rsIsObject7rs_path, _Z11rsSetObjectP7rs_pathS_)
1762IS_CLEAR_SET_OBJ(::rs_mesh, _Z10rsIsObject7rs_mesh, _Z11rsSetObjectP7rs_meshS_)
1763IS_CLEAR_SET_OBJ(::rs_program_fragment, _Z10rsIsObject19rs_program_fragment, _Z11rsSetObjectP19rs_program_fragmentS_)
1764IS_CLEAR_SET_OBJ(::rs_program_vertex, _Z10rsIsObject17rs_program_vertex, _Z11rsSetObjectP17rs_program_vertexS_)
1765IS_CLEAR_SET_OBJ(::rs_program_raster, _Z10rsIsObject17rs_program_raster, _Z11rsSetObjectP17rs_program_rasterS_)
1766IS_CLEAR_SET_OBJ(::rs_program_store, _Z10rsIsObject16rs_program_store, _Z11rsSetObjectP16rs_program_storeS_)
1767IS_CLEAR_SET_OBJ(::rs_font, _Z10rsIsObject7rs_font, _Z11rsSetObjectP7rs_fontS_)
1768
1769
1770#undef IS_CLEAR_SET_OBJ
1771
1772static void SC_ForEach_SAA(::rs_script target,
1773                           ::rs_allocation in,
1774                           ::rs_allocation out) {
1775    Context *rsc = RsdCpuReference::getTlsContext();
1776    rsrForEach(rsc, (Script*)target.p, (Allocation*)in.p, (Allocation*)out.p,
1777               nullptr, 0, nullptr);
1778}
1779
1780static void SC_ForEach_SAAUS(::rs_script target,
1781                             ::rs_allocation in,
1782                             ::rs_allocation out,
1783                             const void *usr,
1784                             const RsScriptCall *call) {
1785    Context *rsc = RsdCpuReference::getTlsContext();
1786    rsrForEach(rsc, (Script*)target.p, (Allocation*)in.p, (Allocation*)out.p,
1787               usr, 0, call);
1788}
1789
1790static void SC_ForEach_SAAUL(::rs_script target,
1791                             ::rs_allocation in,
1792                             ::rs_allocation out,
1793                             const void *usr,
1794                             uint32_t usrLen) {
1795    Context *rsc = RsdCpuReference::getTlsContext();
1796    rsrForEach(rsc, (Script*)target.p, (Allocation*)in.p, (Allocation*)out.p,
1797               usr, usrLen, nullptr);
1798}
1799
1800static void SC_ForEach_SAAULS(::rs_script target,
1801                              ::rs_allocation in,
1802                              ::rs_allocation out,
1803                              const void *usr,
1804                              uint32_t usrLen,
1805                              const RsScriptCall *call) {
1806    Context *rsc = RsdCpuReference::getTlsContext();
1807    rsrForEach(rsc, (Script*)target.p, (Allocation*)in.p, (Allocation*)out.p,
1808               usr, usrLen, call);
1809}
1810
1811#ifdef RS_COMPATIBILITY_LIB
1812static const Allocation * SC_GetAllocation(const void *ptr) {
1813    Context *rsc = RsdCpuReference::getTlsContext();
1814    const Script *sc = RsdCpuReference::getTlsScript();
1815    return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
1816}
1817
1818const Allocation * rsGetAllocation(const void *ptr) {
1819    return SC_GetAllocation(ptr);
1820}
1821
1822#else
1823const android::renderscript::rs_allocation rsGetAllocation(const void *ptr) {
1824#ifdef __i386__
1825    android::renderscript::rs_allocation obj;
1826    obj.p = (Allocation *) SC_GetAllocation(ptr);
1827    return obj;
1828#else
1829    return SC_GetAllocation(ptr);
1830#endif
1831}
1832#endif
1833
1834
1835void __attribute__((overloadable)) rsAllocationIoSend(::rs_allocation a) {
1836    SC_AllocationIoSend(a);
1837}
1838
1839void __attribute__((overloadable)) rsAllocationIoReceive(::rs_allocation a) {
1840    SC_AllocationIoReceive(a);
1841}
1842
1843
1844void __attribute__((overloadable)) rsAllocationCopy1DRange(
1845        ::rs_allocation dstAlloc,
1846        uint32_t dstOff, uint32_t dstMip, uint32_t count,
1847        ::rs_allocation srcAlloc,
1848        uint32_t srcOff, uint32_t srcMip) {
1849    SC_AllocationCopy1DRange(dstAlloc, dstOff, dstMip, count,
1850                             srcAlloc, srcOff, srcMip);
1851}
1852
1853void __attribute__((overloadable)) rsAllocationCopy2DRange(
1854        ::rs_allocation dstAlloc,
1855        uint32_t dstXoff, uint32_t dstYoff,
1856        uint32_t dstMip, rs_allocation_cubemap_face dstFace,
1857        uint32_t width, uint32_t height,
1858        ::rs_allocation srcAlloc,
1859        uint32_t srcXoff, uint32_t srcYoff,
1860        uint32_t srcMip, rs_allocation_cubemap_face srcFace) {
1861    SC_AllocationCopy2DRange(dstAlloc, dstXoff, dstYoff,
1862                             dstMip, dstFace, width, height,
1863                             srcAlloc, srcXoff, srcYoff,
1864                             srcMip, srcFace);
1865}
1866
1867void __attribute__((overloadable)) rsForEach(::rs_script script,
1868                                             ::rs_allocation in,
1869                                             ::rs_allocation out,
1870                                             const void *usr,
1871                                             const rs_script_call *call) {
1872    return SC_ForEach_SAAUS(script, in, out, usr, (RsScriptCall*)call);
1873}
1874
1875void __attribute__((overloadable)) rsForEach(::rs_script script,
1876                                             ::rs_allocation in,
1877                                             ::rs_allocation out,
1878                                             const void *usr) {
1879#ifdef __LP64__
1880    return SC_ForEach_SAAU(&script, &in, &out, usr);
1881#else
1882    return SC_ForEach_SAAU(script, in, out, usr);
1883#endif
1884}
1885
1886void __attribute__((overloadable)) rsForEach(::rs_script script,
1887                                             ::rs_allocation in,
1888                                             ::rs_allocation out) {
1889    return SC_ForEach_SAA(script, in, out);
1890}
1891
1892void __attribute__((overloadable)) rsForEach(::rs_script script,
1893                                             ::rs_allocation in,
1894                                             ::rs_allocation out,
1895                                             const void *usr,
1896                                             uint32_t usrLen) {
1897    return SC_ForEach_SAAUL(script, in, out, usr, usrLen);
1898}
1899
1900void __attribute__((overloadable)) rsForEach(::rs_script script,
1901                                             ::rs_allocation in,
1902                                             ::rs_allocation out,
1903                                             const void *usr,
1904                                             uint32_t usrLen,
1905                                             const rs_script_call *call) {
1906    return SC_ForEach_SAAULS(script, in, out, usr, usrLen, (RsScriptCall*)call);
1907}
1908
1909// #if defined(RS_COMPATIBILITY_LIB) || !defined(__LP64__)
1910#ifndef __LP64__
1911int rsTime(int *timer) {
1912    return SC_Time(timer);
1913}
1914
1915rs_tm* rsLocaltime(rs_tm* local, const int *timer) {
1916    return (rs_tm*)(SC_LocalTime((tm*)local, (time_t *)timer));
1917}
1918#else
1919time_t rsTime(time_t * timer) {
1920    return SC_Time(timer);
1921}
1922
1923rs_tm* rsLocaltime(rs_tm* local, const time_t *timer) {
1924    return (rs_tm*)(SC_LocalTime((tm*)local, (time_t *)timer));
1925}
1926#endif // RS_COMPATIBILITY_LIB
1927
1928int64_t rsUptimeMillis() {
1929    Context *rsc = RsdCpuReference::getTlsContext();
1930    return rsrUptimeMillis(rsc);
1931}
1932
1933int64_t rsUptimeNanos() {
1934    return SC_UptimeNanos();
1935}
1936
1937float rsGetDt() {
1938    return SC_GetDt();
1939}
1940
1941uint32_t rsSendToClient(int cmdID) {
1942    return SC_ToClient(cmdID);
1943}
1944
1945uint32_t rsSendToClient(int cmdID, const void *data, uint32_t len) {
1946    return SC_ToClient2(cmdID, data, len);
1947}
1948
1949uint32_t rsSendToClientBlocking(int cmdID) {
1950    return SC_ToClientBlocking(cmdID);
1951}
1952
1953uint32_t rsSendToClientBlocking(int cmdID, const void *data, uint32_t len) {
1954    return SC_ToClientBlocking2(cmdID, data, len);
1955}
1956
1957static void SC_debugF(const char *s, float f) {
1958    ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
1959}
1960static void SC_debugFv2(const char *s, float f1, float f2) {
1961    ALOGD("%s {%f, %f}", s, f1, f2);
1962}
1963static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
1964    ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
1965}
1966static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
1967    ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
1968}
1969static void SC_debugF2(const char *s, float2 f) {
1970    ALOGD("%s {%f, %f}", s, f.x, f.y);
1971}
1972static void SC_debugF3(const char *s, float3 f) {
1973    ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
1974}
1975static void SC_debugF4(const char *s, float4 f) {
1976    ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
1977}
1978static void SC_debugD(const char *s, double d) {
1979    ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
1980}
1981static void SC_debugFM4v4(const char *s, const float *f) {
1982    ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
1983    ALOGD("%s  %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
1984    ALOGD("%s  %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
1985    ALOGD("%s  %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
1986}
1987static void SC_debugFM3v3(const char *s, const float *f) {
1988    ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
1989    ALOGD("%s  %f, %f, %f", s, f[1], f[4], f[7]);
1990    ALOGD("%s  %f, %f, %f}",s, f[2], f[5], f[8]);
1991}
1992static void SC_debugFM2v2(const char *s, const float *f) {
1993    ALOGD("%s {%f, %f", s, f[0], f[2]);
1994    ALOGD("%s  %f, %f}",s, f[1], f[3]);
1995}
1996static void SC_debugI8(const char *s, char c) {
1997    ALOGD("%s %hhd  0x%hhx", s, c, (unsigned char)c);
1998}
1999static void SC_debugC2(const char *s, char2 c) {
2000    ALOGD("%s {%hhd, %hhd}  0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
2001}
2002static void SC_debugC3(const char *s, char3 c) {
2003    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);
2004}
2005static void SC_debugC4(const char *s, char4 c) {
2006    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);
2007}
2008static void SC_debugU8(const char *s, unsigned char c) {
2009    ALOGD("%s %hhu  0x%hhx", s, c, c);
2010}
2011static void SC_debugUC2(const char *s, uchar2 c) {
2012    ALOGD("%s {%hhu, %hhu}  0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
2013}
2014static void SC_debugUC3(const char *s, uchar3 c) {
2015    ALOGD("%s {%hhu, %hhu, %hhu}  0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2016}
2017static void SC_debugUC4(const char *s, uchar4 c) {
2018    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);
2019}
2020static void SC_debugI16(const char *s, short c) {
2021    ALOGD("%s %hd  0x%hx", s, c, c);
2022}
2023static void SC_debugS2(const char *s, short2 c) {
2024    ALOGD("%s {%hd, %hd}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
2025}
2026static void SC_debugS3(const char *s, short3 c) {
2027    ALOGD("%s {%hd, %hd, %hd}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2028}
2029static void SC_debugS4(const char *s, short4 c) {
2030    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);
2031}
2032static void SC_debugU16(const char *s, unsigned short c) {
2033    ALOGD("%s %hu  0x%hx", s, c, c);
2034}
2035static void SC_debugUS2(const char *s, ushort2 c) {
2036    ALOGD("%s {%hu, %hu}  0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
2037}
2038static void SC_debugUS3(const char *s, ushort3 c) {
2039    ALOGD("%s {%hu, %hu, %hu}  0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2040}
2041static void SC_debugUS4(const char *s, ushort4 c) {
2042    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);
2043}
2044static void SC_debugI32(const char *s, int32_t i) {
2045    ALOGD("%s %d  0x%x", s, i, i);
2046}
2047static void SC_debugI2(const char *s, int2 i) {
2048    ALOGD("%s {%d, %d}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
2049}
2050static void SC_debugI3(const char *s, int3 i) {
2051    ALOGD("%s {%d, %d, %d}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
2052}
2053static void SC_debugI4(const char *s, int4 i) {
2054    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);
2055}
2056static void SC_debugU32(const char *s, uint32_t i) {
2057    ALOGD("%s %u  0x%x", s, i, i);
2058}
2059static void SC_debugUI2(const char *s, uint2 i) {
2060    ALOGD("%s {%u, %u}  0x%x 0x%x", s, i.x, i.y, i.x, i.y);
2061}
2062static void SC_debugUI3(const char *s, uint3 i) {
2063    ALOGD("%s {%u, %u, %u}  0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
2064}
2065static void SC_debugUI4(const char *s, uint4 i) {
2066    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);
2067}
2068
2069template <typename T>
2070static inline long long LL(const T &x) {
2071    return static_cast<long long>(x);
2072}
2073
2074template <typename T>
2075static inline unsigned long long LLu(const T &x) {
2076    return static_cast<unsigned long long>(x);
2077}
2078
2079static void SC_debugLL64(const char *s, long long ll) {
2080    ALOGD("%s %lld  0x%llx", s, LL(ll), LL(ll));
2081}
2082
2083static void SC_debugL2(const char *s, long2 ll) {
2084    ALOGD("%s {%lld, %lld}  0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.x), LL(ll.y));
2085}
2086static void SC_debugL3(const char *s, long3 ll) {
2087    ALOGD("%s {%lld, %lld, %lld}  0x%llx 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.x), LL(ll.y), LL(ll.z));
2088}
2089static void SC_debugL4(const char *s, long4 ll) {
2090    ALOGD("%s {%lld, %lld, %lld, %lld}  0x%llx 0x%llx 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.w), LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.w));
2091}
2092static void SC_debugULL64(const char *s, unsigned long long ll) {
2093    ALOGD("%s %llu  0x%llx", s, ll, ll);
2094}
2095static void SC_debugUL2(const char *s, ulong2 ll) {
2096    ALOGD("%s {%llu, %llu}  0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.x), LLu(ll.y));
2097}
2098static void SC_debugUL3(const char *s, ulong3 ll) {
2099    ALOGD("%s {%llu, %llu, %llu}  0x%llx 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.x), LLu(ll.y), LLu(ll.z));
2100}
2101static void SC_debugUL4(const char *s, ulong4 ll) {
2102    ALOGD("%s {%llu, %llu, %llu, %llu}  0x%llx 0x%llx 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.w), LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.w));
2103}
2104
2105static void SC_debugP(const char *s, const void *p) {
2106    ALOGD("%s %p", s, p);
2107}
2108
2109// TODO: allocation ops, messaging, time
2110
2111void rsDebug(const char *s, float f) {
2112    SC_debugF(s, f);
2113}
2114
2115void rsDebug(const char *s, float f1, float f2) {
2116    SC_debugFv2(s, f1, f2);
2117}
2118
2119void rsDebug(const char *s, float f1, float f2, float f3) {
2120    SC_debugFv3(s, f1, f2, f3);
2121}
2122
2123void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
2124    SC_debugFv4(s, f1, f2, f3, f4);
2125}
2126
2127void rsDebug(const char *s, const float2 *f) {
2128    SC_debugF2(s, *f);
2129}
2130
2131void rsDebug(const char *s, const float3 *f) {
2132    SC_debugF3(s, *f);
2133}
2134
2135void rsDebug(const char *s, const float4 *f) {
2136    SC_debugF4(s, *f);
2137}
2138
2139void rsDebug(const char *s, double d) {
2140    SC_debugD(s, d);
2141}
2142
2143void rsDebug(const char *s, const rs_matrix4x4 *m) {
2144    SC_debugFM4v4(s, (float *) m);
2145}
2146
2147void rsDebug(const char *s, const rs_matrix3x3 *m) {
2148    SC_debugFM3v3(s, (float *) m);
2149}
2150
2151void rsDebug(const char *s, const rs_matrix2x2 *m) {
2152    SC_debugFM2v2(s, (float *) m);
2153}
2154
2155void rsDebug(const char *s, char c) {
2156    SC_debugI8(s, c);
2157}
2158
2159void rsDebug(const char *s, const char2 *c) {
2160    SC_debugC2(s, *c);
2161}
2162
2163void rsDebug(const char *s, const char3 *c) {
2164    SC_debugC3(s, *c);
2165}
2166
2167void rsDebug(const char *s, const char4 *c) {
2168    SC_debugC4(s, *c);
2169}
2170
2171void rsDebug(const char *s, unsigned char c) {
2172    SC_debugU8(s, c);
2173}
2174
2175void rsDebug(const char *s, const uchar2 *c) {
2176    SC_debugUC2(s, *c);
2177}
2178
2179void rsDebug(const char *s, const uchar3 *c) {
2180    SC_debugUC3(s, *c);
2181}
2182
2183void rsDebug(const char *s, const uchar4 *c) {
2184    SC_debugUC4(s, *c);
2185}
2186
2187void rsDebug(const char *s, short c) {
2188    SC_debugI16(s, c);
2189}
2190
2191void rsDebug(const char *s, const short2 *c) {
2192    SC_debugS2(s, *c);
2193}
2194
2195void rsDebug(const char *s, const short3 *c) {
2196    SC_debugS3(s, *c);
2197}
2198
2199void rsDebug(const char *s, const short4 *c) {
2200    SC_debugS4(s, *c);
2201}
2202
2203void rsDebug(const char *s, unsigned short c) {
2204    SC_debugU16(s, c);
2205}
2206
2207void rsDebug(const char *s, const ushort2 *c) {
2208    SC_debugUS2(s, *c);
2209}
2210
2211void rsDebug(const char *s, const ushort3 *c) {
2212    SC_debugUS3(s, *c);
2213}
2214
2215void rsDebug(const char *s, const ushort4 *c) {
2216    SC_debugUS4(s, *c);
2217}
2218
2219void rsDebug(const char *s, int c) {
2220    SC_debugI32(s, c);
2221}
2222
2223void rsDebug(const char *s, const int2 *c) {
2224    SC_debugI2(s, *c);
2225}
2226
2227void rsDebug(const char *s, const int3 *c) {
2228    SC_debugI3(s, *c);
2229}
2230
2231void rsDebug(const char *s, const int4 *c) {
2232    SC_debugI4(s, *c);
2233}
2234
2235void rsDebug(const char *s, unsigned int c) {
2236    SC_debugU32(s, c);
2237}
2238
2239void rsDebug(const char *s, const uint2 *c) {
2240    SC_debugUI2(s, *c);
2241}
2242
2243void rsDebug(const char *s, const uint3 *c) {
2244    SC_debugUI3(s, *c);
2245}
2246
2247void rsDebug(const char *s, const uint4 *c) {
2248    SC_debugUI4(s, *c);
2249}
2250
2251void rsDebug(const char *s, long c) {
2252    SC_debugLL64(s, c);
2253}
2254
2255void rsDebug(const char *s, long long c) {
2256    SC_debugLL64(s, c);
2257}
2258
2259void rsDebug(const char *s, const long2 *c) {
2260    SC_debugL2(s, *c);
2261}
2262
2263void rsDebug(const char *s, const long3 *c) {
2264    SC_debugL3(s, *c);
2265}
2266
2267void rsDebug(const char *s, const long4 *c) {
2268    SC_debugL4(s, *c);
2269}
2270
2271void rsDebug(const char *s, unsigned long c) {
2272    SC_debugULL64(s, c);
2273}
2274
2275void rsDebug(const char *s, unsigned long long c) {
2276    SC_debugULL64(s, c);
2277}
2278
2279void rsDebug(const char *s, const ulong2 *c) {
2280    SC_debugUL2(s, *c);
2281}
2282
2283void rsDebug(const char *s, const ulong3 *c) {
2284    SC_debugUL3(s, *c);
2285}
2286
2287void rsDebug(const char *s, const ulong4 *c) {
2288    SC_debugUL4(s, *c);
2289}
2290
2291// FIXME: We need to export these function signatures for the compatibility
2292// library. The C++ name mangling that LLVM uses for ext_vector_type requires
2293// different versions for "long" vs. "long long". Note that the called
2294// functions are still using the appropriate 64-bit sizes.
2295
2296#ifndef __LP64__
2297typedef long l2 __attribute__((ext_vector_type(2)));
2298typedef long l3 __attribute__((ext_vector_type(3)));
2299typedef long l4 __attribute__((ext_vector_type(4)));
2300typedef unsigned long ul2 __attribute__((ext_vector_type(2)));
2301typedef unsigned long ul3 __attribute__((ext_vector_type(3)));
2302typedef unsigned long ul4 __attribute__((ext_vector_type(4)));
2303
2304void rsDebug(const char *s, const l2 *c) {
2305    SC_debugL2(s, *(const long2 *)c);
2306}
2307
2308void rsDebug(const char *s, const l3 *c) {
2309    SC_debugL3(s, *(const long3 *)c);
2310}
2311
2312void rsDebug(const char *s, const l4 *c) {
2313    SC_debugL4(s, *(const long4 *)c);
2314}
2315
2316void rsDebug(const char *s, const ul2 *c) {
2317    SC_debugUL2(s, *(const ulong2 *)c);
2318}
2319
2320void rsDebug(const char *s, const ul3 *c) {
2321    SC_debugUL3(s, *(const ulong3 *)c);
2322}
2323
2324void rsDebug(const char *s, const ul4 *c) {
2325    SC_debugUL4(s, *(const ulong4 *)c);
2326}
2327#endif
2328
2329void rsDebug(const char *s, const long2 c) {
2330    SC_debugL2(s, c);
2331}
2332
2333void rsDebug(const char *s, const long3 c) {
2334    SC_debugL3(s, c);
2335}
2336
2337void rsDebug(const char *s, const long4 c) {
2338    SC_debugL4(s, c);
2339}
2340
2341void rsDebug(const char *s, const ulong2 c) {
2342    SC_debugUL2(s, c);
2343}
2344
2345void rsDebug(const char *s, const ulong3 c) {
2346    SC_debugUL3(s, c);
2347}
2348
2349void rsDebug(const char *s, const ulong4 c) {
2350    SC_debugUL4(s, c);
2351}
2352
2353
2354void rsDebug(const char *s, const void *p) {
2355    SC_debugP(s, p);
2356}
2357
2358extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
2359    ScriptC *s = (ScriptC *)pContext;
2360    const RsdCpuReference::CpuSymbol *syms = gSyms;
2361    const RsdCpuReference::CpuSymbol *sym = nullptr;
2362
2363    if (!sym) {
2364        while (syms->fnPtr) {
2365            if (!strcmp(syms->name, name)) {
2366                return syms;
2367            }
2368            syms++;
2369        }
2370    }
2371
2372    return nullptr;
2373}
2374