rsdRuntimeStubs.cpp revision 74a827988567a9d65954bb0d825a3ba4a97e2947
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "rsContext.h" 18#include "rsScriptC.h" 19#include "rsMatrix4x4.h" 20#include "rsMatrix3x3.h" 21#include "rsMatrix2x2.h" 22#include "rsRuntime.h" 23 24#include "utils/Timers.h" 25#include "rsdCore.h" 26 27#include "rsdRuntime.h" 28 29#include <time.h> 30 31using namespace android; 32using namespace android::renderscript; 33 34#define GET_TLS() ScriptTLSStruct * tls = \ 35 (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \ 36 Context * rsc = tls->mContext; \ 37 ScriptC * sc = (ScriptC *) tls->mScript 38 39 40 41////////////////////////////////////////////////////////////////////////////// 42// Allocation 43////////////////////////////////////////////////////////////////////////////// 44 45static uint32_t SC_allocGetDimX(Allocation *a) { 46 return a->mHal.state.dimensionX; 47} 48 49static uint32_t SC_allocGetDimY(Allocation *a) { 50 return a->mHal.state.dimensionY; 51} 52 53static uint32_t SC_allocGetDimZ(Allocation *a) { 54 return a->mHal.state.dimensionZ; 55} 56 57static uint32_t SC_allocGetDimLOD(Allocation *a) { 58 return a->mHal.state.hasMipmaps; 59} 60 61static uint32_t SC_allocGetDimFaces(Allocation *a) { 62 return a->mHal.state.hasFaces; 63} 64 65static const void * SC_getElementAtX(Allocation *a, uint32_t x) { 66 const uint8_t *p = (const uint8_t *)a->getPtr(); 67 return &p[a->mHal.state.elementSizeBytes * x]; 68} 69 70static const void * SC_getElementAtXY(Allocation *a, uint32_t x, uint32_t y) { 71 const uint8_t *p = (const uint8_t *)a->getPtr(); 72 return &p[a->mHal.state.elementSizeBytes * (x + y * a->mHal.state.dimensionX)]; 73} 74 75static const void * SC_getElementAtXYZ(Allocation *a, uint32_t x, uint32_t y, uint32_t z) { 76 const uint8_t *p = (const uint8_t *)a->getPtr(); 77 return &p[a->mHal.state.elementSizeBytes * (x + y * a->mHal.state.dimensionX + 78 z * a->mHal.state.dimensionX * a->mHal.state.dimensionY)]; 79} 80 81static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) { 82 GET_TLS(); 83 rsrAllocationSyncAll(rsc, sc, a, source); 84} 85 86static void SC_AllocationSyncAll(Allocation *a) { 87 GET_TLS(); 88 rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT); 89} 90 91static void SC_AllocationCopy1DRange(Allocation *dstAlloc, 92 uint32_t dstOff, 93 uint32_t dstMip, 94 uint32_t count, 95 Allocation *srcAlloc, 96 uint32_t srcOff, uint32_t srcMip) { 97 GET_TLS(); 98} 99 100static void SC_AllocationCopy2DRange(Allocation *dstAlloc, 101 uint32_t dstXoff, uint32_t dstYoff, 102 uint32_t dstMip, uint32_t dstFace, 103 uint32_t width, uint32_t height, 104 Allocation *srcAlloc, 105 uint32_t srcXoff, uint32_t srcYoff, 106 uint32_t srcMip, uint32_t srcFace) { 107 GET_TLS(); 108} 109 110 111const Allocation * SC_getAllocation(const void *ptr) { 112 GET_TLS(); 113 return rsrGetAllocation(rsc, sc, ptr); 114} 115 116 117////////////////////////////////////////////////////////////////////////////// 118// Context 119////////////////////////////////////////////////////////////////////////////// 120 121static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) { 122 GET_TLS(); 123 rsrBindTexture(rsc, sc, pf, slot, a); 124} 125 126static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) { 127 GET_TLS(); 128 rsrBindSampler(rsc, sc, pf, slot, s); 129} 130 131static void SC_BindProgramStore(ProgramStore *ps) { 132 GET_TLS(); 133 rsrBindProgramStore(rsc, sc, ps); 134} 135 136static void SC_BindProgramFragment(ProgramFragment *pf) { 137 GET_TLS(); 138 rsrBindProgramFragment(rsc, sc, pf); 139} 140 141static void SC_BindProgramVertex(ProgramVertex *pv) { 142 GET_TLS(); 143 rsrBindProgramVertex(rsc, sc, pv); 144} 145 146static void SC_BindProgramRaster(ProgramRaster *pr) { 147 GET_TLS(); 148 rsrBindProgramRaster(rsc, sc, pr); 149} 150 151static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) { 152 GET_TLS(); 153 rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot); 154} 155 156static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) { 157 GET_TLS(); 158 rsrBindFrameBufferObjectDepthTarget(rsc, sc, a); 159} 160 161static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) { 162 GET_TLS(); 163 rsrClearFrameBufferObjectColorTarget(rsc, sc, slot); 164} 165 166static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) { 167 GET_TLS(); 168 rsrClearFrameBufferObjectDepthTarget(rsc, sc); 169} 170 171static void SC_ClearFrameBufferObjectTargets(Context *, Script *) { 172 GET_TLS(); 173 rsrClearFrameBufferObjectTargets(rsc, sc); 174} 175 176 177////////////////////////////////////////////////////////////////////////////// 178// VP 179////////////////////////////////////////////////////////////////////////////// 180 181static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) { 182 GET_TLS(); 183 rsrVpLoadProjectionMatrix(rsc, sc, m); 184} 185 186static void SC_VpLoadModelMatrix(const rsc_Matrix *m) { 187 GET_TLS(); 188 rsrVpLoadModelMatrix(rsc, sc, m); 189} 190 191static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) { 192 GET_TLS(); 193 rsrVpLoadTextureMatrix(rsc, sc, m); 194} 195 196static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) { 197 GET_TLS(); 198 rsrPfConstantColor(rsc, sc, pf, r, g, b, a); 199} 200 201static void SC_VpGetProjectionMatrix(rsc_Matrix *m) { 202 GET_TLS(); 203 rsrVpGetProjectionMatrix(rsc, sc, m); 204} 205 206 207////////////////////////////////////////////////////////////////////////////// 208// Drawing 209////////////////////////////////////////////////////////////////////////////// 210 211static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, 212 float x2, float y2, float z2, float u2, float v2, 213 float x3, float y3, float z3, float u3, float v3, 214 float x4, float y4, float z4, float u4, float v4) { 215 GET_TLS(); 216 rsrDrawQuadTexCoords(rsc, sc, 217 x1, y1, z1, u1, v1, 218 x2, y2, z2, u2, v2, 219 x3, y3, z3, u3, v3, 220 x4, y4, z4, u4, v4); 221} 222 223static void SC_DrawQuad(float x1, float y1, float z1, 224 float x2, float y2, float z2, 225 float x3, float y3, float z3, 226 float x4, float y4, float z4) { 227 GET_TLS(); 228 rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4); 229} 230 231static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) { 232 GET_TLS(); 233 rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h); 234} 235 236static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) { 237 GET_TLS(); 238 rsrDrawRect(rsc, sc, x1, y1, x2, y2, z); 239} 240 241static void SC_DrawMesh(Mesh *m) { 242 GET_TLS(); 243 rsrDrawMesh(rsc, sc, m); 244} 245 246static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) { 247 GET_TLS(); 248 rsrDrawMeshPrimitive(rsc, sc, m, primIndex); 249} 250 251static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) { 252 GET_TLS(); 253 rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len); 254} 255 256static void SC_MeshComputeBoundingBox(Mesh *m, 257 float *minX, float *minY, float *minZ, 258 float *maxX, float *maxY, float *maxZ) { 259 GET_TLS(); 260 rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ); 261} 262 263 264 265////////////////////////////////////////////////////////////////////////////// 266// 267////////////////////////////////////////////////////////////////////////////// 268 269 270static void SC_Color(float r, float g, float b, float a) { 271 GET_TLS(); 272 rsrColor(rsc, sc, r, g, b, a); 273} 274 275static void SC_Finish() { 276 GET_TLS(); 277 rsrFinish(rsc, sc); 278} 279 280static void SC_ClearColor(float r, float g, float b, float a) { 281 GET_TLS(); 282 rsrClearColor(rsc, sc, r, g, b, a); 283} 284 285static void SC_ClearDepth(float v) { 286 GET_TLS(); 287 rsrClearDepth(rsc, sc, v); 288} 289 290static uint32_t SC_GetWidth() { 291 GET_TLS(); 292 return rsrGetWidth(rsc, sc); 293} 294 295static uint32_t SC_GetHeight() { 296 GET_TLS(); 297 return rsrGetHeight(rsc, sc); 298} 299 300static void SC_DrawTextAlloc(Allocation *a, int x, int y) { 301 GET_TLS(); 302 rsrDrawTextAlloc(rsc, sc, a, x, y); 303} 304 305static void SC_DrawText(const char *text, int x, int y) { 306 GET_TLS(); 307 rsrDrawText(rsc, sc, text, x, y); 308} 309 310static void SC_MeasureTextAlloc(Allocation *a, 311 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) { 312 GET_TLS(); 313 rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom); 314} 315 316static void SC_MeasureText(const char *text, 317 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) { 318 GET_TLS(); 319 rsrMeasureText(rsc, sc, text, left, right, top, bottom); 320} 321 322static void SC_BindFont(Font *f) { 323 GET_TLS(); 324 rsrBindFont(rsc, sc, f); 325} 326 327static void SC_FontColor(float r, float g, float b, float a) { 328 GET_TLS(); 329 rsrFontColor(rsc, sc, r, g, b, a); 330} 331 332 333 334////////////////////////////////////////////////////////////////////////////// 335// 336////////////////////////////////////////////////////////////////////////////// 337 338static void SC_SetObject(ObjectBase **dst, ObjectBase * src) { 339 GET_TLS(); 340 rsrSetObject(rsc, sc, dst, src); 341} 342 343static void SC_ClearObject(ObjectBase **dst) { 344 GET_TLS(); 345 rsrClearObject(rsc, sc, dst); 346} 347 348static bool SC_IsObject(const ObjectBase *src) { 349 GET_TLS(); 350 return rsrIsObject(rsc, sc, src); 351} 352 353 354 355 356static const Allocation * SC_GetAllocation(const void *ptr) { 357 GET_TLS(); 358 return rsrGetAllocation(rsc, sc, ptr); 359} 360 361static void SC_ForEach(Script *target, 362 Allocation *in, 363 Allocation *out, 364 const void *usr, 365 const RsScriptCall *call) { 366 GET_TLS(); 367 rsrForEach(rsc, sc, target, in, out, usr, 0, NULL); 368} 369 370static void SC_ForEach2(Script *target, 371 Allocation *in, 372 Allocation *out, 373 const void *usr, 374 const RsScriptCall *call) { 375 GET_TLS(); 376 rsrForEach(rsc, sc, target, in, out, usr, 0, call); 377} 378 379 380 381////////////////////////////////////////////////////////////////////////////// 382// Time routines 383////////////////////////////////////////////////////////////////////////////// 384 385static float SC_GetDt() { 386 GET_TLS(); 387 return rsrGetDt(rsc, sc); 388} 389 390time_t SC_Time(time_t *timer) { 391 GET_TLS(); 392 return rsrTime(rsc, sc, timer); 393} 394 395tm* SC_LocalTime(tm *local, time_t *timer) { 396 GET_TLS(); 397 return rsrLocalTime(rsc, sc, local, timer); 398} 399 400int64_t SC_UptimeMillis() { 401 GET_TLS(); 402 return rsrUptimeMillis(rsc, sc); 403} 404 405int64_t SC_UptimeNanos() { 406 GET_TLS(); 407 return rsrUptimeNanos(rsc, sc); 408} 409 410////////////////////////////////////////////////////////////////////////////// 411// Message routines 412////////////////////////////////////////////////////////////////////////////// 413 414static uint32_t SC_ToClient2(int cmdID, void *data, int len) { 415 GET_TLS(); 416 return rsrToClient(rsc, sc, cmdID, data, len); 417} 418 419static uint32_t SC_ToClient(int cmdID) { 420 GET_TLS(); 421 return rsrToClient(rsc, sc, cmdID, NULL, 0); 422} 423 424static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) { 425 GET_TLS(); 426 return rsrToClientBlocking(rsc, sc, cmdID, data, len); 427} 428 429static uint32_t SC_ToClientBlocking(int cmdID) { 430 GET_TLS(); 431 return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0); 432} 433 434int SC_divsi3(int a, int b) { 435 return a / b; 436} 437 438int SC_modsi3(int a, int b) { 439 return a % b; 440} 441 442unsigned int SC_udivsi3(unsigned int a, unsigned int b) { 443 return a / b; 444} 445 446unsigned int SC_umodsi3(unsigned int a, unsigned int b) { 447 return a % b; 448} 449 450static void SC_debugF(const char *s, float f) { 451 LOGD("%s %f, 0x%08x", s, f, *((int *) (&f))); 452} 453static void SC_debugFv2(const char *s, float f1, float f2) { 454 LOGD("%s {%f, %f}", s, f1, f2); 455} 456static void SC_debugFv3(const char *s, float f1, float f2, float f3) { 457 LOGD("%s {%f, %f, %f}", s, f1, f2, f3); 458} 459static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) { 460 LOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4); 461} 462static void SC_debugD(const char *s, double d) { 463 LOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d))); 464} 465static void SC_debugFM4v4(const char *s, const float *f) { 466 LOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]); 467 LOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]); 468 LOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]); 469 LOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]); 470} 471static void SC_debugFM3v3(const char *s, const float *f) { 472 LOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]); 473 LOGD("%s %f, %f, %f", s, f[1], f[4], f[7]); 474 LOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]); 475} 476static void SC_debugFM2v2(const char *s, const float *f) { 477 LOGD("%s {%f, %f", s, f[0], f[2]); 478 LOGD("%s %f, %f}",s, f[1], f[3]); 479} 480 481static void SC_debugI32(const char *s, int32_t i) { 482 LOGD("%s %i 0x%x", s, i, i); 483} 484static void SC_debugU32(const char *s, uint32_t i) { 485 LOGD("%s %u 0x%x", s, i, i); 486} 487static void SC_debugLL64(const char *s, long long ll) { 488 LOGD("%s %lld 0x%llx", s, ll, ll); 489} 490static void SC_debugULL64(const char *s, unsigned long long ll) { 491 LOGD("%s %llu 0x%llx", s, ll, ll); 492} 493 494static void SC_debugP(const char *s, const void *p) { 495 LOGD("%s %p", s, p); 496} 497 498 499////////////////////////////////////////////////////////////////////////////// 500// Stub implementation 501////////////////////////////////////////////////////////////////////////////// 502 503// llvm name mangling ref 504// <builtin-type> ::= v # void 505// ::= b # bool 506// ::= c # char 507// ::= a # signed char 508// ::= h # unsigned char 509// ::= s # short 510// ::= t # unsigned short 511// ::= i # int 512// ::= j # unsigned int 513// ::= l # long 514// ::= m # unsigned long 515// ::= x # long long, __int64 516// ::= y # unsigned long long, __int64 517// ::= f # float 518// ::= d # double 519 520static RsdSymbolTable gSyms[] = { 521 { "__divsi3", (void *)&SC_divsi3, true }, 522 { "__modsi3", (void *)&SC_modsi3, true }, 523 { "__udivsi3", (void *)&SC_udivsi3, true }, 524 { "__umodsi3", (void *)&SC_umodsi3, true }, 525 { "memset", (void *)&memset, true }, 526 { "memcpy", (void *)&memcpy, true }, 527 528 // Refcounting 529 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true }, 530 { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true }, 531 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true }, 532 533 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true }, 534 { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true }, 535 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true }, 536 537 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true }, 538 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true }, 539 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true }, 540 541 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true }, 542 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true }, 543 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true }, 544 545 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true }, 546 { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true }, 547 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true }, 548 549 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true }, 550 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true }, 551 { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true }, 552 553 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true }, 554 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true }, 555 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true }, 556 557 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true }, 558 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true }, 559 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true }, 560 561 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true }, 562 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true }, 563 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true }, 564 565 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true }, 566 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true }, 567 { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true }, 568 569 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true }, 570 { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true }, 571 { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true }, 572 573 // Allocation ops 574 { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX, true }, 575 { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY, true }, 576 { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ, true }, 577 { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD, true }, 578 { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces, true }, 579 580 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX, true }, 581 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY, true }, 582 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ, true }, 583 584 { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation, true }, 585 586 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true }, 587 { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false }, 588 { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false }, 589 { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false }, 590 { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true }, 591 592 { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false }, 593 { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false }, 594 595 // Messaging 596 597 { "_Z14rsSendToClienti", (void *)&SC_ToClient, false }, 598 { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false }, 599 { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false }, 600 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false }, 601 602 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false }, 603 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false }, 604 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false }, 605 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false }, 606 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false }, 607 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false }, 608 609 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false }, 610 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false }, 611 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false }, 612 613 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false }, 614 615 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false }, 616 617 { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false }, 618 { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false }, 619 620 621 { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false }, 622 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false }, 623 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false }, 624 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false }, 625 626 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false }, 627 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false }, 628 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false }, 629 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false }, 630 631 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false }, 632 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false }, 633 634 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false }, 635 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false }, 636 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false }, 637 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false }, 638 639 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false }, 640 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false }, 641 642 { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false }, 643 { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false }, 644 { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false }, 645 { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false }, 646 { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false }, 647 648 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach, false }, 649 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach2, false }, 650 651 // time 652 { "_Z6rsTimePi", (void *)&SC_Time, true }, 653 { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true }, 654 { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true }, 655 { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true }, 656 { "_Z7rsGetDtv", (void*)&SC_GetDt, false }, 657 658 // misc 659 { "_Z5colorffff", (void *)&SC_Color, false }, 660 { "_Z9rsgFinishv", (void *)&SC_Finish, false }, 661 662 // Debug 663 { "_Z7rsDebugPKcf", (void *)&SC_debugF, true }, 664 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true }, 665 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true }, 666 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true }, 667 { "_Z7rsDebugPKcd", (void *)&SC_debugD, true }, 668 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true }, 669 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true }, 670 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true }, 671 { "_Z7rsDebugPKci", (void *)&SC_debugI32, true }, 672 { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true }, 673 // Both "long" and "unsigned long" need to be redirected to their 674 // 64-bit counterparts, since we have hacked Slang to use 64-bit 675 // for "long" on Arm (to be similar to Java). 676 { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true }, 677 { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true }, 678 { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true }, 679 { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true }, 680 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true }, 681 682 { NULL, NULL, false } 683}; 684 685 686void* rsdLookupRuntimeStub(void* pContext, char const* name) { 687 ScriptC *s = (ScriptC *)pContext; 688 if (!strcmp(name, "__isThreadable")) { 689 return (void*) s->mHal.info.isThreadable; 690 } else if (!strcmp(name, "__clearThreadable")) { 691 s->mHal.info.isThreadable = false; 692 return NULL; 693 } 694 695 RsdSymbolTable *syms = gSyms; 696 const RsdSymbolTable *sym = rsdLookupSymbolMath(name); 697 698 if (!sym) { 699 while (syms->mPtr) { 700 if (!strcmp(syms->mName, name)) { 701 sym = syms; 702 } 703 syms++; 704 } 705 } 706 707 if (sym) { 708 s->mHal.info.isThreadable &= sym->threadable; 709 return sym->mPtr; 710 } 711 LOGE("ScriptC sym lookup failed for %s", name); 712 return NULL; 713} 714 715 716