Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 1 | /* |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "rsContext.h" |
Pirama Arumuga Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 18 | #include "rsElement.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 19 | #include "rsScriptC.h" |
| 20 | #include "rsMatrix4x4.h" |
| 21 | #include "rsMatrix3x3.h" |
| 22 | #include "rsMatrix2x2.h" |
| 23 | #include "rsRuntime.h" |
Pirama Arumuga Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 24 | #include "rsType.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 25 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 26 | #include "rsdCore.h" |
Jason Sams | 807fdc4 | 2012-07-25 17:55:39 -0700 | [diff] [blame] | 27 | #include "rsdBcc.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 28 | |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 29 | #include "rsdAllocation.h" |
Stephen Hines | 414a461 | 2012-09-05 18:05:08 -0700 | [diff] [blame] | 30 | #include "rsdShaderCache.h" |
| 31 | #include "rsdVertexArray.h" |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 32 | |
| 33 | #include <time.h> |
| 34 | |
Miao Wang | 59f6142 | 2017-03-14 14:23:52 -0700 | [diff] [blame] | 35 | #if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB) |
Chih-Hung Hsieh | e939ce7 | 2016-11-15 16:27:11 -0800 | [diff] [blame] | 36 | using android::renderscript::Font; |
| 37 | #endif |
| 38 | |
| 39 | using android::renderscript::Allocation; |
| 40 | using android::renderscript::Context; |
| 41 | using android::renderscript::Element; |
| 42 | using android::renderscript::RsdCpuReference; |
| 43 | using android::renderscript::Mesh; |
| 44 | using android::renderscript::ObjectBase; |
| 45 | using android::renderscript::ObjectBaseRef; |
| 46 | using android::renderscript::ProgramFragment; |
| 47 | using android::renderscript::ProgramRaster; |
| 48 | using android::renderscript::ProgramStore; |
| 49 | using android::renderscript::ProgramVertex; |
| 50 | using android::renderscript::Sampler; |
| 51 | using android::renderscript::Script; |
| 52 | using android::renderscript::Type; |
| 53 | using android::renderscript::rs_object_base; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 54 | |
Pirama Arumuga Nainar | 63bd646 | 2015-11-11 12:09:11 -0800 | [diff] [blame] | 55 | typedef __fp16 half; |
| 56 | typedef half half2 __attribute__((ext_vector_type(2))); |
| 57 | typedef half half3 __attribute__((ext_vector_type(3))); |
| 58 | typedef half half4 __attribute__((ext_vector_type(4))); |
| 59 | |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 60 | typedef float float2 __attribute__((ext_vector_type(2))); |
| 61 | typedef float float3 __attribute__((ext_vector_type(3))); |
| 62 | typedef float float4 __attribute__((ext_vector_type(4))); |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 63 | typedef double double2 __attribute__((ext_vector_type(2))); |
| 64 | typedef double double3 __attribute__((ext_vector_type(3))); |
| 65 | typedef double double4 __attribute__((ext_vector_type(4))); |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 66 | typedef char char2 __attribute__((ext_vector_type(2))); |
| 67 | typedef char char3 __attribute__((ext_vector_type(3))); |
| 68 | typedef char char4 __attribute__((ext_vector_type(4))); |
| 69 | typedef unsigned char uchar2 __attribute__((ext_vector_type(2))); |
| 70 | typedef unsigned char uchar3 __attribute__((ext_vector_type(3))); |
| 71 | typedef unsigned char uchar4 __attribute__((ext_vector_type(4))); |
Jason Sams | d8b8f8a | 2014-08-19 17:53:08 -0700 | [diff] [blame] | 72 | typedef int16_t short2 __attribute__((ext_vector_type(2))); |
| 73 | typedef int16_t short3 __attribute__((ext_vector_type(3))); |
| 74 | typedef int16_t short4 __attribute__((ext_vector_type(4))); |
| 75 | typedef uint16_t ushort2 __attribute__((ext_vector_type(2))); |
| 76 | typedef uint16_t ushort3 __attribute__((ext_vector_type(3))); |
| 77 | typedef uint16_t ushort4 __attribute__((ext_vector_type(4))); |
Rajeev Sharma | a1dd74c | 2012-07-09 03:14:47 -0700 | [diff] [blame] | 78 | typedef int32_t int2 __attribute__((ext_vector_type(2))); |
| 79 | typedef int32_t int3 __attribute__((ext_vector_type(3))); |
| 80 | typedef int32_t int4 __attribute__((ext_vector_type(4))); |
| 81 | typedef uint32_t uint2 __attribute__((ext_vector_type(2))); |
| 82 | typedef uint32_t uint3 __attribute__((ext_vector_type(3))); |
| 83 | typedef uint32_t uint4 __attribute__((ext_vector_type(4))); |
Jason Sams | d8b8f8a | 2014-08-19 17:53:08 -0700 | [diff] [blame] | 84 | typedef int64_t long2 __attribute__((ext_vector_type(2))); |
| 85 | typedef int64_t long3 __attribute__((ext_vector_type(3))); |
| 86 | typedef int64_t long4 __attribute__((ext_vector_type(4))); |
| 87 | typedef uint64_t ulong2 __attribute__((ext_vector_type(2))); |
| 88 | typedef uint64_t ulong3 __attribute__((ext_vector_type(3))); |
| 89 | typedef uint64_t ulong4 __attribute__((ext_vector_type(4))); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 90 | |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 91 | typedef uint8_t uchar; |
| 92 | typedef uint16_t ushort; |
| 93 | typedef uint32_t uint; |
| 94 | typedef uint64_t ulong; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 95 | |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 96 | // Add NOLINT to suppress wrong warnings from clang-tidy. |
Miao Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 97 | #ifndef __LP64__ |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 98 | #define OPAQUETYPE(t) \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 99 | typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t; /*NOLINT*/ |
Miao Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 100 | #else |
| 101 | #define OPAQUETYPE(t) \ |
I-Jui (Ray) Sung | 700e688 | 2017-03-06 14:42:53 -0800 | [diff] [blame] | 102 | typedef struct { const void* p; const void* unused1; const void* unused2; const void* unused3; } t; /*NOLINT*/ |
Miao Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 103 | #endif |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 104 | |
| 105 | OPAQUETYPE(rs_element) |
| 106 | OPAQUETYPE(rs_type) |
| 107 | OPAQUETYPE(rs_allocation) |
| 108 | OPAQUETYPE(rs_sampler) |
| 109 | OPAQUETYPE(rs_script) |
| 110 | OPAQUETYPE(rs_script_call) |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 111 | |
| 112 | OPAQUETYPE(rs_program_fragment); |
| 113 | OPAQUETYPE(rs_program_store); |
| 114 | OPAQUETYPE(rs_program_vertex); |
| 115 | OPAQUETYPE(rs_program_raster); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 116 | OPAQUETYPE(rs_mesh); |
| 117 | OPAQUETYPE(rs_font); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 118 | |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 119 | #undef OPAQUETYPE |
| 120 | |
Stephen Hines | 7a01126 | 2013-11-27 14:21:57 -0800 | [diff] [blame] | 121 | typedef enum { |
| 122 | // Empty to avoid conflicting definitions with RsAllocationCubemapFace |
| 123 | } rs_allocation_cubemap_face; |
| 124 | |
Pirama Arumuga Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 125 | typedef enum { |
| 126 | // Empty to avoid conflicting definitions with RsYuvFormat |
| 127 | } rs_yuv_format; |
| 128 | |
| 129 | typedef enum { |
| 130 | // Empty to avoid conflicting definitions with RsAllocationMipmapControl |
| 131 | } rs_allocation_mipmap_control; |
| 132 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 133 | typedef struct { unsigned int val; } rs_allocation_usage_type; |
| 134 | |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 135 | typedef 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 Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 146 | |
Pirama Arumuga Nainar | 7153e1c | 2015-01-29 17:06:49 -0800 | [diff] [blame] | 147 | // 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. |
| 151 | static bool failIfInKernel(Context *rsc, const char *funcName) { |
| 152 | RsdHal *dc = (RsdHal *)rsc->mHal.drv; |
| 153 | RsdCpuReference *impl = (RsdCpuReference *) dc->mCpuRef; |
| 154 | |
David Gross | 35dbc8c | 2016-03-29 13:48:41 -0700 | [diff] [blame] | 155 | if (impl->getInKernel()) { |
Pirama Arumuga Nainar | 7153e1c | 2015-01-29 17:06:49 -0800 | [diff] [blame] | 156 | char buf[256]; |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 157 | snprintf(buf, sizeof(buf), "Error: Call to unsupported function %s " |
Pirama Arumuga Nainar | 7153e1c | 2015-01-29 17:06:49 -0800 | [diff] [blame] | 158 | "in kernel", funcName); |
| 159 | rsc->setError(RS_ERROR_FATAL_DRIVER, buf); |
| 160 | return true; |
| 161 | } |
| 162 | return false; |
| 163 | } |
| 164 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 165 | ////////////////////////////////////////////////////////////////////////////// |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 166 | // Allocation routines |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 167 | ////////////////////////////////////////////////////////////////////////////// |
Petar Jovanovic | 66d9447 | 2015-07-10 14:24:28 +0200 | [diff] [blame] | 168 | #if defined(__i386__) || (defined(__mips__) && __mips==32) |
| 169 | // i386 and MIPS32 have different struct return passing to ARM; emulate with a pointer |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 170 | const Allocation * rsGetAllocation(const void *ptr) { |
Tim Murray | 240a6c9 | 2014-09-08 15:51:22 -0700 | [diff] [blame] | 171 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 176 | return (Allocation *)obj.p; |
Tim Murray | 240a6c9 | 2014-09-08 15:51:22 -0700 | [diff] [blame] | 177 | } |
| 178 | #else |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 179 | const android::renderscript::rs_allocation rsGetAllocation(const void *ptr) { |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 180 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 181 | const Script *sc = RsdCpuReference::getTlsScript(); |
Tim Murray | 47211dc | 2014-08-21 14:12:43 -0700 | [diff] [blame] | 182 | Allocation* alloc = rsdScriptGetAllocationForPointer(rsc, sc, ptr); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 183 | |
Petar Jovanovic | 66d9447 | 2015-07-10 14:24:28 +0200 | [diff] [blame] | 184 | #ifndef __LP64__ // ARMv7 |
Tim Murray | 47211dc | 2014-08-21 14:12:43 -0700 | [diff] [blame] | 185 | android::renderscript::rs_allocation obj = {0}; |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 186 | #else // AArch64/x86_64/MIPS64 |
Tim Murray | 47211dc | 2014-08-21 14:12:43 -0700 | [diff] [blame] | 187 | android::renderscript::rs_allocation obj = {0, 0, 0, 0}; |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 188 | #endif |
Tim Murray | 47211dc | 2014-08-21 14:12:43 -0700 | [diff] [blame] | 189 | alloc->callUpdateCacheObject(rsc, &obj); |
| 190 | return obj; |
| 191 | } |
| 192 | #endif |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 193 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 194 | void __attribute__((overloadable)) rsAllocationIoSend(::rs_allocation a) { |
Pirama Arumuga Nainar | 447e836 | 2015-01-22 12:38:24 -0800 | [diff] [blame] | 195 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 196 | if (failIfInKernel(rsc, "rsAllocationIoSend")) |
| 197 | return; |
| 198 | rsrAllocationIoSend(rsc, (Allocation *)a.p); |
Yong Chen | 31729ad | 2014-11-12 15:20:18 +0800 | [diff] [blame] | 199 | } |
Pirama Arumuga Nainar | 447e836 | 2015-01-22 12:38:24 -0800 | [diff] [blame] | 200 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 201 | void __attribute__((overloadable)) rsAllocationIoReceive(::rs_allocation a) { |
Yong Chen | 444bd20 | 2014-08-14 18:28:38 +0800 | [diff] [blame] | 202 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 203 | if (failIfInKernel(rsc, "rsAllocationIoReceive")) |
| 204 | return; |
| 205 | rsrAllocationIoReceive(rsc, (Allocation *)a.p); |
Yong Chen | 444bd20 | 2014-08-14 18:28:38 +0800 | [diff] [blame] | 206 | } |
Jason Sams | c500e74 | 2011-07-25 12:58:37 -0700 | [diff] [blame] | 207 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 208 | void __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 Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 213 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 214 | if (failIfInKernel(rsc, "rsAllocationCopy1DRange")) |
| 215 | return; |
| 216 | rsrAllocationCopy1DRange(rsc, (Allocation *)dstAlloc.p, dstOff, dstMip, |
| 217 | count, (Allocation *)srcAlloc.p, srcOff, srcMip); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 218 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 219 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 220 | void __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 Nainar | 447e836 | 2015-01-22 12:38:24 -0800 | [diff] [blame] | 228 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 229 | 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 Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Pirama Arumuga Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 237 | static 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 Ni | 8133c66 | 2016-03-08 14:11:22 -0800 | [diff] [blame] | 252 | |
| 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 Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 258 | return obj; |
| 259 | } |
| 260 | |
| 261 | static 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 Ni | 8133c66 | 2016-03-08 14:11:22 -0800 | [diff] [blame] | 327 | |
| 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 Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 333 | return obj; |
| 334 | } |
| 335 | |
| 336 | static 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 Ni | 8133c66 | 2016-03-08 14:11:22 -0800 | [diff] [blame] | 362 | // 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 Nainar | 6b387c1 | 2015-10-12 14:06:57 -0700 | [diff] [blame] | 367 | 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. |
| 379 | Element *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 | |
| 389 | Type *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 | |
| 398 | Allocation *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 |
| 409 | android::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 | |
| 417 | android::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 | |
| 425 | android::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 Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 435 | ////////////////////////////////////////////////////////////////////////////// |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 436 | // Object routines |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 437 | ////////////////////////////////////////////////////////////////////////////// |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 438 | // Add NOLINT to suppress wrong warnings from clang-tidy. |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 439 | #define IS_CLEAR_SET_OBJ(t) \ |
| 440 | bool rsIsObject(t src) { \ |
| 441 | return src.p != nullptr; \ |
| 442 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 443 | void __attribute__((overloadable)) rsClearObject(t *dst) { /*NOLINT*/ \ |
Yang Ni | ade3137 | 2016-04-06 09:34:34 -0700 | [diff] [blame] | 444 | rsrClearObject(reinterpret_cast<rs_object_base *>(dst)); \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 445 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 446 | void __attribute__((overloadable)) rsSetObject(t *dst, t src) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 447 | Context *rsc = RsdCpuReference::getTlsContext(); \ |
| 448 | rsrSetObject(rsc, reinterpret_cast<rs_object_base *>(dst), (ObjectBase*)src.p); \ |
| 449 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 450 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 451 | IS_CLEAR_SET_OBJ(::rs_element) |
| 452 | IS_CLEAR_SET_OBJ(::rs_type) |
| 453 | IS_CLEAR_SET_OBJ(::rs_allocation) |
| 454 | IS_CLEAR_SET_OBJ(::rs_sampler) |
| 455 | IS_CLEAR_SET_OBJ(::rs_script) |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 456 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 457 | IS_CLEAR_SET_OBJ(::rs_mesh) |
| 458 | IS_CLEAR_SET_OBJ(::rs_program_fragment) |
| 459 | IS_CLEAR_SET_OBJ(::rs_program_vertex) |
| 460 | IS_CLEAR_SET_OBJ(::rs_program_raster) |
| 461 | IS_CLEAR_SET_OBJ(::rs_program_store) |
| 462 | IS_CLEAR_SET_OBJ(::rs_font) |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 463 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 464 | #undef IS_CLEAR_SET_OBJ |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 465 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 466 | ////////////////////////////////////////////////////////////////////////////// |
| 467 | // Element routines |
| 468 | ////////////////////////////////////////////////////////////////////////////// |
| 469 | static void * ElementAt(Allocation *a, RsDataType dt, uint32_t vecSize, |
| 470 | uint32_t x, uint32_t y, uint32_t z) { |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 471 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 472 | const Type *t = a->getType(); |
| 473 | const Element *e = t->getElement(); |
| 474 | |
| 475 | char buf[256]; |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 476 | if (x && (x >= t->getLODDimX(0))) { |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 477 | snprintf(buf, sizeof(buf), "Out range ElementAt X %i of %i", x, t->getLODDimX(0)); |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 478 | rsc->setError(RS_ERROR_FATAL_DEBUG, buf); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 479 | return nullptr; |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 480 | } |
| 481 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 482 | if (y && (y >= t->getLODDimY(0))) { |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 483 | snprintf(buf, sizeof(buf), "Out range ElementAt Y %i of %i", y, t->getLODDimY(0)); |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 484 | rsc->setError(RS_ERROR_FATAL_DEBUG, buf); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 485 | return nullptr; |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 488 | if (z && (z >= t->getLODDimZ(0))) { |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 489 | snprintf(buf, sizeof(buf), "Out range ElementAt Z %i of %i", z, t->getLODDimZ(0)); |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 490 | rsc->setError(RS_ERROR_FATAL_DEBUG, buf); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 491 | return nullptr; |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 492 | } |
| 493 | |
Jason Sams | d09b9d6 | 2013-04-02 20:07:04 -0700 | [diff] [blame] | 494 | if (vecSize > 0) { |
| 495 | if (vecSize != e->getVectorSize()) { |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 496 | snprintf(buf, sizeof(buf), "Vector size mismatch for ElementAt %i of %i", vecSize, e->getVectorSize()); |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 497 | rsc->setError(RS_ERROR_FATAL_DEBUG, buf); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 498 | return nullptr; |
Jason Sams | d09b9d6 | 2013-04-02 20:07:04 -0700 | [diff] [blame] | 499 | } |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 500 | |
Jason Sams | d09b9d6 | 2013-04-02 20:07:04 -0700 | [diff] [blame] | 501 | if (dt != e->getType()) { |
Miao Wang | 68e0089 | 2016-02-25 12:44:10 -0800 | [diff] [blame] | 502 | snprintf(buf, sizeof(buf), "Data type mismatch for ElementAt %i of %i", dt, e->getType()); |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 503 | rsc->setError(RS_ERROR_FATAL_DEBUG, buf); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 504 | return nullptr; |
Jason Sams | d09b9d6 | 2013-04-02 20:07:04 -0700 | [diff] [blame] | 505 | } |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 506 | } |
| 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 511 | const uint32_t dimY = a->mHal.drvState.lod[0].dimY; |
| 512 | return &p[(x * eSize) + (y * stride) + (z * stride * dimY)]; |
Pirama Arumuga Nainar | dc0d8f7 | 2014-12-02 15:23:38 -0800 | [diff] [blame] | 513 | } |
| 514 | |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 515 | void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y, uint32_t z) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 516 | 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 Nainar | dc0d8f7 | 2014-12-02 15:23:38 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 523 | void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x, uint32_t y) { |
| 524 | rsSetElementAt(a, ptr, x, y, 0); |
| 525 | } |
Pirama Arumuga Nainar | dc0d8f7 | 2014-12-02 15:23:38 -0800 | [diff] [blame] | 526 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 527 | void rsSetElementAt(::rs_allocation a, const void *ptr, uint32_t x) { |
| 528 | rsSetElementAt(a, ptr, x, 0, 0); |
| 529 | } |
| 530 | |
| 531 | const 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 | |
| 535 | const void *rsGetElementAt(::rs_allocation a, uint32_t x, uint32_t y) { |
| 536 | return rsGetElementAt(a, x, y ,0); |
| 537 | } |
| 538 | |
| 539 | const void *rsGetElementAt(::rs_allocation a, uint32_t x) { |
| 540 | return rsGetElementAt(a, x, 0, 0); |
| 541 | } |
| 542 | |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 543 | // Add NOLINT to suppress wrong warnings from clang-tidy. |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 544 | #define ELEMENT_AT(T, DT, VS) \ |
Pirama Arumuga Nainar | dc0d8f7 | 2014-12-02 15:23:38 -0800 | [diff] [blame] | 545 | void rsSetElementAt_##T(::rs_allocation a, const T *val, uint32_t x, uint32_t y, uint32_t z) { \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 546 | 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 Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 556 | void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y, uint32_t z) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 557 | 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 Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 561 | void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x, uint32_t y) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 562 | rsGetElementAt_##T(a, val, x, y, 0); \ |
| 563 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 564 | void rsGetElementAt_##T(::rs_allocation a, T *val, uint32_t x) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 565 | rsGetElementAt_##T(a, val, x, 0, 0); \ |
| 566 | } |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 567 | |
| 568 | ELEMENT_AT(char, RS_TYPE_SIGNED_8, 1) |
| 569 | ELEMENT_AT(char2, RS_TYPE_SIGNED_8, 2) |
| 570 | ELEMENT_AT(char3, RS_TYPE_SIGNED_8, 3) |
| 571 | ELEMENT_AT(char4, RS_TYPE_SIGNED_8, 4) |
| 572 | ELEMENT_AT(uchar, RS_TYPE_UNSIGNED_8, 1) |
| 573 | ELEMENT_AT(uchar2, RS_TYPE_UNSIGNED_8, 2) |
| 574 | ELEMENT_AT(uchar3, RS_TYPE_UNSIGNED_8, 3) |
| 575 | ELEMENT_AT(uchar4, RS_TYPE_UNSIGNED_8, 4) |
| 576 | ELEMENT_AT(short, RS_TYPE_SIGNED_16, 1) |
| 577 | ELEMENT_AT(short2, RS_TYPE_SIGNED_16, 2) |
| 578 | ELEMENT_AT(short3, RS_TYPE_SIGNED_16, 3) |
| 579 | ELEMENT_AT(short4, RS_TYPE_SIGNED_16, 4) |
| 580 | ELEMENT_AT(ushort, RS_TYPE_UNSIGNED_16, 1) |
| 581 | ELEMENT_AT(ushort2, RS_TYPE_UNSIGNED_16, 2) |
| 582 | ELEMENT_AT(ushort3, RS_TYPE_UNSIGNED_16, 3) |
| 583 | ELEMENT_AT(ushort4, RS_TYPE_UNSIGNED_16, 4) |
| 584 | ELEMENT_AT(int, RS_TYPE_SIGNED_32, 1) |
| 585 | ELEMENT_AT(int2, RS_TYPE_SIGNED_32, 2) |
| 586 | ELEMENT_AT(int3, RS_TYPE_SIGNED_32, 3) |
| 587 | ELEMENT_AT(int4, RS_TYPE_SIGNED_32, 4) |
| 588 | ELEMENT_AT(uint, RS_TYPE_UNSIGNED_32, 1) |
| 589 | ELEMENT_AT(uint2, RS_TYPE_UNSIGNED_32, 2) |
| 590 | ELEMENT_AT(uint3, RS_TYPE_UNSIGNED_32, 3) |
| 591 | ELEMENT_AT(uint4, RS_TYPE_UNSIGNED_32, 4) |
I-Jui (Ray) Sung | e844820 | 2017-05-04 15:45:32 -0700 | [diff] [blame] | 592 | #ifdef __LP64__ |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 593 | ELEMENT_AT(long, RS_TYPE_SIGNED_64, 1) |
I-Jui (Ray) Sung | e844820 | 2017-05-04 15:45:32 -0700 | [diff] [blame] | 594 | #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 | */ |
| 599 | void 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 | } |
| 604 | void rsSetElementAt_long(::rs_allocation a, const long *val, uint32_t x, uint32_t y) { |
| 605 | rsSetElementAt_long(a, val, x, y, 0); |
| 606 | } |
| 607 | void rsSetElementAt_long(::rs_allocation a, const long *val, uint32_t x) { |
| 608 | rsSetElementAt_long(a, val, x, 0, 0); |
| 609 | } |
| 610 | void 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 | } |
| 615 | void rsGetElementAt_long(::rs_allocation a, long *val, uint32_t x, uint32_t y) { /*NOLINT*/ |
| 616 | rsGetElementAt_long(a, val, x, y, 0); |
| 617 | } |
| 618 | void rsGetElementAt_long(::rs_allocation a, long *val, uint32_t x) { /*NOLINT*/ |
| 619 | rsGetElementAt_long(a, val, x, 0, 0); |
| 620 | } |
| 621 | #endif |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 622 | ELEMENT_AT(long2, RS_TYPE_SIGNED_64, 2) |
| 623 | ELEMENT_AT(long3, RS_TYPE_SIGNED_64, 3) |
| 624 | ELEMENT_AT(long4, RS_TYPE_SIGNED_64, 4) |
| 625 | ELEMENT_AT(ulong, RS_TYPE_UNSIGNED_64, 1) |
| 626 | ELEMENT_AT(ulong2, RS_TYPE_UNSIGNED_64, 2) |
| 627 | ELEMENT_AT(ulong3, RS_TYPE_UNSIGNED_64, 3) |
| 628 | ELEMENT_AT(ulong4, RS_TYPE_UNSIGNED_64, 4) |
Pirama Arumuga Nainar | 63bd646 | 2015-11-11 12:09:11 -0800 | [diff] [blame] | 629 | ELEMENT_AT(half, RS_TYPE_FLOAT_16, 1) |
| 630 | ELEMENT_AT(half2, RS_TYPE_FLOAT_16, 2) |
| 631 | ELEMENT_AT(half3, RS_TYPE_FLOAT_16, 3) |
| 632 | ELEMENT_AT(half4, RS_TYPE_FLOAT_16, 4) |
Jason Sams | 5261a5e | 2013-02-27 15:46:24 -0800 | [diff] [blame] | 633 | ELEMENT_AT(float, RS_TYPE_FLOAT_32, 1) |
| 634 | ELEMENT_AT(float2, RS_TYPE_FLOAT_32, 2) |
| 635 | ELEMENT_AT(float3, RS_TYPE_FLOAT_32, 3) |
| 636 | ELEMENT_AT(float4, RS_TYPE_FLOAT_32, 4) |
| 637 | ELEMENT_AT(double, RS_TYPE_FLOAT_64, 1) |
| 638 | ELEMENT_AT(double2, RS_TYPE_FLOAT_64, 2) |
| 639 | ELEMENT_AT(double3, RS_TYPE_FLOAT_64, 3) |
| 640 | ELEMENT_AT(double4, RS_TYPE_FLOAT_64, 4) |
| 641 | |
| 642 | #undef ELEMENT_AT |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 643 | |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 644 | #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 | |
| 654 | typedef long native_long2 __attribute__((ext_vector_type(2))); |
| 655 | typedef long native_long3 __attribute__((ext_vector_type(3))); |
| 656 | typedef long native_long4 __attribute__((ext_vector_type(4))); |
| 657 | typedef unsigned long native_ulong2 __attribute__((ext_vector_type(2))); |
| 658 | typedef unsigned long native_ulong3 __attribute__((ext_vector_type(3))); |
| 659 | typedef unsigned long native_ulong4 __attribute__((ext_vector_type(4))); |
| 660 | |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 661 | // Add NOLINT to suppress wrong warnings from clang-tidy. |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 662 | #define ELEMENT_AT_OVERLOADS(T, U) \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 663 | 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 Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 665 | } \ |
| 666 | void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x, uint32_t y) { \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 667 | rsSetElementAt_##T(a, (T *) val, x, y, 0); \ |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 668 | } \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 669 | void rsSetElementAt_##T(::rs_allocation a, const U *val, uint32_t x) { \ |
| 670 | rsSetElementAt_##T(a, (T *) val, x, 0, 0); \ |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 671 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 672 | void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y, uint32_t z) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 673 | rsGetElementAt_##T(a, (T *) val, x, y, z); \ |
| 674 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 675 | void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x, uint32_t y) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 676 | rsGetElementAt_##T(a, (T *) val, x, y, 0); \ |
| 677 | } \ |
Chih-Hung Hsieh | 250a8b9 | 2016-05-11 16:00:14 -0700 | [diff] [blame] | 678 | void rsGetElementAt_##T(::rs_allocation a, U *val, uint32_t x) { /*NOLINT*/ \ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 679 | rsGetElementAt_##T(a, (T *) val, x, 0, 0); \ |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 680 | } \ |
| 681 | |
| 682 | ELEMENT_AT_OVERLOADS(long2, native_long2) |
| 683 | ELEMENT_AT_OVERLOADS(long3, native_long3) |
| 684 | ELEMENT_AT_OVERLOADS(long4, native_long4) |
| 685 | ELEMENT_AT_OVERLOADS(ulong, unsigned long) |
| 686 | ELEMENT_AT_OVERLOADS(ulong2, native_ulong2) |
| 687 | ELEMENT_AT_OVERLOADS(ulong3, native_ulong3) |
| 688 | ELEMENT_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. |
| 692 | ELEMENT_AT_OVERLOADS(long, long long) |
| 693 | |
| 694 | #undef ELEMENT_AT_OVERLOADS |
| 695 | #endif |
| 696 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 697 | ////////////////////////////////////////////////////////////////////////////// |
| 698 | // ForEach routines |
| 699 | ////////////////////////////////////////////////////////////////////////////// |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 700 | void rsForEachInternal(int slot, |
Yang Ni | 79b75b7 | 2015-11-18 15:56:53 -0800 | [diff] [blame] | 701 | rs_script_call *options, |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 702 | int hasOutput, |
Yang Ni | 79b75b7 | 2015-11-18 15:56:53 -0800 | [diff] [blame] | 703 | int numInputs, |
| 704 | ::rs_allocation* allocs) { |
Yang Ni | 12398d8 | 2015-09-18 14:57:07 -0700 | [diff] [blame] | 705 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 706 | Script *s = const_cast<Script*>(RsdCpuReference::getTlsScript()); |
Yang Ni | 79b75b7 | 2015-11-18 15:56:53 -0800 | [diff] [blame] | 707 | if (numInputs > RS_KERNEL_MAX_ARGUMENTS) { |
| 708 | rsc->setError(RS_ERROR_BAD_SCRIPT, |
| 709 | "rsForEachInternal: too many inputs to a kernel."); |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 710 | return; |
| 711 | } |
Yang Ni | 79b75b7 | 2015-11-18 15:56:53 -0800 | [diff] [blame] | 712 | Allocation* inputs[RS_KERNEL_MAX_ARGUMENTS]; |
| 713 | for (int i = 0; i < numInputs; i++) { |
| 714 | inputs[i] = (Allocation*)allocs[i].p; |
Yang Ni | cf51dd1 | 2017-04-19 10:05:53 -0700 | [diff] [blame] | 715 | CHECK_OBJ(inputs[i]); |
| 716 | inputs[i]->incSysRef(); |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 717 | } |
Yang Ni | cf51dd1 | 2017-04-19 10:05:53 -0700 | [diff] [blame] | 718 | Allocation* out = nullptr; |
| 719 | if (hasOutput) { |
| 720 | out = (Allocation*)allocs[numInputs].p; |
| 721 | CHECK_OBJ(out); |
| 722 | out->incSysRef(); |
| 723 | } |
Yang Ni | 79b75b7 | 2015-11-18 15:56:53 -0800 | [diff] [blame] | 724 | rsrForEach(rsc, s, slot, numInputs, numInputs > 0 ? inputs : nullptr, out, |
| 725 | nullptr, 0, (RsScriptCall*)options); |
Yang Ni | cf51dd1 | 2017-04-19 10:05:53 -0700 | [diff] [blame] | 726 | for (int i = 0; i < numInputs; i++) { |
| 727 | inputs[i]->decSysRef(); |
| 728 | } |
| 729 | if (hasOutput) { |
| 730 | out->decSysRef(); |
| 731 | } |
Yang Ni | 12398d8 | 2015-09-18 14:57:07 -0700 | [diff] [blame] | 732 | } |
| 733 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 734 | void __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 Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 740 | rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, |
Pirama Arumuga Nainar | 9479e5b | 2015-04-28 14:40:45 -0700 | [diff] [blame] | 741 | (Allocation *)out.p, usr, 0, (RsScriptCall *)call); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | void __attribute__((overloadable)) rsForEach(::rs_script script, |
| 745 | ::rs_allocation in, |
| 746 | ::rs_allocation out, |
| 747 | const void *usr) { |
| 748 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 749 | rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p, |
Pirama Arumuga Nainar | 9479e5b | 2015-04-28 14:40:45 -0700 | [diff] [blame] | 750 | usr, 0, nullptr); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | void __attribute__((overloadable)) rsForEach(::rs_script script, |
| 754 | ::rs_allocation in, |
| 755 | ::rs_allocation out) { |
| 756 | Context *rsc = RsdCpuReference::getTlsContext(); |
Yang Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 757 | rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p, |
Pirama Arumuga Nainar | 9479e5b | 2015-04-28 14:40:45 -0700 | [diff] [blame] | 758 | nullptr, 0, nullptr); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | // These functions are only supported in 32-bit. |
| 762 | #ifndef __LP64__ |
| 763 | void __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 Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 769 | rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p, |
Pirama Arumuga Nainar | 9479e5b | 2015-04-28 14:40:45 -0700 | [diff] [blame] | 770 | usr, usrLen, nullptr); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | void __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 Ni | dda5cb5 | 2015-10-27 15:23:17 -0700 | [diff] [blame] | 780 | rsrForEach(rsc, (Script *)script.p, 0, 1, (Allocation **)&in.p, (Allocation *)out.p, |
Pirama Arumuga Nainar | 9479e5b | 2015-04-28 14:40:45 -0700 | [diff] [blame] | 781 | usr, usrLen, (RsScriptCall *)call); |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 782 | } |
| 783 | #endif |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 784 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 785 | ////////////////////////////////////////////////////////////////////////////// |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 786 | // Message routines |
| 787 | ////////////////////////////////////////////////////////////////////////////// |
| 788 | uint32_t rsSendToClient(int cmdID) { |
| 789 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 790 | return rsrToClient(rsc, cmdID, (const void *)nullptr, 0); |
| 791 | } |
| 792 | |
| 793 | uint32_t rsSendToClient(int cmdID, const void *data, uint32_t len) { |
| 794 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 795 | return rsrToClient(rsc, cmdID, data, len); |
| 796 | } |
| 797 | |
| 798 | uint32_t rsSendToClientBlocking(int cmdID) { |
| 799 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 800 | return rsrToClientBlocking(rsc, cmdID, (const void *)nullptr, 0); |
| 801 | } |
| 802 | |
| 803 | uint32_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 Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 810 | ////////////////////////////////////////////////////////////////////////////// |
| 811 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 812 | // 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 Chen | 444bd20 | 2014-08-14 18:28:38 +0800 | [diff] [blame] | 815 | #ifndef __LP64__ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 816 | int rsTime(int *timer) { |
Yong Chen | 444bd20 | 2014-08-14 18:28:38 +0800 | [diff] [blame] | 817 | #else |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 818 | time_t rsTime(time_t * timer) { |
Yong Chen | 444bd20 | 2014-08-14 18:28:38 +0800 | [diff] [blame] | 819 | #endif |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 820 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 821 | return rsrTime(rsc, (time_t *)timer); |
| 822 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 823 | |
Tim Murray | 64147eb | 2014-07-27 13:47:40 -0700 | [diff] [blame] | 824 | #ifndef __LP64__ |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 825 | rs_tm* rsLocaltime(rs_tm* local, const int *timer) { |
Tim Murray | 64147eb | 2014-07-27 13:47:40 -0700 | [diff] [blame] | 826 | #else |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 827 | rs_tm* rsLocaltime(rs_tm* local, const time_t *timer) { |
Tim Murray | 64147eb | 2014-07-27 13:47:40 -0700 | [diff] [blame] | 828 | #endif |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 829 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 830 | return (rs_tm*)rsrLocalTime(rsc, (tm*)local, (time_t *)timer); |
| 831 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 832 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 833 | int64_t rsUptimeMillis() { |
| 834 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 835 | return rsrUptimeMillis(rsc); |
| 836 | } |
| 837 | |
| 838 | int64_t rsUptimeNanos() { |
| 839 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 840 | return rsrUptimeNanos(rsc); |
| 841 | } |
| 842 | |
| 843 | float 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 Wang | 59f6142 | 2017-03-14 14:23:52 -0700 | [diff] [blame] | 852 | #if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB) |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 853 | static 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 Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 858 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 859 | if (!rsc->setupCheck()) { |
| 860 | return; |
| 861 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 862 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 863 | RsdHal *dc = (RsdHal *)rsc->mHal.drv; |
| 864 | if (!dc->gl.shaderCache->setup(rsc)) { |
| 865 | return; |
| 866 | } |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 867 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 868 | //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 | |
| 887 | static 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 | |
| 897 | static 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 Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 914 | |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 915 | void rsAllocationMarkDirty(::rs_allocation a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 916 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 917 | rsrAllocationSyncAll(rsc, (Allocation *)a.p, RS_ALLOCATION_USAGE_SCRIPT); |
Pirama Arumuga Nainar | 709a189 | 2015-01-21 17:19:37 -0800 | [diff] [blame] | 918 | } |
| 919 | |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 920 | void rsgAllocationSyncAll(::rs_allocation a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 921 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 922 | rsrAllocationSyncAll(rsc, (Allocation *)a.p, RS_ALLOCATION_USAGE_SCRIPT); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | void rsgAllocationSyncAll(::rs_allocation a, |
| 926 | unsigned int usage) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 927 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 928 | rsrAllocationSyncAll(rsc, (Allocation *)a.p, (RsAllocationUsageType)usage); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 929 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 930 | |
| 931 | |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 932 | void rsgAllocationSyncAll(::rs_allocation a, |
| 933 | rs_allocation_usage_type source) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 934 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 935 | rsrAllocationSyncAll(rsc, (Allocation *)a.p, (RsAllocationUsageType)source.val); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | void rsgBindProgramFragment(::rs_program_fragment pf) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 939 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 940 | rsrBindProgramFragment(rsc, (ProgramFragment *)pf.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | void rsgBindProgramStore(::rs_program_store ps) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 944 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 945 | rsrBindProgramStore(rsc, (ProgramStore *)ps.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | void rsgBindProgramVertex(::rs_program_vertex pv) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 949 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 950 | rsrBindProgramVertex(rsc, (ProgramVertex *)pv.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | void rsgBindProgramRaster(::rs_program_raster pr) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 954 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 955 | rsrBindProgramRaster(rsc, (ProgramRaster *)pr.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | void rsgBindSampler(::rs_program_fragment pf, |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 959 | uint32_t slot, ::rs_sampler s) { |
| 960 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 961 | rsrBindSampler(rsc, (ProgramFragment *)pf.p, slot, (Sampler *)s.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | void rsgBindTexture(::rs_program_fragment pf, |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 965 | uint32_t slot, ::rs_allocation a) { |
| 966 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 967 | rsrBindTexture(rsc, (ProgramFragment *)pf.p, slot, (Allocation *)a.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | void rsgBindConstant(::rs_program_fragment pf, |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 971 | uint32_t slot, ::rs_allocation a) { |
| 972 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 973 | rsrBindConstant(rsc, (ProgramFragment *)pf.p, slot, (Allocation *)a.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | void rsgBindConstant(::rs_program_vertex pv, |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 977 | uint32_t slot, ::rs_allocation a) { |
| 978 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 979 | rsrBindConstant(rsc, (ProgramVertex *)pv.p, slot, (Allocation *)a.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | void rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *m) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 983 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 984 | rsrVpLoadProjectionMatrix(rsc, (const rsc_Matrix *)m); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | void rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *m) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 988 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 989 | rsrVpLoadModelMatrix(rsc, (const rsc_Matrix *)m); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | void rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *m) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 993 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 994 | rsrVpLoadTextureMatrix(rsc, (const rsc_Matrix *)m); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | void rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *m) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 998 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 999 | rsrVpGetProjectionMatrix(rsc, (rsc_Matrix *)m); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | void rsgProgramFragmentConstantColor(::rs_program_fragment pf, |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1003 | 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 Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | uint32_t rsgGetWidth(void) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1009 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1010 | return rsrGetWidth(rsc); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | uint32_t rsgGetHeight(void) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1014 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1015 | return rsrGetHeight(rsc); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | void rsgDrawRect(float x1, float y1, float x2, float y2, float z) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1019 | SC_DrawQuad(x1, y2, z, |
| 1020 | x2, y2, z, |
| 1021 | x2, y1, z, |
| 1022 | x1, y1, z); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1023 | } |
| 1024 | |
| 1025 | void 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 Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1029 | SC_DrawQuad(x1, y1, z1, |
| 1030 | x2, y2, z2, |
| 1031 | x3, y3, z3, |
| 1032 | x4, y4, z4); |
| 1033 | } |
| 1034 | |
| 1035 | void 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1039 | 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 Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | void rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1046 | SC_DrawSpriteScreenspace(x, y, z, w, h); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | void rsgDrawMesh(::rs_mesh ism) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1050 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1051 | rsrDrawMesh(rsc, (Mesh *)ism.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1055 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1056 | rsrDrawMeshPrimitive(rsc, (Mesh *)ism.p, primitiveIndex); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1057 | } |
| 1058 | |
| 1059 | void rsgDrawMesh(::rs_mesh ism, uint primitiveIndex, uint start, uint len) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1060 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1061 | rsrDrawMeshPrimitiveRange(rsc, (Mesh *)ism.p, primitiveIndex, start, len); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1062 | } |
| 1063 | |
| 1064 | void rsgMeshComputeBoundingBox(::rs_mesh mesh, |
| 1065 | float *minX, float *minY, float *minZ, |
| 1066 | float *maxX, float *maxY, float *maxZ) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1067 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1068 | rsrMeshComputeBoundingBox(rsc, (Mesh *)mesh.p, minX, minY, minZ, maxX, maxY, maxZ); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1069 | } |
| 1070 | |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1071 | void rsgClearColor(float r, float g, float b, float a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1072 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1073 | rsrPrepareClear(rsc); |
| 1074 | rsdGLClearColor(rsc, r, g, b, a); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | void rsgClearDepth(float value) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1078 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1079 | rsrPrepareClear(rsc); |
| 1080 | rsdGLClearDepth(rsc, value); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | void rsgDrawText(const char *text, int x, int y) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1084 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1085 | rsrDrawText(rsc, text, x, y); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | void rsgDrawText(::rs_allocation a, int x, int y) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1089 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1090 | rsrDrawTextAlloc(rsc, (Allocation *)a.p, x, y); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1091 | } |
| 1092 | |
| 1093 | void rsgMeasureText(const char *text, int *left, int *right, |
| 1094 | int *top, int *bottom) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1095 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1096 | rsrMeasureText(rsc, text, left, right, top, bottom); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | void rsgMeasureText(::rs_allocation a, int *left, int *right, |
| 1100 | int *top, int *bottom) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1101 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1102 | rsrMeasureTextAlloc(rsc, (Allocation *)a.p, left, right, top, bottom); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | void rsgBindFont(::rs_font font) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1106 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1107 | rsrBindFont(rsc, (Font *)font.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1108 | } |
| 1109 | |
| 1110 | void rsgFontColor(float r, float g, float b, float a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1111 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1112 | rsrFontColor(rsc, r, g, b, a); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | void rsgBindColorTarget(::rs_allocation a, uint slot) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1116 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1117 | rsrBindFrameBufferObjectColorTarget(rsc, (Allocation *)a.p, slot); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | void rsgBindDepthTarget(::rs_allocation a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1121 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1122 | rsrBindFrameBufferObjectDepthTarget(rsc, (Allocation *)a.p); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1123 | } |
| 1124 | |
| 1125 | void rsgClearColorTarget(uint slot) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1126 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1127 | rsrClearFrameBufferObjectColorTarget(rsc, slot); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | void rsgClearDepthTarget(void) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1131 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1132 | rsrClearFrameBufferObjectDepthTarget(rsc); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | void rsgClearAllRenderTargets(void) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1136 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1137 | rsrClearFrameBufferObjectTargets(rsc); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | void color(float r, float g, float b, float a) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1141 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1142 | rsrColor(rsc, r, g, b, a); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | void rsgFinish(void) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1146 | Context *rsc = RsdCpuReference::getTlsContext(); |
| 1147 | rsdGLFinish(rsc); |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1148 | } |
Pirama Arumuga Nainar | 2544371 | 2015-01-20 17:44:01 -0800 | [diff] [blame] | 1149 | #endif |
| 1150 | |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 1151 | ////////////////////////////////////////////////////////////////////////////// |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1152 | // Debug routines |
Tim Murray | d6f1f46 | 2013-03-25 16:36:59 -0700 | [diff] [blame] | 1153 | ////////////////////////////////////////////////////////////////////////////// |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1154 | void rsDebug(const char *s, float f) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1155 | ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f))); |
| 1156 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1157 | |
| 1158 | void rsDebug(const char *s, float f1, float f2) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1159 | ALOGD("%s {%f, %f}", s, f1, f2); |
| 1160 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1161 | |
| 1162 | void rsDebug(const char *s, float f1, float f2, float f3) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1163 | ALOGD("%s {%f, %f, %f}", s, f1, f2, f3); |
| 1164 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1165 | |
| 1166 | void rsDebug(const char *s, float f1, float f2, float f3, float f4) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1167 | ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4); |
| 1168 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1169 | |
| 1170 | void rsDebug(const char *s, const float2 *f2) { |
| 1171 | float2 f = *f2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1172 | ALOGD("%s {%f, %f}", s, f.x, f.y); |
| 1173 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1174 | |
| 1175 | void rsDebug(const char *s, const float3 *f3) { |
| 1176 | float3 f = *f3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1177 | ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z); |
| 1178 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1179 | |
| 1180 | void rsDebug(const char *s, const float4 *f4) { |
| 1181 | float4 f = *f4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1182 | ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w); |
| 1183 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1184 | |
Pirama Arumuga Nainar | 172b2fd | 2016-04-04 12:01:14 -0700 | [diff] [blame] | 1185 | // 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). |
| 1188 | void rsDebug(const char *s, float f, ushort us) { |
| 1189 | ALOGD("%s {%f} {0x%hx}", s, f, us); |
| 1190 | } |
| 1191 | |
| 1192 | void 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 | |
| 1198 | void 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 | |
| 1205 | void 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1212 | void rsDebug(const char *s, double d) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1213 | ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d))); |
| 1214 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1215 | |
| 1216 | void rsDebug(const char *s, const double2 *d2) { |
| 1217 | double2 d = *d2; |
Jean-Luc Brouillet | 6ba0517 | 2015-04-03 16:39:18 -0700 | [diff] [blame] | 1218 | ALOGD("%s {%f, %f}", s, d.x, d.y); |
| 1219 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1220 | |
| 1221 | void rsDebug(const char *s, const double3 *d3) { |
| 1222 | double3 d = *d3; |
Jean-Luc Brouillet | 6ba0517 | 2015-04-03 16:39:18 -0700 | [diff] [blame] | 1223 | ALOGD("%s {%f, %f, %f}", s, d.x, d.y, d.z); |
| 1224 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1225 | |
| 1226 | void rsDebug(const char *s, const double4 *d4) { |
| 1227 | double4 d = *d4; |
Jean-Luc Brouillet | 6ba0517 | 2015-04-03 16:39:18 -0700 | [diff] [blame] | 1228 | ALOGD("%s {%f, %f, %f, %f}", s, d.x, d.y, d.z, d.w); |
| 1229 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1230 | |
| 1231 | void rsDebug(const char *s, const rs_matrix4x4 *m) { |
| 1232 | float *f = (float *)m; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1233 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1238 | |
| 1239 | void rsDebug(const char *s, const rs_matrix3x3 *m) { |
| 1240 | float *f = (float *)m; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1241 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1245 | |
| 1246 | void rsDebug(const char *s, const rs_matrix2x2 *m) { |
| 1247 | float *f = (float *)m; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1248 | ALOGD("%s {%f, %f", s, f[0], f[2]); |
| 1249 | ALOGD("%s %f, %f}",s, f[1], f[3]); |
| 1250 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1251 | |
| 1252 | void rsDebug(const char *s, char c) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1253 | ALOGD("%s %hhd 0x%hhx", s, c, (unsigned char)c); |
| 1254 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1255 | |
| 1256 | void rsDebug(const char *s, const char2 *c2) { |
| 1257 | char2 c = *c2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1258 | ALOGD("%s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y); |
| 1259 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1260 | |
| 1261 | void rsDebug(const char *s, const char3 *c3) { |
| 1262 | char3 c = *c3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1263 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1265 | |
| 1266 | void rsDebug(const char *s, const char4 *c4) { |
| 1267 | char4 c = *c4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1268 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1270 | |
| 1271 | void rsDebug(const char *s, unsigned char c) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1272 | ALOGD("%s %hhu 0x%hhx", s, c, c); |
| 1273 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1274 | |
| 1275 | void rsDebug(const char *s, const uchar2 *c2) { |
| 1276 | uchar2 c = *c2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1277 | ALOGD("%s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y); |
| 1278 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1279 | |
| 1280 | void rsDebug(const char *s, const uchar3 *c3) { |
| 1281 | uchar3 c = *c3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1282 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1284 | |
| 1285 | void rsDebug(const char *s, const uchar4 *c4) { |
| 1286 | uchar4 c = *c4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1287 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1289 | |
Chih-Hung Hsieh | c9a8d13 | 2018-08-17 13:37:59 -0700 | [diff] [blame] | 1290 | void rsDebug(const char *s, int16_t c) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1291 | ALOGD("%s %hd 0x%hx", s, c, c); |
| 1292 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1293 | |
| 1294 | void rsDebug(const char *s, const short2 *c2) { |
| 1295 | short2 c = *c2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1296 | ALOGD("%s {%hd, %hd} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y); |
| 1297 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1298 | |
| 1299 | void rsDebug(const char *s, const short3 *c3) { |
| 1300 | short3 c = *c3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1301 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1303 | |
| 1304 | void rsDebug(const char *s, const short4 *c4) { |
| 1305 | short4 c = *c4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1306 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1308 | |
Chih-Hung Hsieh | c9a8d13 | 2018-08-17 13:37:59 -0700 | [diff] [blame] | 1309 | void rsDebug(const char *s, uint16_t c) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1310 | ALOGD("%s %hu 0x%hx", s, c, c); |
| 1311 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1312 | |
| 1313 | void rsDebug(const char *s, const ushort2 *c2) { |
| 1314 | ushort2 c = *c2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1315 | ALOGD("%s {%hu, %hu} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y); |
| 1316 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1317 | |
| 1318 | void rsDebug(const char *s, const ushort3 *c3) { |
| 1319 | ushort3 c = *c3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1320 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1322 | |
| 1323 | void rsDebug(const char *s, const ushort4 *c4) { |
| 1324 | ushort4 c = *c4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1325 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1327 | |
| 1328 | void rsDebug(const char *s, int i) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1329 | ALOGD("%s %d 0x%x", s, i, i); |
| 1330 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1331 | |
| 1332 | void rsDebug(const char *s, const int2 *i2) { |
| 1333 | int2 i = *i2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1334 | ALOGD("%s {%d, %d} 0x%x 0x%x", s, i.x, i.y, i.x, i.y); |
| 1335 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1336 | |
| 1337 | void rsDebug(const char *s, const int3 *i3) { |
| 1338 | int3 i = *i3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1339 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1341 | |
| 1342 | void rsDebug(const char *s, const int4 *i4) { |
| 1343 | int4 i = *i4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1344 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1346 | |
| 1347 | void rsDebug(const char *s, unsigned int i) { |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1348 | ALOGD("%s %u 0x%x", s, i, i); |
| 1349 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1350 | |
| 1351 | void rsDebug(const char *s, const uint2 *i2) { |
| 1352 | uint2 i = *i2; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1353 | ALOGD("%s {%u, %u} 0x%x 0x%x", s, i.x, i.y, i.x, i.y); |
| 1354 | } |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1355 | |
| 1356 | void rsDebug(const char *s, const uint3 *i3) { |
| 1357 | uint3 i = *i3; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1358 | 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 Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1360 | |
| 1361 | void rsDebug(const char *s, const uint4 *i4) { |
| 1362 | uint4 i = *i4; |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1363 | 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 Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 1365 | |
| 1366 | template <typename T> |
| 1367 | static inline long long LL(const T &x) { |
| 1368 | return static_cast<long long>(x); |
| 1369 | } |
| 1370 | |
| 1371 | template <typename T> |
| 1372 | static inline unsigned long long LLu(const T &x) { |
| 1373 | return static_cast<unsigned long long>(x); |
| 1374 | } |
| 1375 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1376 | void rsDebug(const char *s, long l) { |
| 1377 | ALOGD("%s %lld 0x%llx", s, LL(l), LL(l)); |
| 1378 | } |
| 1379 | |
| 1380 | void rsDebug(const char *s, long long ll) { |
Pirama Arumuga Nainar | dc0d8f7 | 2014-12-02 15:23:38 -0800 | [diff] [blame] | 1381 | ALOGD("%s %lld 0x%llx", s, LL(ll), LL(ll)); |
| 1382 | } |
| 1383 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1384 | void rsDebug(const char *s, const long2 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1385 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1387 | } |
| 1388 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1389 | void rsDebug(const char *s, const long3 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1390 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1394 | void rsDebug(const char *s, const long4 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1395 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1399 | void rsDebug(const char *s, unsigned long l) { |
| 1400 | unsigned long long ll = l; |
| 1401 | ALOGD("%s %llu 0x%llx", s, ll, ll); |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1402 | } |
| 1403 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1404 | void rsDebug(const char *s, unsigned long long ll) { |
| 1405 | ALOGD("%s %llu 0x%llx", s, ll, ll); |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1408 | void rsDebug(const char *s, const ulong2 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1409 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1413 | void rsDebug(const char *s, const ulong3 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1414 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1416 | } |
| 1417 | |
Stephen Hines | b0934b6 | 2013-07-03 17:27:38 -0700 | [diff] [blame] | 1418 | void rsDebug(const char *s, const ulong4 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1419 | 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 Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1421 | } |
| 1422 | |
Stephen Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1423 | // 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 Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 1427 | |
| 1428 | #ifndef __LP64__ |
Stephen Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1429 | typedef long l2 __attribute__((ext_vector_type(2))); |
| 1430 | typedef long l3 __attribute__((ext_vector_type(3))); |
| 1431 | typedef long l4 __attribute__((ext_vector_type(4))); |
| 1432 | typedef unsigned long ul2 __attribute__((ext_vector_type(2))); |
| 1433 | typedef unsigned long ul3 __attribute__((ext_vector_type(3))); |
| 1434 | typedef unsigned long ul4 __attribute__((ext_vector_type(4))); |
| 1435 | |
| 1436 | void rsDebug(const char *s, const l2 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1437 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | void rsDebug(const char *s, const l3 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1442 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1444 | } |
| 1445 | |
| 1446 | void rsDebug(const char *s, const l4 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1447 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1449 | } |
| 1450 | |
| 1451 | void rsDebug(const char *s, const ul2 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1452 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | void rsDebug(const char *s, const ul3 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1457 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | void rsDebug(const char *s, const ul4 *c) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1462 | 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 Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1464 | } |
Miao Wang | 127d51c | 2014-11-24 13:41:33 -0800 | [diff] [blame] | 1465 | #endif |
Stephen Hines | a5d9bef | 2013-12-05 17:57:49 -0800 | [diff] [blame] | 1466 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1467 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1469 | } |
| 1470 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1471 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1475 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1477 | } |
| 1478 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1479 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1481 | } |
| 1482 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1483 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1485 | } |
| 1486 | |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1487 | void 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 Murray | 9f39aaf | 2014-10-13 12:35:32 -0700 | [diff] [blame] | 1489 | } |
| 1490 | |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1491 | void rsDebug(const char *s, const void *p) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1492 | ALOGD("%s %p", s, p); |
Tim Murray | 0b575de | 2013-03-15 15:56:43 -0700 | [diff] [blame] | 1493 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 1494 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 1495 | extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name) { |
Yong Chen | 174ebc4 | 2015-03-27 17:56:09 +0800 | [diff] [blame] | 1496 | // TODO: remove |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 1497 | return nullptr; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 1498 | } |