blob: 2627ae682c7d7bf0dfaecf82d2ebd9c7a264aae9 [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"
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -070018#include "rsElement.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070019#include "rsScriptC.h"
20#include "rsMatrix4x4.h"
21#include "rsMatrix3x3.h"
22#include "rsMatrix2x2.h"
23#include "rsRuntime.h"
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -070024#include "rsType.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070025
Jason Sams87fe59a2011-04-20 15:09:01 -070026#include "rsdCore.h"
Jason Sams807fdc42012-07-25 17:55:39 -070027#include "rsdBcc.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070028
Jason Samsb3220332012-04-02 14:41:54 -070029#include "rsdAllocation.h"
Stephen Hines414a4612012-09-05 18:05:08 -070030#include "rsdShaderCache.h"
31#include "rsdVertexArray.h"
Jason Sams87fe59a2011-04-20 15:09:01 -070032
33#include <time.h>
34
Miao Wang59f61422017-03-14 14:23:52 -070035#if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
Chih-Hung Hsiehe939ce72016-11-15 16:27:11 -080036using android::renderscript::Font;
37#endif
38
39using android::renderscript::Allocation;
40using android::renderscript::Context;
41using android::renderscript::Element;
42using android::renderscript::RsdCpuReference;
43using android::renderscript::Mesh;
44using android::renderscript::ObjectBase;
45using android::renderscript::ObjectBaseRef;
46using android::renderscript::ProgramFragment;
47using android::renderscript::ProgramRaster;
48using android::renderscript::ProgramStore;
49using android::renderscript::ProgramVertex;
50using android::renderscript::Sampler;
51using android::renderscript::Script;
52using android::renderscript::Type;
53using android::renderscript::rs_object_base;
Jason Sams87fe59a2011-04-20 15:09:01 -070054
Pirama Arumuga Nainar63bd6462015-11-11 12:09:11 -080055typedef __fp16 half;
56typedef half half2 __attribute__((ext_vector_type(2)));
57typedef half half3 __attribute__((ext_vector_type(3)));
58typedef half half4 __attribute__((ext_vector_type(4)));
59
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070060typedef float float2 __attribute__((ext_vector_type(2)));
61typedef float float3 __attribute__((ext_vector_type(3)));
62typedef float float4 __attribute__((ext_vector_type(4)));
Jason Sams5261a5e2013-02-27 15:46:24 -080063typedef double double2 __attribute__((ext_vector_type(2)));
64typedef double double3 __attribute__((ext_vector_type(3)));
65typedef double double4 __attribute__((ext_vector_type(4)));
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070066typedef char char2 __attribute__((ext_vector_type(2)));
67typedef char char3 __attribute__((ext_vector_type(3)));
68typedef char char4 __attribute__((ext_vector_type(4)));
69typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
70typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
71typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
Jason Samsd8b8f8a2014-08-19 17:53:08 -070072typedef int16_t short2 __attribute__((ext_vector_type(2)));
73typedef int16_t short3 __attribute__((ext_vector_type(3)));
74typedef int16_t short4 __attribute__((ext_vector_type(4)));
75typedef uint16_t ushort2 __attribute__((ext_vector_type(2)));
76typedef uint16_t ushort3 __attribute__((ext_vector_type(3)));
77typedef uint16_t ushort4 __attribute__((ext_vector_type(4)));
Rajeev Sharmaa1dd74c2012-07-09 03:14:47 -070078typedef int32_t int2 __attribute__((ext_vector_type(2)));
79typedef int32_t int3 __attribute__((ext_vector_type(3)));
80typedef int32_t int4 __attribute__((ext_vector_type(4)));
81typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
82typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
83typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
Jason Samsd8b8f8a2014-08-19 17:53:08 -070084typedef int64_t long2 __attribute__((ext_vector_type(2)));
85typedef int64_t long3 __attribute__((ext_vector_type(3)));
86typedef int64_t long4 __attribute__((ext_vector_type(4)));
87typedef uint64_t ulong2 __attribute__((ext_vector_type(2)));
88typedef uint64_t ulong3 __attribute__((ext_vector_type(3)));
89typedef uint64_t ulong4 __attribute__((ext_vector_type(4)));
Jason Sams87fe59a2011-04-20 15:09:01 -070090
Jason Sams5261a5e2013-02-27 15:46:24 -080091typedef uint8_t uchar;
92typedef uint16_t ushort;
93typedef uint32_t uint;
94typedef uint64_t ulong;
Jason Sams87fe59a2011-04-20 15:09:01 -070095
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -070096// Add NOLINT to suppress wrong warnings from clang-tidy.
Miao Wang127d51c2014-11-24 13:41:33 -080097#ifndef __LP64__
Tim Murrayd6f1f462013-03-25 16:36:59 -070098#define OPAQUETYPE(t) \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -070099 typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t; /*NOLINT*/
Miao Wang127d51c2014-11-24 13:41:33 -0800100#else
101#define OPAQUETYPE(t) \
I-Jui (Ray) Sung700e6882017-03-06 14:42:53 -0800102 typedef struct { const void* p; const void* unused1; const void* unused2; const void* unused3; } t; /*NOLINT*/
Miao Wang127d51c2014-11-24 13:41:33 -0800103#endif
Tim Murrayd6f1f462013-03-25 16:36:59 -0700104
105OPAQUETYPE(rs_element)
106OPAQUETYPE(rs_type)
107OPAQUETYPE(rs_allocation)
108OPAQUETYPE(rs_sampler)
109OPAQUETYPE(rs_script)
110OPAQUETYPE(rs_script_call)
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800111
112OPAQUETYPE(rs_program_fragment);
113OPAQUETYPE(rs_program_store);
114OPAQUETYPE(rs_program_vertex);
115OPAQUETYPE(rs_program_raster);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800116OPAQUETYPE(rs_mesh);
117OPAQUETYPE(rs_font);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800118
Tim Murrayd6f1f462013-03-25 16:36:59 -0700119#undef OPAQUETYPE
120
Stephen Hines7a011262013-11-27 14:21:57 -0800121typedef enum {
122 // Empty to avoid conflicting definitions with RsAllocationCubemapFace
123} rs_allocation_cubemap_face;
124
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700125typedef enum {
126 // Empty to avoid conflicting definitions with RsYuvFormat
127} rs_yuv_format;
128
129typedef enum {
130 // Empty to avoid conflicting definitions with RsAllocationMipmapControl
131} rs_allocation_mipmap_control;
132
Yong Chen174ebc42015-03-27 17:56:09 +0800133typedef struct { unsigned int val; } rs_allocation_usage_type;
134
Tim Murrayd6f1f462013-03-25 16:36:59 -0700135typedef struct {
136 int tm_sec; ///< seconds
137 int tm_min; ///< minutes
138 int tm_hour; ///< hours
139 int tm_mday; ///< day of the month
140 int tm_mon; ///< month
141 int tm_year; ///< year
142 int tm_wday; ///< day of the week
143 int tm_yday; ///< day of the year
144 int tm_isdst; ///< daylight savings time
145} rs_tm;
Tim Murrayd6f1f462013-03-25 16:36:59 -0700146
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800147// Some RS functions are not threadsafe but can be called from an invoke
148// function. Instead of summarily marking scripts that call these functions as
149// not-threadable we detect calls to them in the driver and sends a fatal error
150// message.
151static bool failIfInKernel(Context *rsc, const char *funcName) {
152 RsdHal *dc = (RsdHal *)rsc->mHal.drv;
153 RsdCpuReference *impl = (RsdCpuReference *) dc->mCpuRef;
154
David Gross35dbc8c2016-03-29 13:48:41 -0700155 if (impl->getInKernel()) {
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800156 char buf[256];
Miao Wang68e00892016-02-25 12:44:10 -0800157 snprintf(buf, sizeof(buf), "Error: Call to unsupported function %s "
Pirama Arumuga Nainar7153e1c2015-01-29 17:06:49 -0800158 "in kernel", funcName);
159 rsc->setError(RS_ERROR_FATAL_DRIVER, buf);
160 return true;
161 }
162 return false;
163}
164
Jason Sams87fe59a2011-04-20 15:09:01 -0700165//////////////////////////////////////////////////////////////////////////////
Yong Chen174ebc42015-03-27 17:56:09 +0800166// Allocation routines
Jason Sams87fe59a2011-04-20 15:09:01 -0700167//////////////////////////////////////////////////////////////////////////////
Petar Jovanovic66d94472015-07-10 14:24:28 +0200168#if defined(__i386__) || (defined(__mips__) && __mips==32)
169// i386 and MIPS32 have different struct return passing to ARM; emulate with a pointer
Yong Chen174ebc42015-03-27 17:56:09 +0800170const Allocation * rsGetAllocation(const void *ptr) {
Tim Murray240a6c92014-09-08 15:51:22 -0700171 Context *rsc = RsdCpuReference::getTlsContext();
172 const Script *sc = RsdCpuReference::getTlsScript();
173 Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
174 android::renderscript::rs_allocation obj = {0};
175 alloc->callUpdateCacheObject(rsc, &obj);
Yong Chen174ebc42015-03-27 17:56:09 +0800176 return (Allocation *)obj.p;
Tim Murray240a6c92014-09-08 15:51:22 -0700177}
178#else
Yong Chen174ebc42015-03-27 17:56:09 +0800179const android::renderscript::rs_allocation rsGetAllocation(const void *ptr) {
Jason Sams709a0972012-11-15 18:18:04 -0800180 Context *rsc = RsdCpuReference::getTlsContext();
181 const Script *sc = RsdCpuReference::getTlsScript();
Tim Murray47211dc2014-08-21 14:12:43 -0700182 Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr);
Yong Chen174ebc42015-03-27 17:56:09 +0800183
Petar Jovanovic66d94472015-07-10 14:24:28 +0200184#ifndef __LP64__ // ARMv7
Tim Murray47211dc2014-08-21 14:12:43 -0700185 android::renderscript::rs_allocation obj = {0};
Yong Chen174ebc42015-03-27 17:56:09 +0800186#else // AArch64/x86_64/MIPS64
Tim Murray47211dc2014-08-21 14:12:43 -0700187 android::renderscript::rs_allocation obj = {0, 0, 0, 0};
Yong Chen174ebc42015-03-27 17:56:09 +0800188#endif
Tim Murray47211dc2014-08-21 14:12:43 -0700189 alloc->callUpdateCacheObject(rsc, &obj);
190 return obj;
191}
192#endif
Jason Sams87fe59a2011-04-20 15:09:01 -0700193
Yong Chen174ebc42015-03-27 17:56:09 +0800194void __attribute__((overloadable)) rsAllocationIoSend(::rs_allocation a) {
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800195 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen174ebc42015-03-27 17:56:09 +0800196 if (failIfInKernel(rsc, "rsAllocationIoSend"))
197 return;
198 rsrAllocationIoSend(rsc, (Allocation *)a.p);
Yong Chen31729ad2014-11-12 15:20:18 +0800199}
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800200
Yong Chen174ebc42015-03-27 17:56:09 +0800201void __attribute__((overloadable)) rsAllocationIoReceive(::rs_allocation a) {
Yong Chen444bd202014-08-14 18:28:38 +0800202 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen174ebc42015-03-27 17:56:09 +0800203 if (failIfInKernel(rsc, "rsAllocationIoReceive"))
204 return;
205 rsrAllocationIoReceive(rsc, (Allocation *)a.p);
Yong Chen444bd202014-08-14 18:28:38 +0800206}
Jason Samsc500e742011-07-25 12:58:37 -0700207
Yong Chen174ebc42015-03-27 17:56:09 +0800208void __attribute__((overloadable)) rsAllocationCopy1DRange(
209 ::rs_allocation dstAlloc,
210 uint32_t dstOff, uint32_t dstMip, uint32_t count,
211 ::rs_allocation srcAlloc,
212 uint32_t srcOff, uint32_t srcMip) {
Jason Sams709a0972012-11-15 18:18:04 -0800213 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen174ebc42015-03-27 17:56:09 +0800214 if (failIfInKernel(rsc, "rsAllocationCopy1DRange"))
215 return;
216 rsrAllocationCopy1DRange(rsc, (Allocation *)dstAlloc.p, dstOff, dstMip,
217 count, (Allocation *)srcAlloc.p, srcOff, srcMip);
Jason Sams87fe59a2011-04-20 15:09:01 -0700218}
Jason Sams87fe59a2011-04-20 15:09:01 -0700219
Yong Chen174ebc42015-03-27 17:56:09 +0800220void __attribute__((overloadable)) rsAllocationCopy2DRange(
221 ::rs_allocation dstAlloc,
222 uint32_t dstXoff, uint32_t dstYoff,
223 uint32_t dstMip, rs_allocation_cubemap_face dstFace,
224 uint32_t width, uint32_t height,
225 ::rs_allocation srcAlloc,
226 uint32_t srcXoff, uint32_t srcYoff,
227 uint32_t srcMip, rs_allocation_cubemap_face srcFace) {
Pirama Arumuga Nainar447e8362015-01-22 12:38:24 -0800228 Context *rsc = RsdCpuReference::getTlsContext();
Yong Chen174ebc42015-03-27 17:56:09 +0800229 if (failIfInKernel(rsc, "rsAllocationCopy2DRange"))
230 return;
231 rsrAllocationCopy2DRange(rsc, (Allocation *)dstAlloc.p,
232 dstXoff, dstYoff, dstMip, dstFace,
233 width, height, (Allocation *)srcAlloc.p,
234 srcXoff, srcYoff, srcMip, srcFace);
Jason Sams87fe59a2011-04-20 15:09:01 -0700235}
236
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700237static android::renderscript::rs_element CreateElement(RsDataType dt,
238 RsDataKind dk,
239 bool isNormalized,
240 uint32_t vecSize) {
241 Context *rsc = RsdCpuReference::getTlsContext();
242
243 // No need for validation here. The rsCreateElement overload below is not
244 // exposed to the Script. The Element-creation APIs call this function in a
245 // consistent manner and rsComponent.cpp asserts on any inconsistency.
246 Element *element = (Element *) rsrElementCreate(rsc, dt, dk, isNormalized,
247 vecSize);
248 android::renderscript::rs_element obj = {};
249 if (element == nullptr)
250 return obj;
251 element->callUpdateCacheObject(rsc, &obj);
Yang Ni8133c662016-03-08 14:11:22 -0800252
253 // Any new rsObject created from inside a script should have the usrRefCount
254 // initialized to 0 and the sysRefCount initialized to 1.
255 element->incSysRef();
256 element->decUserRef();
257
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700258 return obj;
259}
260
261static android::renderscript::rs_type CreateType(RsElement element,
262 uint32_t dimX, uint32_t dimY,
263 uint32_t dimZ, bool mipmaps,
264 bool faces,
265 uint32_t yuv_format) {
266
267 Context *rsc = RsdCpuReference::getTlsContext();
268 android::renderscript::rs_type obj = {};
269
270 if (element == nullptr) {
271 ALOGE("rs_type creation error: Invalid element");
272 return obj;
273 }
274
275 // validate yuv_format
276 RsYuvFormat yuv = (RsYuvFormat) yuv_format;
277 if (yuv != RS_YUV_NONE &&
278 yuv != RS_YUV_YV12 &&
279 yuv != RS_YUV_NV21 &&
280 yuv != RS_YUV_420_888) {
281
282 ALOGE("rs_type creation error: Invalid yuv_format %d\n", yuv_format);
283 return obj;
284 }
285
286 // validate consistency of shape parameters
287 if (dimZ > 0) {
288 if (dimX < 1 || dimY < 1) {
289 ALOGE("rs_type creation error: Both X and Y dimension required "
290 "when Z is present.");
291 return obj;
292 }
293 if (mipmaps) {
294 ALOGE("rs_type creation error: mipmap control requires 2D types");
295 return obj;
296 }
297 if (faces) {
298 ALOGE("rs_type creation error: Cube maps require 2D types");
299 return obj;
300 }
301 }
302 if (dimY > 0 && dimX < 1) {
303 ALOGE("rs_type creation error: X dimension required when Y is "
304 "present.");
305 return obj;
306 }
307 if (mipmaps && dimY < 1) {
308 ALOGE("rs_type creation error: mipmap control require 2D Types.");
309 return obj;
310 }
311 if (faces && dimY < 1) {
312 ALOGE("rs_type creation error: Cube maps require 2D Types.");
313 return obj;
314 }
315 if (yuv_format != RS_YUV_NONE) {
316 if (dimZ != 0 || dimY == 0 || faces || mipmaps) {
317 ALOGE("rs_type creation error: YUV only supports basic 2D.");
318 return obj;
319 }
320 }
321
322 Type *type = (Type *) rsrTypeCreate(rsc, element, dimX, dimY, dimZ, mipmaps,
323 faces, yuv_format);
324 if (type == nullptr)
325 return obj;
326 type->callUpdateCacheObject(rsc, &obj);
Yang Ni8133c662016-03-08 14:11:22 -0800327
328 // Any new rsObject created from inside a script should have the usrRefCount
329 // initialized to 0 and the sysRefCount initialized to 1.
330 type->incSysRef();
331 type->decUserRef();
332
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700333 return obj;
334}
335
336static android::renderscript::rs_allocation CreateAllocation(
337 RsType type, RsAllocationMipmapControl mipmaps, uint32_t usages,
338 void *ptr) {
339
340 Context *rsc = RsdCpuReference::getTlsContext();
341 android::renderscript::rs_allocation obj = {};
342
343 if (type == nullptr) {
344 ALOGE("rs_allocation creation error: Invalid type");
345 return obj;
346 }
347
348 uint32_t validUsages = RS_ALLOCATION_USAGE_SCRIPT | \
349 RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE;
350 if (usages & ~validUsages) {
351 ALOGE("rs_allocation creation error: Invalid usage flag");
352 return obj;
353 }
354
355 Allocation *alloc = (Allocation *) rsrAllocationCreateTyped(rsc, type,
356 mipmaps, usages,
357 (uintptr_t) ptr);
358 if (alloc == nullptr)
359 return obj;
360 alloc->callUpdateCacheObject(rsc, &obj);
361
Yang Ni8133c662016-03-08 14:11:22 -0800362 // Any new rsObject created from inside a script should have the usrRefCount
363 // initialized to 0 and the sysRefCount initialized to 1.
364 alloc->incSysRef();
365 alloc->decUserRef();
366
Pirama Arumuga Nainar6b387c12015-10-12 14:06:57 -0700367 return obj;
368}
369
370// Define rsCreateElement, rsCreateType and rsCreateAllocation entry points
371// differently for 32-bit x86 and Mips. The definitions for ARM32 and all
372// 64-bit architectures is further below.
373#if defined(__i386__) || (defined(__mips__) && __mips==32)
374
375// The calling convention for the driver on 32-bit x86 and Mips returns
376// rs_element etc. as a stack-return parameter. The Script uses ARM32 calling
377// conventions that return the structs in a register. To match this convention,
378// emulate the return value using a pointer.
379Element *rsCreateElement(int32_t dt, int32_t dk, bool isNormalized,
380 uint32_t vecSize) {
381
382 android::renderscript::rs_element obj = CreateElement((RsDataType) dt,
383 (RsDataKind) dk,
384 isNormalized,
385 vecSize);
386 return (Element *) obj.p;
387}
388
389Type *rsCreateType(::rs_element element, uint32_t dimX, uint32_t dimY,
390 uint32_t dimZ, bool mipmaps, bool faces,
391 rs_yuv_format yuv_format) {
392 android::renderscript::rs_type obj = CreateType((RsElement) element.p, dimX,
393 dimY, dimZ, mipmaps, faces,
394 (RsYuvFormat) yuv_format);
395 return (Type *) obj.p;
396}
397
398Allocation *rsCreateAllocation(::rs_type type,
399 rs_allocation_mipmap_control mipmaps,
400 uint32_t usages, void *ptr) {
401
402 android::renderscript::rs_allocation obj;
403 obj = CreateAllocation((RsType) type.p, (RsAllocationMipmapControl) mipmaps,
404 usages, ptr);
405 return (Allocation *) obj.p;
406}
407
408#else
409android::renderscript::rs_element rsCreateElement(int32_t dt, int32_t dk,
410 bool isNormalized,
411 uint32_t vecSize) {
412
413 return CreateElement((RsDataType) dt, (RsDataKind) dk, isNormalized,
414 vecSize);
415}
416
417android::renderscript::rs_type rsCreateType(::rs_element element, uint32_t dimX,
418 uint32_t dimY, uint32_t dimZ,
419 bool mipmaps, bool faces,
420 rs_yuv_format yuv_format) {
421 return CreateType((RsElement) element.p, dimX, dimY, dimZ, mipmaps, faces,
422 yuv_format);
423}
424
425android::renderscript::rs_allocation rsCreateAllocation(
426 ::rs_type type, rs_allocation_mipmap_control mipmaps, uint32_t usages,
427 void *ptr) {
428
429 return CreateAllocation((RsType) type.p,
430 (RsAllocationMipmapControl) mipmaps,
431 usages, ptr);
432}
433#endif
434
Jason Sams87fe59a2011-04-20 15:09:01 -0700435//////////////////////////////////////////////////////////////////////////////
Yong Chen174ebc42015-03-27 17:56:09 +0800436// Object routines
Jason Sams87fe59a2011-04-20 15:09:01 -0700437//////////////////////////////////////////////////////////////////////////////
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700438// Add NOLINT to suppress wrong warnings from clang-tidy.
Yong Chen174ebc42015-03-27 17:56:09 +0800439#define IS_CLEAR_SET_OBJ(t) \
440 bool rsIsObject(t src) { \
441 return src.p != nullptr; \
442 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700443 void __attribute__((overloadable)) rsClearObject(t *dst) { /*NOLINT*/ \
Yang Niade31372016-04-06 09:34:34 -0700444 rsrClearObject(reinterpret_cast<rs_object_base *>(dst)); \
Yong Chen174ebc42015-03-27 17:56:09 +0800445 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700446 void __attribute__((overloadable)) rsSetObject(t *dst, t src) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800447 Context *rsc = RsdCpuReference::getTlsContext(); \
448 rsrSetObject(rsc, reinterpret_cast<rs_object_base *>(dst), (ObjectBase*)src.p); \
449 }
Jason Sams87fe59a2011-04-20 15:09:01 -0700450
Yong Chen174ebc42015-03-27 17:56:09 +0800451IS_CLEAR_SET_OBJ(::rs_element)
452IS_CLEAR_SET_OBJ(::rs_type)
453IS_CLEAR_SET_OBJ(::rs_allocation)
454IS_CLEAR_SET_OBJ(::rs_sampler)
455IS_CLEAR_SET_OBJ(::rs_script)
Jason Sams87fe59a2011-04-20 15:09:01 -0700456
Yong Chen174ebc42015-03-27 17:56:09 +0800457IS_CLEAR_SET_OBJ(::rs_mesh)
458IS_CLEAR_SET_OBJ(::rs_program_fragment)
459IS_CLEAR_SET_OBJ(::rs_program_vertex)
460IS_CLEAR_SET_OBJ(::rs_program_raster)
461IS_CLEAR_SET_OBJ(::rs_program_store)
462IS_CLEAR_SET_OBJ(::rs_font)
Jason Sams87fe59a2011-04-20 15:09:01 -0700463
Yong Chen174ebc42015-03-27 17:56:09 +0800464#undef IS_CLEAR_SET_OBJ
Jason Sams87fe59a2011-04-20 15:09:01 -0700465
Yong Chen174ebc42015-03-27 17:56:09 +0800466//////////////////////////////////////////////////////////////////////////////
467// Element routines
468//////////////////////////////////////////////////////////////////////////////
469static void * ElementAt(Allocation *a, RsDataType dt, uint32_t vecSize,
470 uint32_t x, uint32_t y, uint32_t z) {
Jason Sams5261a5e2013-02-27 15:46:24 -0800471 Context *rsc = RsdCpuReference::getTlsContext();
472 const Type *t = a->getType();
473 const Element *e = t->getElement();
474
475 char buf[256];
Yong Chen174ebc42015-03-27 17:56:09 +0800476 if (x && (x >= t->getLODDimX(0))) {
Miao Wang68e00892016-02-25 12:44:10 -0800477 snprintf(buf, sizeof(buf), "Out range ElementAt X %i of %i", x, t->getLODDimX(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700478 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700479 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800480 }
481
Yong Chen174ebc42015-03-27 17:56:09 +0800482 if (y && (y >= t->getLODDimY(0))) {
Miao Wang68e00892016-02-25 12:44:10 -0800483 snprintf(buf, sizeof(buf), "Out range ElementAt Y %i of %i", y, t->getLODDimY(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700484 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700485 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800486 }
487
Yong Chen174ebc42015-03-27 17:56:09 +0800488 if (z && (z >= t->getLODDimZ(0))) {
Miao Wang68e00892016-02-25 12:44:10 -0800489 snprintf(buf, sizeof(buf), "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0));
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700490 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700491 return nullptr;
Jason Sams5261a5e2013-02-27 15:46:24 -0800492 }
493
Jason Samsd09b9d62013-04-02 20:07:04 -0700494 if (vecSize > 0) {
495 if (vecSize != e->getVectorSize()) {
Miao Wang68e00892016-02-25 12:44:10 -0800496 snprintf(buf, sizeof(buf), "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700497 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700498 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700499 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800500
Jason Samsd09b9d62013-04-02 20:07:04 -0700501 if (dt != e->getType()) {
Miao Wang68e00892016-02-25 12:44:10 -0800502 snprintf(buf, sizeof(buf), "Data type mismatch for ElementAt %i of %i", dt, e->getType());
Stephen Hinescca3d6c2013-04-15 01:06:39 -0700503 rsc->setError(RS_ERROR_FATAL_DEBUG, buf);
Chris Wailes44bef6f2014-08-12 13:51:10 -0700504 return nullptr;
Jason Samsd09b9d62013-04-02 20:07:04 -0700505 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800506 }
507
508 uint8_t *p = (uint8_t *)a->mHal.drvState.lod[0].mallocPtr;
509 const uint32_t eSize = e->getSizeBytes();
510 const uint32_t stride = a->mHal.drvState.lod[0].stride;
Yong Chen174ebc42015-03-27 17:56:09 +0800511 const uint32_t dimY = a->mHal.drvState.lod[0].dimY;
512 return &p[(x * eSize) + (y * stride) + (z * stride * dimY)];
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800513}
514
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800515void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) {
Yong Chen174ebc42015-03-27 17:56:09 +0800516 const Type *t = const_cast<Allocation*>((Allocation*)a.p)->getType();
517 const Element *e = t->getElement();
518 void *tmp = ElementAt((Allocation *)a.p, RS_TYPE_UNSIGNED_8, 0, x, y, z);
519 if (tmp != nullptr)
520 memcpy(tmp, ptr, e->getSizeBytes());
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800521}
522
Yong Chen174ebc42015-03-27 17:56:09 +0800523void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y) {
524 rsSetElementAt(a, ptr, x, y, 0);
525}
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800526
Yong Chen174ebc42015-03-27 17:56:09 +0800527void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x) {
528 rsSetElementAt(a, ptr, x, 0, 0);
529}
530
531const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y, uint32_t z) {
532 return ElementAt((Allocation *)a.p, RS_TYPE_UNSIGNED_8, 0, x, y, z);
533}
534
535const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y) {
536 return rsGetElementAt(a, x, y ,0);
537}
538
539const void *rsGetElementAt(::rs_allocation a, uint32_t x) {
540 return rsGetElementAt(a, x, 0, 0);
541}
542
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700543// Add NOLINT to suppress wrong warnings from clang-tidy.
Yong Chen174ebc42015-03-27 17:56:09 +0800544#define ELEMENT_AT(T, DT, VS) \
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -0800545 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y, uint32_t z) { \
Yong Chen174ebc42015-03-27 17:56:09 +0800546 void *r = ElementAt((Allocation *)a.p, DT, VS, x, y, z); \
547 if (r != nullptr) ((T *)r)[0] = *val; \
548 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
549 } \
550 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y) { \
551 rsSetElementAt_##T(a, val, x, y, 0); \
552 } \
553 void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x) { \
554 rsSetElementAt_##T(a, val, x, 0, 0); \
555 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700556 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y, uint32_t z) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800557 void *r = ElementAt((Allocation *)a.p, DT, VS, x, y, z); \
558 if (r != nullptr) *val = ((T *)r)[0]; \
559 else ALOGE("Error from %s", __PRETTY_FUNCTION__); \
560 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700561 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800562 rsGetElementAt_##T(a, val, x, y, 0); \
563 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700564 void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800565 rsGetElementAt_##T(a, val, x, 0, 0); \
566 }
Jason Sams5261a5e2013-02-27 15:46:24 -0800567
568ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1)
569ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2)
570ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3)
571ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4)
572ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1)
573ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2)
574ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3)
575ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4)
576ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1)
577ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2)
578ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3)
579ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4)
580ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1)
581ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2)
582ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3)
583ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4)
584ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1)
585ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2)
586ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3)
587ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4)
588ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1)
589ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2)
590ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3)
591ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4)
I-Jui (Ray) Sunge8448202017-05-04 15:45:32 -0700592#ifdef __LP64__
Jason Sams5261a5e2013-02-27 15:46:24 -0800593ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1)
I-Jui (Ray) Sunge8448202017-05-04 15:45:32 -0700594#else
595/* the long versions need special treatment; the long * argument has to be
596 * kept so the signatures match, but the actual accesses have to be done in
597 * int64_t * to be consistent with the script ABI.
598 */
599void rsSetElementAt_long(::rs_allocation a, const long *val, uint32_t x, uint32_t y, uint32_t z) {
600 void *r = ElementAt((Allocation *)a.p, RS_TYPE_SIGNED_64, 1, x, y, z);
601 if (r != nullptr) ((int64_t *)r)[0] = *((int64_t *)val);
602 else ALOGE("Error from %s", __PRETTY_FUNCTION__);
603}
604void rsSetElementAt_long(::rs_allocation a, const long *val, uint32_t x, uint32_t y) {
605 rsSetElementAt_long(a, val, x, y, 0);
606}
607void rsSetElementAt_long(::rs_allocation a, const long *val, uint32_t x) {
608 rsSetElementAt_long(a, val, x, 0, 0);
609}
610void rsGetElementAt_long(::rs_allocation a, long *val, uint32_t x, uint32_t y, uint32_t z) { /*NOLINT*/
611 void *r = ElementAt((Allocation *)a.p, RS_TYPE_SIGNED_64, 1, x, y, z);
612 if (r != nullptr) *((int64_t*)val) = ((int64_t *)r)[0];
613 else ALOGE("Error from %s", __PRETTY_FUNCTION__);
614}
615void rsGetElementAt_long(::rs_allocation a, long *val, uint32_t x, uint32_t y) { /*NOLINT*/
616 rsGetElementAt_long(a, val, x, y, 0);
617}
618void rsGetElementAt_long(::rs_allocation a, long *val, uint32_t x) { /*NOLINT*/
619 rsGetElementAt_long(a, val, x, 0, 0);
620}
621#endif
Jason Sams5261a5e2013-02-27 15:46:24 -0800622ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2)
623ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3)
624ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4)
625ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1)
626ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2)
627ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3)
628ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4)
Pirama Arumuga Nainar63bd6462015-11-11 12:09:11 -0800629ELEMENT_AT(half, RS_TYPE_FLOAT_16, 1)
630ELEMENT_AT(half2, RS_TYPE_FLOAT_16, 2)
631ELEMENT_AT(half3, RS_TYPE_FLOAT_16, 3)
632ELEMENT_AT(half4, RS_TYPE_FLOAT_16, 4)
Jason Sams5261a5e2013-02-27 15:46:24 -0800633ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1)
634ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2)
635ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3)
636ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4)
637ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1)
638ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2)
639ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3)
640ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4)
641
642#undef ELEMENT_AT
Jason Sams87fe59a2011-04-20 15:09:01 -0700643
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800644#ifndef __LP64__
645/*
646 * We miss some symbols for rs{Get,Set}Element_long,ulong variants because 64
647 * bit integer values are 'long' in RS-land but might be 'long long' in the
648 * driver. Define native_long* and native_ulong* types to be vectors of
649 * 'long' as seen by the driver and define overloaded versions of
650 * rsSetElementAt_* and rsGetElementAt_*. This should get us the correct
651 * mangled names in the driver.
652 */
653
654typedef long native_long2 __attribute__((ext_vector_type(2)));
655typedef long native_long3 __attribute__((ext_vector_type(3)));
656typedef long native_long4 __attribute__((ext_vector_type(4)));
657typedef unsigned long native_ulong2 __attribute__((ext_vector_type(2)));
658typedef unsigned long native_ulong3 __attribute__((ext_vector_type(3)));
659typedef unsigned long native_ulong4 __attribute__((ext_vector_type(4)));
660
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700661// Add NOLINT to suppress wrong warnings from clang-tidy.
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800662#define ELEMENT_AT_OVERLOADS(T, U) \
Yong Chen174ebc42015-03-27 17:56:09 +0800663 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y, uint32_t z) { \
664 rsSetElementAt_##T(a, (T *) val, x, y, z); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800665 } \
666 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y) { \
Yong Chen174ebc42015-03-27 17:56:09 +0800667 rsSetElementAt_##T(a, (T *) val, x, y, 0); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800668 } \
Yong Chen174ebc42015-03-27 17:56:09 +0800669 void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x) { \
670 rsSetElementAt_##T(a, (T *) val, x, 0, 0); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800671 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700672 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y, uint32_t z) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800673 rsGetElementAt_##T(a, (T *) val, x, y, z); \
674 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700675 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800676 rsGetElementAt_##T(a, (T *) val, x, y, 0); \
677 } \
Chih-Hung Hsieh250a8b92016-05-11 16:00:14 -0700678 void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x) { /*NOLINT*/ \
Yong Chen174ebc42015-03-27 17:56:09 +0800679 rsGetElementAt_##T(a, (T *) val, x, 0, 0); \
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800680 } \
681
682ELEMENT_AT_OVERLOADS(long2, native_long2)
683ELEMENT_AT_OVERLOADS(long3, native_long3)
684ELEMENT_AT_OVERLOADS(long4, native_long4)
685ELEMENT_AT_OVERLOADS(ulong, unsigned long)
686ELEMENT_AT_OVERLOADS(ulong2, native_ulong2)
687ELEMENT_AT_OVERLOADS(ulong3, native_ulong3)
688ELEMENT_AT_OVERLOADS(ulong4, native_ulong4)
689
690// We also need variants of rs{Get,Set}ElementAt_long that take 'long long *' as
691// we might have this overloaded variant in old APKs.
692ELEMENT_AT_OVERLOADS(long, long long)
693
694#undef ELEMENT_AT_OVERLOADS
695#endif
696
Yong Chen174ebc42015-03-27 17:56:09 +0800697//////////////////////////////////////////////////////////////////////////////
698// ForEach routines
699//////////////////////////////////////////////////////////////////////////////
Yang Nidda5cb52015-10-27 15:23:17 -0700700void rsForEachInternal(int slot,
Yang Ni79b75b72015-11-18 15:56:53 -0800701 rs_script_call *options,
Yang Nidda5cb52015-10-27 15:23:17 -0700702 int hasOutput,
Yang Ni79b75b72015-11-18 15:56:53 -0800703 int numInputs,
704 ::rs_allocation* allocs) {
Yang Ni12398d82015-09-18 14:57:07 -0700705 Context *rsc = RsdCpuReference::getTlsContext();
706 Script *s = const_cast<Script*>(RsdCpuReference::getTlsScript());
Yang Ni79b75b72015-11-18 15:56:53 -0800707 if (numInputs > RS_KERNEL_MAX_ARGUMENTS) {
708 rsc->setError(RS_ERROR_BAD_SCRIPT,
709 "rsForEachInternal: too many inputs to a kernel.");
Yang Nidda5cb52015-10-27 15:23:17 -0700710 return;
711 }
Yang Ni79b75b72015-11-18 15:56:53 -0800712 Allocation* inputs[RS_KERNEL_MAX_ARGUMENTS];
713 for (int i = 0; i < numInputs; i++) {
714 inputs[i] = (Allocation*)allocs[i].p;
Yang Nicf51dd12017-04-19 10:05:53 -0700715 CHECK_OBJ(inputs[i]);
716 inputs[i]->incSysRef();
Yang Nidda5cb52015-10-27 15:23:17 -0700717 }
Yang Nicf51dd12017-04-19 10:05:53 -0700718 Allocation* out = nullptr;
719 if (hasOutput) {
720 out = (Allocation*)allocs[numInputs].p;
721 CHECK_OBJ(out);
722 out->incSysRef();
723 }
Yang Ni79b75b72015-11-18 15:56:53 -0800724 rsrForEach(rsc, s, slot, numInputs, numInputs > 0 ? inputs : nullptr, out,
725 nullptr, 0, (RsScriptCall*)options);
Yang Nicf51dd12017-04-19 10:05:53 -0700726 for (int i = 0; i < numInputs; i++) {
727 inputs[i]->decSysRef();
728 }
729 if (hasOutput) {
730 out->decSysRef();
731 }
Yang Ni12398d82015-09-18 14:57:07 -0700732}
733
Yong Chen174ebc42015-03-27 17:56:09 +0800734void __attribute__((overloadable)) rsForEach(::rs_script script,
735 ::rs_allocation in,
736 ::rs_allocation out,
737 const void *usr,
738 const rs_script_call *call) {
739 Context *rsc = RsdCpuReference::getTlsContext();
Yang Nidda5cb52015-10-27 15:23:17 -0700740 rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p,
Pirama Arumuga Nainar9479e5b2015-04-28 14:40:45 -0700741 (Allocation *)out.p, usr, 0, (RsScriptCall *)call);
Yong Chen174ebc42015-03-27 17:56:09 +0800742}
743
744void __attribute__((overloadable)) rsForEach(::rs_script script,
745 ::rs_allocation in,
746 ::rs_allocation out,
747 const void *usr) {
748 Context *rsc = RsdCpuReference::getTlsContext();
Yang Nidda5cb52015-10-27 15:23:17 -0700749 rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p,
Pirama Arumuga Nainar9479e5b2015-04-28 14:40:45 -0700750 usr, 0, nullptr);
Yong Chen174ebc42015-03-27 17:56:09 +0800751}
752
753void __attribute__((overloadable)) rsForEach(::rs_script script,
754 ::rs_allocation in,
755 ::rs_allocation out) {
756 Context *rsc = RsdCpuReference::getTlsContext();
Yang Nidda5cb52015-10-27 15:23:17 -0700757 rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p,
Pirama Arumuga Nainar9479e5b2015-04-28 14:40:45 -0700758 nullptr, 0, nullptr);
Yong Chen174ebc42015-03-27 17:56:09 +0800759}
760
761// These functions are only supported in 32-bit.
762#ifndef __LP64__
763void __attribute__((overloadable)) rsForEach(::rs_script script,
764 ::rs_allocation in,
765 ::rs_allocation out,
766 const void *usr,
767 uint32_t usrLen) {
768 Context *rsc = RsdCpuReference::getTlsContext();
Yang Nidda5cb52015-10-27 15:23:17 -0700769 rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p,
Pirama Arumuga Nainar9479e5b2015-04-28 14:40:45 -0700770 usr, usrLen, nullptr);
Yong Chen174ebc42015-03-27 17:56:09 +0800771}
772
773void __attribute__((overloadable)) rsForEach(::rs_script script,
774 ::rs_allocation in,
775 ::rs_allocation out,
776 const void *usr,
777 uint32_t usrLen,
778 const rs_script_call *call) {
779 Context *rsc = RsdCpuReference::getTlsContext();
Yang Nidda5cb52015-10-27 15:23:17 -0700780 rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p,
Pirama Arumuga Nainar9479e5b2015-04-28 14:40:45 -0700781 usr, usrLen, (RsScriptCall *)call);
Yong Chen174ebc42015-03-27 17:56:09 +0800782}
783#endif
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800784
Jason Sams87fe59a2011-04-20 15:09:01 -0700785//////////////////////////////////////////////////////////////////////////////
Yong Chen174ebc42015-03-27 17:56:09 +0800786// Message routines
787//////////////////////////////////////////////////////////////////////////////
788uint32_t rsSendToClient(int cmdID) {
789 Context *rsc = RsdCpuReference::getTlsContext();
790 return rsrToClient(rsc, cmdID, (const void *)nullptr, 0);
791}
792
793uint32_t rsSendToClient(int cmdID, const void *data, uint32_t len) {
794 Context *rsc = RsdCpuReference::getTlsContext();
795 return rsrToClient(rsc, cmdID, data, len);
796}
797
798uint32_t rsSendToClientBlocking(int cmdID) {
799 Context *rsc = RsdCpuReference::getTlsContext();
800 return rsrToClientBlocking(rsc, cmdID, (const void *)nullptr, 0);
801}
802
803uint32_t rsSendToClientBlocking(int cmdID, const void *data, uint32_t len) {
804 Context *rsc = RsdCpuReference::getTlsContext();
805 return rsrToClientBlocking(rsc, cmdID, data, len);
806}
807
808//////////////////////////////////////////////////////////////////////////////
809// Time routines
Jason Sams87fe59a2011-04-20 15:09:01 -0700810//////////////////////////////////////////////////////////////////////////////
811
Yong Chen174ebc42015-03-27 17:56:09 +0800812// time_t is int in 32-bit RenderScript. time_t is long in bionic. rsTime and
813// rsLocaltime are set to explicitly take 'const int *' so we generate the
814// correct mangled names.
Yong Chen444bd202014-08-14 18:28:38 +0800815#ifndef __LP64__
Yong Chen174ebc42015-03-27 17:56:09 +0800816int rsTime(int *timer) {
Yong Chen444bd202014-08-14 18:28:38 +0800817#else
Yong Chen174ebc42015-03-27 17:56:09 +0800818time_t rsTime(time_t * timer) {
Yong Chen444bd202014-08-14 18:28:38 +0800819#endif
Yong Chen174ebc42015-03-27 17:56:09 +0800820 Context *rsc = RsdCpuReference::getTlsContext();
821 return rsrTime(rsc, (time_t *)timer);
822}
Jason Sams87fe59a2011-04-20 15:09:01 -0700823
Tim Murray64147eb2014-07-27 13:47:40 -0700824#ifndef __LP64__
Yong Chen174ebc42015-03-27 17:56:09 +0800825rs_tm* rsLocaltime(rs_tm* local, const int *timer) {
Tim Murray64147eb2014-07-27 13:47:40 -0700826#else
Yong Chen174ebc42015-03-27 17:56:09 +0800827rs_tm* rsLocaltime(rs_tm* local, const time_t *timer) {
Tim Murray64147eb2014-07-27 13:47:40 -0700828#endif
Yong Chen174ebc42015-03-27 17:56:09 +0800829 Context *rsc = RsdCpuReference::getTlsContext();
830 return (rs_tm*)rsrLocalTime(rsc, (tm*)local, (time_t *)timer);
831}
Jason Sams87fe59a2011-04-20 15:09:01 -0700832
Yong Chen174ebc42015-03-27 17:56:09 +0800833int64_t rsUptimeMillis() {
834 Context *rsc = RsdCpuReference::getTlsContext();
835 return rsrUptimeMillis(rsc);
836}
837
838int64_t rsUptimeNanos() {
839 Context *rsc = RsdCpuReference::getTlsContext();
840 return rsrUptimeNanos(rsc);
841}
842
843float rsGetDt() {
844 Context *rsc = RsdCpuReference::getTlsContext();
845 const Script *sc = RsdCpuReference::getTlsScript();
846 return rsrGetDt(rsc, sc);
847}
848
849//////////////////////////////////////////////////////////////////////////////
850// Graphics routines
851//////////////////////////////////////////////////////////////////////////////
Miao Wang59f61422017-03-14 14:23:52 -0700852#if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
Yong Chen174ebc42015-03-27 17:56:09 +0800853static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
854 float x2, float y2, float z2, float u2, float v2,
855 float x3, float y3, float z3, float u3, float v3,
856 float x4, float y4, float z4, float u4, float v4) {
857 Context *rsc = RsdCpuReference::getTlsContext();
Jason Sams87fe59a2011-04-20 15:09:01 -0700858
Yong Chen174ebc42015-03-27 17:56:09 +0800859 if (!rsc->setupCheck()) {
860 return;
861 }
Jason Sams87fe59a2011-04-20 15:09:01 -0700862
Yong Chen174ebc42015-03-27 17:56:09 +0800863 RsdHal *dc = (RsdHal *)rsc->mHal.drv;
864 if (!dc->gl.shaderCache->setup(rsc)) {
865 return;
866 }
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800867
Yong Chen174ebc42015-03-27 17:56:09 +0800868 //ALOGE("Quad");
869 //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
870 //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
871 //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
872 //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
873
874 float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
875 const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
876
877 RsdVertexArray::Attrib attribs[2];
878 attribs[0].set(GL_FLOAT, 3, 12, false, (size_t)vtx, "ATTRIB_position");
879 attribs[1].set(GL_FLOAT, 2, 8, false, (size_t)tex, "ATTRIB_texture0");
880
881 RsdVertexArray va(attribs, 2);
882 va.setup(rsc);
883
884 RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
885}
886
887static void SC_DrawQuad(float x1, float y1, float z1,
888 float x2, float y2, float z2,
889 float x3, float y3, float z3,
890 float x4, float y4, float z4) {
891 SC_DrawQuadTexCoords(x1, y1, z1, 0, 1,
892 x2, y2, z2, 1, 1,
893 x3, y3, z3, 1, 0,
894 x4, y4, z4, 0, 0);
895}
896
897static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
898 Context *rsc = RsdCpuReference::getTlsContext();
899
900 ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
901 rsc->setProgramVertex(rsc->getDefaultProgramVertex());
902 //rsc->setupCheck();
903
904 //GLint crop[4] = {0, h, w, -h};
905
906 float sh = rsc->getHeight();
907
908 SC_DrawQuad(x, sh - y, z,
909 x+w, sh - y, z,
910 x+w, sh - (y+h), z,
911 x, sh - (y+h), z);
912 rsc->setProgramVertex((ProgramVertex *)tmp.get());
913}
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800914
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800915void rsAllocationMarkDirty(::rs_allocation a) {
Yong Chen174ebc42015-03-27 17:56:09 +0800916 Context *rsc = RsdCpuReference::getTlsContext();
917 rsrAllocationSyncAll(rsc, (Allocation *)a.p, RS_ALLOCATION_USAGE_SCRIPT);
Pirama Arumuga Nainar709a1892015-01-21 17:19:37 -0800918}
919
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800920void rsgAllocationSyncAll(::rs_allocation a) {
Yong Chen174ebc42015-03-27 17:56:09 +0800921 Context *rsc = RsdCpuReference::getTlsContext();
922 rsrAllocationSyncAll(rsc, (Allocation *)a.p, RS_ALLOCATION_USAGE_SCRIPT);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800923}
924
925void rsgAllocationSyncAll(::rs_allocation a,
926 unsigned int usage) {
Yong Chen174ebc42015-03-27 17:56:09 +0800927 Context *rsc = RsdCpuReference::getTlsContext();
928 rsrAllocationSyncAll(rsc, (Allocation *)a.p, (RsAllocationUsageType)usage);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800929}
Yong Chen174ebc42015-03-27 17:56:09 +0800930
931
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800932void rsgAllocationSyncAll(::rs_allocation a,
933 rs_allocation_usage_type source) {
Yong Chen174ebc42015-03-27 17:56:09 +0800934 Context *rsc = RsdCpuReference::getTlsContext();
935 rsrAllocationSyncAll(rsc, (Allocation *)a.p, (RsAllocationUsageType)source.val);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800936}
937
938void rsgBindProgramFragment(::rs_program_fragment pf) {
Yong Chen174ebc42015-03-27 17:56:09 +0800939 Context *rsc = RsdCpuReference::getTlsContext();
940 rsrBindProgramFragment(rsc, (ProgramFragment *)pf.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800941}
942
943void rsgBindProgramStore(::rs_program_store ps) {
Yong Chen174ebc42015-03-27 17:56:09 +0800944 Context *rsc = RsdCpuReference::getTlsContext();
945 rsrBindProgramStore(rsc, (ProgramStore *)ps.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800946}
947
948void rsgBindProgramVertex(::rs_program_vertex pv) {
Yong Chen174ebc42015-03-27 17:56:09 +0800949 Context *rsc = RsdCpuReference::getTlsContext();
950 rsrBindProgramVertex(rsc, (ProgramVertex *)pv.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800951}
952
953void rsgBindProgramRaster(::rs_program_raster pr) {
Yong Chen174ebc42015-03-27 17:56:09 +0800954 Context *rsc = RsdCpuReference::getTlsContext();
955 rsrBindProgramRaster(rsc, (ProgramRaster *)pr.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800956}
957
958void rsgBindSampler(::rs_program_fragment pf,
Yong Chen174ebc42015-03-27 17:56:09 +0800959 uint32_t slot, ::rs_sampler s) {
960 Context *rsc = RsdCpuReference::getTlsContext();
961 rsrBindSampler(rsc, (ProgramFragment *)pf.p, slot, (Sampler *)s.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800962}
963
964void rsgBindTexture(::rs_program_fragment pf,
Yong Chen174ebc42015-03-27 17:56:09 +0800965 uint32_t slot, ::rs_allocation a) {
966 Context *rsc = RsdCpuReference::getTlsContext();
967 rsrBindTexture(rsc, (ProgramFragment *)pf.p, slot, (Allocation *)a.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800968}
969
970void rsgBindConstant(::rs_program_fragment pf,
Yong Chen174ebc42015-03-27 17:56:09 +0800971 uint32_t slot, ::rs_allocation a) {
972 Context *rsc = RsdCpuReference::getTlsContext();
973 rsrBindConstant(rsc, (ProgramFragment *)pf.p, slot, (Allocation *)a.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800974}
975
976void rsgBindConstant(::rs_program_vertex pv,
Yong Chen174ebc42015-03-27 17:56:09 +0800977 uint32_t slot, ::rs_allocation a) {
978 Context *rsc = RsdCpuReference::getTlsContext();
979 rsrBindConstant(rsc, (ProgramVertex *)pv.p, slot, (Allocation *)a.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800980}
981
982void rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *m) {
Yong Chen174ebc42015-03-27 17:56:09 +0800983 Context *rsc = RsdCpuReference::getTlsContext();
984 rsrVpLoadProjectionMatrix(rsc, (const rsc_Matrix *)m);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800985}
986
987void rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *m) {
Yong Chen174ebc42015-03-27 17:56:09 +0800988 Context *rsc = RsdCpuReference::getTlsContext();
989 rsrVpLoadModelMatrix(rsc, (const rsc_Matrix *)m);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800990}
991
992void rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *m) {
Yong Chen174ebc42015-03-27 17:56:09 +0800993 Context *rsc = RsdCpuReference::getTlsContext();
994 rsrVpLoadTextureMatrix(rsc, (const rsc_Matrix *)m);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -0800995}
996
997void rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *m) {
Yong Chen174ebc42015-03-27 17:56:09 +0800998 Context *rsc = RsdCpuReference::getTlsContext();
999 rsrVpGetProjectionMatrix(rsc, (rsc_Matrix *)m);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001000}
1001
1002void rsgProgramFragmentConstantColor(::rs_program_fragment pf,
Yong Chen174ebc42015-03-27 17:56:09 +08001003 float r, float g, float b, float a) {
1004 Context *rsc = RsdCpuReference::getTlsContext();
1005 rsrPfConstantColor(rsc, (ProgramFragment *)pf.p, r, g, b, a);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001006}
1007
1008uint32_t rsgGetWidth(void) {
Yong Chen174ebc42015-03-27 17:56:09 +08001009 Context *rsc = RsdCpuReference::getTlsContext();
1010 return rsrGetWidth(rsc);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001011}
1012
1013uint32_t rsgGetHeight(void) {
Yong Chen174ebc42015-03-27 17:56:09 +08001014 Context *rsc = RsdCpuReference::getTlsContext();
1015 return rsrGetHeight(rsc);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001016}
1017
1018void rsgDrawRect(float x1, float y1, float x2, float y2, float z) {
Yong Chen174ebc42015-03-27 17:56:09 +08001019 SC_DrawQuad(x1, y2, z,
1020 x2, y2, z,
1021 x2, y1, z,
1022 x1, y1, z);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001023}
1024
1025void rsgDrawQuad(float x1, float y1, float z1,
1026 float x2, float y2, float z2,
1027 float x3, float y3, float z3,
1028 float x4, float y4, float z4) {
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001029 SC_DrawQuad(x1, y1, z1,
1030 x2, y2, z2,
1031 x3, y3, z3,
1032 x4, y4, z4);
1033}
1034
1035void rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
1036 float x2, float y2, float z2, float u2, float v2,
1037 float x3, float y3, float z3, float u3, float v3,
1038 float x4, float y4, float z4, float u4, float v4) {
Yong Chen174ebc42015-03-27 17:56:09 +08001039 SC_DrawQuadTexCoords(x1, y1, z1, u1, v1,
1040 x2, y2, z2, u2, v2,
1041 x3, y3, z3, u3, v3,
1042 x4, y4, z4, u4, v4);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001043}
1044
1045void rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h) {
Yong Chen174ebc42015-03-27 17:56:09 +08001046 SC_DrawSpriteScreenspace(x, y, z, w, h);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001047}
1048
1049void rsgDrawMesh(::rs_mesh ism) {
Yong Chen174ebc42015-03-27 17:56:09 +08001050 Context *rsc = RsdCpuReference::getTlsContext();
1051 rsrDrawMesh(rsc, (Mesh *)ism.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001052}
1053
1054void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex) {
Yong Chen174ebc42015-03-27 17:56:09 +08001055 Context *rsc = RsdCpuReference::getTlsContext();
1056 rsrDrawMeshPrimitive(rsc, (Mesh *)ism.p, primitiveIndex);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001057}
1058
1059void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex, uint start, uint len) {
Yong Chen174ebc42015-03-27 17:56:09 +08001060 Context *rsc = RsdCpuReference::getTlsContext();
1061 rsrDrawMeshPrimitiveRange(rsc, (Mesh *)ism.p, primitiveIndex, start, len);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001062}
1063
1064void rsgMeshComputeBoundingBox(::rs_mesh mesh,
1065 float *minX, float *minY, float *minZ,
1066 float *maxX, float *maxY, float *maxZ) {
Yong Chen174ebc42015-03-27 17:56:09 +08001067 Context *rsc = RsdCpuReference::getTlsContext();
1068 rsrMeshComputeBoundingBox(rsc, (Mesh *)mesh.p, minX, minY, minZ, maxX, maxY, maxZ);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001069}
1070
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001071void rsgClearColor(float r, float g, float b, float a) {
Yong Chen174ebc42015-03-27 17:56:09 +08001072 Context *rsc = RsdCpuReference::getTlsContext();
1073 rsrPrepareClear(rsc);
1074 rsdGLClearColor(rsc, r, g, b, a);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001075}
1076
1077void rsgClearDepth(float value) {
Yong Chen174ebc42015-03-27 17:56:09 +08001078 Context *rsc = RsdCpuReference::getTlsContext();
1079 rsrPrepareClear(rsc);
1080 rsdGLClearDepth(rsc, value);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001081}
1082
1083void rsgDrawText(const char *text, int x, int y) {
Yong Chen174ebc42015-03-27 17:56:09 +08001084 Context *rsc = RsdCpuReference::getTlsContext();
1085 rsrDrawText(rsc, text, x, y);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001086}
1087
1088void rsgDrawText(::rs_allocation a, int x, int y) {
Yong Chen174ebc42015-03-27 17:56:09 +08001089 Context *rsc = RsdCpuReference::getTlsContext();
1090 rsrDrawTextAlloc(rsc, (Allocation *)a.p, x, y);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001091}
1092
1093void rsgMeasureText(const char *text, int *left, int *right,
1094 int *top, int *bottom) {
Yong Chen174ebc42015-03-27 17:56:09 +08001095 Context *rsc = RsdCpuReference::getTlsContext();
1096 rsrMeasureText(rsc, text, left, right, top, bottom);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001097}
1098
1099void rsgMeasureText(::rs_allocation a, int *left, int *right,
1100 int *top, int *bottom) {
Yong Chen174ebc42015-03-27 17:56:09 +08001101 Context *rsc = RsdCpuReference::getTlsContext();
1102 rsrMeasureTextAlloc(rsc, (Allocation *)a.p, left, right, top, bottom);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001103}
1104
1105void rsgBindFont(::rs_font font) {
Yong Chen174ebc42015-03-27 17:56:09 +08001106 Context *rsc = RsdCpuReference::getTlsContext();
1107 rsrBindFont(rsc, (Font *)font.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001108}
1109
1110void rsgFontColor(float r, float g, float b, float a) {
Yong Chen174ebc42015-03-27 17:56:09 +08001111 Context *rsc = RsdCpuReference::getTlsContext();
1112 rsrFontColor(rsc, r, g, b, a);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001113}
1114
1115void rsgBindColorTarget(::rs_allocation a, uint slot) {
Yong Chen174ebc42015-03-27 17:56:09 +08001116 Context *rsc = RsdCpuReference::getTlsContext();
1117 rsrBindFrameBufferObjectColorTarget(rsc, (Allocation *)a.p, slot);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001118}
1119
1120void rsgBindDepthTarget(::rs_allocation a) {
Yong Chen174ebc42015-03-27 17:56:09 +08001121 Context *rsc = RsdCpuReference::getTlsContext();
1122 rsrBindFrameBufferObjectDepthTarget(rsc, (Allocation *)a.p);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001123}
1124
1125void rsgClearColorTarget(uint slot) {
Yong Chen174ebc42015-03-27 17:56:09 +08001126 Context *rsc = RsdCpuReference::getTlsContext();
1127 rsrClearFrameBufferObjectColorTarget(rsc, slot);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001128}
1129
1130void rsgClearDepthTarget(void) {
Yong Chen174ebc42015-03-27 17:56:09 +08001131 Context *rsc = RsdCpuReference::getTlsContext();
1132 rsrClearFrameBufferObjectDepthTarget(rsc);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001133}
1134
1135void rsgClearAllRenderTargets(void) {
Yong Chen174ebc42015-03-27 17:56:09 +08001136 Context *rsc = RsdCpuReference::getTlsContext();
1137 rsrClearFrameBufferObjectTargets(rsc);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001138}
1139
1140void color(float r, float g, float b, float a) {
Yong Chen174ebc42015-03-27 17:56:09 +08001141 Context *rsc = RsdCpuReference::getTlsContext();
1142 rsrColor(rsc, r, g, b, a);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001143}
1144
1145void rsgFinish(void) {
Yong Chen174ebc42015-03-27 17:56:09 +08001146 Context *rsc = RsdCpuReference::getTlsContext();
1147 rsdGLFinish(rsc);
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001148}
Pirama Arumuga Nainar25443712015-01-20 17:44:01 -08001149#endif
1150
Tim Murrayd6f1f462013-03-25 16:36:59 -07001151//////////////////////////////////////////////////////////////////////////////
Yong Chen174ebc42015-03-27 17:56:09 +08001152// Debug routines
Tim Murrayd6f1f462013-03-25 16:36:59 -07001153//////////////////////////////////////////////////////////////////////////////
Yong Chen174ebc42015-03-27 17:56:09 +08001154void rsDebug(const char *s, float f) {
Tim Murray0b575de2013-03-15 15:56:43 -07001155 ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
1156}
Yong Chen174ebc42015-03-27 17:56:09 +08001157
1158void rsDebug(const char *s, float f1, float f2) {
Tim Murray0b575de2013-03-15 15:56:43 -07001159 ALOGD("%s {%f, %f}", s, f1, f2);
1160}
Yong Chen174ebc42015-03-27 17:56:09 +08001161
1162void rsDebug(const char *s, float f1, float f2, float f3) {
Tim Murray0b575de2013-03-15 15:56:43 -07001163 ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
1164}
Yong Chen174ebc42015-03-27 17:56:09 +08001165
1166void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
Tim Murray0b575de2013-03-15 15:56:43 -07001167 ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
1168}
Yong Chen174ebc42015-03-27 17:56:09 +08001169
1170void rsDebug(const char *s, const float2 *f2) {
1171 float2 f = *f2;
Tim Murray0b575de2013-03-15 15:56:43 -07001172 ALOGD("%s {%f, %f}", s, f.x, f.y);
1173}
Yong Chen174ebc42015-03-27 17:56:09 +08001174
1175void rsDebug(const char *s, const float3 *f3) {
1176 float3 f = *f3;
Tim Murray0b575de2013-03-15 15:56:43 -07001177 ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
1178}
Yong Chen174ebc42015-03-27 17:56:09 +08001179
1180void rsDebug(const char *s, const float4 *f4) {
1181 float4 f = *f4;
Tim Murray0b575de2013-03-15 15:56:43 -07001182 ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
1183}
Yong Chen174ebc42015-03-27 17:56:09 +08001184
Pirama Arumuga Nainar172b2fd2016-04-04 12:01:14 -07001185// Accept a half value converted to float. This eliminates the need in the
1186// driver to properly support the half datatype (either by adding compiler flags
1187// for half or link against compiler_rt).
1188void rsDebug(const char *s, float f, ushort us) {
1189 ALOGD("%s {%f} {0x%hx}", s, f, us);
1190}
1191
1192void rsDebug(const char *s, const float2 *f2, const ushort2 *us2) {
1193 float2 f = *f2;
1194 ushort2 us = *us2;
1195 ALOGD("%s {%f %f} {0x%hx 0x%hx}", s, f.x, f.y, us.x, us.y);
1196}
1197
1198void rsDebug(const char *s, const float3 *f3, const ushort3 *us3) {
1199 float3 f = *f3;
1200 ushort3 us = *us3;
1201 ALOGD("%s {%f %f %f} {0x%hx 0x%hx 0x%hx}", s, f.x, f.y, f.z, us.x, us.y,
1202 us.z);
1203}
1204
1205void rsDebug(const char *s, const float4 *f4, const ushort4 *us4) {
1206 float4 f = *f4;
1207 ushort4 us = *us4;
1208 ALOGD("%s {%f %f %f %f} {0x%hx 0x%hx 0x%hx 0x%hx}", s, f.x, f.y, f.z, f.w,
1209 us.x, us.y, us.z, us.w);
1210}
1211
Yong Chen174ebc42015-03-27 17:56:09 +08001212void rsDebug(const char *s, double d) {
Tim Murray0b575de2013-03-15 15:56:43 -07001213 ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
1214}
Yong Chen174ebc42015-03-27 17:56:09 +08001215
1216void rsDebug(const char *s, const double2 *d2) {
1217 double2 d = *d2;
Jean-Luc Brouillet6ba05172015-04-03 16:39:18 -07001218 ALOGD("%s {%f, %f}", s, d.x, d.y);
1219}
Yong Chen174ebc42015-03-27 17:56:09 +08001220
1221void rsDebug(const char *s, const double3 *d3) {
1222 double3 d = *d3;
Jean-Luc Brouillet6ba05172015-04-03 16:39:18 -07001223 ALOGD("%s {%f, %f, %f}", s, d.x, d.y, d.z);
1224}
Yong Chen174ebc42015-03-27 17:56:09 +08001225
1226void rsDebug(const char *s, const double4 *d4) {
1227 double4 d = *d4;
Jean-Luc Brouillet6ba05172015-04-03 16:39:18 -07001228 ALOGD("%s {%f, %f, %f, %f}", s, d.x, d.y, d.z, d.w);
1229}
Yong Chen174ebc42015-03-27 17:56:09 +08001230
1231void rsDebug(const char *s, const rs_matrix4x4 *m) {
1232 float *f = (float *)m;
Tim Murray0b575de2013-03-15 15:56:43 -07001233 ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
1234 ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
1235 ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
1236 ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
1237}
Yong Chen174ebc42015-03-27 17:56:09 +08001238
1239void rsDebug(const char *s, const rs_matrix3x3 *m) {
1240 float *f = (float *)m;
Tim Murray0b575de2013-03-15 15:56:43 -07001241 ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
1242 ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
1243 ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
1244}
Yong Chen174ebc42015-03-27 17:56:09 +08001245
1246void rsDebug(const char *s, const rs_matrix2x2 *m) {
1247 float *f = (float *)m;
Tim Murray0b575de2013-03-15 15:56:43 -07001248 ALOGD("%s {%f, %f", s, f[0], f[2]);
1249 ALOGD("%s %f, %f}",s, f[1], f[3]);
1250}
Yong Chen174ebc42015-03-27 17:56:09 +08001251
1252void rsDebug(const char *s, char c) {
Tim Murray0b575de2013-03-15 15:56:43 -07001253 ALOGD("%s %hhd 0x%hhx", s, c, (unsigned char)c);
1254}
Yong Chen174ebc42015-03-27 17:56:09 +08001255
1256void rsDebug(const char *s, const char2 *c2) {
1257 char2 c = *c2;
Tim Murray0b575de2013-03-15 15:56:43 -07001258 ALOGD("%s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
1259}
Yong Chen174ebc42015-03-27 17:56:09 +08001260
1261void rsDebug(const char *s, const char3 *c3) {
1262 char3 c = *c3;
Tim Murray0b575de2013-03-15 15:56:43 -07001263 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);
1264}
Yong Chen174ebc42015-03-27 17:56:09 +08001265
1266void rsDebug(const char *s, const char4 *c4) {
1267 char4 c = *c4;
Tim Murray0b575de2013-03-15 15:56:43 -07001268 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);
1269}
Yong Chen174ebc42015-03-27 17:56:09 +08001270
1271void rsDebug(const char *s, unsigned char c) {
Tim Murray0b575de2013-03-15 15:56:43 -07001272 ALOGD("%s %hhu 0x%hhx", s, c, c);
1273}
Yong Chen174ebc42015-03-27 17:56:09 +08001274
1275void rsDebug(const char *s, const uchar2 *c2) {
1276 uchar2 c = *c2;
Tim Murray0b575de2013-03-15 15:56:43 -07001277 ALOGD("%s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
1278}
Yong Chen174ebc42015-03-27 17:56:09 +08001279
1280void rsDebug(const char *s, const uchar3 *c3) {
1281 uchar3 c = *c3;
Tim Murray0b575de2013-03-15 15:56:43 -07001282 ALOGD("%s {%hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1283}
Yong Chen174ebc42015-03-27 17:56:09 +08001284
1285void rsDebug(const char *s, const uchar4 *c4) {
1286 uchar4 c = *c4;
Tim Murray0b575de2013-03-15 15:56:43 -07001287 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);
1288}
Yong Chen174ebc42015-03-27 17:56:09 +08001289
Chih-Hung Hsiehc9a8d132018-08-17 13:37:59 -07001290void rsDebug(const char *s, int16_t c) {
Tim Murray0b575de2013-03-15 15:56:43 -07001291 ALOGD("%s %hd 0x%hx", s, c, c);
1292}
Yong Chen174ebc42015-03-27 17:56:09 +08001293
1294void rsDebug(const char *s, const short2 *c2) {
1295 short2 c = *c2;
Tim Murray0b575de2013-03-15 15:56:43 -07001296 ALOGD("%s {%hd, %hd} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1297}
Yong Chen174ebc42015-03-27 17:56:09 +08001298
1299void rsDebug(const char *s, const short3 *c3) {
1300 short3 c = *c3;
Tim Murray0b575de2013-03-15 15:56:43 -07001301 ALOGD("%s {%hd, %hd, %hd} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1302}
Yong Chen174ebc42015-03-27 17:56:09 +08001303
1304void rsDebug(const char *s, const short4 *c4) {
1305 short4 c = *c4;
Tim Murray0b575de2013-03-15 15:56:43 -07001306 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);
1307}
Yong Chen174ebc42015-03-27 17:56:09 +08001308
Chih-Hung Hsiehc9a8d132018-08-17 13:37:59 -07001309void rsDebug(const char *s, uint16_t c) {
Tim Murray0b575de2013-03-15 15:56:43 -07001310 ALOGD("%s %hu 0x%hx", s, c, c);
1311}
Yong Chen174ebc42015-03-27 17:56:09 +08001312
1313void rsDebug(const char *s, const ushort2 *c2) {
1314 ushort2 c = *c2;
Tim Murray0b575de2013-03-15 15:56:43 -07001315 ALOGD("%s {%hu, %hu} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
1316}
Yong Chen174ebc42015-03-27 17:56:09 +08001317
1318void rsDebug(const char *s, const ushort3 *c3) {
1319 ushort3 c = *c3;
Tim Murray0b575de2013-03-15 15:56:43 -07001320 ALOGD("%s {%hu, %hu, %hu} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
1321}
Yong Chen174ebc42015-03-27 17:56:09 +08001322
1323void rsDebug(const char *s, const ushort4 *c4) {
1324 ushort4 c = *c4;
Tim Murray0b575de2013-03-15 15:56:43 -07001325 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);
1326}
Yong Chen174ebc42015-03-27 17:56:09 +08001327
1328void rsDebug(const char *s, int i) {
Tim Murray0b575de2013-03-15 15:56:43 -07001329 ALOGD("%s %d 0x%x", s, i, i);
1330}
Yong Chen174ebc42015-03-27 17:56:09 +08001331
1332void rsDebug(const char *s, const int2 *i2) {
1333 int2 i = *i2;
Tim Murray0b575de2013-03-15 15:56:43 -07001334 ALOGD("%s {%d, %d} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1335}
Yong Chen174ebc42015-03-27 17:56:09 +08001336
1337void rsDebug(const char *s, const int3 *i3) {
1338 int3 i = *i3;
Tim Murray0b575de2013-03-15 15:56:43 -07001339 ALOGD("%s {%d, %d, %d} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1340}
Yong Chen174ebc42015-03-27 17:56:09 +08001341
1342void rsDebug(const char *s, const int4 *i4) {
1343 int4 i = *i4;
Tim Murray0b575de2013-03-15 15:56:43 -07001344 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);
1345}
Yong Chen174ebc42015-03-27 17:56:09 +08001346
1347void rsDebug(const char *s, unsigned int i) {
Tim Murray0b575de2013-03-15 15:56:43 -07001348 ALOGD("%s %u 0x%x", s, i, i);
1349}
Yong Chen174ebc42015-03-27 17:56:09 +08001350
1351void rsDebug(const char *s, const uint2 *i2) {
1352 uint2 i = *i2;
Tim Murray0b575de2013-03-15 15:56:43 -07001353 ALOGD("%s {%u, %u} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
1354}
Yong Chen174ebc42015-03-27 17:56:09 +08001355
1356void rsDebug(const char *s, const uint3 *i3) {
1357 uint3 i = *i3;
Tim Murray0b575de2013-03-15 15:56:43 -07001358 ALOGD("%s {%u, %u, %u} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
1359}
Yong Chen174ebc42015-03-27 17:56:09 +08001360
1361void rsDebug(const char *s, const uint4 *i4) {
1362 uint4 i = *i4;
Tim Murray0b575de2013-03-15 15:56:43 -07001363 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);
1364}
Miao Wang127d51c2014-11-24 13:41:33 -08001365
1366template <typename T>
1367static inline long long LL(const T &x) {
1368 return static_cast<long long>(x);
1369}
1370
1371template <typename T>
1372static inline unsigned long long LLu(const T &x) {
1373 return static_cast<unsigned long long>(x);
1374}
1375
Yong Chen174ebc42015-03-27 17:56:09 +08001376void rsDebug(const char *s, long l) {
1377 ALOGD("%s %lld 0x%llx", s, LL(l), LL(l));
1378}
1379
1380void rsDebug(const char *s, long long ll) {
Pirama Arumuga Nainardc0d8f72014-12-02 15:23:38 -08001381 ALOGD("%s %lld 0x%llx", s, LL(ll), LL(ll));
1382}
1383
Stephen Hinesb0934b62013-07-03 17:27:38 -07001384void rsDebug(const char *s, const long2 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001385 long2 ll = *c;
1386 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 -07001387}
1388
Stephen Hinesb0934b62013-07-03 17:27:38 -07001389void rsDebug(const char *s, const long3 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001390 long3 ll = *c;
1391 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 -07001392}
1393
Stephen Hinesb0934b62013-07-03 17:27:38 -07001394void rsDebug(const char *s, const long4 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001395 long4 ll = *c;
1396 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 -07001397}
1398
Yong Chen174ebc42015-03-27 17:56:09 +08001399void rsDebug(const char *s, unsigned long l) {
1400 unsigned long long ll = l;
1401 ALOGD("%s %llu 0x%llx", s, ll, ll);
Tim Murray0b575de2013-03-15 15:56:43 -07001402}
1403
Yong Chen174ebc42015-03-27 17:56:09 +08001404void rsDebug(const char *s, unsigned long long ll) {
1405 ALOGD("%s %llu 0x%llx", s, ll, ll);
Tim Murray0b575de2013-03-15 15:56:43 -07001406}
1407
Stephen Hinesb0934b62013-07-03 17:27:38 -07001408void rsDebug(const char *s, const ulong2 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001409 ulong2 ll = *c;
1410 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 -07001411}
1412
Stephen Hinesb0934b62013-07-03 17:27:38 -07001413void rsDebug(const char *s, const ulong3 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001414 ulong3 ll = *c;
1415 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 -07001416}
1417
Stephen Hinesb0934b62013-07-03 17:27:38 -07001418void rsDebug(const char *s, const ulong4 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001419 ulong4 ll = *c;
1420 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 -07001421}
1422
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001423// FIXME: We need to export these function signatures for the compatibility
1424// library. The C++ name mangling that LLVM uses for ext_vector_type requires
1425// different versions for "long" vs. "long long". Note that the called
1426// functions are still using the appropriate 64-bit sizes.
Miao Wang127d51c2014-11-24 13:41:33 -08001427
1428#ifndef __LP64__
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001429typedef long l2 __attribute__((ext_vector_type(2)));
1430typedef long l3 __attribute__((ext_vector_type(3)));
1431typedef long l4 __attribute__((ext_vector_type(4)));
1432typedef unsigned long ul2 __attribute__((ext_vector_type(2)));
1433typedef unsigned long ul3 __attribute__((ext_vector_type(3)));
1434typedef unsigned long ul4 __attribute__((ext_vector_type(4)));
1435
1436void rsDebug(const char *s, const l2 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001437 long2 ll = *(const long2 *)c;
1438 ALOGD("%s {%lld, %lld} 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.x), LL(ll.y));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001439}
1440
1441void rsDebug(const char *s, const l3 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001442 long3 ll = *(const long3 *)c;
1443 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));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001444}
1445
1446void rsDebug(const char *s, const l4 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001447 long4 ll = *(const long4 *)c;
1448 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));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001449}
1450
1451void rsDebug(const char *s, const ul2 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001452 ulong2 ll = *(const ulong2 *)c;
1453 ALOGD("%s {%llu, %llu} 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.x), LLu(ll.y));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001454}
1455
1456void rsDebug(const char *s, const ul3 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001457 ulong3 ll = *(const ulong3 *)c;
1458 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));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001459}
1460
1461void rsDebug(const char *s, const ul4 *c) {
Yong Chen174ebc42015-03-27 17:56:09 +08001462 ulong4 ll = *(const ulong4 *)c;
1463 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));
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001464}
Miao Wang127d51c2014-11-24 13:41:33 -08001465#endif
Stephen Hinesa5d9bef2013-12-05 17:57:49 -08001466
Yong Chen174ebc42015-03-27 17:56:09 +08001467void rsDebug(const char *s, const long2 ll) {
1468 ALOGD("%s {%lld, %lld} 0x%llx 0x%llx", s, LL(ll.x), LL(ll.y), LL(ll.x), LL(ll.y));
Tim Murray9f39aaf2014-10-13 12:35:32 -07001469}
1470
Yong Chen174ebc42015-03-27 17:56:09 +08001471void rsDebug(const char *s, const long3 ll) {
1472 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 Murray9f39aaf2014-10-13 12:35:32 -07001473}
1474
Yong Chen174ebc42015-03-27 17:56:09 +08001475void rsDebug(const char *s, const long4 ll) {
1476 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 Murray9f39aaf2014-10-13 12:35:32 -07001477}
1478
Yong Chen174ebc42015-03-27 17:56:09 +08001479void rsDebug(const char *s, const ulong2 ll) {
1480 ALOGD("%s {%llu, %llu} 0x%llx 0x%llx", s, LLu(ll.x), LLu(ll.y), LLu(ll.x), LLu(ll.y));
Tim Murray9f39aaf2014-10-13 12:35:32 -07001481}
1482
Yong Chen174ebc42015-03-27 17:56:09 +08001483void rsDebug(const char *s, const ulong3 ll) {
1484 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 Murray9f39aaf2014-10-13 12:35:32 -07001485}
1486
Yong Chen174ebc42015-03-27 17:56:09 +08001487void rsDebug(const char *s, const ulong4 ll) {
1488 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 Murray9f39aaf2014-10-13 12:35:32 -07001489}
1490
Tim Murray0b575de2013-03-15 15:56:43 -07001491void rsDebug(const char *s, const void *p) {
Yong Chen174ebc42015-03-27 17:56:09 +08001492 ALOGD("%s %p", s, p);
Tim Murray0b575de2013-03-15 15:56:43 -07001493}
Jason Sams87fe59a2011-04-20 15:09:01 -07001494
Jason Sams709a0972012-11-15 18:18:04 -08001495extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) {
Yong Chen174ebc42015-03-27 17:56:09 +08001496// TODO: remove
Chris Wailes44bef6f2014-08-12 13:51:10 -07001497 return nullptr;
Jason Sams87fe59a2011-04-20 15:09:01 -07001498}