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