rsdRuntimeStubs.cpp revision 709a0978ae141198018ca9769f8d96292a8928e6
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 "utils/Timers.h"
25#include "rsdCore.h"
26#include "rsdBcc.h"
27
28#include "rsdPath.h"
29#include "rsdAllocation.h"
30#include "rsdShaderCache.h"
31#include "rsdVertexArray.h"
32
33#include <time.h>
34
35using namespace android;
36using namespace android::renderscript;
37
38typedef float float2 __attribute__((ext_vector_type(2)));
39typedef float float3 __attribute__((ext_vector_type(3)));
40typedef float float4 __attribute__((ext_vector_type(4)));
41typedef char char2 __attribute__((ext_vector_type(2)));
42typedef char char3 __attribute__((ext_vector_type(3)));
43typedef char char4 __attribute__((ext_vector_type(4)));
44typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
45typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
46typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
47typedef short short2 __attribute__((ext_vector_type(2)));
48typedef short short3 __attribute__((ext_vector_type(3)));
49typedef short short4 __attribute__((ext_vector_type(4)));
50typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
51typedef unsigned short ushort3 __attribute__((ext_vector_type(3)));
52typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
53typedef int32_t int2 __attribute__((ext_vector_type(2)));
54typedef int32_t int3 __attribute__((ext_vector_type(3)));
55typedef int32_t int4 __attribute__((ext_vector_type(4)));
56typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
57typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
58typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
59typedef long long long2 __attribute__((ext_vector_type(2)));
60typedef long long long3 __attribute__((ext_vector_type(3)));
61typedef long long long4 __attribute__((ext_vector_type(4)));
62typedef unsigned long long ulong2 __attribute__((ext_vector_type(2)));
63typedef unsigned long long ulong3 __attribute__((ext_vector_type(3)));
64typedef unsigned long long ulong4 __attribute__((ext_vector_type(4)));
65
66
67//////////////////////////////////////////////////////////////////////////////
68// Allocation
69//////////////////////////////////////////////////////////////////////////////
70
71
72static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
73    Context *rsc = RsdCpuReference::getTlsContext();
74    rsrAllocationSyncAll(rsc, a, source);
75}
76
77static void SC_AllocationSyncAll(Allocation *a) {
78    Context *rsc = RsdCpuReference::getTlsContext();
79    rsrAllocationSyncAll(rsc, a, RS_ALLOCATION_USAGE_SCRIPT);
80}
81
82static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
83                                     uint32_t dstOff,
84                                     uint32_t dstMip,
85                                     uint32_t count,
86                                     Allocation *srcAlloc,
87                                     uint32_t srcOff, uint32_t srcMip) {
88    Context *rsc = RsdCpuReference::getTlsContext();
89    rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
90                             srcAlloc, srcOff, srcMip);
91}
92
93static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
94                                     uint32_t dstXoff, uint32_t dstYoff,
95                                     uint32_t dstMip, uint32_t dstFace,
96                                     uint32_t width, uint32_t height,
97                                     Allocation *srcAlloc,
98                                     uint32_t srcXoff, uint32_t srcYoff,
99                                     uint32_t srcMip, uint32_t srcFace) {
100    Context *rsc = RsdCpuReference::getTlsContext();
101    rsrAllocationCopy2DRange(rsc, dstAlloc,
102                             dstXoff, dstYoff, dstMip, dstFace,
103                             width, height,
104                             srcAlloc,
105                             srcXoff, srcYoff, srcMip, srcFace);
106}
107
108static void SC_AllocationIoSend(Allocation *alloc) {
109    Context *rsc = RsdCpuReference::getTlsContext();
110    rsdAllocationIoSend(rsc, alloc);
111}
112
113
114static void SC_AllocationIoReceive(Allocation *alloc) {
115    Context *rsc = RsdCpuReference::getTlsContext();
116    rsdAllocationIoReceive(rsc, alloc);
117}
118
119
120
121//////////////////////////////////////////////////////////////////////////////
122// Context
123//////////////////////////////////////////////////////////////////////////////
124
125static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
126    Context *rsc = RsdCpuReference::getTlsContext();
127    rsrBindTexture(rsc, pf, slot, a);
128}
129
130static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
131    Context *rsc = RsdCpuReference::getTlsContext();
132    rsrBindConstant(rsc, pv, slot, a);
133}
134
135static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
136    Context *rsc = RsdCpuReference::getTlsContext();
137    rsrBindConstant(rsc, pf, slot, a);
138}
139
140static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
141    Context *rsc = RsdCpuReference::getTlsContext();
142    rsrBindSampler(rsc, pf, slot, s);
143}
144
145static void SC_BindProgramStore(ProgramStore *ps) {
146    Context *rsc = RsdCpuReference::getTlsContext();
147    rsrBindProgramStore(rsc, ps);
148}
149
150static void SC_BindProgramFragment(ProgramFragment *pf) {
151    Context *rsc = RsdCpuReference::getTlsContext();
152    rsrBindProgramFragment(rsc, pf);
153}
154
155static void SC_BindProgramVertex(ProgramVertex *pv) {
156    Context *rsc = RsdCpuReference::getTlsContext();
157    rsrBindProgramVertex(rsc, pv);
158}
159
160static void SC_BindProgramRaster(ProgramRaster *pr) {
161    Context *rsc = RsdCpuReference::getTlsContext();
162    rsrBindProgramRaster(rsc, pr);
163}
164
165static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
166    Context *rsc = RsdCpuReference::getTlsContext();
167    rsrBindFrameBufferObjectColorTarget(rsc, a, slot);
168}
169
170static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
171    Context *rsc = RsdCpuReference::getTlsContext();
172    rsrBindFrameBufferObjectDepthTarget(rsc, a);
173}
174
175static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
176    Context *rsc = RsdCpuReference::getTlsContext();
177    rsrClearFrameBufferObjectColorTarget(rsc, slot);
178}
179
180static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
181    Context *rsc = RsdCpuReference::getTlsContext();
182    rsrClearFrameBufferObjectDepthTarget(rsc);
183}
184
185static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
186    Context *rsc = RsdCpuReference::getTlsContext();
187    rsrClearFrameBufferObjectTargets(rsc);
188}
189
190
191//////////////////////////////////////////////////////////////////////////////
192// VP
193//////////////////////////////////////////////////////////////////////////////
194
195static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
196    Context *rsc = RsdCpuReference::getTlsContext();
197    rsrVpLoadProjectionMatrix(rsc, m);
198}
199
200static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
201    Context *rsc = RsdCpuReference::getTlsContext();
202    rsrVpLoadModelMatrix(rsc, m);
203}
204
205static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
206    Context *rsc = RsdCpuReference::getTlsContext();
207    rsrVpLoadTextureMatrix(rsc, m);
208}
209
210static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
211    Context *rsc = RsdCpuReference::getTlsContext();
212    rsrPfConstantColor(rsc, pf, r, g, b, a);
213}
214
215static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
216    Context *rsc = RsdCpuReference::getTlsContext();
217    rsrVpGetProjectionMatrix(rsc, m);
218}
219
220
221//////////////////////////////////////////////////////////////////////////////
222// Drawing
223//////////////////////////////////////////////////////////////////////////////
224
225static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
226                                 float x2, float y2, float z2, float u2, float v2,
227                                 float x3, float y3, float z3, float u3, float v3,
228                                 float x4, float y4, float z4, float u4, float v4) {
229    Context *rsc = RsdCpuReference::getTlsContext();
230
231    if (!rsc->setupCheck()) {
232        return;
233    }
234
235    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
236    if (!dc->gl.shaderCache->setup(rsc)) {
237        return;
238    }
239
240    //ALOGE("Quad");
241    //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
242    //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
243    //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
244    //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
245
246    float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
247    const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
248
249    RsdVertexArray::Attrib attribs[2];
250    attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
251    attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
252
253    RsdVertexArray va(attribs, 2);
254    va.setup(rsc);
255
256    RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
257}
258
259static void SC_DrawQuad(float x1, float y1, float z1,
260                        float x2, float y2, float z2,
261                        float x3, float y3, float z3,
262                        float x4, float y4, float z4) {
263    SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
264                         x2, y2, z2, 1, 1,
265                         x3, y3, z3, 1, 0,
266                         x4, y4, z4, 0, 0);
267}
268
269static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
270    Context *rsc = RsdCpuReference::getTlsContext();
271
272    ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
273    rsc->setProgramVertex(rsc->getDefaultProgramVertex());
274    //rsc->setupCheck();
275
276    //GLint crop[4] = {0, h, w, -h};
277
278    float sh = rsc->getHeight();
279
280    SC_DrawQuad(x,   sh - y,     z,
281                x+w, sh - y,     z,
282                x+w, sh - (y+h), z,
283                x,   sh - (y+h), z);
284    rsc->setProgramVertex((ProgramVertex *)tmp.get());
285}
286
287static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
288    SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
289}
290
291static void SC_DrawPath(Path *p) {
292    Context *rsc = RsdCpuReference::getTlsContext();
293    rsdPathDraw(rsc, p);
294}
295
296static void SC_DrawMesh(Mesh *m) {
297    Context *rsc = RsdCpuReference::getTlsContext();
298    rsrDrawMesh(rsc, m);
299}
300
301static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
302    Context *rsc = RsdCpuReference::getTlsContext();
303    rsrDrawMeshPrimitive(rsc, m, primIndex);
304}
305
306static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
307    Context *rsc = RsdCpuReference::getTlsContext();
308    rsrDrawMeshPrimitiveRange(rsc, m, primIndex, start, len);
309}
310
311static void SC_MeshComputeBoundingBox(Mesh *m,
312                               float *minX, float *minY, float *minZ,
313                               float *maxX, float *maxY, float *maxZ) {
314    Context *rsc = RsdCpuReference::getTlsContext();
315    rsrMeshComputeBoundingBox(rsc, m, minX, minY, minZ, maxX, maxY, maxZ);
316}
317
318
319
320//////////////////////////////////////////////////////////////////////////////
321//
322//////////////////////////////////////////////////////////////////////////////
323
324
325static void SC_Color(float r, float g, float b, float a) {
326    Context *rsc = RsdCpuReference::getTlsContext();
327    rsrColor(rsc, r, g, b, a);
328}
329
330static void SC_Finish() {
331    Context *rsc = RsdCpuReference::getTlsContext();
332    rsdGLFinish(rsc);
333}
334
335static void SC_ClearColor(float r, float g, float b, float a) {
336    Context *rsc = RsdCpuReference::getTlsContext();
337    rsrPrepareClear(rsc);
338    rsdGLClearColor(rsc, r, g, b, a);
339}
340
341static void SC_ClearDepth(float v) {
342    Context *rsc = RsdCpuReference::getTlsContext();
343    rsrPrepareClear(rsc);
344    rsdGLClearDepth(rsc, v);
345}
346
347static uint32_t SC_GetWidth() {
348    Context *rsc = RsdCpuReference::getTlsContext();
349    return rsrGetWidth(rsc);
350}
351
352static uint32_t SC_GetHeight() {
353    Context *rsc = RsdCpuReference::getTlsContext();
354    return rsrGetHeight(rsc);
355}
356
357static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
358    Context *rsc = RsdCpuReference::getTlsContext();
359    rsrDrawTextAlloc(rsc, a, x, y);
360}
361
362static void SC_DrawText(const char *text, int x, int y) {
363    Context *rsc = RsdCpuReference::getTlsContext();
364    rsrDrawText(rsc, text, x, y);
365}
366
367static void SC_MeasureTextAlloc(Allocation *a,
368                         int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
369    Context *rsc = RsdCpuReference::getTlsContext();
370    rsrMeasureTextAlloc(rsc, a, left, right, top, bottom);
371}
372
373static void SC_MeasureText(const char *text,
374                    int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
375    Context *rsc = RsdCpuReference::getTlsContext();
376    rsrMeasureText(rsc, text, left, right, top, bottom);
377}
378
379static void SC_BindFont(Font *f) {
380    Context *rsc = RsdCpuReference::getTlsContext();
381    rsrBindFont(rsc, f);
382}
383
384static void SC_FontColor(float r, float g, float b, float a) {
385    Context *rsc = RsdCpuReference::getTlsContext();
386    rsrFontColor(rsc, r, g, b, a);
387}
388
389
390
391//////////////////////////////////////////////////////////////////////////////
392//
393//////////////////////////////////////////////////////////////////////////////
394
395static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
396    Context *rsc = RsdCpuReference::getTlsContext();
397    rsrSetObject(rsc, dst, src);
398}
399
400static void SC_ClearObject(ObjectBase **dst) {
401    Context *rsc = RsdCpuReference::getTlsContext();
402    rsrClearObject(rsc, dst);
403}
404
405static bool SC_IsObject(const ObjectBase *src) {
406    Context *rsc = RsdCpuReference::getTlsContext();
407    return rsrIsObject(rsc, src);
408}
409
410
411
412
413static const Allocation * SC_GetAllocation(const void *ptr) {
414    Context *rsc = RsdCpuReference::getTlsContext();
415    const Script *sc = RsdCpuReference::getTlsScript();
416    return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
417}
418
419static void SC_ForEach_SAA(Script *target,
420                            Allocation *in,
421                            Allocation *out) {
422    Context *rsc = RsdCpuReference::getTlsContext();
423    rsrForEach(rsc, target, in, out, NULL, 0, NULL);
424}
425
426static void SC_ForEach_SAAU(Script *target,
427                            Allocation *in,
428                            Allocation *out,
429                            const void *usr) {
430    Context *rsc = RsdCpuReference::getTlsContext();
431    rsrForEach(rsc, target, in, out, usr, 0, NULL);
432}
433
434static void SC_ForEach_SAAUS(Script *target,
435                             Allocation *in,
436                             Allocation *out,
437                             const void *usr,
438                             const RsScriptCall *call) {
439    Context *rsc = RsdCpuReference::getTlsContext();
440    rsrForEach(rsc, target, in, out, usr, 0, call);
441}
442
443static void SC_ForEach_SAAUL(Script *target,
444                             Allocation *in,
445                             Allocation *out,
446                             const void *usr,
447                             uint32_t usrLen) {
448    Context *rsc = RsdCpuReference::getTlsContext();
449    rsrForEach(rsc, target, in, out, usr, usrLen, NULL);
450}
451
452static void SC_ForEach_SAAULS(Script *target,
453                              Allocation *in,
454                              Allocation *out,
455                              const void *usr,
456                              uint32_t usrLen,
457                              const RsScriptCall *call) {
458    Context *rsc = RsdCpuReference::getTlsContext();
459    rsrForEach(rsc, target, in, out, usr, usrLen, call);
460}
461
462
463
464//////////////////////////////////////////////////////////////////////////////
465// Time routines
466//////////////////////////////////////////////////////////////////////////////
467
468static float SC_GetDt() {
469    Context *rsc = RsdCpuReference::getTlsContext();
470    const Script *sc = RsdCpuReference::getTlsScript();
471    return rsrGetDt(rsc, sc);
472}
473
474time_t SC_Time(time_t *timer) {
475    Context *rsc = RsdCpuReference::getTlsContext();
476    return rsrTime(rsc, timer);
477}
478
479tm* SC_LocalTime(tm *local, time_t *timer) {
480    Context *rsc = RsdCpuReference::getTlsContext();
481    return rsrLocalTime(rsc, local, timer);
482}
483
484int64_t SC_UptimeMillis() {
485    Context *rsc = RsdCpuReference::getTlsContext();
486    return rsrUptimeMillis(rsc);
487}
488
489int64_t SC_UptimeNanos() {
490    Context *rsc = RsdCpuReference::getTlsContext();
491    return rsrUptimeNanos(rsc);
492}
493
494//////////////////////////////////////////////////////////////////////////////
495// Message routines
496//////////////////////////////////////////////////////////////////////////////
497
498static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
499    Context *rsc = RsdCpuReference::getTlsContext();
500    return rsrToClient(rsc, cmdID, data, len);
501}
502
503static uint32_t SC_ToClient(int cmdID) {
504    Context *rsc = RsdCpuReference::getTlsContext();
505    return rsrToClient(rsc, cmdID, NULL, 0);
506}
507
508static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
509    Context *rsc = RsdCpuReference::getTlsContext();
510    return rsrToClientBlocking(rsc, cmdID, data, len);
511}
512
513static uint32_t SC_ToClientBlocking(int cmdID) {
514    Context *rsc = RsdCpuReference::getTlsContext();
515    return rsrToClientBlocking(rsc, cmdID, NULL, 0);
516}
517
518
519
520//////////////////////////////////////////////////////////////////////////////
521// Stub implementation
522//////////////////////////////////////////////////////////////////////////////
523
524// llvm name mangling ref
525//  <builtin-type> ::= v  # void
526//                 ::= b  # bool
527//                 ::= c  # char
528//                 ::= a  # signed char
529//                 ::= h  # unsigned char
530//                 ::= s  # short
531//                 ::= t  # unsigned short
532//                 ::= i  # int
533//                 ::= j  # unsigned int
534//                 ::= l  # long
535//                 ::= m  # unsigned long
536//                 ::= x  # long long, __int64
537//                 ::= y  # unsigned long long, __int64
538//                 ::= f  # float
539//                 ::= d  # double
540
541static RsdCpuReference::CpuSymbol gSyms[] = {
542    // Refcounting
543    { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
544    { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
545    { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
546
547    { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
548    { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
549    { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
550
551    { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
552    { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
553    { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
554
555    { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
556    { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
557    { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
558
559    { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
560    { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
561    { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
562
563    { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
564    { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
565    { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
566
567    { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
568    { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
569    { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
570
571    { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
572    { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
573    { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
574
575    { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
576    { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
577    { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
578
579    { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
580    { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
581    { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
582
583    { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
584    { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
585    { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
586
587    { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
588    { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
589    { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
590
591    // Allocation ops
592    { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
593    { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
594    { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
595    { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
596    { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
597    { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
598    { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
599    { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
600    { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
601
602    // Messaging
603
604    { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
605    { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
606    { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
607    { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
608
609    { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
610    { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
611    { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
612    { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
613    { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
614    { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
615    { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
616    { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
617
618    { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
619    { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
620    { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
621
622    { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
623
624    { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
625
626    { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
627    { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
628
629
630    { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
631    { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
632    { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
633    { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
634
635    { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
636    { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
637    { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
638    { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
639
640    { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
641
642    { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
643    { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
644
645    { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
646    { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
647    { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
648    { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
649
650    { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
651    { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
652
653    { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
654    { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
655    { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
656    { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
657    { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
658
659    { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
660    { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
661    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
662    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
663    { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
664
665    // time
666    { "_Z6rsTimePi", (void *)&SC_Time, true },
667    { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
668    { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
669    { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
670    { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
671
672    // misc
673    { "_Z5colorffff", (void *)&SC_Color, false },
674    { "_Z9rsgFinishv", (void *)&SC_Finish, false },
675
676    { NULL, NULL, false }
677};
678
679
680extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
681    ScriptC *s = (ScriptC *)pContext;
682    const RsdCpuReference::CpuSymbol *syms = gSyms;
683    const RsdCpuReference::CpuSymbol *sym = NULL;
684
685    if (!sym) {
686        while (syms->fnPtr) {
687            if (!strcmp(syms->name, name)) {
688                return syms;
689            }
690            syms++;
691        }
692    }
693
694    return NULL;
695}
696
697
698