Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 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" |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame^] | 26 | #include "rsdBcc.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 27 | |
| 28 | #include "rsdRuntime.h" |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 29 | #include "rsdPath.h" |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 30 | #include "rsdAllocation.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 31 | |
| 32 | #include <time.h> |
| 33 | |
| 34 | using namespace android; |
| 35 | using namespace android::renderscript; |
| 36 | |
| 37 | #define GET_TLS() ScriptTLSStruct * tls = \ |
Jason Sams | 83c451a | 2011-04-21 11:46:50 -0700 | [diff] [blame] | 38 | (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \ |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 39 | Context * rsc = tls->mContext; \ |
| 40 | ScriptC * sc = (ScriptC *) tls->mScript |
| 41 | |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 42 | typedef float float2 __attribute__((ext_vector_type(2))); |
| 43 | typedef float float3 __attribute__((ext_vector_type(3))); |
| 44 | typedef float float4 __attribute__((ext_vector_type(4))); |
| 45 | typedef char char2 __attribute__((ext_vector_type(2))); |
| 46 | typedef char char3 __attribute__((ext_vector_type(3))); |
| 47 | typedef char char4 __attribute__((ext_vector_type(4))); |
| 48 | typedef unsigned char uchar2 __attribute__((ext_vector_type(2))); |
| 49 | typedef unsigned char uchar3 __attribute__((ext_vector_type(3))); |
| 50 | typedef unsigned char uchar4 __attribute__((ext_vector_type(4))); |
| 51 | typedef short short2 __attribute__((ext_vector_type(2))); |
| 52 | typedef short short3 __attribute__((ext_vector_type(3))); |
| 53 | typedef short short4 __attribute__((ext_vector_type(4))); |
| 54 | typedef unsigned short ushort2 __attribute__((ext_vector_type(2))); |
| 55 | typedef unsigned short ushort3 __attribute__((ext_vector_type(3))); |
| 56 | typedef unsigned short ushort4 __attribute__((ext_vector_type(4))); |
| 57 | typedef int32_t int2 __attribute__((ext_vector_type(2))); |
| 58 | typedef int32_t int3 __attribute__((ext_vector_type(3))); |
| 59 | typedef int32_t int4 __attribute__((ext_vector_type(4))); |
| 60 | typedef uint32_t uint2 __attribute__((ext_vector_type(2))); |
| 61 | typedef uint32_t uint3 __attribute__((ext_vector_type(3))); |
| 62 | typedef uint32_t uint4 __attribute__((ext_vector_type(4))); |
| 63 | typedef long long long2 __attribute__((ext_vector_type(2))); |
| 64 | typedef long long long3 __attribute__((ext_vector_type(3))); |
| 65 | typedef long long long4 __attribute__((ext_vector_type(4))); |
| 66 | typedef unsigned long long ulong2 __attribute__((ext_vector_type(2))); |
| 67 | typedef unsigned long long ulong3 __attribute__((ext_vector_type(3))); |
| 68 | typedef unsigned long long ulong4 __attribute__((ext_vector_type(4))); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 69 | |
| 70 | |
| 71 | ////////////////////////////////////////////////////////////////////////////// |
| 72 | // Allocation |
| 73 | ////////////////////////////////////////////////////////////////////////////// |
| 74 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 75 | |
| 76 | static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) { |
| 77 | GET_TLS(); |
| 78 | rsrAllocationSyncAll(rsc, sc, a, source); |
| 79 | } |
| 80 | |
| 81 | static void SC_AllocationSyncAll(Allocation *a) { |
| 82 | GET_TLS(); |
| 83 | rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT); |
| 84 | } |
| 85 | |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 86 | static void SC_AllocationCopy1DRange(Allocation *dstAlloc, |
| 87 | uint32_t dstOff, |
| 88 | uint32_t dstMip, |
| 89 | uint32_t count, |
| 90 | Allocation *srcAlloc, |
| 91 | uint32_t srcOff, uint32_t srcMip) { |
| 92 | GET_TLS(); |
Alex Sakhartchouk | a949524 | 2011-06-16 11:05:13 -0700 | [diff] [blame] | 93 | rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count, |
| 94 | srcAlloc, srcOff, srcMip); |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static void SC_AllocationCopy2DRange(Allocation *dstAlloc, |
| 98 | uint32_t dstXoff, uint32_t dstYoff, |
| 99 | uint32_t dstMip, uint32_t dstFace, |
| 100 | uint32_t width, uint32_t height, |
| 101 | Allocation *srcAlloc, |
| 102 | uint32_t srcXoff, uint32_t srcYoff, |
| 103 | uint32_t srcMip, uint32_t srcFace) { |
| 104 | GET_TLS(); |
Alex Sakhartchouk | a949524 | 2011-06-16 11:05:13 -0700 | [diff] [blame] | 105 | rsrAllocationCopy2DRange(rsc, dstAlloc, |
| 106 | dstXoff, dstYoff, dstMip, dstFace, |
| 107 | width, height, |
| 108 | srcAlloc, |
| 109 | srcXoff, srcYoff, srcMip, srcFace); |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 112 | static void SC_AllocationIoSend(Allocation *alloc) { |
| 113 | GET_TLS(); |
| 114 | rsdAllocationIoSend(rsc, alloc); |
| 115 | } |
| 116 | |
| 117 | |
| 118 | static void SC_AllocationIoReceive(Allocation *alloc) { |
| 119 | GET_TLS(); |
| 120 | rsdAllocationIoReceive(rsc, alloc); |
| 121 | } |
| 122 | |
| 123 | |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 124 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 125 | ////////////////////////////////////////////////////////////////////////////// |
| 126 | // Context |
| 127 | ////////////////////////////////////////////////////////////////////////////// |
| 128 | |
| 129 | static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) { |
| 130 | GET_TLS(); |
| 131 | rsrBindTexture(rsc, sc, pf, slot, a); |
| 132 | } |
| 133 | |
Alex Sakhartchouk | a720a14 | 2012-01-10 10:16:52 -0800 | [diff] [blame] | 134 | static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) { |
| 135 | GET_TLS(); |
| 136 | rsrBindConstant(rsc, sc, pv, slot, a); |
| 137 | } |
| 138 | |
| 139 | static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) { |
| 140 | GET_TLS(); |
| 141 | rsrBindConstant(rsc, sc, pf, slot, a); |
| 142 | } |
| 143 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 144 | static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) { |
| 145 | GET_TLS(); |
| 146 | rsrBindSampler(rsc, sc, pf, slot, s); |
| 147 | } |
| 148 | |
| 149 | static void SC_BindProgramStore(ProgramStore *ps) { |
| 150 | GET_TLS(); |
| 151 | rsrBindProgramStore(rsc, sc, ps); |
| 152 | } |
| 153 | |
| 154 | static void SC_BindProgramFragment(ProgramFragment *pf) { |
| 155 | GET_TLS(); |
| 156 | rsrBindProgramFragment(rsc, sc, pf); |
| 157 | } |
| 158 | |
| 159 | static void SC_BindProgramVertex(ProgramVertex *pv) { |
| 160 | GET_TLS(); |
| 161 | rsrBindProgramVertex(rsc, sc, pv); |
| 162 | } |
| 163 | |
| 164 | static void SC_BindProgramRaster(ProgramRaster *pr) { |
| 165 | GET_TLS(); |
| 166 | rsrBindProgramRaster(rsc, sc, pr); |
| 167 | } |
| 168 | |
| 169 | static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) { |
| 170 | GET_TLS(); |
| 171 | rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot); |
| 172 | } |
| 173 | |
| 174 | static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) { |
| 175 | GET_TLS(); |
| 176 | rsrBindFrameBufferObjectDepthTarget(rsc, sc, a); |
| 177 | } |
| 178 | |
| 179 | static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) { |
| 180 | GET_TLS(); |
| 181 | rsrClearFrameBufferObjectColorTarget(rsc, sc, slot); |
| 182 | } |
| 183 | |
| 184 | static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) { |
| 185 | GET_TLS(); |
| 186 | rsrClearFrameBufferObjectDepthTarget(rsc, sc); |
| 187 | } |
| 188 | |
| 189 | static void SC_ClearFrameBufferObjectTargets(Context *, Script *) { |
| 190 | GET_TLS(); |
| 191 | rsrClearFrameBufferObjectTargets(rsc, sc); |
| 192 | } |
| 193 | |
| 194 | |
| 195 | ////////////////////////////////////////////////////////////////////////////// |
| 196 | // VP |
| 197 | ////////////////////////////////////////////////////////////////////////////// |
| 198 | |
| 199 | static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) { |
| 200 | GET_TLS(); |
| 201 | rsrVpLoadProjectionMatrix(rsc, sc, m); |
| 202 | } |
| 203 | |
| 204 | static void SC_VpLoadModelMatrix(const rsc_Matrix *m) { |
| 205 | GET_TLS(); |
| 206 | rsrVpLoadModelMatrix(rsc, sc, m); |
| 207 | } |
| 208 | |
| 209 | static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) { |
| 210 | GET_TLS(); |
| 211 | rsrVpLoadTextureMatrix(rsc, sc, m); |
| 212 | } |
| 213 | |
| 214 | static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) { |
| 215 | GET_TLS(); |
| 216 | rsrPfConstantColor(rsc, sc, pf, r, g, b, a); |
| 217 | } |
| 218 | |
| 219 | static void SC_VpGetProjectionMatrix(rsc_Matrix *m) { |
| 220 | GET_TLS(); |
| 221 | rsrVpGetProjectionMatrix(rsc, sc, m); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | ////////////////////////////////////////////////////////////////////////////// |
| 226 | // Drawing |
| 227 | ////////////////////////////////////////////////////////////////////////////// |
| 228 | |
| 229 | static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, |
| 230 | float x2, float y2, float z2, float u2, float v2, |
| 231 | float x3, float y3, float z3, float u3, float v3, |
| 232 | float x4, float y4, float z4, float u4, float v4) { |
| 233 | GET_TLS(); |
| 234 | rsrDrawQuadTexCoords(rsc, sc, |
| 235 | x1, y1, z1, u1, v1, |
| 236 | x2, y2, z2, u2, v2, |
| 237 | x3, y3, z3, u3, v3, |
| 238 | x4, y4, z4, u4, v4); |
| 239 | } |
| 240 | |
| 241 | static void SC_DrawQuad(float x1, float y1, float z1, |
| 242 | float x2, float y2, float z2, |
| 243 | float x3, float y3, float z3, |
| 244 | float x4, float y4, float z4) { |
| 245 | GET_TLS(); |
| 246 | rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4); |
| 247 | } |
| 248 | |
| 249 | static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) { |
| 250 | GET_TLS(); |
| 251 | rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h); |
| 252 | } |
| 253 | |
| 254 | static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) { |
| 255 | GET_TLS(); |
| 256 | rsrDrawRect(rsc, sc, x1, y1, x2, y2, z); |
| 257 | } |
| 258 | |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 259 | static void SC_DrawPath(Path *p) { |
| 260 | GET_TLS(); |
| 261 | //rsrDrawPath(rsc, sc, p); |
| 262 | rsdPathDraw(rsc, p); |
| 263 | } |
| 264 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 265 | static void SC_DrawMesh(Mesh *m) { |
| 266 | GET_TLS(); |
| 267 | rsrDrawMesh(rsc, sc, m); |
| 268 | } |
| 269 | |
| 270 | static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) { |
| 271 | GET_TLS(); |
| 272 | rsrDrawMeshPrimitive(rsc, sc, m, primIndex); |
| 273 | } |
| 274 | |
| 275 | static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) { |
| 276 | GET_TLS(); |
| 277 | rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len); |
| 278 | } |
| 279 | |
| 280 | static void SC_MeshComputeBoundingBox(Mesh *m, |
| 281 | float *minX, float *minY, float *minZ, |
| 282 | float *maxX, float *maxY, float *maxZ) { |
| 283 | GET_TLS(); |
| 284 | rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ); |
| 285 | } |
| 286 | |
| 287 | |
| 288 | |
| 289 | ////////////////////////////////////////////////////////////////////////////// |
| 290 | // |
| 291 | ////////////////////////////////////////////////////////////////////////////// |
| 292 | |
| 293 | |
| 294 | static void SC_Color(float r, float g, float b, float a) { |
| 295 | GET_TLS(); |
| 296 | rsrColor(rsc, sc, r, g, b, a); |
| 297 | } |
| 298 | |
| 299 | static void SC_Finish() { |
| 300 | GET_TLS(); |
Alex Sakhartchouk | 653b53e | 2012-02-24 14:22:34 -0800 | [diff] [blame] | 301 | rsdGLFinish(rsc); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static void SC_ClearColor(float r, float g, float b, float a) { |
| 305 | GET_TLS(); |
Alex Sakhartchouk | 653b53e | 2012-02-24 14:22:34 -0800 | [diff] [blame] | 306 | rsrPrepareClear(rsc, sc); |
| 307 | rsdGLClearColor(rsc, r, g, b, a); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | static void SC_ClearDepth(float v) { |
| 311 | GET_TLS(); |
Alex Sakhartchouk | 653b53e | 2012-02-24 14:22:34 -0800 | [diff] [blame] | 312 | rsrPrepareClear(rsc, sc); |
| 313 | rsdGLClearDepth(rsc, v); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | static uint32_t SC_GetWidth() { |
| 317 | GET_TLS(); |
| 318 | return rsrGetWidth(rsc, sc); |
| 319 | } |
| 320 | |
| 321 | static uint32_t SC_GetHeight() { |
| 322 | GET_TLS(); |
| 323 | return rsrGetHeight(rsc, sc); |
| 324 | } |
| 325 | |
| 326 | static void SC_DrawTextAlloc(Allocation *a, int x, int y) { |
| 327 | GET_TLS(); |
| 328 | rsrDrawTextAlloc(rsc, sc, a, x, y); |
| 329 | } |
| 330 | |
| 331 | static void SC_DrawText(const char *text, int x, int y) { |
| 332 | GET_TLS(); |
| 333 | rsrDrawText(rsc, sc, text, x, y); |
| 334 | } |
| 335 | |
| 336 | static void SC_MeasureTextAlloc(Allocation *a, |
| 337 | int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) { |
| 338 | GET_TLS(); |
| 339 | rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom); |
| 340 | } |
| 341 | |
| 342 | static void SC_MeasureText(const char *text, |
| 343 | int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) { |
| 344 | GET_TLS(); |
| 345 | rsrMeasureText(rsc, sc, text, left, right, top, bottom); |
| 346 | } |
| 347 | |
| 348 | static void SC_BindFont(Font *f) { |
| 349 | GET_TLS(); |
| 350 | rsrBindFont(rsc, sc, f); |
| 351 | } |
| 352 | |
| 353 | static void SC_FontColor(float r, float g, float b, float a) { |
| 354 | GET_TLS(); |
| 355 | rsrFontColor(rsc, sc, r, g, b, a); |
| 356 | } |
| 357 | |
| 358 | |
| 359 | |
| 360 | ////////////////////////////////////////////////////////////////////////////// |
| 361 | // |
| 362 | ////////////////////////////////////////////////////////////////////////////// |
| 363 | |
| 364 | static void SC_SetObject(ObjectBase **dst, ObjectBase * src) { |
| 365 | GET_TLS(); |
| 366 | rsrSetObject(rsc, sc, dst, src); |
| 367 | } |
| 368 | |
| 369 | static void SC_ClearObject(ObjectBase **dst) { |
| 370 | GET_TLS(); |
| 371 | rsrClearObject(rsc, sc, dst); |
| 372 | } |
| 373 | |
| 374 | static bool SC_IsObject(const ObjectBase *src) { |
| 375 | GET_TLS(); |
| 376 | return rsrIsObject(rsc, sc, src); |
| 377 | } |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | static const Allocation * SC_GetAllocation(const void *ptr) { |
| 383 | GET_TLS(); |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame^] | 384 | return rsdScriptGetAllocationForPointer(rsc, sc, ptr); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 387 | static void SC_ForEach_SAA(Script *target, |
| 388 | Allocation *in, |
| 389 | Allocation *out) { |
| 390 | GET_TLS(); |
| 391 | rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL); |
| 392 | } |
| 393 | |
| 394 | static void SC_ForEach_SAAU(Script *target, |
| 395 | Allocation *in, |
| 396 | Allocation *out, |
| 397 | const void *usr) { |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 398 | GET_TLS(); |
| 399 | rsrForEach(rsc, sc, target, in, out, usr, 0, NULL); |
| 400 | } |
| 401 | |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 402 | static void SC_ForEach_SAAUS(Script *target, |
| 403 | Allocation *in, |
| 404 | Allocation *out, |
| 405 | const void *usr, |
| 406 | const RsScriptCall *call) { |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 407 | GET_TLS(); |
| 408 | rsrForEach(rsc, sc, target, in, out, usr, 0, call); |
| 409 | } |
| 410 | |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 411 | static void SC_ForEach_SAAUL(Script *target, |
| 412 | Allocation *in, |
| 413 | Allocation *out, |
| 414 | const void *usr, |
| 415 | uint32_t usrLen) { |
| 416 | GET_TLS(); |
| 417 | rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL); |
| 418 | } |
| 419 | |
| 420 | static void SC_ForEach_SAAULS(Script *target, |
| 421 | Allocation *in, |
| 422 | Allocation *out, |
| 423 | const void *usr, |
| 424 | uint32_t usrLen, |
| 425 | const RsScriptCall *call) { |
| 426 | GET_TLS(); |
| 427 | rsrForEach(rsc, sc, target, in, out, usr, usrLen, call); |
| 428 | } |
| 429 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 430 | |
| 431 | |
| 432 | ////////////////////////////////////////////////////////////////////////////// |
| 433 | // Time routines |
| 434 | ////////////////////////////////////////////////////////////////////////////// |
| 435 | |
| 436 | static float SC_GetDt() { |
| 437 | GET_TLS(); |
| 438 | return rsrGetDt(rsc, sc); |
| 439 | } |
| 440 | |
| 441 | time_t SC_Time(time_t *timer) { |
| 442 | GET_TLS(); |
| 443 | return rsrTime(rsc, sc, timer); |
| 444 | } |
| 445 | |
| 446 | tm* SC_LocalTime(tm *local, time_t *timer) { |
| 447 | GET_TLS(); |
| 448 | return rsrLocalTime(rsc, sc, local, timer); |
| 449 | } |
| 450 | |
| 451 | int64_t SC_UptimeMillis() { |
| 452 | GET_TLS(); |
| 453 | return rsrUptimeMillis(rsc, sc); |
| 454 | } |
| 455 | |
| 456 | int64_t SC_UptimeNanos() { |
| 457 | GET_TLS(); |
| 458 | return rsrUptimeNanos(rsc, sc); |
| 459 | } |
| 460 | |
| 461 | ////////////////////////////////////////////////////////////////////////////// |
| 462 | // Message routines |
| 463 | ////////////////////////////////////////////////////////////////////////////// |
| 464 | |
| 465 | static uint32_t SC_ToClient2(int cmdID, void *data, int len) { |
| 466 | GET_TLS(); |
| 467 | return rsrToClient(rsc, sc, cmdID, data, len); |
| 468 | } |
| 469 | |
| 470 | static uint32_t SC_ToClient(int cmdID) { |
| 471 | GET_TLS(); |
| 472 | return rsrToClient(rsc, sc, cmdID, NULL, 0); |
| 473 | } |
| 474 | |
| 475 | static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) { |
| 476 | GET_TLS(); |
| 477 | return rsrToClientBlocking(rsc, sc, cmdID, data, len); |
| 478 | } |
| 479 | |
| 480 | static uint32_t SC_ToClientBlocking(int cmdID) { |
| 481 | GET_TLS(); |
| 482 | return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0); |
| 483 | } |
| 484 | |
| 485 | int SC_divsi3(int a, int b) { |
| 486 | return a / b; |
| 487 | } |
| 488 | |
| 489 | int SC_modsi3(int a, int b) { |
| 490 | return a % b; |
| 491 | } |
| 492 | |
| 493 | unsigned int SC_udivsi3(unsigned int a, unsigned int b) { |
| 494 | return a / b; |
| 495 | } |
| 496 | |
| 497 | unsigned int SC_umodsi3(unsigned int a, unsigned int b) { |
| 498 | return a % b; |
| 499 | } |
| 500 | |
| 501 | static void SC_debugF(const char *s, float f) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 502 | ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f))); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 503 | } |
| 504 | static void SC_debugFv2(const char *s, float f1, float f2) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 505 | ALOGD("%s {%f, %f}", s, f1, f2); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 506 | } |
| 507 | static void SC_debugFv3(const char *s, float f1, float f2, float f3) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 508 | ALOGD("%s {%f, %f, %f}", s, f1, f2, f3); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 509 | } |
| 510 | static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 511 | ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 512 | } |
Stephen Hines | 6537404 | 2012-05-14 18:04:10 -0700 | [diff] [blame] | 513 | static void SC_debugF2(const char *s, float2 f) { |
| 514 | ALOGD("%s {%f, %f}", s, f.x, f.y); |
| 515 | } |
| 516 | static void SC_debugF3(const char *s, float3 f) { |
| 517 | ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z); |
| 518 | } |
| 519 | static void SC_debugF4(const char *s, float4 f) { |
| 520 | ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w); |
| 521 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 522 | static void SC_debugD(const char *s, double d) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 523 | ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d))); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 524 | } |
| 525 | static void SC_debugFM4v4(const char *s, const float *f) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 526 | ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]); |
| 527 | ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]); |
| 528 | ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]); |
| 529 | ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 530 | } |
| 531 | static void SC_debugFM3v3(const char *s, const float *f) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 532 | ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]); |
| 533 | ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]); |
| 534 | ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 535 | } |
| 536 | static void SC_debugFM2v2(const char *s, const float *f) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 537 | ALOGD("%s {%f, %f", s, f[0], f[2]); |
| 538 | ALOGD("%s %f, %f}",s, f[1], f[3]); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 539 | } |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 540 | static void SC_debugI8(const char *s, char c) { |
| 541 | ALOGD("%s %hhd 0x%hhx", s, c, (unsigned char)c); |
| 542 | } |
| 543 | static void SC_debugC2(const char *s, char2 c) { |
| 544 | ALOGD("%s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y); |
| 545 | } |
| 546 | static void SC_debugC3(const char *s, char3 c) { |
| 547 | 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); |
| 548 | } |
| 549 | static void SC_debugC4(const char *s, char4 c) { |
| 550 | 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); |
| 551 | } |
| 552 | static void SC_debugU8(const char *s, unsigned char c) { |
| 553 | ALOGD("%s %hhu 0x%hhx", s, c, c); |
| 554 | } |
| 555 | static void SC_debugUC2(const char *s, uchar2 c) { |
| 556 | ALOGD("%s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y); |
| 557 | } |
| 558 | static void SC_debugUC3(const char *s, uchar3 c) { |
| 559 | ALOGD("%s {%hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z); |
| 560 | } |
| 561 | static void SC_debugUC4(const char *s, uchar4 c) { |
| 562 | 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); |
| 563 | } |
| 564 | static void SC_debugI16(const char *s, short c) { |
| 565 | ALOGD("%s %hd 0x%hx", s, c, c); |
| 566 | } |
| 567 | static void SC_debugS2(const char *s, short2 c) { |
| 568 | ALOGD("%s {%hd, %hd} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y); |
| 569 | } |
| 570 | static void SC_debugS3(const char *s, short3 c) { |
| 571 | ALOGD("%s {%hd, %hd, %hd} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z); |
| 572 | } |
| 573 | static void SC_debugS4(const char *s, short4 c) { |
| 574 | 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); |
| 575 | } |
| 576 | static void SC_debugU16(const char *s, unsigned short c) { |
| 577 | ALOGD("%s %hu 0x%hx", s, c, c); |
| 578 | } |
| 579 | static void SC_debugUS2(const char *s, ushort2 c) { |
| 580 | ALOGD("%s {%hu, %hu} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y); |
| 581 | } |
| 582 | static void SC_debugUS3(const char *s, ushort3 c) { |
| 583 | ALOGD("%s {%hu, %hu, %hu} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z); |
| 584 | } |
| 585 | static void SC_debugUS4(const char *s, ushort4 c) { |
| 586 | 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); |
| 587 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 588 | static void SC_debugI32(const char *s, int32_t i) { |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 589 | ALOGD("%s %d 0x%x", s, i, i); |
| 590 | } |
| 591 | static void SC_debugI2(const char *s, int2 i) { |
| 592 | ALOGD("%s {%d, %d} 0x%x 0x%x", s, i.x, i.y, i.x, i.y); |
| 593 | } |
| 594 | static void SC_debugI3(const char *s, int3 i) { |
| 595 | ALOGD("%s {%d, %d, %d} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z); |
| 596 | } |
| 597 | static void SC_debugI4(const char *s, int4 i) { |
| 598 | 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); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 599 | } |
| 600 | static void SC_debugU32(const char *s, uint32_t i) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 601 | ALOGD("%s %u 0x%x", s, i, i); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 602 | } |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 603 | static void SC_debugUI2(const char *s, uint2 i) { |
| 604 | ALOGD("%s {%u, %u} 0x%x 0x%x", s, i.x, i.y, i.x, i.y); |
| 605 | } |
| 606 | static void SC_debugUI3(const char *s, uint3 i) { |
| 607 | ALOGD("%s {%u, %u, %u} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z); |
| 608 | } |
| 609 | static void SC_debugUI4(const char *s, uint4 i) { |
| 610 | 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); |
| 611 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 612 | static void SC_debugLL64(const char *s, long long ll) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 613 | ALOGD("%s %lld 0x%llx", s, ll, ll); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 614 | } |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 615 | static void SC_debugL2(const char *s, long2 ll) { |
| 616 | ALOGD("%s {%lld, %lld} 0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y); |
| 617 | } |
| 618 | static void SC_debugL3(const char *s, long3 ll) { |
| 619 | ALOGD("%s {%lld, %lld, %lld} 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z); |
| 620 | } |
| 621 | static void SC_debugL4(const char *s, long4 ll) { |
| 622 | ALOGD("%s {%lld, %lld, %lld, %lld} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w); |
| 623 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 624 | static void SC_debugULL64(const char *s, unsigned long long ll) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 625 | ALOGD("%s %llu 0x%llx", s, ll, ll); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 626 | } |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 627 | static void SC_debugUL2(const char *s, ulong2 ll) { |
| 628 | ALOGD("%s {%llu, %llu} 0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y); |
| 629 | } |
| 630 | static void SC_debugUL3(const char *s, ulong3 ll) { |
| 631 | ALOGD("%s {%llu, %llu, %llu} 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z); |
| 632 | } |
| 633 | static void SC_debugUL4(const char *s, ulong4 ll) { |
| 634 | ALOGD("%s {%llu, %llu, %llu, %llu} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w); |
| 635 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 636 | static void SC_debugP(const char *s, const void *p) { |
Steve Block | 4a48244 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 637 | ALOGD("%s %p", s, p); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | |
| 641 | ////////////////////////////////////////////////////////////////////////////// |
| 642 | // Stub implementation |
| 643 | ////////////////////////////////////////////////////////////////////////////// |
| 644 | |
| 645 | // llvm name mangling ref |
| 646 | // <builtin-type> ::= v # void |
| 647 | // ::= b # bool |
| 648 | // ::= c # char |
| 649 | // ::= a # signed char |
| 650 | // ::= h # unsigned char |
| 651 | // ::= s # short |
| 652 | // ::= t # unsigned short |
| 653 | // ::= i # int |
| 654 | // ::= j # unsigned int |
| 655 | // ::= l # long |
| 656 | // ::= m # unsigned long |
| 657 | // ::= x # long long, __int64 |
| 658 | // ::= y # unsigned long long, __int64 |
| 659 | // ::= f # float |
| 660 | // ::= d # double |
| 661 | |
| 662 | static RsdSymbolTable gSyms[] = { |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 663 | { "memset", (void *)&memset, true }, |
| 664 | { "memcpy", (void *)&memcpy, true }, |
| 665 | |
| 666 | // Refcounting |
| 667 | { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true }, |
| 668 | { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true }, |
| 669 | { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true }, |
| 670 | |
| 671 | { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true }, |
| 672 | { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true }, |
| 673 | { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true }, |
| 674 | |
| 675 | { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true }, |
| 676 | { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true }, |
| 677 | { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true }, |
| 678 | |
| 679 | { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true }, |
| 680 | { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true }, |
| 681 | { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true }, |
| 682 | |
| 683 | { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true }, |
| 684 | { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true }, |
| 685 | { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true }, |
| 686 | |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 687 | { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true }, |
| 688 | { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true }, |
| 689 | { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true }, |
| 690 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 691 | { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true }, |
| 692 | { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true }, |
| 693 | { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true }, |
| 694 | |
| 695 | { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true }, |
| 696 | { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true }, |
| 697 | { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true }, |
| 698 | |
| 699 | { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true }, |
| 700 | { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true }, |
| 701 | { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true }, |
| 702 | |
| 703 | { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true }, |
| 704 | { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true }, |
| 705 | { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true }, |
| 706 | |
| 707 | { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true }, |
| 708 | { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true }, |
| 709 | { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true }, |
| 710 | |
| 711 | { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true }, |
| 712 | { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true }, |
| 713 | { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true }, |
| 714 | |
| 715 | // Allocation ops |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 716 | { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true }, |
| 717 | { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false }, |
| 718 | { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false }, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 719 | { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 720 | { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true }, |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 721 | { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false }, |
| 722 | { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false }, |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 723 | { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false }, |
| 724 | { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 725 | |
| 726 | // Messaging |
| 727 | |
| 728 | { "_Z14rsSendToClienti", (void *)&SC_ToClient, false }, |
| 729 | { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false }, |
| 730 | { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false }, |
| 731 | { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false }, |
| 732 | |
| 733 | { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false }, |
| 734 | { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false }, |
| 735 | { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false }, |
| 736 | { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false }, |
| 737 | { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false }, |
| 738 | { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false }, |
Alex Sakhartchouk | a720a14 | 2012-01-10 10:16:52 -0800 | [diff] [blame] | 739 | { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false }, |
| 740 | { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 741 | |
| 742 | { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false }, |
| 743 | { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false }, |
| 744 | { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false }, |
| 745 | |
| 746 | { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false }, |
| 747 | |
| 748 | { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false }, |
| 749 | |
| 750 | { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false }, |
| 751 | { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false }, |
| 752 | |
| 753 | |
| 754 | { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false }, |
| 755 | { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false }, |
| 756 | { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false }, |
| 757 | { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false }, |
| 758 | |
| 759 | { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false }, |
| 760 | { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false }, |
| 761 | { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false }, |
| 762 | { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false }, |
| 763 | |
Jason Sams | 9e0afb5 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 764 | { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false }, |
| 765 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 766 | { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false }, |
| 767 | { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false }, |
| 768 | |
| 769 | { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false }, |
| 770 | { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false }, |
| 771 | { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false }, |
| 772 | { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false }, |
| 773 | |
| 774 | { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false }, |
| 775 | { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false }, |
| 776 | |
| 777 | { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false }, |
| 778 | { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false }, |
| 779 | { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false }, |
| 780 | { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false }, |
| 781 | { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false }, |
| 782 | |
Jason Sams | aa15210 | 2012-06-13 15:16:44 -0700 | [diff] [blame] | 783 | { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true }, |
| 784 | { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true }, |
| 785 | { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK16rs_script_call_t", (void *)&SC_ForEach_SAAUS, true }, |
| 786 | { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true }, |
| 787 | { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK16rs_script_call_t", (void *)&SC_ForEach_SAAULS, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 788 | |
| 789 | // time |
| 790 | { "_Z6rsTimePi", (void *)&SC_Time, true }, |
| 791 | { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true }, |
| 792 | { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true }, |
| 793 | { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true }, |
| 794 | { "_Z7rsGetDtv", (void*)&SC_GetDt, false }, |
| 795 | |
| 796 | // misc |
| 797 | { "_Z5colorffff", (void *)&SC_Color, false }, |
| 798 | { "_Z9rsgFinishv", (void *)&SC_Finish, false }, |
| 799 | |
| 800 | // Debug |
| 801 | { "_Z7rsDebugPKcf", (void *)&SC_debugF, true }, |
| 802 | { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true }, |
| 803 | { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true }, |
| 804 | { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true }, |
Stephen Hines | 6537404 | 2012-05-14 18:04:10 -0700 | [diff] [blame] | 805 | { "_Z7rsDebugPKcDv2_f", (void *)&SC_debugF2, true }, |
| 806 | { "_Z7rsDebugPKcDv3_f", (void *)&SC_debugF3, true }, |
| 807 | { "_Z7rsDebugPKcDv4_f", (void *)&SC_debugF4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 808 | { "_Z7rsDebugPKcd", (void *)&SC_debugD, true }, |
| 809 | { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true }, |
| 810 | { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true }, |
| 811 | { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 812 | { "_Z7rsDebugPKcc", (void *)&SC_debugI8, true }, |
| 813 | { "_Z7rsDebugPKcDv2_c", (void *)&SC_debugC2, true }, |
| 814 | { "_Z7rsDebugPKcDv3_c", (void *)&SC_debugC3, true }, |
| 815 | { "_Z7rsDebugPKcDv4_c", (void *)&SC_debugC4, true }, |
| 816 | { "_Z7rsDebugPKch", (void *)&SC_debugU8, true }, |
| 817 | { "_Z7rsDebugPKcDv2_h", (void *)&SC_debugUC2, true }, |
| 818 | { "_Z7rsDebugPKcDv3_h", (void *)&SC_debugUC3, true }, |
| 819 | { "_Z7rsDebugPKcDv4_h", (void *)&SC_debugUC4, true }, |
| 820 | { "_Z7rsDebugPKcs", (void *)&SC_debugI16, true }, |
| 821 | { "_Z7rsDebugPKcDv2_s", (void *)&SC_debugS2, true }, |
| 822 | { "_Z7rsDebugPKcDv3_s", (void *)&SC_debugS3, true }, |
| 823 | { "_Z7rsDebugPKcDv4_s", (void *)&SC_debugS4, true }, |
| 824 | { "_Z7rsDebugPKct", (void *)&SC_debugU16, true }, |
| 825 | { "_Z7rsDebugPKcDv2_t", (void *)&SC_debugUS2, true }, |
| 826 | { "_Z7rsDebugPKcDv3_t", (void *)&SC_debugUS3, true }, |
| 827 | { "_Z7rsDebugPKcDv4_t", (void *)&SC_debugUS4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 828 | { "_Z7rsDebugPKci", (void *)&SC_debugI32, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 829 | { "_Z7rsDebugPKcDv2_i", (void *)&SC_debugI2, true }, |
| 830 | { "_Z7rsDebugPKcDv3_i", (void *)&SC_debugI3, true }, |
| 831 | { "_Z7rsDebugPKcDv4_i", (void *)&SC_debugI4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 832 | { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 833 | { "_Z7rsDebugPKcDv2_j", (void *)&SC_debugUI2, true }, |
| 834 | { "_Z7rsDebugPKcDv3_j", (void *)&SC_debugUI3, true }, |
| 835 | { "_Z7rsDebugPKcDv4_j", (void *)&SC_debugUI4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 836 | // Both "long" and "unsigned long" need to be redirected to their |
| 837 | // 64-bit counterparts, since we have hacked Slang to use 64-bit |
| 838 | // for "long" on Arm (to be similar to Java). |
| 839 | { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 840 | { "_Z7rsDebugPKcDv2_l", (void *)&SC_debugL2, true }, |
| 841 | { "_Z7rsDebugPKcDv3_l", (void *)&SC_debugL3, true }, |
| 842 | { "_Z7rsDebugPKcDv4_l", (void *)&SC_debugL4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 843 | { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 844 | { "_Z7rsDebugPKcDv2_m", (void *)&SC_debugUL2, true }, |
| 845 | { "_Z7rsDebugPKcDv3_m", (void *)&SC_debugUL3, true }, |
| 846 | { "_Z7rsDebugPKcDv4_m", (void *)&SC_debugUL4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 847 | { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 848 | { "_Z7rsDebugPKcDv2_x", (void *)&SC_debugL2, true }, |
| 849 | { "_Z7rsDebugPKcDv3_x", (void *)&SC_debugL3, true }, |
| 850 | { "_Z7rsDebugPKcDv4_x", (void *)&SC_debugL4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 851 | { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true }, |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 852 | { "_Z7rsDebugPKcDv2_y", (void *)&SC_debugUL2, true }, |
| 853 | { "_Z7rsDebugPKcDv3_y", (void *)&SC_debugUL3, true }, |
| 854 | { "_Z7rsDebugPKcDv4_y", (void *)&SC_debugUL4, true }, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 855 | { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true }, |
| 856 | |
| 857 | { NULL, NULL, false } |
| 858 | }; |
| 859 | |
| 860 | |
| 861 | void* rsdLookupRuntimeStub(void* pContext, char const* name) { |
| 862 | ScriptC *s = (ScriptC *)pContext; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 863 | RsdSymbolTable *syms = gSyms; |
| 864 | const RsdSymbolTable *sym = rsdLookupSymbolMath(name); |
| 865 | |
| 866 | if (!sym) { |
| 867 | while (syms->mPtr) { |
| 868 | if (!strcmp(syms->mName, name)) { |
| 869 | sym = syms; |
| 870 | } |
| 871 | syms++; |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | if (sym) { |
| 876 | s->mHal.info.isThreadable &= sym->threadable; |
| 877 | return sym->mPtr; |
| 878 | } |
Steve Block | af12ac6 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 879 | ALOGE("ScriptC sym lookup failed for %s", name); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 880 | return NULL; |
| 881 | } |
| 882 | |
| 883 | |