blob: 0fa30d12ac2ade8c4f9730ac08c895482bb6a51b [file] [log] [blame]
Jason Sams87fe59a2011-04-20 15:09:01 -07001/*
Jason Sams709a0972012-11-15 18:18:04 -08002 * Copyright (C) 2011-2012 The Android Open Source Project
Jason Sams87fe59a2011-04-20 15:09:01 -07003 *
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
Jason Sams87fe59a2011-04-20 15:09:01 -070024#include "rsdCore.h"
Jason Sams807fdc42012-07-25 17:55:39 -070025#include "rsdBcc.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070026
Jason Samsb3220332012-04-02 14:41:54 -070027#include "rsdAllocation.h"
Stephen Hines414a4612012-09-05 18:05:08 -070028#include "rsdShaderCache.h"
29#include "rsdVertexArray.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070030
31#include <time.h>
32
33using namespace android;
34using namespace android::renderscript;
35
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070036typedef float float2 __attribute__((ext_vector_type(2)));
37typedef float float3 __attribute__((ext_vector_type(3)));
38typedef float float4 __attribute__((ext_vector_type(4)));
Jason Sams5261a5e2013-02-27 15:46:24 -080039typedef double double2 __attribute__((ext_vector_type(2)));
40typedef double double3 __attribute__((ext_vector_type(3)));
41typedef double double4 __attribute__((ext_vector_type(4)));
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070042typedef char char2 __attribute__((ext_vector_type(2)));
43typedef char char3 __attribute__((ext_vector_type(3)));
44typedef char char4 __attribute__((ext_vector_type(4)));
45typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
46typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
47typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
Jason Samsd8b8f8a2014-08-19 17:53:08 -070048typedef int16_t short2 __attribute__((ext_vector_type(2)));
49typedef int16_t short3 __attribute__((ext_vector_type(3)));
50typedef int16_t short4 __attribute__((ext_vector_type(4)));
51typedef uint16_t ushort2 __attribute__((ext_vector_type(2)));
52typedef uint16_t ushort3 __attribute__((ext_vector_type(3)));
53typedef uint16_t ushort4 __attribute__((ext_vector_type(4)));
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070054typedef int32_t int2 __attribute__((ext_vector_type(2)));
55typedef int32_t int3 __attribute__((ext_vector_type(3)));
56typedef int32_t int4 __attribute__((ext_vector_type(4)));
57typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
58typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
59typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
Jason Samsd8b8f8a2014-08-19 17:53:08 -070060typedef int64_t long2 __attribute__((ext_vector_type(2)));
61typedef int64_t long3 __attribute__((ext_vector_type(3)));
62typedef int64_t long4 __attribute__((ext_vector_type(4)));
63typedef uint64_t ulong2 __attribute__((ext_vector_type(2)));
64typedef uint64_t ulong3 __attribute__((ext_vector_type(3)));
65typedef uint64_t ulong4 __attribute__((ext_vector_type(4)));
Jason Sams87fe59a2011-04-20 15:09:01 -070066
Jason Sams5261a5e2013-02-27 15:46:24 -080067typedef uint8_t uchar;
68typedef uint16_t ushort;
69typedef uint32_t uint;
Tim Murray0b575de2013-03-15 15:56:43 -070070#ifndef RS_SERVER
Jason Sams5261a5e2013-02-27 15:46:24 -080071typedef uint64_t ulong;
Tim Murray0b575de2013-03-15 15:56:43 -070072#endif
Jason Sams87fe59a2011-04-20 15:09:01 -070073
Miao Wang127d51c2014-11-24 13:41:33 -080074#ifndef __LP64__
Tim Murrayd6f1f462013-03-25 16:36:59 -070075#define OPAQUETYPE(t) \
76 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t;
Miao Wang127d51c2014-11-24 13:41:33 -080077#else
78#define OPAQUETYPE(t) \
79 typedef struct { const void* p; const void* r; const void* v1; const void* v2; } t;
80#endif
Tim Murrayd6f1f462013-03-25 16:36:59 -070081
82OPAQUETYPE(rs_element)
83OPAQUETYPE(rs_type)
84OPAQUETYPE(rs_allocation)
85OPAQUETYPE(rs_sampler)
86OPAQUETYPE(rs_script)
87OPAQUETYPE(rs_script_call)
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -080088
89OPAQUETYPE(rs_program_fragment);
90OPAQUETYPE(rs_program_store);
91OPAQUETYPE(rs_program_vertex);
92OPAQUETYPE(rs_program_raster);
93
94OPAQUETYPE(rs_mesh);
95OPAQUETYPE(rs_font);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -080096
Tim Murrayd6f1f462013-03-25 16:36:59 -070097#undef OPAQUETYPE
98
Stephen Hines7a011262013-11-27 14:21:57 -080099typedef enum {
100 // Empty to avoid conflicting definitions with RsAllocationCubemapFace
101} rs_allocation_cubemap_face;
102
Tim Murrayd6f1f462013-03-25 16:36:59 -0700103typedef struct {
104 int tm_sec; ///< seconds
105 int tm_min; ///< minutes
106 int tm_hour; ///< hours
107 int tm_mday; ///< day of the month
108 int tm_mon; ///< month
109 int tm_year; ///< year
110 int tm_wday; ///< day of the week
111 int tm_yday; ///< day of the year
112 int tm_isdst; ///< daylight savings time
113} rs_tm;
Tim Murrayd6f1f462013-03-25 16:36:59 -0700114
Yong Chen31729ad2014-11-12 15:20:18 +0800115#ifndef __LP64__
116typedef android::renderscript::rs_script RS_TY_SCRIPT;
117typedef android::renderscript::rs_allocation RS_TY_ALLOC;
118
119static inline Script* rsGetObjPtr(RS_TY_SCRIPT s) {
120 return const_cast<Script*>(s.p);
121}
122static inline Allocation* rsGetObjPtr(RS_TY_ALLOC a) {
123 return const_cast<Allocation*>(a.p);
124}
125static inline RS_TY_SCRIPT rsTyCast(::rs_script s) {
126 RS_TY_SCRIPT cast;
127 cast.p = (const Script*)s.p;
128 return cast;
129}
130static inline RS_TY_ALLOC rsTyCast(::rs_allocation a) {
131 RS_TY_ALLOC cast;
132 cast.p = (const Allocation*)a.p;
133 return cast;
134}
135#define RS_CAST(a) rsTyCast(a)
136
137#else
138
139typedef android::renderscript::rs_script* RS_TY_SCRIPT;
140typedef android::renderscript::rs_allocation* RS_TY_ALLOC;
141
142static inline Script* rsGetObjPtr(RS_TY_SCRIPT s) {
143 return const_cast<Script*>(s->p);
144}
145static inline Allocation* rsGetObjPtr(RS_TY_ALLOC a) {
146 return const_cast<Allocation*>(a->p);
147}
148static inline RS_TY_SCRIPT rsTyCast(::rs_script *s) {
149 return reinterpret_cast<RS_TY_SCRIPT>(s);
150}
151static inline RS_TY_ALLOC rsTyCast(::rs_allocation *a) {
152 return reinterpret_cast<RS_TY_ALLOC>(a);
153}
154#define RS_CAST(a) rsTyCast(&(a))
155
156#endif
157
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800158// Some RS functions are not threadsafe but can be called from an invoke
159// function. Instead of summarily marking scripts that call these functions as
160// not-threadable we detect calls to them in the driver and sends a fatal error
161// message.
162static bool failIfInKernel(Context *rsc, const char *funcName) {
163 RsdHal *dc = (RsdHal *)rsc->mHal.drv;
164 RsdCpuReference *impl = (RsdCpuReference *) dc->mCpuRef;
165
166 if (impl->getInForEach()) {
167 char buf[256];
168 sprintf(buf, "Error: Call to unsupported function %s "
169 "in kernel", funcName);
170 rsc->setError(RS_ERROR_FATAL_DRIVER, buf);
171 return true;
172 }
173 return false;
174}
175
Jason Sams87fe59a2011-04-20 15:09:01 -0700176//////////////////////////////////////////////////////////////////////////////
177// Allocation
178//////////////////////////////////////////////////////////////////////////////
179
Jason Sams87fe59a2011-04-20 15:09:01 -0700180
Yong Chen31729ad2014-11-12 15:20:18 +0800181static void SC_AllocationSyncAll2(RS_TY_ALLOC a, RsAllocationUsageType source) {
Jason Sams709a0972012-11-15 18:18:04 -0800182 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800183 rsrAllocationSyncAll(rsc, rsGetObjPtr(a), source);
Jason Sams87fe59a2011-04-20 15:09:01 -0700184}
185
Yong Chen31729ad2014-11-12 15:20:18 +0800186static void SC_AllocationSyncAll(RS_TY_ALLOC a) {
Jason Sams709a0972012-11-15 18:18:04 -0800187 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800188 rsrAllocationSyncAll(rsc, rsGetObjPtr(a), RS_ALLOCATION_USAGE_SCRIPT);
Jason Sams87fe59a2011-04-20 15:09:01 -0700189}
190
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700191#ifndef RS_COMPATIBILITY_LIB
192
Yong Chen31729ad2014-11-12 15:20:18 +0800193static void SC_AllocationCopy1DRange(RS_TY_ALLOC dstAlloc,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700194 uint32_t dstOff,
195 uint32_t dstMip,
196 uint32_t count,
Yong Chen31729ad2014-11-12 15:20:18 +0800197 RS_TY_ALLOC srcAlloc,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700198 uint32_t srcOff, uint32_t srcMip) {
Jason Sams709a0972012-11-15 18:18:04 -0800199 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800200 if (failIfInKernel(rsc, "rsAllocationCopy1DRange"))
201 return;
202
Yong Chen31729ad2014-11-12 15:20:18 +0800203 rsrAllocationCopy1DRange(rsc, rsGetObjPtr(dstAlloc), dstOff, dstMip, count,
204 rsGetObjPtr(srcAlloc), srcOff, srcMip);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700205}
206
Yong Chen31729ad2014-11-12 15:20:18 +0800207static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700208 uint32_t dstXoff, uint32_t dstYoff,
209 uint32_t dstMip, uint32_t dstFace,
210 uint32_t width, uint32_t height,
Yong Chen31729ad2014-11-12 15:20:18 +0800211 RS_TY_ALLOC srcAlloc,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700212 uint32_t srcXoff, uint32_t srcYoff,
213 uint32_t srcMip, uint32_t srcFace) {
Jason Sams709a0972012-11-15 18:18:04 -0800214 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800215 if (failIfInKernel(rsc, "rsAllocationCopy2DRange"))
216 return;
217
Yong Chen31729ad2014-11-12 15:20:18 +0800218 rsrAllocationCopy2DRange(rsc, rsGetObjPtr(dstAlloc),
Alex Sakhartchouka9495242011-06-16 11:05:13 -0700219 dstXoff, dstYoff, dstMip, dstFace,
Yong Chen31729ad2014-11-12 15:20:18 +0800220 width, height, rsGetObjPtr(srcAlloc),
Alex Sakhartchouka9495242011-06-16 11:05:13 -0700221 srcXoff, srcYoff, srcMip, srcFace);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700222}
223
Yong Chen31729ad2014-11-12 15:20:18 +0800224static void SC_AllocationIoSend(RS_TY_ALLOC alloc) {
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700225 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800226 if (failIfInKernel(rsc, "rsAllocationIoSend"))
227 return;
228
Yong Chen31729ad2014-11-12 15:20:18 +0800229 rsrAllocationIoSend(rsc, rsGetObjPtr(alloc));
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700230}
231
232
Yong Chen31729ad2014-11-12 15:20:18 +0800233static void SC_AllocationIoReceive(RS_TY_ALLOC alloc) {
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700234 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800235 if (failIfInKernel(rsc, "rsAllocationIoReceive"))
236 return;
237
Yong Chen31729ad2014-11-12 15:20:18 +0800238 rsrAllocationIoReceive(rsc, rsGetObjPtr(alloc));
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700239}
240
241#else
242
Yong Chen31729ad2014-11-12 15:20:18 +0800243static void SC_AllocationCopy1DRange(RS_TY_ALLOC dstAlloc,
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700244 uint32_t dstOff,
245 uint32_t dstMip,
246 uint32_t count,
Yong Chen31729ad2014-11-12 15:20:18 +0800247 RS_TY_ALLOC srcAlloc,
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700248 uint32_t srcOff, uint32_t srcMip) {
249 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800250 if (failIfInKernel(rsc, "rsAllocationCopy1DRange"))
251 return;
252
Yong Chen31729ad2014-11-12 15:20:18 +0800253 rsrAllocationCopy1DRange(rsc, rsGetObjPtr(dstAlloc), dstOff, dstMip, count,
254 rsGetObjPtr(srcAlloc), srcOff, srcMip);
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700255}
256
Yong Chen31729ad2014-11-12 15:20:18 +0800257static void SC_AllocationCopy2DRange(RS_TY_ALLOC dstAlloc,
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700258 uint32_t dstXoff, uint32_t dstYoff,
259 uint32_t dstMip, uint32_t dstFace,
260 uint32_t width, uint32_t height,
Yong Chen31729ad2014-11-12 15:20:18 +0800261 RS_TY_ALLOC srcAlloc,
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700262 uint32_t srcXoff, uint32_t srcYoff,
263 uint32_t srcMip, uint32_t srcFace) {
264 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800265 if (failIfInKernel(rsc, "rsAllocationCopy2DRange"))
266 return;
267
Yong Chen31729ad2014-11-12 15:20:18 +0800268 rsrAllocationCopy2DRange(rsc, rsGetObjPtr(dstAlloc),
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700269 dstXoff, dstYoff, dstMip, dstFace,
270 width, height,
Yong Chen31729ad2014-11-12 15:20:18 +0800271 rsGetObjPtr(srcAlloc),
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700272 srcXoff, srcYoff, srcMip, srcFace);
273}
274
Yong Chen31729ad2014-11-12 15:20:18 +0800275static void SC_AllocationIoSend(RS_TY_ALLOC alloc) {
Jason Sams709a0972012-11-15 18:18:04 -0800276 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800277 if (failIfInKernel(rsc, "rsAllocationIoSend"))
278 return;
279
Yong Chen31729ad2014-11-12 15:20:18 +0800280 rsrAllocationIoSend(rsc, rsGetObjPtr(alloc));
Jason Samsb3220332012-04-02 14:41:54 -0700281}
282
283
Yong Chen31729ad2014-11-12 15:20:18 +0800284static void SC_AllocationIoReceive(RS_TY_ALLOC alloc) {
Jason Sams709a0972012-11-15 18:18:04 -0800285 Context *rsc = RsdCpuReference::getTlsContext();
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800286 if (failIfInKernel(rsc, "rsAllocationIoReceive"))
287 return;
288
Yong Chen31729ad2014-11-12 15:20:18 +0800289 rsrAllocationIoReceive(rsc, rsGetObjPtr(alloc));
Jason Samsb3220332012-04-02 14:41:54 -0700290}
291
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700292#endif
293
Stephen Hines7a011262013-11-27 14:21:57 -0800294#ifndef RS_COMPATIBILITY_LIB
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700295
Jason Sams87fe59a2011-04-20 15:09:01 -0700296//////////////////////////////////////////////////////////////////////////////
297// Context
298//////////////////////////////////////////////////////////////////////////////
299
300static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
Jason Sams709a0972012-11-15 18:18:04 -0800301 Context *rsc = RsdCpuReference::getTlsContext();
302 rsrBindTexture(rsc, pf, slot, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700303}
304
Alex Sakhartchouka720a142012-01-10 10:16:52 -0800305static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
Jason Sams709a0972012-11-15 18:18:04 -0800306 Context *rsc = RsdCpuReference::getTlsContext();
307 rsrBindConstant(rsc, pv, slot, a);
Alex Sakhartchouka720a142012-01-10 10:16:52 -0800308}
309
310static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
Jason Sams709a0972012-11-15 18:18:04 -0800311 Context *rsc = RsdCpuReference::getTlsContext();
312 rsrBindConstant(rsc, pf, slot, a);
Alex Sakhartchouka720a142012-01-10 10:16:52 -0800313}
314
Jason Sams87fe59a2011-04-20 15:09:01 -0700315static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
Jason Sams709a0972012-11-15 18:18:04 -0800316 Context *rsc = RsdCpuReference::getTlsContext();
317 rsrBindSampler(rsc, pf, slot, s);
Jason Sams87fe59a2011-04-20 15:09:01 -0700318}
319
320static void SC_BindProgramStore(ProgramStore *ps) {
Jason Sams709a0972012-11-15 18:18:04 -0800321 Context *rsc = RsdCpuReference::getTlsContext();
322 rsrBindProgramStore(rsc, ps);
Jason Sams87fe59a2011-04-20 15:09:01 -0700323}
324
325static void SC_BindProgramFragment(ProgramFragment *pf) {
Jason Sams709a0972012-11-15 18:18:04 -0800326 Context *rsc = RsdCpuReference::getTlsContext();
327 rsrBindProgramFragment(rsc, pf);
Jason Sams87fe59a2011-04-20 15:09:01 -0700328}
329
330static void SC_BindProgramVertex(ProgramVertex *pv) {
Jason Sams709a0972012-11-15 18:18:04 -0800331 Context *rsc = RsdCpuReference::getTlsContext();
332 rsrBindProgramVertex(rsc, pv);
Jason Sams87fe59a2011-04-20 15:09:01 -0700333}
334
335static void SC_BindProgramRaster(ProgramRaster *pr) {
Jason Sams709a0972012-11-15 18:18:04 -0800336 Context *rsc = RsdCpuReference::getTlsContext();
337 rsrBindProgramRaster(rsc, pr);
Jason Sams87fe59a2011-04-20 15:09:01 -0700338}
339
340static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
Jason Sams709a0972012-11-15 18:18:04 -0800341 Context *rsc = RsdCpuReference::getTlsContext();
342 rsrBindFrameBufferObjectColorTarget(rsc, a, slot);
Jason Sams87fe59a2011-04-20 15:09:01 -0700343}
344
345static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
Jason Sams709a0972012-11-15 18:18:04 -0800346 Context *rsc = RsdCpuReference::getTlsContext();
347 rsrBindFrameBufferObjectDepthTarget(rsc, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700348}
349
350static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
Jason Sams709a0972012-11-15 18:18:04 -0800351 Context *rsc = RsdCpuReference::getTlsContext();
352 rsrClearFrameBufferObjectColorTarget(rsc, slot);
Jason Sams87fe59a2011-04-20 15:09:01 -0700353}
354
355static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
Jason Sams709a0972012-11-15 18:18:04 -0800356 Context *rsc = RsdCpuReference::getTlsContext();
357 rsrClearFrameBufferObjectDepthTarget(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700358}
359
360static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
Jason Sams709a0972012-11-15 18:18:04 -0800361 Context *rsc = RsdCpuReference::getTlsContext();
362 rsrClearFrameBufferObjectTargets(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700363}
364
365
366//////////////////////////////////////////////////////////////////////////////
367// VP
368//////////////////////////////////////////////////////////////////////////////
369
370static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
Jason Sams709a0972012-11-15 18:18:04 -0800371 Context *rsc = RsdCpuReference::getTlsContext();
372 rsrVpLoadProjectionMatrix(rsc, m);
Jason Sams87fe59a2011-04-20 15:09:01 -0700373}
374
375static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
Jason Sams709a0972012-11-15 18:18:04 -0800376 Context *rsc = RsdCpuReference::getTlsContext();
377 rsrVpLoadModelMatrix(rsc, m);
Jason Sams87fe59a2011-04-20 15:09:01 -0700378}
379
380static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
Jason Sams709a0972012-11-15 18:18:04 -0800381 Context *rsc = RsdCpuReference::getTlsContext();
382 rsrVpLoadTextureMatrix(rsc, m);
Jason Sams87fe59a2011-04-20 15:09:01 -0700383}
384
385static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
Jason Sams709a0972012-11-15 18:18:04 -0800386 Context *rsc = RsdCpuReference::getTlsContext();
387 rsrPfConstantColor(rsc, pf, r, g, b, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700388}
389
390static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
Jason Sams709a0972012-11-15 18:18:04 -0800391 Context *rsc = RsdCpuReference::getTlsContext();
392 rsrVpGetProjectionMatrix(rsc, m);
Jason Sams87fe59a2011-04-20 15:09:01 -0700393}
394
395
396//////////////////////////////////////////////////////////////////////////////
397// Drawing
398//////////////////////////////////////////////////////////////////////////////
399
400static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
401 float x2, float y2, float z2, float u2, float v2,
402 float x3, float y3, float z3, float u3, float v3,
403 float x4, float y4, float z4, float u4, float v4) {
Jason Sams709a0972012-11-15 18:18:04 -0800404 Context *rsc = RsdCpuReference::getTlsContext();
Stephen Hines414a4612012-09-05 18:05:08 -0700405
406 if (!rsc->setupCheck()) {
407 return;
408 }
409
410 RsdHal *dc = (RsdHal *)rsc->mHal.drv;
411 if (!dc->gl.shaderCache->setup(rsc)) {
412 return;
413 }
414
415 //ALOGE("Quad");
416 //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
417 //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
418 //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
419 //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
420
421 float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
422 const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
423
424 RsdVertexArray::Attrib attribs[2];
Tim Murraye195a3f2014-03-13 15:04:58 -0700425 attribs[0].set(GL_FLOAT, 3, 12, false, (size_t)vtx, "ATTRIB_position");
426 attribs[1].set(GL_FLOAT, 2, 8, false, (size_t)tex, "ATTRIB_texture0");
Stephen Hines414a4612012-09-05 18:05:08 -0700427
428 RsdVertexArray va(attribs, 2);
429 va.setup(rsc);
430
431 RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
Jason Sams87fe59a2011-04-20 15:09:01 -0700432}
433
434static void SC_DrawQuad(float x1, float y1, float z1,
435 float x2, float y2, float z2,
436 float x3, float y3, float z3,
437 float x4, float y4, float z4) {
Stephen Hines414a4612012-09-05 18:05:08 -0700438 SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
439 x2, y2, z2, 1, 1,
440 x3, y3, z3, 1, 0,
441 x4, y4, z4, 0, 0);
Jason Sams87fe59a2011-04-20 15:09:01 -0700442}
443
444static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
Jason Sams709a0972012-11-15 18:18:04 -0800445 Context *rsc = RsdCpuReference::getTlsContext();
Stephen Hines414a4612012-09-05 18:05:08 -0700446
447 ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
448 rsc->setProgramVertex(rsc->getDefaultProgramVertex());
449 //rsc->setupCheck();
450
451 //GLint crop[4] = {0, h, w, -h};
452
453 float sh = rsc->getHeight();
454
455 SC_DrawQuad(x, sh - y, z,
456 x+w, sh - y, z,
457 x+w, sh - (y+h), z,
458 x, sh - (y+h), z);
459 rsc->setProgramVertex((ProgramVertex *)tmp.get());
Jason Sams87fe59a2011-04-20 15:09:01 -0700460}
461
462static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
Stephen Hines414a4612012-09-05 18:05:08 -0700463 SC_DrawQuad(x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
Jason Sams87fe59a2011-04-20 15:09:01 -0700464}
465
466static void SC_DrawMesh(Mesh *m) {
Jason Sams709a0972012-11-15 18:18:04 -0800467 Context *rsc = RsdCpuReference::getTlsContext();
468 rsrDrawMesh(rsc, m);
Jason Sams87fe59a2011-04-20 15:09:01 -0700469}
470
471static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
Jason Sams709a0972012-11-15 18:18:04 -0800472 Context *rsc = RsdCpuReference::getTlsContext();
473 rsrDrawMeshPrimitive(rsc, m, primIndex);
Jason Sams87fe59a2011-04-20 15:09:01 -0700474}
475
476static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
Jason Sams709a0972012-11-15 18:18:04 -0800477 Context *rsc = RsdCpuReference::getTlsContext();
478 rsrDrawMeshPrimitiveRange(rsc, m, primIndex, start, len);
Jason Sams87fe59a2011-04-20 15:09:01 -0700479}
480
481static void SC_MeshComputeBoundingBox(Mesh *m,
482 float *minX, float *minY, float *minZ,
483 float *maxX, float *maxY, float *maxZ) {
Jason Sams709a0972012-11-15 18:18:04 -0800484 Context *rsc = RsdCpuReference::getTlsContext();
485 rsrMeshComputeBoundingBox(rsc, m, minX, minY, minZ, maxX, maxY, maxZ);
Jason Sams87fe59a2011-04-20 15:09:01 -0700486}
487
488
489
490//////////////////////////////////////////////////////////////////////////////
491//
492//////////////////////////////////////////////////////////////////////////////
493
494
495static void SC_Color(float r, float g, float b, float a) {
Jason Sams709a0972012-11-15 18:18:04 -0800496 Context *rsc = RsdCpuReference::getTlsContext();
497 rsrColor(rsc, r, g, b, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700498}
499
500static void SC_Finish() {
Jason Sams709a0972012-11-15 18:18:04 -0800501 Context *rsc = RsdCpuReference::getTlsContext();
Alex Sakhartchouk653b53e2012-02-24 14:22:34 -0800502 rsdGLFinish(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700503}
504
505static void SC_ClearColor(float r, float g, float b, float a) {
Jason Sams709a0972012-11-15 18:18:04 -0800506 Context *rsc = RsdCpuReference::getTlsContext();
507 rsrPrepareClear(rsc);
Alex Sakhartchouk653b53e2012-02-24 14:22:34 -0800508 rsdGLClearColor(rsc, r, g, b, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700509}
510
511static void SC_ClearDepth(float v) {
Jason Sams709a0972012-11-15 18:18:04 -0800512 Context *rsc = RsdCpuReference::getTlsContext();
513 rsrPrepareClear(rsc);
Alex Sakhartchouk653b53e2012-02-24 14:22:34 -0800514 rsdGLClearDepth(rsc, v);
Jason Sams87fe59a2011-04-20 15:09:01 -0700515}
516
517static uint32_t SC_GetWidth() {
Jason Sams709a0972012-11-15 18:18:04 -0800518 Context *rsc = RsdCpuReference::getTlsContext();
519 return rsrGetWidth(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700520}
521
522static uint32_t SC_GetHeight() {
Jason Sams709a0972012-11-15 18:18:04 -0800523 Context *rsc = RsdCpuReference::getTlsContext();
524 return rsrGetHeight(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700525}
526
527static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
Jason Sams709a0972012-11-15 18:18:04 -0800528 Context *rsc = RsdCpuReference::getTlsContext();
529 rsrDrawTextAlloc(rsc, a, x, y);
Jason Sams87fe59a2011-04-20 15:09:01 -0700530}
531
532static void SC_DrawText(const char *text, int x, int y) {
Jason Sams709a0972012-11-15 18:18:04 -0800533 Context *rsc = RsdCpuReference::getTlsContext();
534 rsrDrawText(rsc, text, x, y);
Jason Sams87fe59a2011-04-20 15:09:01 -0700535}
536
537static void SC_MeasureTextAlloc(Allocation *a,
538 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
Jason Sams709a0972012-11-15 18:18:04 -0800539 Context *rsc = RsdCpuReference::getTlsContext();
540 rsrMeasureTextAlloc(rsc, a, left, right, top, bottom);
Jason Sams87fe59a2011-04-20 15:09:01 -0700541}
542
543static void SC_MeasureText(const char *text,
544 int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
Jason Sams709a0972012-11-15 18:18:04 -0800545 Context *rsc = RsdCpuReference::getTlsContext();
546 rsrMeasureText(rsc, text, left, right, top, bottom);
Jason Sams87fe59a2011-04-20 15:09:01 -0700547}
548
549static void SC_BindFont(Font *f) {
Jason Sams709a0972012-11-15 18:18:04 -0800550 Context *rsc = RsdCpuReference::getTlsContext();
551 rsrBindFont(rsc, f);
Jason Sams87fe59a2011-04-20 15:09:01 -0700552}
553
554static void SC_FontColor(float r, float g, float b, float a) {
Jason Sams709a0972012-11-15 18:18:04 -0800555 Context *rsc = RsdCpuReference::getTlsContext();
556 rsrFontColor(rsc, r, g, b, a);
Jason Sams87fe59a2011-04-20 15:09:01 -0700557}
Jason Sams110f1812013-03-14 16:02:18 -0700558#endif
Jason Sams87fe59a2011-04-20 15:09:01 -0700559
560
561//////////////////////////////////////////////////////////////////////////////
562//
563//////////////////////////////////////////////////////////////////////////////
564
Jason Samsf29edf82014-08-05 14:59:22 -0700565static void SC_ClearObject(rs_object_base *dst) {
Jason Sams709a0972012-11-15 18:18:04 -0800566 Context *rsc = RsdCpuReference::getTlsContext();
567 rsrClearObject(rsc, dst);
Jason Sams87fe59a2011-04-20 15:09:01 -0700568}
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800569
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700570static void SC_SetObject(rs_object_base *dst, rs_object_base src) {
571 // ALOGE("SC_SetObject: dst = %p, src = %p", dst, src.p);
572 // ALOGE("SC_SetObject: dst[0] = %p", dst[0]);
573 Context *rsc = RsdCpuReference::getTlsContext();
574 rsrSetObject(rsc, dst, (ObjectBase*)src.p);
575}
Jason Sams87fe59a2011-04-20 15:09:01 -0700576
Jason Samsf29edf82014-08-05 14:59:22 -0700577static bool SC_IsObject(rs_object_base o) {
Jason Sams709a0972012-11-15 18:18:04 -0800578 Context *rsc = RsdCpuReference::getTlsContext();
Jason Samsf29edf82014-08-05 14:59:22 -0700579 return rsrIsObject(rsc, o);
Jason Sams87fe59a2011-04-20 15:09:01 -0700580}
Yong Chen444bd202014-08-14 18:28:38 +0800581
Miao Wang127d51c2014-11-24 13:41:33 -0800582#ifdef __LP64__
583static void SC_SetObject_ByRef(rs_object_base *dst, rs_object_base *src) {
Yong Chen31729ad2014-11-12 15:20:18 +0800584 // ALOGE("SC_SetObject_ByRef: dst = %p, src = %p", dst, src->p);
Miao Wang127d51c2014-11-24 13:41:33 -0800585 Context *rsc = RsdCpuReference::getTlsContext();
586 rsrSetObject(rsc, dst, (ObjectBase*)src->p);
587}
588
589static bool SC_IsObject_ByRef(rs_object_base *o) {
590 Context *rsc = RsdCpuReference::getTlsContext();
591 return rsrIsObject(rsc, *o);
592}
593#endif
594
Tim Murray240a6c92014-09-08 15:51:22 -0700595
Tim Murray47211dc2014-08-21 14:12:43 -0700596#ifndef RS_COMPATIBILITY_LIB
597#ifndef __LP64__
Tim Murray240a6c92014-09-08 15:51:22 -0700598
599// i386 has different struct return passing to ARM; emulate with void*
600#ifdef __i386__
601static const void* SC_GetAllocation(const void *ptr) {
602 Context *rsc = RsdCpuReference::getTlsContext();
603 const Script *sc = RsdCpuReference::getTlsScript();
604 Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
605 android::renderscript::rs_allocation obj = {0};
606 alloc->callUpdateCacheObject(rsc, &obj);
607 return (void*)obj.p;
608}
609#else
610// ARMv7/MIPS
Tim Murray47211dc2014-08-21 14:12:43 -0700611static const android::renderscript::rs_allocation SC_GetAllocation(const void *ptr) {
Jason Sams709a0972012-11-15 18:18:04 -0800612 Context *rsc = RsdCpuReference::getTlsContext();
613 const Script *sc = RsdCpuReference::getTlsScript();
Tim Murray47211dc2014-08-21 14:12:43 -0700614 Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
615 android::renderscript::rs_allocation obj = {0};
616 alloc->callUpdateCacheObject(rsc, &obj);
617 return obj;
Jason Sams87fe59a2011-04-20 15:09:01 -0700618}
Tim Murray240a6c92014-09-08 15:51:22 -0700619#endif
Tim Murray47211dc2014-08-21 14:12:43 -0700620#else
Tim Murray240a6c92014-09-08 15:51:22 -0700621// AArch64/x86_64/MIPS64
Tim Murray47211dc2014-08-21 14:12:43 -0700622static const android::renderscript::rs_allocation SC_GetAllocation(const void *ptr) {
623 Context *rsc = RsdCpuReference::getTlsContext();
624 const Script *sc = RsdCpuReference::getTlsScript();
625 Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
626 android::renderscript::rs_allocation obj = {0, 0, 0, 0};
627 alloc->callUpdateCacheObject(rsc, &obj);
628 return obj;
629}
630#endif
631#endif
Jason Sams87fe59a2011-04-20 15:09:01 -0700632
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800633
Yong Chen31729ad2014-11-12 15:20:18 +0800634static void SC_ForEach_SAA(RS_TY_SCRIPT target, RS_TY_ALLOC in, RS_TY_ALLOC out) {
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800635 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800636 rsrForEach(rsc, rsGetObjPtr(target), rsGetObjPtr(in), rsGetObjPtr(out), nullptr, 0, nullptr);
637}
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800638
Yong Chen31729ad2014-11-12 15:20:18 +0800639static void SC_ForEach_SAAU(RS_TY_SCRIPT target, RS_TY_ALLOC in,
640 RS_TY_ALLOC out, const void *usr) {
Yong Chen444bd202014-08-14 18:28:38 +0800641 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800642 rsrForEach(rsc, rsGetObjPtr(target), rsGetObjPtr(in), rsGetObjPtr(out), usr, 0, nullptr);
Yong Chen444bd202014-08-14 18:28:38 +0800643}
Jason Samsc500e742011-07-25 12:58:37 -0700644
Yong Chen31729ad2014-11-12 15:20:18 +0800645static void SC_ForEach_SAAUS(RS_TY_SCRIPT target, RS_TY_ALLOC in,
646 RS_TY_ALLOC out, const void *usr, const RsScriptCall *call) {
Jason Sams709a0972012-11-15 18:18:04 -0800647 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800648 rsrForEach(rsc, rsGetObjPtr(target), rsGetObjPtr(in), rsGetObjPtr(out), usr, 0, call);
Jason Sams87fe59a2011-04-20 15:09:01 -0700649}
Jason Sams87fe59a2011-04-20 15:09:01 -0700650
Tim Murray2f6dc842014-11-14 13:27:05 -0800651// These functions are only supported in 32-bit.
Yong Chen444bd202014-08-14 18:28:38 +0800652#ifndef __LP64__
Yong Chen31729ad2014-11-12 15:20:18 +0800653static void SC_ForEach_SAAUL(RS_TY_SCRIPT target, RS_TY_ALLOC in,
654 RS_TY_ALLOC out, const void *usr, uint32_t usrLen) {
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800655 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800656 rsrForEach(rsc, rsGetObjPtr(target), rsGetObjPtr(in), rsGetObjPtr(out), usr, usrLen, nullptr);
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800657}
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800658
Yong Chen31729ad2014-11-12 15:20:18 +0800659static void SC_ForEach_SAAULS(RS_TY_SCRIPT target, RS_TY_ALLOC in, RS_TY_ALLOC out,
660 const void *usr, uint32_t usrLen, const RsScriptCall *call) {
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800661 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen31729ad2014-11-12 15:20:18 +0800662 rsrForEach(rsc, rsGetObjPtr(target), rsGetObjPtr(in), rsGetObjPtr(out), usr, usrLen, call);
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800663}
Tim Murray1aa9dfc2014-08-06 11:49:02 -0700664#endif
Jason Sams87fe59a2011-04-20 15:09:01 -0700665
666
667//////////////////////////////////////////////////////////////////////////////
668// Time routines
669//////////////////////////////////////////////////////////////////////////////
670
671static float SC_GetDt() {
Jason Sams709a0972012-11-15 18:18:04 -0800672 Context *rsc = RsdCpuReference::getTlsContext();
673 const Script *sc = RsdCpuReference::getTlsScript();
Jason Sams87fe59a2011-04-20 15:09:01 -0700674 return rsrGetDt(rsc, sc);
675}
676
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800677// #if !defined(RS_COMPATIBILITY_LIB) && defined(__LP64__)
678#ifdef __LP64__
Jason Sams87fe59a2011-04-20 15:09:01 -0700679time_t SC_Time(time_t *timer) {
Jason Sams709a0972012-11-15 18:18:04 -0800680 Context *rsc = RsdCpuReference::getTlsContext();
681 return rsrTime(rsc, timer);
Jason Sams87fe59a2011-04-20 15:09:01 -0700682}
Tim Murrayd6f1f462013-03-25 16:36:59 -0700683#else
684static int SC_Time(int *timer) {
685 Context *rsc = RsdCpuReference::getTlsContext();
686 return rsrTime(rsc, (long*)timer);
687}
688#endif
Jason Sams87fe59a2011-04-20 15:09:01 -0700689
690tm* SC_LocalTime(tm *local, time_t *timer) {
Jason Sams709a0972012-11-15 18:18:04 -0800691 Context *rsc = RsdCpuReference::getTlsContext();
692 return rsrLocalTime(rsc, local, timer);
Jason Sams87fe59a2011-04-20 15:09:01 -0700693}
694
695int64_t SC_UptimeMillis() {
Jason Sams709a0972012-11-15 18:18:04 -0800696 Context *rsc = RsdCpuReference::getTlsContext();
697 return rsrUptimeMillis(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700698}
699
700int64_t SC_UptimeNanos() {
Jason Sams709a0972012-11-15 18:18:04 -0800701 Context *rsc = RsdCpuReference::getTlsContext();
702 return rsrUptimeNanos(rsc);
Jason Sams87fe59a2011-04-20 15:09:01 -0700703}
704
705//////////////////////////////////////////////////////////////////////////////
706// Message routines
707//////////////////////////////////////////////////////////////////////////////
708
Stephen Hines276000a2013-12-03 09:33:32 -0800709static uint32_t SC_ToClient2(int cmdID, const void *data, uint32_t len) {
Jason Sams709a0972012-11-15 18:18:04 -0800710 Context *rsc = RsdCpuReference::getTlsContext();
711 return rsrToClient(rsc, cmdID, data, len);
Jason Sams87fe59a2011-04-20 15:09:01 -0700712}
713
714static uint32_t SC_ToClient(int cmdID) {
Jason Sams709a0972012-11-15 18:18:04 -0800715 Context *rsc = RsdCpuReference::getTlsContext();
Chris Wailes44bef6f2014-08-12 13:51:10 -0700716 return rsrToClient(rsc, cmdID, (const void *)nullptr, 0);
Jason Sams87fe59a2011-04-20 15:09:01 -0700717}
718
Stephen Hines276000a2013-12-03 09:33:32 -0800719static uint32_t SC_ToClientBlocking2(int cmdID, const void *data, uint32_t len) {
Jason Sams709a0972012-11-15 18:18:04 -0800720 Context *rsc = RsdCpuReference::getTlsContext();
721 return rsrToClientBlocking(rsc, cmdID, data, len);
Jason Sams87fe59a2011-04-20 15:09:01 -0700722}
723
724static uint32_t SC_ToClientBlocking(int cmdID) {
Jason Sams709a0972012-11-15 18:18:04 -0800725 Context *rsc = RsdCpuReference::getTlsContext();
Chris Wailes44bef6f2014-08-12 13:51:10 -0700726 return rsrToClientBlocking(rsc, cmdID, (const void *)nullptr, 0);
Jason Sams87fe59a2011-04-20 15:09:01 -0700727}
728
Jason Sams87fe59a2011-04-20 15:09:01 -0700729
Jason Sams5261a5e2013-02-27 15:46:24 -0800730static void * ElementAt1D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x) {
731 Context *rsc = RsdCpuReference::getTlsContext();
732 const Type *t = a->getType();
733 const Element *e = t->getElement();
734
735 char buf[256];
736 if (x >= t->getLODDimX(0)) {
737 sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700738 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700739 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800740 }
741
Jason Samsd09b9d62013-04-02 20:07:04 -0700742 if (vecSize > 0) {
743 if (vecSize != e->getVectorSize()) {
744 sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700745 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700746 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700747 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800748
Jason Samsd09b9d62013-04-02 20:07:04 -0700749 if (dt != e->getType()) {
750 sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700751 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700752 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700753 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800754 }
755
756 uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
757 const uint32_t eSize = e->getSizeBytes();
758 return &p[(eSize * x)];
759}
760
761static void * ElementAt2D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y) {
762 Context *rsc = RsdCpuReference::getTlsContext();
763 const Type *t = a->getType();
764 const Element *e = t->getElement();
765
766 char buf[256];
767 if (x >= t->getLODDimX(0)) {
768 sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700769 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700770 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800771 }
772
773 if (y >= t->getLODDimY(0)) {
774 sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700775 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700776 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800777 }
778
Jason Samsd09b9d62013-04-02 20:07:04 -0700779 if (vecSize > 0) {
780 if (vecSize != e->getVectorSize()) {
781 sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700782 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700783 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700784 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800785
Jason Samsd09b9d62013-04-02 20:07:04 -0700786 if (dt != e->getType()) {
787 sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700788 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700789 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700790 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800791 }
792
793 uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
794 const uint32_t eSize = e->getSizeBytes();
795 const uint32_t stride = a->mHal.drvState.lod[0].stride;
796 return &p[(eSize * x) + (y * stride)];
797}
798
799static void * ElementAt3D(Allocation *a, RsDataType dt, uint32_t vecSize, uint32_t x, uint32_t y, uint32_t z) {
800 Context *rsc = RsdCpuReference::getTlsContext();
801 const Type *t = a->getType();
802 const Element *e = t->getElement();
803
804 char buf[256];
805 if (x >= t->getLODDimX(0)) {
806 sprintf(buf, "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700807 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700808 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800809 }
810
811 if (y >= t->getLODDimY(0)) {
812 sprintf(buf, "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700813 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700814 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800815 }
816
817 if (z >= t->getLODDimZ(0)) {
818 sprintf(buf, "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700819 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700820 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800821 }
822
Jason Samsd09b9d62013-04-02 20:07:04 -0700823 if (vecSize > 0) {
824 if (vecSize != e->getVectorSize()) {
825 sprintf(buf, "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700826 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700827 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700828 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800829
Jason Samsd09b9d62013-04-02 20:07:04 -0700830 if (dt != e->getType()) {
831 sprintf(buf, "Data type mismatch for ElementAt %i of %i", dt, e->getType());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700832 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700833 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700834 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800835 }
836
837 uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
838 const uint32_t eSize = e->getSizeBytes();
839 const uint32_t stride = a->mHal.drvState.lod[0].stride;
840 return &p[(eSize * x) + (y * stride)];
841}
842
Yong Chen31729ad2014-11-12 15:20:18 +0800843static const void * SC_GetElementAt1D(RS_TY_ALLOC a, uint32_t x) {
844 return ElementAt1D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x);
Jason Samsd09b9d62013-04-02 20:07:04 -0700845}
Yong Chen31729ad2014-11-12 15:20:18 +0800846static const void * SC_GetElementAt2D(RS_TY_ALLOC a, uint32_t x, uint32_t y) {
847 return ElementAt2D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x, y);
Jason Samsd09b9d62013-04-02 20:07:04 -0700848}
Yong Chen31729ad2014-11-12 15:20:18 +0800849static const void * SC_GetElementAt3D(RS_TY_ALLOC a, uint32_t x, uint32_t y, uint32_t z) {
850 return ElementAt3D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x, y, z);
Jason Samsd09b9d62013-04-02 20:07:04 -0700851}
852
Yong Chen31729ad2014-11-12 15:20:18 +0800853static void SC_SetElementAt1D(RS_TY_ALLOC a, const void *ptr, uint32_t x) {
854 const Type *t = rsGetObjPtr(a)->getType();
Jason Samsd09b9d62013-04-02 20:07:04 -0700855 const Element *e = t->getElement();
Yong Chen31729ad2014-11-12 15:20:18 +0800856 void *tmp = ElementAt1D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700857 if (tmp != nullptr) {
Jason Samsd09b9d62013-04-02 20:07:04 -0700858 memcpy(tmp, ptr, e->getSizeBytes());
859 }
860}
Yong Chen31729ad2014-11-12 15:20:18 +0800861static void SC_SetElementAt2D(RS_TY_ALLOC a, const void *ptr, uint32_t x, uint32_t y) {
862 const Type *t = rsGetObjPtr(a)->getType();
Jason Samsd09b9d62013-04-02 20:07:04 -0700863 const Element *e = t->getElement();
Yong Chen31729ad2014-11-12 15:20:18 +0800864 void *tmp = ElementAt2D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x, y);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700865 if (tmp != nullptr) {
Jason Samsd09b9d62013-04-02 20:07:04 -0700866 memcpy(tmp, ptr, e->getSizeBytes());
867 }
868}
Yong Chen31729ad2014-11-12 15:20:18 +0800869static void SC_SetElementAt3D(RS_TY_ALLOC a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
870 const Type *t = rsGetObjPtr(a)->getType();
Jason Samsd09b9d62013-04-02 20:07:04 -0700871 const Element *e = t->getElement();
Yong Chen31729ad2014-11-12 15:20:18 +0800872 void *tmp = ElementAt3D(rsGetObjPtr(a), RS_TYPE_UNSIGNED_8, 0, x, y, z);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700873 if (tmp != nullptr) {
Jason Samsd09b9d62013-04-02 20:07:04 -0700874 memcpy(tmp, ptr, e->getSizeBytes());
875 }
876}
877
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800878const void *rsGetElementAt(::rs_allocation a, uint32_t x) {
Yong Chen31729ad2014-11-12 15:20:18 +0800879 return SC_GetElementAt1D(RS_CAST(a), x);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800880}
881
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800882const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y) {
Yong Chen31729ad2014-11-12 15:20:18 +0800883 return SC_GetElementAt2D(RS_CAST(a), x, y);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800884}
885
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800886const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y, uint32_t z) {
Yong Chen31729ad2014-11-12 15:20:18 +0800887 return SC_GetElementAt3D(RS_CAST(a), x, y, z);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800888}
889
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800890void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x) {
Yong Chen31729ad2014-11-12 15:20:18 +0800891 SC_SetElementAt1D(RS_CAST(a), ptr, x);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800892}
893
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800894void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y) {
Yong Chen31729ad2014-11-12 15:20:18 +0800895 SC_SetElementAt2D(RS_CAST(a), ptr, x, y);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800896}
897
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800898void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
Yong Chen31729ad2014-11-12 15:20:18 +0800899 SC_SetElementAt3D(RS_CAST(a), ptr, x, y, z);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800900}
901
902
Yong Chen31729ad2014-11-12 15:20:18 +0800903#define ELEMENT_AT(T, DT, VS) \
904 static void SC_SetElementAt1_##T(RS_TY_ALLOC a, const T *val, uint32_t x) { \
905 void *r = ElementAt1D(rsGetObjPtr(a), DT, VS, x); \
Chris Wailes44bef6f2014-08-12 13:51:10 -0700906 if (r != nullptr) ((T *)r)[0] = *val; \
Jason Sams5261a5e2013-02-27 15:46:24 -0800907 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
908 } \
Yong Chen31729ad2014-11-12 15:20:18 +0800909 static void SC_SetElementAt2_##T(RS_TY_ALLOC a, const T * val, uint32_t x, uint32_t y) { \
910 void *r = ElementAt2D(rsGetObjPtr(a), DT, VS, x, y); \
Chris Wailes44bef6f2014-08-12 13:51:10 -0700911 if (r != nullptr) ((T *)r)[0] = *val; \
Jason Sams5261a5e2013-02-27 15:46:24 -0800912 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
913 } \
Yong Chen31729ad2014-11-12 15:20:18 +0800914 static void SC_SetElementAt3_##T(RS_TY_ALLOC a, const T * val, uint32_t x, uint32_t y, uint32_t z) { \
915 void *r = ElementAt3D(rsGetObjPtr(a), DT, VS, x, y, z); \
Chris Wailes44bef6f2014-08-12 13:51:10 -0700916 if (r != nullptr) ((T *)r)[0] = *val; \
Jason Sams5261a5e2013-02-27 15:46:24 -0800917 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
918 } \
Yong Chen31729ad2014-11-12 15:20:18 +0800919 static void SC_GetElementAt1_##T(RS_TY_ALLOC a, T *val, uint32_t x) { \
920 void *r = ElementAt1D(rsGetObjPtr(a), DT, VS, x); \
Chris Wailes44bef6f2014-08-12 13:51:10 -0700921 if (r != nullptr) *val = ((T *)r)[0]; \
922 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
Jason Sams5261a5e2013-02-27 15:46:24 -0800923 } \
Yong Chen31729ad2014-11-12 15:20:18 +0800924 static void SC_GetElementAt2_##T(RS_TY_ALLOC a, T *val, uint32_t x, uint32_t y) { \
925 void *r = ElementAt2D(rsGetObjPtr(a), DT, VS, x, y); \
926 if (r != nullptr) *val = ((T *)r)[0]; \
927 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
928 } \
929 static void SC_GetElementAt3_##T(RS_TY_ALLOC a, T *val, uint32_t x, uint32_t y, uint32_t z) { \
930 void *r = ElementAt3D(rsGetObjPtr(a), DT, VS, x, y, z); \
931 if (r != nullptr) *val = ((T *)r)[0]; \
932 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
933 } \
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800934 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x) { \
Yong Chen31729ad2014-11-12 15:20:18 +0800935 SC_SetElementAt1_##T(RS_CAST(a), val, x); \
936 } \
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800937 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y) { \
Yong Chen31729ad2014-11-12 15:20:18 +0800938 SC_SetElementAt2_##T(RS_CAST(a), val, x, y); \
939 } \
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800940 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y, uint32_t z) { \
Yong Chen31729ad2014-11-12 15:20:18 +0800941 SC_SetElementAt3_##T(RS_CAST(a), val, x, y, z); \
942 } \
943 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x) { \
944 SC_GetElementAt1_##T(RS_CAST(a), val, x); \
945 } \
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800946 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y) { \
Yong Chen31729ad2014-11-12 15:20:18 +0800947 SC_GetElementAt2_##T(RS_CAST(a), val, x, y); \
948 } \
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800949 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y, uint32_t z) { \
Yong Chen31729ad2014-11-12 15:20:18 +0800950 SC_GetElementAt3_##T(RS_CAST(a), val, x, y, z); \
951 } \
Jason Sams5261a5e2013-02-27 15:46:24 -0800952
953ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1)
954ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2)
955ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3)
956ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4)
957ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1)
958ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2)
959ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3)
960ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4)
961ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1)
962ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2)
963ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3)
964ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4)
965ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1)
966ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2)
967ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3)
968ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4)
969ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1)
970ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2)
971ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3)
972ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4)
973ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1)
974ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2)
975ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3)
976ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4)
977ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1)
978ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2)
979ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3)
980ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4)
981ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1)
982ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2)
983ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3)
984ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4)
985ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1)
986ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2)
987ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3)
988ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4)
989ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1)
990ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2)
991ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3)
992ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4)
993
994#undef ELEMENT_AT
Jason Sams87fe59a2011-04-20 15:09:01 -0700995
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800996#ifndef __LP64__
997/*
998 * We miss some symbols for rs{Get,Set}Element_long,ulong variants because 64
999 * bit integer values are 'long' in RS-land but might be 'long long' in the
1000 * driver. Define native_long* and native_ulong* types to be vectors of
1001 * 'long' as seen by the driver and define overloaded versions of
1002 * rsSetElementAt_* and rsGetElementAt_*. This should get us the correct
1003 * mangled names in the driver.
1004 */
1005
1006typedef long native_long2 __attribute__((ext_vector_type(2)));
1007typedef long native_long3 __attribute__((ext_vector_type(3)));
1008typedef long native_long4 __attribute__((ext_vector_type(4)));
1009typedef unsigned long native_ulong2 __attribute__((ext_vector_type(2)));
1010typedef unsigned long native_ulong3 __attribute__((ext_vector_type(3)));
1011typedef unsigned long native_ulong4 __attribute__((ext_vector_type(4)));
1012
1013#define ELEMENT_AT_OVERLOADS(T, U) \
1014 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001015 SC_SetElementAt1_##T(RS_CAST(a), (T *) val, x); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001016 } \
1017 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001018 SC_SetElementAt2_##T(RS_CAST(a), (T *) val, x, y); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001019 } \
1020 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y, uint32_t z) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001021 SC_SetElementAt3_##T(RS_CAST(a), (T *) val, x, y, z); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001022 } \
1023 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001024 SC_GetElementAt1_##T(RS_CAST(a), (T *) val, x); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001025 } \
1026 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001027 SC_GetElementAt2_##T(RS_CAST(a), (T *) val, x, y); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001028 } \
1029 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y, uint32_t z) { \
Yong Chen31729ad2014-11-12 15:20:18 +08001030 SC_GetElementAt3_##T(RS_CAST(a), (T *) val, x, y, z); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001031 } \
1032
1033ELEMENT_AT_OVERLOADS(long2, native_long2)
1034ELEMENT_AT_OVERLOADS(long3, native_long3)
1035ELEMENT_AT_OVERLOADS(long4, native_long4)
1036ELEMENT_AT_OVERLOADS(ulong, unsigned long)
1037ELEMENT_AT_OVERLOADS(ulong2, native_ulong2)
1038ELEMENT_AT_OVERLOADS(ulong3, native_ulong3)
1039ELEMENT_AT_OVERLOADS(ulong4, native_ulong4)
1040
1041// We also need variants of rs{Get,Set}ElementAt_long that take 'long long *' as
1042// we might have this overloaded variant in old APKs.
1043ELEMENT_AT_OVERLOADS(long, long long)
1044
1045#undef ELEMENT_AT_OVERLOADS
1046#endif
1047
1048
Jason Sams87fe59a2011-04-20 15:09:01 -07001049//////////////////////////////////////////////////////////////////////////////
1050// Stub implementation
1051//////////////////////////////////////////////////////////////////////////////
1052
1053// llvm name mangling ref
1054// <builtin-type> ::= v # void
1055// ::= b # bool
1056// ::= c # char
1057// ::= a # signed char
1058// ::= h # unsigned char
1059// ::= s # short
1060// ::= t # unsigned short
1061// ::= i # int
1062// ::= j # unsigned int
1063// ::= l # long
1064// ::= m # unsigned long
1065// ::= x # long long, __int64
1066// ::= y # unsigned long long, __int64
1067// ::= f # float
1068// ::= d # double
1069
Jason Sams709a0972012-11-15 18:18:04 -08001070static RsdCpuReference::CpuSymbol gSyms[] = {
Jason Sams5261a5e2013-02-27 15:46:24 -08001071 // Debug runtime
Jason Samsd09b9d62013-04-02 20:07:04 -07001072 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_GetElementAt1D, true },
1073 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_GetElementAt2D, true },
1074 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_GetElementAt3D, true },
1075 { "_Z14rsSetElementAt13rs_allocationPKvj", (void *)&SC_SetElementAt1D, true },
1076 { "_Z14rsSetElementAt13rs_allocationPKvjj", (void *)&SC_SetElementAt2D, true },
1077 { "_Z14rsSetElementAt13rs_allocationPKvjjj", (void *)&SC_SetElementAt3D, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001078
Jason Sams5261a5e2013-02-27 15:46:24 -08001079
Jason Samsd09b9d62013-04-02 20:07:04 -07001080 { "_Z20rsGetElementAt_uchar13rs_allocationPhj", (void *)&SC_GetElementAt1_uchar, true },
1081 { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hj", (void *)&SC_GetElementAt1_uchar2, true },
1082 { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hj", (void *)&SC_GetElementAt1_uchar3, true },
1083 { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hj", (void *)&SC_GetElementAt1_uchar4, true },
1084 { "_Z20rsGetElementAt_uchar13rs_allocationPhjj", (void *)&SC_GetElementAt2_uchar, true },
1085 { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjj", (void *)&SC_GetElementAt2_uchar2, true },
1086 { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjj", (void *)&SC_GetElementAt2_uchar3, true },
1087 { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjj", (void *)&SC_GetElementAt2_uchar4, true },
1088 { "_Z20rsGetElementAt_uchar13rs_allocationPhjjj", (void *)&SC_GetElementAt3_uchar, true },
1089 { "_Z21rsGetElementAt_uchar213rs_allocationPDv2_hjjj", (void *)&SC_GetElementAt3_uchar2, true },
1090 { "_Z21rsGetElementAt_uchar313rs_allocationPDv3_hjjj", (void *)&SC_GetElementAt3_uchar3, true },
1091 { "_Z21rsGetElementAt_uchar413rs_allocationPDv4_hjjj", (void *)&SC_GetElementAt3_uchar4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001092
Jason Samsd09b9d62013-04-02 20:07:04 -07001093 { "_Z19rsGetElementAt_char13rs_allocationPcj", (void *)&SC_GetElementAt1_char, true },
1094 { "_Z20rsGetElementAt_char213rs_allocationPDv2_cj", (void *)&SC_GetElementAt1_char2, true },
1095 { "_Z20rsGetElementAt_char313rs_allocationPDv3_cj", (void *)&SC_GetElementAt1_char3, true },
1096 { "_Z20rsGetElementAt_char413rs_allocationPDv4_cj", (void *)&SC_GetElementAt1_char4, true },
1097 { "_Z19rsGetElementAt_char13rs_allocationPcjj", (void *)&SC_GetElementAt2_char, true },
1098 { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjj", (void *)&SC_GetElementAt2_char2, true },
1099 { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjj", (void *)&SC_GetElementAt2_char3, true },
1100 { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjj", (void *)&SC_GetElementAt2_char4, true },
1101 { "_Z19rsGetElementAt_char13rs_allocationPcjjj", (void *)&SC_GetElementAt3_char, true },
1102 { "_Z20rsGetElementAt_char213rs_allocationPDv2_cjjj", (void *)&SC_GetElementAt3_char2, true },
1103 { "_Z20rsGetElementAt_char313rs_allocationPDv3_cjjj", (void *)&SC_GetElementAt3_char3, true },
1104 { "_Z20rsGetElementAt_char413rs_allocationPDv4_cjjj", (void *)&SC_GetElementAt3_char4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001105
Jason Samsd09b9d62013-04-02 20:07:04 -07001106 { "_Z21rsGetElementAt_ushort13rs_allocationPtj", (void *)&SC_GetElementAt1_ushort, true },
1107 { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tj", (void *)&SC_GetElementAt1_ushort2, true },
1108 { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tj", (void *)&SC_GetElementAt1_ushort3, true },
1109 { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tj", (void *)&SC_GetElementAt1_ushort4, true },
1110 { "_Z21rsGetElementAt_ushort13rs_allocationPtjj", (void *)&SC_GetElementAt2_ushort, true },
1111 { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjj", (void *)&SC_GetElementAt2_ushort2, true },
1112 { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjj", (void *)&SC_GetElementAt2_ushort3, true },
1113 { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjj", (void *)&SC_GetElementAt2_ushort4, true },
1114 { "_Z21rsGetElementAt_ushort13rs_allocationPtjjj", (void *)&SC_GetElementAt3_ushort, true },
1115 { "_Z22rsGetElementAt_ushort213rs_allocationPDv2_tjjj", (void *)&SC_GetElementAt3_ushort2, true },
1116 { "_Z22rsGetElementAt_ushort313rs_allocationPDv3_tjjj", (void *)&SC_GetElementAt3_ushort3, true },
1117 { "_Z22rsGetElementAt_ushort413rs_allocationPDv4_tjjj", (void *)&SC_GetElementAt3_ushort4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001118
Jason Samsd09b9d62013-04-02 20:07:04 -07001119 { "_Z20rsGetElementAt_short13rs_allocationPsj", (void *)&SC_GetElementAt1_short, true },
1120 { "_Z21rsGetElementAt_short213rs_allocationPDv2_sj", (void *)&SC_GetElementAt1_short2, true },
1121 { "_Z21rsGetElementAt_short313rs_allocationPDv3_sj", (void *)&SC_GetElementAt1_short3, true },
1122 { "_Z21rsGetElementAt_short413rs_allocationPDv4_sj", (void *)&SC_GetElementAt1_short4, true },
1123 { "_Z20rsGetElementAt_short13rs_allocationPsjj", (void *)&SC_GetElementAt2_short, true },
1124 { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjj", (void *)&SC_GetElementAt2_short2, true },
1125 { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjj", (void *)&SC_GetElementAt2_short3, true },
1126 { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjj", (void *)&SC_GetElementAt2_short4, true },
1127 { "_Z20rsGetElementAt_short13rs_allocationPsjjj", (void *)&SC_GetElementAt3_short, true },
1128 { "_Z21rsGetElementAt_short213rs_allocationPDv2_sjjj", (void *)&SC_GetElementAt3_short2, true },
1129 { "_Z21rsGetElementAt_short313rs_allocationPDv3_sjjj", (void *)&SC_GetElementAt3_short3, true },
1130 { "_Z21rsGetElementAt_short413rs_allocationPDv4_sjjj", (void *)&SC_GetElementAt3_short4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001131
Jason Samsd09b9d62013-04-02 20:07:04 -07001132 { "_Z19rsGetElementAt_uint13rs_allocationPjj", (void *)&SC_GetElementAt1_uint, true },
1133 { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jj", (void *)&SC_GetElementAt1_uint2, true },
1134 { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jj", (void *)&SC_GetElementAt1_uint3, true },
1135 { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jj", (void *)&SC_GetElementAt1_uint4, true },
1136 { "_Z19rsGetElementAt_uint13rs_allocationPjjj", (void *)&SC_GetElementAt2_uint, true },
1137 { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjj", (void *)&SC_GetElementAt2_uint2, true },
1138 { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjj", (void *)&SC_GetElementAt2_uint3, true },
1139 { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjj", (void *)&SC_GetElementAt2_uint4, true },
1140 { "_Z19rsGetElementAt_uint13rs_allocationPjjjj", (void *)&SC_GetElementAt3_uint, true },
1141 { "_Z20rsGetElementAt_uint213rs_allocationPDv2_jjjj", (void *)&SC_GetElementAt3_uint2, true },
1142 { "_Z20rsGetElementAt_uint313rs_allocationPDv3_jjjj", (void *)&SC_GetElementAt3_uint3, true },
1143 { "_Z20rsGetElementAt_uint413rs_allocationPDv4_jjjj", (void *)&SC_GetElementAt3_uint4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001144
Jason Samsd09b9d62013-04-02 20:07:04 -07001145 { "_Z18rsGetElementAt_int13rs_allocationPij", (void *)&SC_GetElementAt1_int, true },
1146 { "_Z19rsGetElementAt_int213rs_allocationPDv2_ij", (void *)&SC_GetElementAt1_int2, true },
1147 { "_Z19rsGetElementAt_int313rs_allocationPDv3_ij", (void *)&SC_GetElementAt1_int3, true },
1148 { "_Z19rsGetElementAt_int413rs_allocationPDv4_ij", (void *)&SC_GetElementAt1_int4, true },
1149 { "_Z18rsGetElementAt_int13rs_allocationPijj", (void *)&SC_GetElementAt2_int, true },
1150 { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijj", (void *)&SC_GetElementAt2_int2, true },
1151 { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijj", (void *)&SC_GetElementAt2_int3, true },
1152 { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijj", (void *)&SC_GetElementAt2_int4, true },
1153 { "_Z18rsGetElementAt_int13rs_allocationPijjj", (void *)&SC_GetElementAt3_int, true },
1154 { "_Z19rsGetElementAt_int213rs_allocationPDv2_ijjj", (void *)&SC_GetElementAt3_int2, true },
1155 { "_Z19rsGetElementAt_int313rs_allocationPDv3_ijjj", (void *)&SC_GetElementAt3_int3, true },
1156 { "_Z19rsGetElementAt_int413rs_allocationPDv4_ijjj", (void *)&SC_GetElementAt3_int4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001157
Jason Samsd09b9d62013-04-02 20:07:04 -07001158 { "_Z20rsGetElementAt_ulong13rs_allocationPmj", (void *)&SC_GetElementAt1_ulong, true },
1159 { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mj", (void *)&SC_GetElementAt1_ulong2, true },
1160 { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mj", (void *)&SC_GetElementAt1_ulong3, true },
1161 { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mj", (void *)&SC_GetElementAt1_ulong4, true },
1162 { "_Z20rsGetElementAt_ulong13rs_allocationPmjj", (void *)&SC_GetElementAt2_ulong, true },
1163 { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjj", (void *)&SC_GetElementAt2_ulong2, true },
1164 { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjj", (void *)&SC_GetElementAt2_ulong3, true },
1165 { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjj", (void *)&SC_GetElementAt2_ulong4, true },
1166 { "_Z20rsGetElementAt_ulong13rs_allocationPmjjj", (void *)&SC_GetElementAt3_ulong, true },
1167 { "_Z21rsGetElementAt_ulong213rs_allocationPDv2_mjjj", (void *)&SC_GetElementAt3_ulong2, true },
1168 { "_Z21rsGetElementAt_ulong313rs_allocationPDv3_mjjj", (void *)&SC_GetElementAt3_ulong3, true },
1169 { "_Z21rsGetElementAt_ulong413rs_allocationPDv4_mjjj", (void *)&SC_GetElementAt3_ulong4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001170
Jason Samsd09b9d62013-04-02 20:07:04 -07001171 { "_Z19rsGetElementAt_long13rs_allocationPlj", (void *)&SC_GetElementAt1_long, true },
1172 { "_Z20rsGetElementAt_long213rs_allocationPDv2_lj", (void *)&SC_GetElementAt1_long2, true },
1173 { "_Z20rsGetElementAt_long313rs_allocationPDv3_lj", (void *)&SC_GetElementAt1_long3, true },
1174 { "_Z20rsGetElementAt_long413rs_allocationPDv4_lj", (void *)&SC_GetElementAt1_long4, true },
1175 { "_Z19rsGetElementAt_long13rs_allocationPljj", (void *)&SC_GetElementAt2_long, true },
1176 { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljj", (void *)&SC_GetElementAt2_long2, true },
1177 { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljj", (void *)&SC_GetElementAt2_long3, true },
1178 { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljj", (void *)&SC_GetElementAt2_long4, true },
1179 { "_Z19rsGetElementAt_long13rs_allocationPljjj", (void *)&SC_GetElementAt3_long, true },
1180 { "_Z20rsGetElementAt_long213rs_allocationPDv2_ljjj", (void *)&SC_GetElementAt3_long2, true },
1181 { "_Z20rsGetElementAt_long313rs_allocationPDv3_ljjj", (void *)&SC_GetElementAt3_long3, true },
1182 { "_Z20rsGetElementAt_long413rs_allocationPDv4_ljjj", (void *)&SC_GetElementAt3_long4, true },
1183
1184 { "_Z20rsGetElementAt_float13rs_allocationPfj", (void *)&SC_GetElementAt1_float, true },
1185 { "_Z21rsGetElementAt_float213rs_allocationPDv2_fj", (void *)&SC_GetElementAt1_float2, true },
1186 { "_Z21rsGetElementAt_float313rs_allocationPDv3_fj", (void *)&SC_GetElementAt1_float3, true },
1187 { "_Z21rsGetElementAt_float413rs_allocationPDv4_fj", (void *)&SC_GetElementAt1_float4, true },
1188 { "_Z20rsGetElementAt_float13rs_allocationPfjj", (void *)&SC_GetElementAt2_float, true },
1189 { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjj", (void *)&SC_GetElementAt2_float2, true },
1190 { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjj", (void *)&SC_GetElementAt2_float3, true },
1191 { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjj", (void *)&SC_GetElementAt2_float4, true },
1192 { "_Z20rsGetElementAt_float13rs_allocationPfjjj", (void *)&SC_GetElementAt3_float, true },
1193 { "_Z21rsGetElementAt_float213rs_allocationPDv2_fjjj", (void *)&SC_GetElementAt3_float2, true },
1194 { "_Z21rsGetElementAt_float313rs_allocationPDv3_fjjj", (void *)&SC_GetElementAt3_float3, true },
1195 { "_Z21rsGetElementAt_float413rs_allocationPDv4_fjjj", (void *)&SC_GetElementAt3_float4, true },
1196
1197 { "_Z21rsGetElementAt_double13rs_allocationPdj", (void *)&SC_GetElementAt1_double, true },
1198 { "_Z22rsGetElementAt_double213rs_allocationPDv2_dj", (void *)&SC_GetElementAt1_double2, true },
1199 { "_Z22rsGetElementAt_double313rs_allocationPDv3_dj", (void *)&SC_GetElementAt1_double3, true },
1200 { "_Z22rsGetElementAt_double413rs_allocationPDv4_dj", (void *)&SC_GetElementAt1_double4, true },
1201 { "_Z21rsGetElementAt_double13rs_allocationPdjj", (void *)&SC_GetElementAt2_double, true },
1202 { "_Z22rsGetElementAt_double213rs_allocationPDv2_djj", (void *)&SC_GetElementAt2_double2, true },
1203 { "_Z22rsGetElementAt_double313rs_allocationPDv3_djj", (void *)&SC_GetElementAt2_double3, true },
1204 { "_Z22rsGetElementAt_double413rs_allocationPDv4_djj", (void *)&SC_GetElementAt2_double4, true },
1205 { "_Z21rsGetElementAt_double13rs_allocationPdjjj", (void *)&SC_GetElementAt3_double, true },
1206 { "_Z22rsGetElementAt_double213rs_allocationPDv2_djjj", (void *)&SC_GetElementAt3_double2, true },
1207 { "_Z22rsGetElementAt_double313rs_allocationPDv3_djjj", (void *)&SC_GetElementAt3_double3, true },
1208 { "_Z22rsGetElementAt_double413rs_allocationPDv4_djjj", (void *)&SC_GetElementAt3_double4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001209
1210
1211
Jason Samsd09b9d62013-04-02 20:07:04 -07001212 { "_Z20rsSetElementAt_uchar13rs_allocationPKhj", (void *)&SC_SetElementAt1_uchar, true },
1213 { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hj", (void *)&SC_SetElementAt1_uchar2, true },
1214 { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hj", (void *)&SC_SetElementAt1_uchar3, true },
1215 { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hj", (void *)&SC_SetElementAt1_uchar4, true },
1216 { "_Z20rsSetElementAt_uchar13rs_allocationPKhjj", (void *)&SC_SetElementAt2_uchar, true },
1217 { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjj", (void *)&SC_SetElementAt2_uchar2, true },
1218 { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjj", (void *)&SC_SetElementAt2_uchar3, true },
1219 { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjj", (void *)&SC_SetElementAt2_uchar4, true },
1220 { "_Z20rsSetElementAt_uchar13rs_allocationPKhjjj", (void *)&SC_SetElementAt3_uchar, true },
1221 { "_Z21rsSetElementAt_uchar213rs_allocationPKDv2_hjjj", (void *)&SC_SetElementAt3_uchar2, true },
1222 { "_Z21rsSetElementAt_uchar313rs_allocationPKDv3_hjjj", (void *)&SC_SetElementAt3_uchar3, true },
1223 { "_Z21rsSetElementAt_uchar413rs_allocationPKDv4_hjjj", (void *)&SC_SetElementAt3_uchar4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001224
Jason Samsd09b9d62013-04-02 20:07:04 -07001225 { "_Z19rsSetElementAt_char13rs_allocationPKcj", (void *)&SC_SetElementAt1_char, true },
1226 { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cj", (void *)&SC_SetElementAt1_char2, true },
1227 { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cj", (void *)&SC_SetElementAt1_char3, true },
1228 { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cj", (void *)&SC_SetElementAt1_char4, true },
1229 { "_Z19rsSetElementAt_char13rs_allocationPKcjj", (void *)&SC_SetElementAt2_char, true },
1230 { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjj", (void *)&SC_SetElementAt2_char2, true },
1231 { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjj", (void *)&SC_SetElementAt2_char3, true },
1232 { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjj", (void *)&SC_SetElementAt2_char4, true },
1233 { "_Z19rsSetElementAt_char13rs_allocationPKcjjj", (void *)&SC_SetElementAt3_char, true },
1234 { "_Z20rsSetElementAt_char213rs_allocationPKDv2_cjjj", (void *)&SC_SetElementAt3_char2, true },
1235 { "_Z20rsSetElementAt_char313rs_allocationPKDv3_cjjj", (void *)&SC_SetElementAt3_char3, true },
1236 { "_Z20rsSetElementAt_char413rs_allocationPKDv4_cjjj", (void *)&SC_SetElementAt3_char4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001237
Stephen Hines40db7a22015-01-06 01:50:16 -08001238 { "_Z21rsSetElementAt_ushort13rs_allocationPKtj", (void *)&SC_SetElementAt1_ushort, true },
Jason Samsd09b9d62013-04-02 20:07:04 -07001239 { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tj", (void *)&SC_SetElementAt1_ushort2, true },
1240 { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tj", (void *)&SC_SetElementAt1_ushort3, true },
1241 { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tj", (void *)&SC_SetElementAt1_ushort4, true },
1242 { "_Z21rsSetElementAt_ushort13rs_allocationPKtjj", (void *)&SC_SetElementAt2_ushort, true },
1243 { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjj", (void *)&SC_SetElementAt2_ushort2, true },
1244 { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjj", (void *)&SC_SetElementAt2_ushort3, true },
1245 { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjj", (void *)&SC_SetElementAt2_ushort4, true },
1246 { "_Z21rsSetElementAt_ushort13rs_allocationPKtjjj", (void *)&SC_SetElementAt3_ushort, true },
1247 { "_Z22rsSetElementAt_ushort213rs_allocationPKDv2_tjjj", (void *)&SC_SetElementAt3_ushort2, true },
1248 { "_Z22rsSetElementAt_ushort313rs_allocationPKDv3_tjjj", (void *)&SC_SetElementAt3_ushort3, true },
1249 { "_Z22rsSetElementAt_ushort413rs_allocationPKDv4_tjjj", (void *)&SC_SetElementAt3_ushort4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001250
Jason Samsd09b9d62013-04-02 20:07:04 -07001251 { "_Z20rsSetElementAt_short13rs_allocationPKsj", (void *)&SC_SetElementAt1_short, true },
1252 { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sj", (void *)&SC_SetElementAt1_short2, true },
1253 { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sj", (void *)&SC_SetElementAt1_short3, true },
1254 { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sj", (void *)&SC_SetElementAt1_short4, true },
1255 { "_Z20rsSetElementAt_short13rs_allocationPKsjj", (void *)&SC_SetElementAt2_short, true },
1256 { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjj", (void *)&SC_SetElementAt2_short2, true },
1257 { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjj", (void *)&SC_SetElementAt2_short3, true },
1258 { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjj", (void *)&SC_SetElementAt2_short4, true },
1259 { "_Z20rsSetElementAt_short13rs_allocationPKsjjj", (void *)&SC_SetElementAt3_short, true },
1260 { "_Z21rsSetElementAt_short213rs_allocationPKDv2_sjjj", (void *)&SC_SetElementAt3_short2, true },
1261 { "_Z21rsSetElementAt_short313rs_allocationPKDv3_sjjj", (void *)&SC_SetElementAt3_short3, true },
1262 { "_Z21rsSetElementAt_short413rs_allocationPKDv4_sjjj", (void *)&SC_SetElementAt3_short4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001263
Jason Samsd09b9d62013-04-02 20:07:04 -07001264 { "_Z19rsSetElementAt_uint13rs_allocationPKjj", (void *)&SC_SetElementAt1_uint, true },
1265 { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jj", (void *)&SC_SetElementAt1_uint2, true },
1266 { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jj", (void *)&SC_SetElementAt1_uint3, true },
1267 { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jj", (void *)&SC_SetElementAt1_uint4, true },
1268 { "_Z19rsSetElementAt_uint13rs_allocationPKjjj", (void *)&SC_SetElementAt2_uint, true },
1269 { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjj", (void *)&SC_SetElementAt2_uint2, true },
1270 { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjj", (void *)&SC_SetElementAt2_uint3, true },
1271 { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjj", (void *)&SC_SetElementAt2_uint4, true },
1272 { "_Z19rsSetElementAt_uint13rs_allocationPKjjjj", (void *)&SC_SetElementAt3_uint, true },
1273 { "_Z20rsSetElementAt_uint213rs_allocationPKDv2_jjjj", (void *)&SC_SetElementAt3_uint2, true },
1274 { "_Z20rsSetElementAt_uint313rs_allocationPKDv3_jjjj", (void *)&SC_SetElementAt3_uint3, true },
1275 { "_Z20rsSetElementAt_uint413rs_allocationPKDv4_jjjj", (void *)&SC_SetElementAt3_uint4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001276
Stephen Hinescca3d6c2013-04-15 01:06:39 -07001277 { "_Z18rsSetElementAt_int13rs_allocationPKij", (void *)&SC_SetElementAt1_int, true },
Jason Samsd09b9d62013-04-02 20:07:04 -07001278 { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ij", (void *)&SC_SetElementAt1_int2, true },
1279 { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ij", (void *)&SC_SetElementAt1_int3, true },
1280 { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ij", (void *)&SC_SetElementAt1_int4, true },
1281 { "_Z18rsSetElementAt_int13rs_allocationPKijj", (void *)&SC_SetElementAt2_int, true },
1282 { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijj", (void *)&SC_SetElementAt2_int2, true },
1283 { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijj", (void *)&SC_SetElementAt2_int3, true },
1284 { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijj", (void *)&SC_SetElementAt2_int4, true },
1285 { "_Z18rsSetElementAt_int13rs_allocationPKijjj", (void *)&SC_SetElementAt3_int, true },
1286 { "_Z19rsSetElementAt_int213rs_allocationPKDv2_ijjj", (void *)&SC_SetElementAt3_int2, true },
1287 { "_Z19rsSetElementAt_int313rs_allocationPKDv3_ijjj", (void *)&SC_SetElementAt3_int3, true },
1288 { "_Z19rsSetElementAt_int413rs_allocationPKDv4_ijjj", (void *)&SC_SetElementAt3_int4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001289
Tim Murraycbdb6482014-10-09 14:08:30 -07001290 { "_Z20rsSetElementAt_ulong13rs_allocationPKmj", (void *)&SC_SetElementAt1_ulong, true },
Jason Samsd09b9d62013-04-02 20:07:04 -07001291 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mj", (void *)&SC_SetElementAt1_ulong2, true },
1292 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mj", (void *)&SC_SetElementAt1_ulong3, true },
1293 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mj", (void *)&SC_SetElementAt1_ulong4, true },
1294 { "_Z20rsSetElementAt_ulong13rs_allocationPKmjj", (void *)&SC_SetElementAt2_ulong, true },
1295 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjj", (void *)&SC_SetElementAt2_ulong2, true },
1296 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjj", (void *)&SC_SetElementAt2_ulong3, true },
1297 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjj", (void *)&SC_SetElementAt2_ulong4, true },
1298 { "_Z20rsSetElementAt_ulong13rs_allocationPKmjjj", (void *)&SC_SetElementAt3_ulong, true },
1299 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_mjjj", (void *)&SC_SetElementAt3_ulong2, true },
1300 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_mjjj", (void *)&SC_SetElementAt3_ulong3, true },
1301 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_mjjj", (void *)&SC_SetElementAt3_ulong4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001302
Tim Murraycbdb6482014-10-09 14:08:30 -07001303 // Pre-21 compatibility path
1304 { "_Z20rsSetElementAt_ulong13rs_allocationPKyj", (void *)&SC_SetElementAt1_ulong, true },
1305 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yj", (void *)&SC_SetElementAt1_ulong2, true },
1306 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yj", (void *)&SC_SetElementAt1_ulong3, true },
1307 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yj", (void *)&SC_SetElementAt1_ulong4, true },
1308 { "_Z20rsSetElementAt_ulong13rs_allocationPKyjj", (void *)&SC_SetElementAt2_ulong, true },
1309 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yjj", (void *)&SC_SetElementAt2_ulong2, true },
1310 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yjj", (void *)&SC_SetElementAt2_ulong3, true },
1311 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yjj", (void *)&SC_SetElementAt2_ulong4, true },
1312 { "_Z20rsSetElementAt_ulong13rs_allocationPKyjjj", (void *)&SC_SetElementAt3_ulong, true },
1313 { "_Z21rsSetElementAt_ulong213rs_allocationPKDv2_yjjj", (void *)&SC_SetElementAt3_ulong2, true },
1314 { "_Z21rsSetElementAt_ulong313rs_allocationPKDv3_yjjj", (void *)&SC_SetElementAt3_ulong3, true },
1315 { "_Z21rsSetElementAt_ulong413rs_allocationPKDv4_yjjj", (void *)&SC_SetElementAt3_ulong4, true },
1316
Jason Samsd09b9d62013-04-02 20:07:04 -07001317 { "_Z19rsSetElementAt_long13rs_allocationPKlj", (void *)&SC_SetElementAt1_long, true },
1318 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_lj", (void *)&SC_SetElementAt1_long2, true },
1319 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_lj", (void *)&SC_SetElementAt1_long3, true },
1320 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_lj", (void *)&SC_SetElementAt1_long4, true },
1321 { "_Z19rsSetElementAt_long13rs_allocationPKljj", (void *)&SC_SetElementAt2_long, true },
1322 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljj", (void *)&SC_SetElementAt2_long2, true },
1323 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljj", (void *)&SC_SetElementAt2_long3, true },
1324 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljj", (void *)&SC_SetElementAt2_long4, true },
1325 { "_Z19rsSetElementAt_long13rs_allocationPKljjj", (void *)&SC_SetElementAt3_long, true },
1326 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_ljjj", (void *)&SC_SetElementAt3_long2, true },
1327 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_ljjj", (void *)&SC_SetElementAt3_long3, true },
1328 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_ljjj", (void *)&SC_SetElementAt3_long4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001329
Tim Murraycbdb6482014-10-09 14:08:30 -07001330 // Pre-21 compatibility path
1331 { "_Z19rsSetElementAt_long13rs_allocationPKxj", (void *)&SC_SetElementAt1_long, true },
1332 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xj", (void *)&SC_SetElementAt1_long2, true },
1333 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xj", (void *)&SC_SetElementAt1_long3, true },
1334 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xj", (void *)&SC_SetElementAt1_long4, true },
1335 { "_Z19rsSetElementAt_long13rs_allocationPKxjj", (void *)&SC_SetElementAt2_long, true },
1336 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xjj", (void *)&SC_SetElementAt2_long2, true },
1337 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xjj", (void *)&SC_SetElementAt2_long3, true },
1338 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xjj", (void *)&SC_SetElementAt2_long4, true },
1339 { "_Z19rsSetElementAt_long13rs_allocationPKxjjj", (void *)&SC_SetElementAt3_long, true },
1340 { "_Z20rsSetElementAt_long213rs_allocationPKDv2_xjjj", (void *)&SC_SetElementAt3_long2, true },
1341 { "_Z20rsSetElementAt_long313rs_allocationPKDv3_xjjj", (void *)&SC_SetElementAt3_long3, true },
1342 { "_Z20rsSetElementAt_long413rs_allocationPKDv4_xjjj", (void *)&SC_SetElementAt3_long4, true },
1343
Stephen Hines40db7a22015-01-06 01:50:16 -08001344 { "_Z20rsSetElementAt_float13rs_allocationPKfj", (void *)&SC_SetElementAt1_float, true },
Jason Samsd09b9d62013-04-02 20:07:04 -07001345 { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fj", (void *)&SC_SetElementAt1_float2, true },
1346 { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fj", (void *)&SC_SetElementAt1_float3, true },
1347 { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fj", (void *)&SC_SetElementAt1_float4, true },
1348 { "_Z20rsSetElementAt_float13rs_allocationPKfjj", (void *)&SC_SetElementAt2_float, true },
1349 { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjj", (void *)&SC_SetElementAt2_float2, true },
1350 { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjj", (void *)&SC_SetElementAt2_float3, true },
1351 { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjj", (void *)&SC_SetElementAt2_float4, true },
1352 { "_Z20rsSetElementAt_float13rs_allocationPKfjjj", (void *)&SC_SetElementAt3_float, true },
1353 { "_Z21rsSetElementAt_float213rs_allocationPKDv2_fjjj", (void *)&SC_SetElementAt3_float2, true },
1354 { "_Z21rsSetElementAt_float313rs_allocationPKDv3_fjjj", (void *)&SC_SetElementAt3_float3, true },
1355 { "_Z21rsSetElementAt_float413rs_allocationPKDv4_fjjj", (void *)&SC_SetElementAt3_float4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001356
Stephen Hines40db7a22015-01-06 01:50:16 -08001357 { "_Z21rsSetElementAt_double13rs_allocationPKdj", (void *)&SC_SetElementAt1_double, true },
Jason Samsd09b9d62013-04-02 20:07:04 -07001358 { "_Z22rsSetElementAt_double213rs_allocationPKDv2_dj", (void *)&SC_SetElementAt1_double2, true },
1359 { "_Z22rsSetElementAt_double313rs_allocationPKDv3_dj", (void *)&SC_SetElementAt1_double3, true },
1360 { "_Z22rsSetElementAt_double413rs_allocationPKDv4_dj", (void *)&SC_SetElementAt1_double4, true },
1361 { "_Z21rsSetElementAt_double13rs_allocationPKdjj", (void *)&SC_SetElementAt2_double, true },
1362 { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djj", (void *)&SC_SetElementAt2_double2, true },
1363 { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djj", (void *)&SC_SetElementAt2_double3, true },
1364 { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djj", (void *)&SC_SetElementAt2_double4, true },
1365 { "_Z21rsSetElementAt_double13rs_allocationPKdjjj", (void *)&SC_SetElementAt3_double, true },
1366 { "_Z22rsSetElementAt_double213rs_allocationPKDv2_djjj", (void *)&SC_SetElementAt3_double2, true },
1367 { "_Z22rsSetElementAt_double313rs_allocationPKDv3_djjj", (void *)&SC_SetElementAt3_double3, true },
1368 { "_Z22rsSetElementAt_double413rs_allocationPKDv4_djjj", (void *)&SC_SetElementAt3_double4, true },
Jason Sams5261a5e2013-02-27 15:46:24 -08001369
1370
Jason Sams87fe59a2011-04-20 15:09:01 -07001371 // Refcounting
Yong Chen444bd202014-08-14 18:28:38 +08001372#ifndef __LP64__
Jason Sams87fe59a2011-04-20 15:09:01 -07001373 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001374 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
1375
1376 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001377 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
1378
1379 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001380 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
1381
1382 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001383 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
1384
1385 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001386 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
Yong Chen444bd202014-08-14 18:28:38 +08001387#else
1388 { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject_ByRef, true },
1389 { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject_ByRef, true },
1390
1391 { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject_ByRef, true },
1392 { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject_ByRef, true },
1393
1394 { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject_ByRef, true },
1395 { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject_ByRef, true },
1396
1397 { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject_ByRef, true },
1398 { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject_ByRef, true },
1399
1400 { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject_ByRef, true },
1401 { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject_ByRef, true },
1402#endif
1403 { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
1404 { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
1405 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
1406 { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
1407 { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
Jason Sams87fe59a2011-04-20 15:09:01 -07001408
Jason Sams9e0afb52011-10-31 13:23:43 -07001409
Jason Sams87fe59a2011-04-20 15:09:01 -07001410 { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
1411 { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
1412 { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
1413
1414 { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
1415 { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
1416 { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
1417
1418 { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
1419 { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
1420 { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
1421
1422 { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
1423 { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
1424 { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
1425
1426 { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
1427 { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
1428 { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
1429
1430 { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
1431 { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
1432 { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
1433
1434 // Allocation ops
Jason Sams87fe59a2011-04-20 15:09:01 -07001435 { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
1436 { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
1437 { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
Alex Sakhartchouk74a82792011-06-14 11:13:19 -07001438 { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
Tim Murray0b575de2013-03-15 15:56:43 -07001439#ifndef RS_COMPATIBILITY_LIB
Tim Murray47211dc2014-08-21 14:12:43 -07001440 { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
Jason Samsb3220332012-04-02 14:41:54 -07001441 { "_Z18rsAllocationIoSend13rs_allocation", (void *)&SC_AllocationIoSend, false },
1442 { "_Z21rsAllocationIoReceive13rs_allocation", (void *)&SC_AllocationIoReceive, false },
Tim Murray0b575de2013-03-15 15:56:43 -07001443#endif
Alex Sakhartchouk74a82792011-06-14 11:13:19 -07001444 { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
1445 { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
Jason Sams87fe59a2011-04-20 15:09:01 -07001446
1447 // Messaging
1448
1449 { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
1450 { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
1451 { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
1452 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
Tim Murray0b575de2013-03-15 15:56:43 -07001453#ifndef RS_COMPATIBILITY_LIB
Jason Sams87fe59a2011-04-20 15:09:01 -07001454 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
1455 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
1456 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
1457 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
1458 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
1459 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
Alex Sakhartchouka720a142012-01-10 10:16:52 -08001460 { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
1461 { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
Jason Sams87fe59a2011-04-20 15:09:01 -07001462
1463 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
1464 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
1465 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
1466
1467 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
1468
1469 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
1470
1471 { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
1472 { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
1473
1474
1475 { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
1476 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
1477 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
1478 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
1479
1480 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
1481 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
1482 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
1483 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
1484
1485 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
1486 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
1487
1488 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
1489 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
1490 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
1491 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
1492
1493 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
1494 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
1495
1496 { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
1497 { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
1498 { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
1499 { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
1500 { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
Tim Murray1aa9dfc2014-08-06 11:49:02 -07001501
Jason Sams87fe59a2011-04-20 15:09:01 -07001502
Jason Samsaa152102012-06-13 15:16:44 -07001503 { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
1504 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
Stephen Hinesf5988112012-10-16 00:05:46 -07001505 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK14rs_script_call", (void *)&SC_ForEach_SAAUS, true },
Tim Murray2f6dc842014-11-14 13:27:05 -08001506
1507 //rsForEach with usrdata is not supported in 64-bit
1508#ifndef __LP64__
Jason Samsaa152102012-06-13 15:16:44 -07001509 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
Stephen Hinesf5988112012-10-16 00:05:46 -07001510 { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK14rs_script_call", (void *)&SC_ForEach_SAAULS, true },
Tim Murray2f6dc842014-11-14 13:27:05 -08001511#endif
Tim Murray1aa9dfc2014-08-06 11:49:02 -07001512#endif // RS_COMPATIBILITY_LIB
Jason Sams87fe59a2011-04-20 15:09:01 -07001513
Tim Murray64147eb2014-07-27 13:47:40 -07001514#ifndef __LP64__
Jason Sams87fe59a2011-04-20 15:09:01 -07001515 // time
1516 { "_Z6rsTimePi", (void *)&SC_Time, true },
1517 { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
Tim Murray64147eb2014-07-27 13:47:40 -07001518#else
1519 // time
1520 { "_Z6rsTimePl", (void *)&SC_Time, true },
1521 { "_Z11rsLocaltimeP5rs_tmPKl", (void *)&SC_LocalTime, true },
1522#endif
Jason Sams87fe59a2011-04-20 15:09:01 -07001523 { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
1524 { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
1525 { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
1526
1527 // misc
Tim Murray0b575de2013-03-15 15:56:43 -07001528#ifndef RS_COMPATIBILITY_LIB
Jason Sams87fe59a2011-04-20 15:09:01 -07001529 { "_Z5colorffff", (void *)&SC_Color, false },
1530 { "_Z9rsgFinishv", (void *)&SC_Finish, false },
Tim Murray0b575de2013-03-15 15:56:43 -07001531#endif
Jason Sams87fe59a2011-04-20 15:09:01 -07001532
Chris Wailes44bef6f2014-08-12 13:51:10 -07001533 { nullptr, nullptr, false }
Jason Sams87fe59a2011-04-20 15:09:01 -07001534};
1535
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001536#ifndef RS_COMPATIBILITY_LIB
1537
1538typedef struct { unsigned int val; } rs_allocation_usage_type;
1539
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001540void rsAllocationMarkDirty(::rs_allocation a) {
Yong Chen31729ad2014-11-12 15:20:18 +08001541 return SC_AllocationSyncAll(RS_CAST(a));
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -08001542}
1543
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001544void rsgAllocationSyncAll(::rs_allocation a) {
Yong Chen31729ad2014-11-12 15:20:18 +08001545 return SC_AllocationSyncAll(RS_CAST(a));
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001546}
1547
1548void rsgAllocationSyncAll(::rs_allocation a,
1549 unsigned int usage) {
Yong Chen31729ad2014-11-12 15:20:18 +08001550 return SC_AllocationSyncAll2(RS_CAST(a), (RsAllocationUsageType) usage);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001551}
1552void rsgAllocationSyncAll(::rs_allocation a,
1553 rs_allocation_usage_type source) {
Yong Chen31729ad2014-11-12 15:20:18 +08001554 return SC_AllocationSyncAll2(RS_CAST(a), (RsAllocationUsageType) source.val);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001555}
1556
1557void rsgBindProgramFragment(::rs_program_fragment pf) {
1558 return SC_BindProgramFragment((ProgramFragment *) pf.p);
1559}
1560
1561void rsgBindProgramStore(::rs_program_store ps) {
1562 return SC_BindProgramStore((ProgramStore *) ps.p);
1563}
1564
1565void rsgBindProgramVertex(::rs_program_vertex pv) {
1566 return SC_BindProgramVertex((ProgramVertex *) pv.p);
1567}
1568
1569void rsgBindProgramRaster(::rs_program_raster pr) {
1570 return SC_BindProgramRaster((ProgramRaster *) pr.p);
1571}
1572
1573void rsgBindSampler(::rs_program_fragment pf,
1574 uint32_t slot,
1575 ::rs_sampler s) {
1576 return SC_BindSampler((ProgramFragment *) pf.p, slot, (Sampler *) s.p);
1577}
1578
1579void rsgBindTexture(::rs_program_fragment pf,
1580 uint32_t slot,
1581 ::rs_allocation a) {
1582 return SC_BindTexture((ProgramFragment *) pf.p,
1583 slot,
1584 (Allocation *) a.p);
1585}
1586
1587void rsgBindConstant(::rs_program_fragment pf,
1588 uint32_t slot,
1589 ::rs_allocation a) {
1590 return SC_BindFragmentConstant((ProgramFragment *) pf.p,
1591 slot,
1592 (Allocation *) a.p);
1593}
1594
1595void rsgBindConstant(::rs_program_vertex pv,
1596 uint32_t slot,
1597 ::rs_allocation a) {
1598 return SC_BindVertexConstant((ProgramVertex *) pv.p,
1599 slot,
1600 (Allocation *) a.p);
1601}
1602
1603void rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *m) {
1604 return SC_VpLoadProjectionMatrix((const rsc_Matrix *) m);
1605}
1606
1607void rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *m) {
1608 return SC_VpLoadModelMatrix((const rsc_Matrix *) m);
1609}
1610
1611void rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *m) {
1612 return SC_VpLoadTextureMatrix((const rsc_Matrix *) m);
1613}
1614
1615void rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *m) {
1616 return SC_VpGetProjectionMatrix((rsc_Matrix *) m);
1617}
1618
1619void rsgProgramFragmentConstantColor(::rs_program_fragment pf,
1620 float r, float g,
1621 float b, float a) {
1622
1623 return SC_PfConstantColor((ProgramFragment *) pf.p, r, g, b, a);
1624}
1625
1626uint32_t rsgGetWidth(void) {
1627 return SC_GetWidth();
1628}
1629
1630uint32_t rsgGetHeight(void) {
1631 return SC_GetHeight();
1632}
1633
1634void rsgDrawRect(float x1, float y1, float x2, float y2, float z) {
1635 return SC_DrawRect(x1, y1, x2, y2, z);
1636}
1637
1638void rsgDrawQuad(float x1, float y1, float z1,
1639 float x2, float y2, float z2,
1640 float x3, float y3, float z3,
1641 float x4, float y4, float z4) {
1642
1643 SC_DrawQuad(x1, y1, z1,
1644 x2, y2, z2,
1645 x3, y3, z3,
1646 x4, y4, z4);
1647}
1648
1649void rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
1650 float x2, float y2, float z2, float u2, float v2,
1651 float x3, float y3, float z3, float u3, float v3,
1652 float x4, float y4, float z4, float u4, float v4) {
1653
1654 return rsgDrawQuadTexCoords(x1, y1, z1, u1, v1,
1655 x2, y2, z2, u2, v2,
1656 x3, y3, z3, u3, v3,
1657 x4, y4, z4, u4, v4);
1658}
1659
1660void rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h) {
1661 return SC_DrawSpriteScreenspace(x, y, z, w, h);
1662}
1663
1664void rsgDrawMesh(::rs_mesh ism) {
1665 return SC_DrawMesh((Mesh *) ism.p);
1666}
1667
1668void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex) {
1669 return SC_DrawMeshPrimitive((Mesh *) ism.p, primitiveIndex);
1670}
1671
1672void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex, uint start, uint len) {
1673 return SC_DrawMeshPrimitiveRange((Mesh *) ism.p, primitiveIndex, start, len);
1674}
1675
1676void rsgMeshComputeBoundingBox(::rs_mesh mesh,
1677 float *minX, float *minY, float *minZ,
1678 float *maxX, float *maxY, float *maxZ) {
1679
1680 return SC_MeshComputeBoundingBox((Mesh *) mesh.p,
1681 minX, minY, minZ,
1682 maxX, maxY, maxZ);
1683}
1684
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001685void rsgClearColor(float r, float g, float b, float a) {
1686 return SC_ClearColor(r, g, b, a);
1687}
1688
1689void rsgClearDepth(float value) {
1690 return SC_ClearDepth(value);
1691}
1692
1693void rsgDrawText(const char *text, int x, int y) {
1694 return SC_DrawText(text, x, y);
1695}
1696
1697void rsgDrawText(::rs_allocation a, int x, int y) {
1698 return SC_DrawTextAlloc((Allocation *) a.p, x, y);
1699}
1700
1701void rsgMeasureText(const char *text, int *left, int *right,
1702 int *top, int *bottom) {
1703 return SC_MeasureText(text, left, right, top, bottom);
1704}
1705
1706void rsgMeasureText(::rs_allocation a, int *left, int *right,
1707 int *top, int *bottom) {
1708 return SC_MeasureTextAlloc((Allocation *) a.p, left, right, top, bottom);
1709}
1710
1711void rsgBindFont(::rs_font font) {
1712 return SC_BindFont((Font *) font.p);
1713}
1714
1715void rsgFontColor(float r, float g, float b, float a) {
1716 return SC_FontColor(r, g, b, a);
1717}
1718
1719void rsgBindColorTarget(::rs_allocation a, uint slot) {
1720 return SC_BindFrameBufferObjectColorTarget((Allocation *) a.p, slot);
1721}
1722
1723void rsgBindDepthTarget(::rs_allocation a) {
1724 return SC_BindFrameBufferObjectDepthTarget((Allocation *) a.p);
1725}
1726
1727void rsgClearColorTarget(uint slot) {
1728 return SC_ClearFrameBufferObjectColorTarget(slot);
1729}
1730
1731void rsgClearDepthTarget(void) {
1732 return SC_ClearFrameBufferObjectDepthTarget(nullptr, nullptr);
1733}
1734
1735void rsgClearAllRenderTargets(void) {
1736 return SC_ClearFrameBufferObjectTargets(nullptr, nullptr);
1737}
1738
1739void color(float r, float g, float b, float a) {
1740 return SC_Color(r, g, b, a);
1741}
1742
1743void rsgFinish(void) {
1744 return SC_Finish();
1745}
1746
1747#endif
1748
Tim Murrayd6f1f462013-03-25 16:36:59 -07001749//////////////////////////////////////////////////////////////////////////////
1750// Compatibility Library entry points
1751//////////////////////////////////////////////////////////////////////////////
1752
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001753#ifndef __LP64__
1754#define IS_CLEAR_SET_OBJ(t, u, v) \
Stephen Hinesf827cad2013-11-18 16:47:55 -08001755 bool rsIsObject(t src) { \
Chris Wailes44bef6f2014-08-12 13:51:10 -07001756 return src.p != nullptr; \
Stephen Hinesf827cad2013-11-18 16:47:55 -08001757 } \
Tim Murrayd6f1f462013-03-25 16:36:59 -07001758 void __attribute__((overloadable)) rsClearObject(t *dst) { \
Jason Samsf29edf82014-08-05 14:59:22 -07001759 return SC_ClearObject(reinterpret_cast<rs_object_base *>(dst)); \
Tim Murrayd6f1f462013-03-25 16:36:59 -07001760 } \
1761 void __attribute__((overloadable)) rsSetObject(t *dst, t src) { \
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001762 android::renderscript::rs_object_base cast; \
1763 cast.p = (ObjectBase *) src.p; \
1764 return SC_SetObject(reinterpret_cast<rs_object_base *>(dst), cast);\
Tim Murrayd6f1f462013-03-25 16:36:59 -07001765 }
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001766#else
1767#define IS_CLEAR_SET_OBJ(t, u, v) \
1768 extern "C" { bool u(t* src) { \
1769 return src->p != nullptr; \
1770 } }\
1771 void __attribute__((overloadable)) rsClearObject(t *dst) { \
1772 return SC_ClearObject(reinterpret_cast<rs_object_base *>(dst)); \
1773 } \
1774 extern "C" {\
1775 void v (t *dst, t *src) { \
1776 return SC_SetObject_ByRef(reinterpret_cast<rs_object_base *>(dst),\
1777 reinterpret_cast<rs_object_base *>(src));\
1778 } }
1779#endif
Tim Murrayd6f1f462013-03-25 16:36:59 -07001780
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001781IS_CLEAR_SET_OBJ(::rs_element, _Z10rsIsObject10rs_element, _Z11rsSetObjectP10rs_elementS_)
1782IS_CLEAR_SET_OBJ(::rs_type, _Z10rsIsObject7rs_type, _Z11rsSetObjectP7rs_typeS_)
1783IS_CLEAR_SET_OBJ(::rs_allocation, _Z10rsIsObject13rs_allocation, _Z11rsSetObjectP13rs_allocationS_)
1784IS_CLEAR_SET_OBJ(::rs_sampler, _Z10rsIsObject10rs_sampler, _Z11rsSetObjectP10rs_samplerS_)
1785IS_CLEAR_SET_OBJ(::rs_script, _Z10rsIsObject9rs_script, _Z11rsSetObjectP9rs_scriptS_)
1786
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001787IS_CLEAR_SET_OBJ(::rs_mesh, _Z10rsIsObject7rs_mesh, _Z11rsSetObjectP7rs_meshS_)
1788IS_CLEAR_SET_OBJ(::rs_program_fragment, _Z10rsIsObject19rs_program_fragment, _Z11rsSetObjectP19rs_program_fragmentS_)
1789IS_CLEAR_SET_OBJ(::rs_program_vertex, _Z10rsIsObject17rs_program_vertex, _Z11rsSetObjectP17rs_program_vertexS_)
1790IS_CLEAR_SET_OBJ(::rs_program_raster, _Z10rsIsObject17rs_program_raster, _Z11rsSetObjectP17rs_program_rasterS_)
1791IS_CLEAR_SET_OBJ(::rs_program_store, _Z10rsIsObject16rs_program_store, _Z11rsSetObjectP16rs_program_storeS_)
1792IS_CLEAR_SET_OBJ(::rs_font, _Z10rsIsObject7rs_font, _Z11rsSetObjectP7rs_fontS_)
1793
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001794
Stephen Hinesf827cad2013-11-18 16:47:55 -08001795#undef IS_CLEAR_SET_OBJ
Tim Murrayd6f1f462013-03-25 16:36:59 -07001796
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001797#ifdef RS_COMPATIBILITY_LIB
Tim Murray47211dc2014-08-21 14:12:43 -07001798static const Allocation * SC_GetAllocation(const void *ptr) {
1799 Context *rsc = RsdCpuReference::getTlsContext();
1800 const Script *sc = RsdCpuReference::getTlsScript();
1801 return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
1802}
1803
Tim Murrayd6f1f462013-03-25 16:36:59 -07001804const Allocation * rsGetAllocation(const void *ptr) {
1805 return SC_GetAllocation(ptr);
1806}
1807
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001808#else
1809const android::renderscript::rs_allocation rsGetAllocation(const void *ptr) {
1810#ifdef __i386__
1811 android::renderscript::rs_allocation obj;
1812 obj.p = (Allocation *) SC_GetAllocation(ptr);
1813 return obj;
1814#else
1815 return SC_GetAllocation(ptr);
1816#endif
1817}
1818#endif
1819
1820
Jason Samsa36c50a2014-06-17 12:06:06 -07001821void __attribute__((overloadable)) rsAllocationIoSend(::rs_allocation a) {
Yong Chen31729ad2014-11-12 15:20:18 +08001822 SC_AllocationIoSend(RS_CAST(a));
Stephen Hines7a011262013-11-27 14:21:57 -08001823}
1824
Jason Samsa36c50a2014-06-17 12:06:06 -07001825void __attribute__((overloadable)) rsAllocationIoReceive(::rs_allocation a) {
Yong Chen31729ad2014-11-12 15:20:18 +08001826 SC_AllocationIoReceive(RS_CAST(a));
Stephen Hines7a011262013-11-27 14:21:57 -08001827}
1828
1829
1830void __attribute__((overloadable)) rsAllocationCopy1DRange(
Jason Samsa36c50a2014-06-17 12:06:06 -07001831 ::rs_allocation dstAlloc,
Stephen Hines7a011262013-11-27 14:21:57 -08001832 uint32_t dstOff, uint32_t dstMip, uint32_t count,
Jason Samsa36c50a2014-06-17 12:06:06 -07001833 ::rs_allocation srcAlloc,
Stephen Hines7a011262013-11-27 14:21:57 -08001834 uint32_t srcOff, uint32_t srcMip) {
Yong Chen31729ad2014-11-12 15:20:18 +08001835 SC_AllocationCopy1DRange(RS_CAST(dstAlloc), dstOff, dstMip, count,
1836 RS_CAST(srcAlloc), srcOff, srcMip);
Stephen Hines7a011262013-11-27 14:21:57 -08001837}
1838
1839void __attribute__((overloadable)) rsAllocationCopy2DRange(
Jason Samsa36c50a2014-06-17 12:06:06 -07001840 ::rs_allocation dstAlloc,
Stephen Hines7a011262013-11-27 14:21:57 -08001841 uint32_t dstXoff, uint32_t dstYoff,
1842 uint32_t dstMip, rs_allocation_cubemap_face dstFace,
1843 uint32_t width, uint32_t height,
Jason Samsa36c50a2014-06-17 12:06:06 -07001844 ::rs_allocation srcAlloc,
Stephen Hines7a011262013-11-27 14:21:57 -08001845 uint32_t srcXoff, uint32_t srcYoff,
1846 uint32_t srcMip, rs_allocation_cubemap_face srcFace) {
Yong Chen31729ad2014-11-12 15:20:18 +08001847 SC_AllocationCopy2DRange(RS_CAST(dstAlloc), dstXoff, dstYoff,
Stephen Hines7a011262013-11-27 14:21:57 -08001848 dstMip, dstFace, width, height,
Yong Chen31729ad2014-11-12 15:20:18 +08001849 RS_CAST(srcAlloc), srcXoff, srcYoff,
Stephen Hines7a011262013-11-27 14:21:57 -08001850 srcMip, srcFace);
1851}
1852
Jason Samsa36c50a2014-06-17 12:06:06 -07001853void __attribute__((overloadable)) rsForEach(::rs_script script,
1854 ::rs_allocation in,
1855 ::rs_allocation out,
Tim Murrayd6f1f462013-03-25 16:36:59 -07001856 const void *usr,
1857 const rs_script_call *call) {
Yong Chen31729ad2014-11-12 15:20:18 +08001858 return SC_ForEach_SAAUS(RS_CAST(script), RS_CAST(in), RS_CAST(out), usr, (RsScriptCall*)call);
Tim Murrayd6f1f462013-03-25 16:36:59 -07001859}
1860
Jason Samsa36c50a2014-06-17 12:06:06 -07001861void __attribute__((overloadable)) rsForEach(::rs_script script,
1862 ::rs_allocation in,
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001863 ::rs_allocation out,
1864 const void *usr) {
Yong Chen31729ad2014-11-12 15:20:18 +08001865 return SC_ForEach_SAAU(RS_CAST(script), RS_CAST(in), RS_CAST(out), usr);
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001866}
1867
1868void __attribute__((overloadable)) rsForEach(::rs_script script,
1869 ::rs_allocation in,
Jason Samsa36c50a2014-06-17 12:06:06 -07001870 ::rs_allocation out) {
Yong Chen31729ad2014-11-12 15:20:18 +08001871 return SC_ForEach_SAA(RS_CAST(script), RS_CAST(in), RS_CAST(out));
Stephen Hines276000a2013-12-03 09:33:32 -08001872}
1873
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -08001874#ifndef __LP64__
Jason Samsa36c50a2014-06-17 12:06:06 -07001875void __attribute__((overloadable)) rsForEach(::rs_script script,
1876 ::rs_allocation in,
1877 ::rs_allocation out,
Stephen Hines276000a2013-12-03 09:33:32 -08001878 const void *usr,
1879 uint32_t usrLen) {
Yong Chen31729ad2014-11-12 15:20:18 +08001880 return SC_ForEach_SAAUL(RS_CAST(script), RS_CAST(in), RS_CAST(out), usr, usrLen);
Stephen Hines276000a2013-12-03 09:33:32 -08001881}
1882
Jason Samsa36c50a2014-06-17 12:06:06 -07001883void __attribute__((overloadable)) rsForEach(::rs_script script,
1884 ::rs_allocation in,
1885 ::rs_allocation out,
Tim Murrayd6f1f462013-03-25 16:36:59 -07001886 const void *usr,
1887 uint32_t usrLen,
1888 const rs_script_call *call) {
Yong Chen31729ad2014-11-12 15:20:18 +08001889 return SC_ForEach_SAAULS(RS_CAST(script), RS_CAST(in), RS_CAST(out), usr, usrLen, (RsScriptCall*)call);
Tim Murrayd6f1f462013-03-25 16:36:59 -07001890}
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -08001891#endif
Tim Murrayd6f1f462013-03-25 16:36:59 -07001892
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001893// #if defined(RS_COMPATIBILITY_LIB) || !defined(__LP64__)
1894#ifndef __LP64__
Tim Murrayd6f1f462013-03-25 16:36:59 -07001895int rsTime(int *timer) {
1896 return SC_Time(timer);
1897}
Stephen Hines140a8eb2015-01-16 19:20:26 -08001898
1899rs_tm* rsLocaltime(rs_tm* local, const int *timer) {
1900 return (rs_tm*)(SC_LocalTime((tm*)local, (time_t *)timer));
1901}
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001902#else
1903time_t rsTime(time_t * timer) {
1904 return SC_Time(timer);
1905}
Tim Murrayd6f1f462013-03-25 16:36:59 -07001906
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001907rs_tm* rsLocaltime(rs_tm* local, const time_t *timer) {
1908 return (rs_tm*)(SC_LocalTime((tm*)local, (time_t *)timer));
Tim Murrayd6f1f462013-03-25 16:36:59 -07001909}
Stephen Hines140a8eb2015-01-16 19:20:26 -08001910#endif // RS_COMPATIBILITY_LIB
Tim Murrayd6f1f462013-03-25 16:36:59 -07001911
1912int64_t rsUptimeMillis() {
1913 Context *rsc = RsdCpuReference::getTlsContext();
1914 return rsrUptimeMillis(rsc);
1915}
1916
Stephen Hinescadee382013-12-12 13:21:00 -08001917int64_t rsUptimeNanos() {
1918 return SC_UptimeNanos();
1919}
1920
1921float rsGetDt() {
1922 return SC_GetDt();
1923}
1924
Stephen Hines276000a2013-12-03 09:33:32 -08001925uint32_t rsSendToClient(int cmdID) {
1926 return SC_ToClient(cmdID);
1927}
1928
1929uint32_t rsSendToClient(int cmdID, const void *data, uint32_t len) {
1930 return SC_ToClient2(cmdID, data, len);
Tim Murrayd6f1f462013-03-25 16:36:59 -07001931}
1932
Tim Murray0b575de2013-03-15 15:56:43 -07001933uint32_t rsSendToClientBlocking(int cmdID) {
Stephen Hines276000a2013-12-03 09:33:32 -08001934 return SC_ToClientBlocking(cmdID);
1935}
1936
1937uint32_t rsSendToClientBlocking(int cmdID, const void *data, uint32_t len) {
1938 return SC_ToClientBlocking2(cmdID, data, len);
Tim Murray0b575de2013-03-15 15:56:43 -07001939}
1940
1941static void SC_debugF(const char *s, float f) {
1942 ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
1943}
1944static void SC_debugFv2(const char *s, float f1, float f2) {
1945 ALOGD("%s {%f, %f}", s, f1, f2);
1946}
1947static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
1948 ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
1949}
1950static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
1951 ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
1952}
1953static void SC_debugF2(const char *s, float2 f) {
1954 ALOGD("%s {%f, %f}", s, f.x, f.y);
1955}
1956static void SC_debugF3(const char *s, float3 f) {
1957 ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
1958}
1959static void SC_debugF4(const char *s, float4 f) {
1960 ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
1961}
1962static void SC_debugD(const char *s, double d) {
1963 ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
1964}
Jean-Luc Brouillet6ba05172015-04-03 16:39:18 -07001965static void SC_debugD2(const char *s, double2 d) {
1966 ALOGD("%s {%f, %f}", s, d.x, d.y);
1967}
1968static void SC_debugD3(const char *s, double3 d) {
1969 ALOGD("%s {%f, %f, %f}", s, d.x, d.y, d.z);
1970}
1971static void SC_debugD4(const char *s, double4 d) {
1972 ALOGD("%s {%f, %f, %f, %f}", s, d.x, d.y, d.z, d.w);
1973}
Tim Murray0b575de2013-03-15 15:56:43 -07001974static void SC_debugFM4v4(const char *s, const float *f) {
1975 ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
1976 ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
1977 ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
1978 ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
1979}
1980static void SC_debugFM3v3(const char *s, const float *f) {
1981 ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
1982 ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
1983 ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
1984}
1985static void SC_debugFM2v2(const char *s, const float *f) {
1986 ALOGD("%s {%f, %f", s, f[0], f[2]);
1987 ALOGD("%s %f, %f}",s, f[1], f[3]);
1988}
1989static void SC_debugI8(const char *s, char c) {
1990 ALOGD("%s %hhd 0x%hhx", s, c, (unsigned char)c);
1991}
1992static void SC_debugC2(const char *s, char2 c) {
1993 ALOGD("%s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
1994}
1995static void SC_debugC3(const char *s, char3 c) {
1996 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);
1997}
1998static void SC_debugC4(const char *s, char4 c) {
1999 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);
2000}
2001static void SC_debugU8(const char *s, unsigned char c) {
2002 ALOGD("%s %hhu 0x%hhx", s, c, c);
2003}
2004static void SC_debugUC2(const char *s, uchar2 c) {
2005 ALOGD("%s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
2006}
2007static void SC_debugUC3(const char *s, uchar3 c) {
2008 ALOGD("%s {%hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2009}
2010static void SC_debugUC4(const char *s, uchar4 c) {
2011 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);
2012}
2013static void SC_debugI16(const char *s, short c) {
2014 ALOGD("%s %hd 0x%hx", s, c, c);
2015}
2016static void SC_debugS2(const char *s, short2 c) {
2017 ALOGD("%s {%hd, %hd} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
2018}
2019static void SC_debugS3(const char *s, short3 c) {
2020 ALOGD("%s {%hd, %hd, %hd} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2021}
2022static void SC_debugS4(const char *s, short4 c) {
2023 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);
2024}
2025static void SC_debugU16(const char *s, unsigned short c) {
2026 ALOGD("%s %hu 0x%hx", s, c, c);
2027}
2028static void SC_debugUS2(const char *s, ushort2 c) {
2029 ALOGD("%s {%hu, %hu} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
2030}
2031static void SC_debugUS3(const char *s, ushort3 c) {
2032 ALOGD("%s {%hu, %hu, %hu} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
2033}
2034static void SC_debugUS4(const char *s, ushort4 c) {
2035 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);
2036}
2037static void SC_debugI32(const char *s, int32_t i) {
2038 ALOGD("%s %d 0x%x", s, i, i);
2039}
2040static void SC_debugI2(const char *s, int2 i) {
2041 ALOGD("%s {%d, %d} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
2042}
2043static void SC_debugI3(const char *s, int3 i) {
2044 ALOGD("%s {%d, %d, %d} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
2045}
2046static void SC_debugI4(const char *s, int4 i) {
2047 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);
2048}
2049static void SC_debugU32(const char *s, uint32_t i) {
2050 ALOGD("%s %u 0x%x", s, i, i);
2051}
2052static void SC_debugUI2(const char *s, uint2 i) {
2053 ALOGD("%s {%u, %u} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
2054}
2055static void SC_debugUI3(const char *s, uint3 i) {
2056 ALOGD("%s {%u, %u, %u} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
2057}
2058static void SC_debugUI4(const char *s, uint4 i) {
2059 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);
2060}
Miao Wang127d51c2014-11-24 13:41:33 -08002061
2062template <typename T>
2063static inline long long LL(const T &x) {
2064 return static_cast<long long>(x);
2065}
2066
2067template <typename T>
2068static inline unsigned long long LLu(const T &x) {
2069 return static_cast<unsigned long long>(x);
2070}
2071
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08002072static void SC_debugLL64(const char *s, long long ll) {
2073 ALOGD("%s %lld 0x%llx", s, LL(ll), LL(ll));
2074}
2075
Tim Murray0b575de2013-03-15 15:56:43 -07002076static void SC_debugL2(const char *s, long2 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002077 ALOGD("%s {%lld, %lld} 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.x), LL(ll.y));
Tim Murray0b575de2013-03-15 15:56:43 -07002078}
2079static void SC_debugL3(const char *s, long3 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002080 ALOGD("%s {%lld, %lld, %lld} 0x%llx 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.x), LL(ll.y), LL(ll.z));
Tim Murray0b575de2013-03-15 15:56:43 -07002081}
2082static void SC_debugL4(const char *s, long4 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002083 ALOGD("%s {%lld, %lld, %lld, %lld} 0x%llx 0x%llx 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.w), LL(ll.x), LL(ll.y), LL(ll.z), LL(ll.w));
Tim Murray0b575de2013-03-15 15:56:43 -07002084}
2085static void SC_debugULL64(const char *s, unsigned long long ll) {
2086 ALOGD("%s %llu 0x%llx", s, ll, ll);
2087}
2088static void SC_debugUL2(const char *s, ulong2 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002089 ALOGD("%s {%llu, %llu} 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.x), LLu(ll.y));
Tim Murray0b575de2013-03-15 15:56:43 -07002090}
2091static void SC_debugUL3(const char *s, ulong3 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002092 ALOGD("%s {%llu, %llu, %llu} 0x%llx 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.x), LLu(ll.y), LLu(ll.z));
Tim Murray0b575de2013-03-15 15:56:43 -07002093}
2094static void SC_debugUL4(const char *s, ulong4 ll) {
Miao Wang127d51c2014-11-24 13:41:33 -08002095 ALOGD("%s {%llu, %llu, %llu, %llu} 0x%llx 0x%llx 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.w), LLu(ll.x), LLu(ll.y), LLu(ll.z), LLu(ll.w));
Tim Murray0b575de2013-03-15 15:56:43 -07002096}
Miao Wang127d51c2014-11-24 13:41:33 -08002097
Tim Murray0b575de2013-03-15 15:56:43 -07002098static void SC_debugP(const char *s, const void *p) {
2099 ALOGD("%s %p", s, p);
2100}
2101
2102// TODO: allocation ops, messaging, time
2103
2104void rsDebug(const char *s, float f) {
2105 SC_debugF(s, f);
2106}
2107
2108void rsDebug(const char *s, float f1, float f2) {
2109 SC_debugFv2(s, f1, f2);
2110}
2111
2112void rsDebug(const char *s, float f1, float f2, float f3) {
2113 SC_debugFv3(s, f1, f2, f3);
2114}
2115
2116void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
2117 SC_debugFv4(s, f1, f2, f3, f4);
2118}
2119
Stephen Hinesb0934b62013-07-03 17:27:38 -07002120void rsDebug(const char *s, const float2 *f) {
2121 SC_debugF2(s, *f);
Tim Murray0b575de2013-03-15 15:56:43 -07002122}
2123
Stephen Hinesb0934b62013-07-03 17:27:38 -07002124void rsDebug(const char *s, const float3 *f) {
2125 SC_debugF3(s, *f);
Tim Murray0b575de2013-03-15 15:56:43 -07002126}
2127
Stephen Hinesb0934b62013-07-03 17:27:38 -07002128void rsDebug(const char *s, const float4 *f) {
2129 SC_debugF4(s, *f);
Tim Murray0b575de2013-03-15 15:56:43 -07002130}
2131
2132void rsDebug(const char *s, double d) {
2133 SC_debugD(s, d);
2134}
2135
Jean-Luc Brouillet6ba05172015-04-03 16:39:18 -07002136void rsDebug(const char *s, const double2 *d) {
2137 SC_debugD2(s, *d);
2138}
2139
2140void rsDebug(const char *s, const double3 *d) {
2141 SC_debugD3(s, *d);
2142}
2143
2144void rsDebug(const char *s, const double4 *d) {
2145 SC_debugD4(s, *d);
2146}
2147
Stephen Hinesb0934b62013-07-03 17:27:38 -07002148void rsDebug(const char *s, const rs_matrix4x4 *m) {
Tim Murray0b575de2013-03-15 15:56:43 -07002149 SC_debugFM4v4(s, (float *) m);
2150}
2151
Stephen Hinesb0934b62013-07-03 17:27:38 -07002152void rsDebug(const char *s, const rs_matrix3x3 *m) {
Tim Murrayd6f1f462013-03-25 16:36:59 -07002153 SC_debugFM3v3(s, (float *) m);
Tim Murray0b575de2013-03-15 15:56:43 -07002154}
2155
Stephen Hinesb0934b62013-07-03 17:27:38 -07002156void rsDebug(const char *s, const rs_matrix2x2 *m) {
Tim Murrayd6f1f462013-03-25 16:36:59 -07002157 SC_debugFM2v2(s, (float *) m);
Tim Murray0b575de2013-03-15 15:56:43 -07002158}
2159
2160void rsDebug(const char *s, char c) {
2161 SC_debugI8(s, c);
2162}
2163
Stephen Hinesb0934b62013-07-03 17:27:38 -07002164void rsDebug(const char *s, const char2 *c) {
2165 SC_debugC2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002166}
2167
Stephen Hinesb0934b62013-07-03 17:27:38 -07002168void rsDebug(const char *s, const char3 *c) {
2169 SC_debugC3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002170}
2171
Stephen Hinesb0934b62013-07-03 17:27:38 -07002172void rsDebug(const char *s, const char4 *c) {
2173 SC_debugC4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002174}
2175
2176void rsDebug(const char *s, unsigned char c) {
2177 SC_debugU8(s, c);
2178}
2179
Stephen Hinesb0934b62013-07-03 17:27:38 -07002180void rsDebug(const char *s, const uchar2 *c) {
2181 SC_debugUC2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002182}
2183
Stephen Hinesb0934b62013-07-03 17:27:38 -07002184void rsDebug(const char *s, const uchar3 *c) {
2185 SC_debugUC3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002186}
2187
Stephen Hinesb0934b62013-07-03 17:27:38 -07002188void rsDebug(const char *s, const uchar4 *c) {
2189 SC_debugUC4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002190}
2191
2192void rsDebug(const char *s, short c) {
2193 SC_debugI16(s, c);
2194}
2195
Stephen Hinesb0934b62013-07-03 17:27:38 -07002196void rsDebug(const char *s, const short2 *c) {
2197 SC_debugS2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002198}
2199
Stephen Hinesb0934b62013-07-03 17:27:38 -07002200void rsDebug(const char *s, const short3 *c) {
2201 SC_debugS3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002202}
2203
Stephen Hinesb0934b62013-07-03 17:27:38 -07002204void rsDebug(const char *s, const short4 *c) {
2205 SC_debugS4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002206}
2207
2208void rsDebug(const char *s, unsigned short c) {
2209 SC_debugU16(s, c);
2210}
2211
Stephen Hinesb0934b62013-07-03 17:27:38 -07002212void rsDebug(const char *s, const ushort2 *c) {
2213 SC_debugUS2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002214}
2215
Stephen Hinesb0934b62013-07-03 17:27:38 -07002216void rsDebug(const char *s, const ushort3 *c) {
2217 SC_debugUS3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002218}
2219
Stephen Hinesb0934b62013-07-03 17:27:38 -07002220void rsDebug(const char *s, const ushort4 *c) {
2221 SC_debugUS4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002222}
2223
2224void rsDebug(const char *s, int c) {
2225 SC_debugI32(s, c);
2226}
2227
Stephen Hinesb0934b62013-07-03 17:27:38 -07002228void rsDebug(const char *s, const int2 *c) {
2229 SC_debugI2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002230}
2231
Stephen Hinesb0934b62013-07-03 17:27:38 -07002232void rsDebug(const char *s, const int3 *c) {
2233 SC_debugI3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002234}
2235
Stephen Hinesb0934b62013-07-03 17:27:38 -07002236void rsDebug(const char *s, const int4 *c) {
2237 SC_debugI4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002238}
2239
2240void rsDebug(const char *s, unsigned int c) {
2241 SC_debugU32(s, c);
2242}
2243
Stephen Hinesb0934b62013-07-03 17:27:38 -07002244void rsDebug(const char *s, const uint2 *c) {
2245 SC_debugUI2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002246}
2247
Stephen Hinesb0934b62013-07-03 17:27:38 -07002248void rsDebug(const char *s, const uint3 *c) {
2249 SC_debugUI3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002250}
2251
Stephen Hinesb0934b62013-07-03 17:27:38 -07002252void rsDebug(const char *s, const uint4 *c) {
2253 SC_debugUI4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002254}
2255
2256void rsDebug(const char *s, long c) {
2257 SC_debugLL64(s, c);
2258}
2259
2260void rsDebug(const char *s, long long c) {
2261 SC_debugLL64(s, c);
2262}
2263
Stephen Hinesb0934b62013-07-03 17:27:38 -07002264void rsDebug(const char *s, const long2 *c) {
2265 SC_debugL2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002266}
2267
Stephen Hinesb0934b62013-07-03 17:27:38 -07002268void rsDebug(const char *s, const long3 *c) {
2269 SC_debugL3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002270}
2271
Stephen Hinesb0934b62013-07-03 17:27:38 -07002272void rsDebug(const char *s, const long4 *c) {
2273 SC_debugL4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002274}
2275
2276void rsDebug(const char *s, unsigned long c) {
2277 SC_debugULL64(s, c);
2278}
2279
2280void rsDebug(const char *s, unsigned long long c) {
2281 SC_debugULL64(s, c);
2282}
2283
Stephen Hinesb0934b62013-07-03 17:27:38 -07002284void rsDebug(const char *s, const ulong2 *c) {
2285 SC_debugUL2(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002286}
2287
Stephen Hinesb0934b62013-07-03 17:27:38 -07002288void rsDebug(const char *s, const ulong3 *c) {
2289 SC_debugUL3(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002290}
2291
Stephen Hinesb0934b62013-07-03 17:27:38 -07002292void rsDebug(const char *s, const ulong4 *c) {
2293 SC_debugUL4(s, *c);
Tim Murray0b575de2013-03-15 15:56:43 -07002294}
2295
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08002296// FIXME: We need to export these function signatures for the compatibility
2297// library. The C++ name mangling that LLVM uses for ext_vector_type requires
2298// different versions for "long" vs. "long long". Note that the called
2299// functions are still using the appropriate 64-bit sizes.
Miao Wang127d51c2014-11-24 13:41:33 -08002300
2301#ifndef __LP64__
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08002302typedef long l2 __attribute__((ext_vector_type(2)));
2303typedef long l3 __attribute__((ext_vector_type(3)));
2304typedef long l4 __attribute__((ext_vector_type(4)));
2305typedef unsigned long ul2 __attribute__((ext_vector_type(2)));
2306typedef unsigned long ul3 __attribute__((ext_vector_type(3)));
2307typedef unsigned long ul4 __attribute__((ext_vector_type(4)));
2308
2309void rsDebug(const char *s, const l2 *c) {
2310 SC_debugL2(s, *(const long2 *)c);
2311}
2312
2313void rsDebug(const char *s, const l3 *c) {
2314 SC_debugL3(s, *(const long3 *)c);
2315}
2316
2317void rsDebug(const char *s, const l4 *c) {
2318 SC_debugL4(s, *(const long4 *)c);
2319}
2320
2321void rsDebug(const char *s, const ul2 *c) {
2322 SC_debugUL2(s, *(const ulong2 *)c);
2323}
2324
2325void rsDebug(const char *s, const ul3 *c) {
2326 SC_debugUL3(s, *(const ulong3 *)c);
2327}
2328
2329void rsDebug(const char *s, const ul4 *c) {
2330 SC_debugUL4(s, *(const ulong4 *)c);
2331}
Miao Wang127d51c2014-11-24 13:41:33 -08002332#endif
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08002333
Tim Murray9f39aaf2014-10-13 12:35:32 -07002334void rsDebug(const char *s, const long2 c) {
2335 SC_debugL2(s, c);
2336}
2337
2338void rsDebug(const char *s, const long3 c) {
2339 SC_debugL3(s, c);
2340}
2341
2342void rsDebug(const char *s, const long4 c) {
2343 SC_debugL4(s, c);
2344}
2345
2346void rsDebug(const char *s, const ulong2 c) {
2347 SC_debugUL2(s, c);
2348}
2349
2350void rsDebug(const char *s, const ulong3 c) {
2351 SC_debugUL3(s, c);
2352}
2353
2354void rsDebug(const char *s, const ulong4 c) {
2355 SC_debugUL4(s, c);
2356}
2357
2358
Tim Murray0b575de2013-03-15 15:56:43 -07002359void rsDebug(const char *s, const void *p) {
2360 SC_debugP(s, p);
2361}
Jason Sams87fe59a2011-04-20 15:09:01 -07002362
Jason Sams709a0972012-11-15 18:18:04 -08002363extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
Jason Sams87fe59a2011-04-20 15:09:01 -07002364 ScriptC *s = (ScriptC *)pContext;
Jason Sams709a0972012-11-15 18:18:04 -08002365 const RsdCpuReference::CpuSymbol *syms = gSyms;
Chris Wailes44bef6f2014-08-12 13:51:10 -07002366 const RsdCpuReference::CpuSymbol *sym = nullptr;
Jason Sams87fe59a2011-04-20 15:09:01 -07002367
2368 if (!sym) {
Jason Sams709a0972012-11-15 18:18:04 -08002369 while (syms->fnPtr) {
2370 if (!strcmp(syms->name, name)) {
2371 return syms;
Jason Sams87fe59a2011-04-20 15:09:01 -07002372 }
2373 syms++;
2374 }
2375 }
2376
Chris Wailes44bef6f2014-08-12 13:51:10 -07002377 return nullptr;
Jason Sams87fe59a2011-04-20 15:09:01 -07002378}