Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 1 | /* |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 The Android Open Source Project |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [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 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 17 | #include <malloc.h> |
| 18 | #include <string.h> |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 19 | #include <pthread.h> |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 20 | |
| 21 | #include "RenderScript.h" |
Tim Murray | 89daad6 | 2013-07-29 14:30:02 -0700 | [diff] [blame] | 22 | #include "rsCppStructs.h" |
Tim Murray | eeaf714 | 2013-09-09 15:03:50 -0700 | [diff] [blame] | 23 | #include "rsCppInternal.h" |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 24 | |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 25 | #include <dlfcn.h> |
Tim Murray | 0f98d50 | 2014-01-15 14:35:31 -0800 | [diff] [blame] | 26 | #include <unistd.h> |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 27 | |
Tim Murray | 0f98d50 | 2014-01-15 14:35:31 -0800 | [diff] [blame] | 28 | #if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB) && defined(HAVE_ANDROID_OS) |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 29 | #include <cutils/properties.h> |
Tim Murray | 0f98d50 | 2014-01-15 14:35:31 -0800 | [diff] [blame] | 30 | #else |
| 31 | #include "rsCompatibilityLib.h" |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 32 | #endif |
| 33 | |
Tim Murray | 0f98d50 | 2014-01-15 14:35:31 -0800 | [diff] [blame] | 34 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 35 | using namespace android; |
Tim Murray | 9eb7f4b | 2012-11-16 14:02:18 -0800 | [diff] [blame] | 36 | using namespace RSC; |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 37 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 38 | bool RS::gInitialized = false; |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 39 | bool RS::usingNative = false; |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 40 | pthread_mutex_t RS::gInitMutex = PTHREAD_MUTEX_INITIALIZER; |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 41 | dispatchTable* RS::dispatch = nullptr; |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 42 | static int gInitError = 0; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 43 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 44 | RS::RS() { |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 45 | mDev = nullptr; |
| 46 | mContext = nullptr; |
| 47 | mErrorFunc = nullptr; |
| 48 | mMessageFunc = nullptr; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 49 | mMessageRun = false; |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 50 | mInit = false; |
Tim Murray | 21fa7a0 | 2013-08-15 16:25:03 -0700 | [diff] [blame] | 51 | mCurrentError = RS_SUCCESS; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 52 | |
| 53 | memset(&mElements, 0, sizeof(mElements)); |
Tim Murray | 729b6fe | 2013-07-23 16:20:42 -0700 | [diff] [blame] | 54 | memset(&mSamplers, 0, sizeof(mSamplers)); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 57 | RS::~RS() { |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 58 | if (mInit == true) { |
| 59 | mMessageRun = false; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 60 | |
Xiaofei Wan | fea96e8 | 2014-03-31 16:43:15 +0800 | [diff] [blame] | 61 | if (mContext) { |
| 62 | RS::dispatch->ContextDeinitToClient(mContext); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 63 | |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 64 | void *res = nullptr; |
Xiaofei Wan | fea96e8 | 2014-03-31 16:43:15 +0800 | [diff] [blame] | 65 | int status = pthread_join(mMessageThreadId, &res); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 66 | |
Xiaofei Wan | fea96e8 | 2014-03-31 16:43:15 +0800 | [diff] [blame] | 67 | RS::dispatch->ContextDestroy(mContext); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 68 | mContext = nullptr; |
Xiaofei Wan | fea96e8 | 2014-03-31 16:43:15 +0800 | [diff] [blame] | 69 | } |
| 70 | if (mDev) { |
| 71 | RS::dispatch->DeviceDestroy(mDev); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 72 | mDev = nullptr; |
Xiaofei Wan | fea96e8 | 2014-03-31 16:43:15 +0800 | [diff] [blame] | 73 | } |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 74 | } |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Tim Murray | caf4126 | 2013-12-13 12:54:37 -0800 | [diff] [blame] | 77 | bool RS::init(std::string name, uint32_t flags) { |
| 78 | return RS::init(name, RS_VERSION, flags); |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 81 | static bool loadSymbols(void* handle) { |
| 82 | |
| 83 | RS::dispatch->AllocationGetType = (AllocationGetTypeFnPtr)dlsym(handle, "rsaAllocationGetType"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 84 | if (RS::dispatch->AllocationGetType == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 85 | ALOGV("Couldn't initialize RS::dispatch->AllocationGetType"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 86 | return false; |
| 87 | } |
| 88 | RS::dispatch->TypeGetNativeData = (TypeGetNativeDataFnPtr)dlsym(handle, "rsaTypeGetNativeData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 89 | if (RS::dispatch->TypeGetNativeData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 90 | ALOGV("Couldn't initialize RS::dispatch->TypeGetNativeData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 91 | return false; |
| 92 | } |
| 93 | RS::dispatch->ElementGetNativeData = (ElementGetNativeDataFnPtr)dlsym(handle, "rsaElementGetNativeData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 94 | if (RS::dispatch->ElementGetNativeData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 95 | ALOGV("Couldn't initialize RS::dispatch->ElementGetNativeData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 96 | return false; |
| 97 | } |
| 98 | RS::dispatch->ElementGetSubElements = (ElementGetSubElementsFnPtr)dlsym(handle, "rsaElementGetSubElements"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 99 | if (RS::dispatch->ElementGetSubElements == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 100 | ALOGV("Couldn't initialize RS::dispatch->ElementGetSubElements"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 101 | return false; |
| 102 | } |
| 103 | RS::dispatch->DeviceCreate = (DeviceCreateFnPtr)dlsym(handle, "rsDeviceCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 104 | if (RS::dispatch->DeviceCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 105 | ALOGV("Couldn't initialize RS::dispatch->DeviceCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 106 | return false; |
| 107 | } |
| 108 | RS::dispatch->DeviceDestroy = (DeviceDestroyFnPtr)dlsym(handle, "rsDeviceDestroy"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 109 | if (RS::dispatch->DeviceDestroy == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 110 | ALOGV("Couldn't initialize RS::dispatch->DeviceDestroy"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 111 | return false; |
| 112 | } |
| 113 | RS::dispatch->DeviceSetConfig = (DeviceSetConfigFnPtr)dlsym(handle, "rsDeviceSetConfig"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 114 | if (RS::dispatch->DeviceSetConfig == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 115 | ALOGV("Couldn't initialize RS::dispatch->DeviceSetConfig"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 116 | return false; |
| 117 | } |
| 118 | RS::dispatch->ContextCreate = (ContextCreateFnPtr)dlsym(handle, "rsContextCreate");; |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 119 | if (RS::dispatch->ContextCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 120 | ALOGV("Couldn't initialize RS::dispatch->ContextCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 121 | return false; |
| 122 | } |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 123 | RS::dispatch->GetName = (GetNameFnPtr)dlsym(handle, "rsaGetName");; |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 124 | if (RS::dispatch->GetName == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 125 | ALOGV("Couldn't initialize RS::dispatch->GetName"); |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 126 | return false; |
| 127 | } |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 128 | RS::dispatch->ContextDestroy = (ContextDestroyFnPtr)dlsym(handle, "rsContextDestroy"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 129 | if (RS::dispatch->ContextDestroy == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 130 | ALOGV("Couldn't initialize RS::dispatch->ContextDestroy"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 131 | return false; |
| 132 | } |
| 133 | RS::dispatch->ContextGetMessage = (ContextGetMessageFnPtr)dlsym(handle, "rsContextGetMessage"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 134 | if (RS::dispatch->ContextGetMessage == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 135 | ALOGV("Couldn't initialize RS::dispatch->ContextGetMessage"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 136 | return false; |
| 137 | } |
| 138 | RS::dispatch->ContextPeekMessage = (ContextPeekMessageFnPtr)dlsym(handle, "rsContextPeekMessage"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 139 | if (RS::dispatch->ContextPeekMessage == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 140 | ALOGV("Couldn't initialize RS::dispatch->ContextPeekMessage"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 141 | return false; |
| 142 | } |
| 143 | RS::dispatch->ContextSendMessage = (ContextSendMessageFnPtr)dlsym(handle, "rsContextSendMessage"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 144 | if (RS::dispatch->ContextSendMessage == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 145 | ALOGV("Couldn't initialize RS::dispatch->ContextSendMessage"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 146 | return false; |
| 147 | } |
| 148 | RS::dispatch->ContextInitToClient = (ContextInitToClientFnPtr)dlsym(handle, "rsContextInitToClient"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 149 | if (RS::dispatch->ContextInitToClient == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 150 | ALOGV("Couldn't initialize RS::dispatch->ContextInitToClient"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | RS::dispatch->ContextDeinitToClient = (ContextDeinitToClientFnPtr)dlsym(handle, "rsContextDeinitToClient"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 154 | if (RS::dispatch->ContextDeinitToClient == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 155 | ALOGV("Couldn't initialize RS::dispatch->ContextDeinitToClient"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 156 | return false; |
| 157 | } |
| 158 | RS::dispatch->TypeCreate = (TypeCreateFnPtr)dlsym(handle, "rsTypeCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 159 | if (RS::dispatch->TypeCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 160 | ALOGV("Couldn't initialize RS::dispatch->TypeCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 161 | return false; |
| 162 | } |
| 163 | RS::dispatch->AllocationCreateTyped = (AllocationCreateTypedFnPtr)dlsym(handle, "rsAllocationCreateTyped"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 164 | if (RS::dispatch->AllocationCreateTyped == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 165 | ALOGV("Couldn't initialize RS::dispatch->AllocationCreateTyped"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 166 | return false; |
| 167 | } |
| 168 | RS::dispatch->AllocationCreateFromBitmap = (AllocationCreateFromBitmapFnPtr)dlsym(handle, "rsAllocationCreateFromBitmap"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 169 | if (RS::dispatch->AllocationCreateFromBitmap == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 170 | ALOGV("Couldn't initialize RS::dispatch->AllocationCreateFromBitmap"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 171 | return false; |
| 172 | } |
| 173 | RS::dispatch->AllocationCubeCreateFromBitmap = (AllocationCubeCreateFromBitmapFnPtr)dlsym(handle, "rsAllocationCubeCreateFromBitmap"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 174 | if (RS::dispatch->AllocationCubeCreateFromBitmap == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 175 | ALOGV("Couldn't initialize RS::dispatch->AllocationCubeCreateFromBitmap"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 176 | return false; |
| 177 | } |
| 178 | RS::dispatch->AllocationGetSurface = (AllocationGetSurfaceFnPtr)dlsym(handle, "rsAllocationGetSurface"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 179 | if (RS::dispatch->AllocationGetSurface == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 180 | ALOGV("Couldn't initialize RS::dispatch->AllocationGetSurface"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 181 | return false; |
| 182 | } |
| 183 | RS::dispatch->AllocationSetSurface = (AllocationSetSurfaceFnPtr)dlsym(handle, "rsAllocationSetSurface"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 184 | if (RS::dispatch->AllocationSetSurface == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 185 | ALOGV("Couldn't initialize RS::dispatch->AllocationSetSurface"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 186 | return false; |
| 187 | } |
| 188 | RS::dispatch->ContextFinish = (ContextFinishFnPtr)dlsym(handle, "rsContextFinish"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 189 | if (RS::dispatch->ContextFinish == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 190 | ALOGV("Couldn't initialize RS::dispatch->ContextFinish"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 191 | return false; |
| 192 | } |
| 193 | RS::dispatch->ContextDump = (ContextDumpFnPtr)dlsym(handle, "rsContextDump"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 194 | if (RS::dispatch->ContextDump == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 195 | ALOGV("Couldn't initialize RS::dispatch->ContextDump"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 196 | return false; |
| 197 | } |
| 198 | RS::dispatch->ContextSetPriority = (ContextSetPriorityFnPtr)dlsym(handle, "rsContextSetPriority"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 199 | if (RS::dispatch->ContextSetPriority == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 200 | ALOGV("Couldn't initialize RS::dispatch->ContextSetPriority"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 201 | return false; |
| 202 | } |
| 203 | RS::dispatch->AssignName = (AssignNameFnPtr)dlsym(handle, "rsAssignName"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 204 | if (RS::dispatch->AssignName == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 205 | ALOGV("Couldn't initialize RS::dispatch->AssignName"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 206 | return false; |
| 207 | } |
| 208 | RS::dispatch->ObjDestroy = (ObjDestroyFnPtr)dlsym(handle, "rsObjDestroy"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 209 | if (RS::dispatch->ObjDestroy == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 210 | ALOGV("Couldn't initialize RS::dispatch->ObjDestroy"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 211 | return false; |
| 212 | } |
| 213 | RS::dispatch->ElementCreate = (ElementCreateFnPtr)dlsym(handle, "rsElementCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 214 | if (RS::dispatch->ElementCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 215 | ALOGV("Couldn't initialize RS::dispatch->ElementCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 216 | return false; |
| 217 | } |
| 218 | RS::dispatch->ElementCreate2 = (ElementCreate2FnPtr)dlsym(handle, "rsElementCreate2"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 219 | if (RS::dispatch->ElementCreate2 == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 220 | ALOGV("Couldn't initialize RS::dispatch->ElementCreate2"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 221 | return false; |
| 222 | } |
| 223 | RS::dispatch->AllocationCopyToBitmap = (AllocationCopyToBitmapFnPtr)dlsym(handle, "rsAllocationCopyToBitmap"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 224 | if (RS::dispatch->AllocationCopyToBitmap == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 225 | ALOGV("Couldn't initialize RS::dispatch->AllocationCopyToBitmap"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 226 | return false; |
| 227 | } |
| 228 | RS::dispatch->Allocation1DData = (Allocation1DDataFnPtr)dlsym(handle, "rsAllocation1DData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 229 | if (RS::dispatch->Allocation1DData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 230 | ALOGV("Couldn't initialize RS::dispatch->Allocation1DData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 231 | return false; |
| 232 | } |
| 233 | RS::dispatch->Allocation1DElementData = (Allocation1DElementDataFnPtr)dlsym(handle, "rsAllocation1DElementData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 234 | if (RS::dispatch->Allocation1DElementData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 235 | ALOGV("Couldn't initialize RS::dispatch->Allocation1DElementData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 236 | return false; |
| 237 | } |
| 238 | RS::dispatch->Allocation2DData = (Allocation2DDataFnPtr)dlsym(handle, "rsAllocation2DData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 239 | if (RS::dispatch->Allocation2DData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 240 | ALOGV("Couldn't initialize RS::dispatch->Allocation2DData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 241 | return false; |
| 242 | } |
| 243 | RS::dispatch->Allocation3DData = (Allocation3DDataFnPtr)dlsym(handle, "rsAllocation3DData"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 244 | if (RS::dispatch->Allocation3DData == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 245 | ALOGV("Couldn't initialize RS::dispatch->Allocation3DData"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 246 | return false; |
| 247 | } |
| 248 | RS::dispatch->AllocationGenerateMipmaps = (AllocationGenerateMipmapsFnPtr)dlsym(handle, "rsAllocationGenerateMipmaps"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 249 | if (RS::dispatch->AllocationGenerateMipmaps == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 250 | ALOGV("Couldn't initialize RS::dispatch->AllocationGenerateMipmaps"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 251 | return false; |
| 252 | } |
| 253 | RS::dispatch->AllocationRead = (AllocationReadFnPtr)dlsym(handle, "rsAllocationRead"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 254 | if (RS::dispatch->AllocationRead == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 255 | ALOGV("Couldn't initialize RS::dispatch->AllocationRead"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 256 | return false; |
| 257 | } |
| 258 | RS::dispatch->Allocation1DRead = (Allocation1DReadFnPtr)dlsym(handle, "rsAllocation1DRead"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 259 | if (RS::dispatch->Allocation1DRead == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 260 | ALOGV("Couldn't initialize RS::dispatch->Allocation1DRead"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 261 | return false; |
| 262 | } |
| 263 | RS::dispatch->Allocation2DRead = (Allocation2DReadFnPtr)dlsym(handle, "rsAllocation2DRead"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 264 | if (RS::dispatch->Allocation2DRead == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 265 | ALOGV("Couldn't initialize RS::dispatch->Allocation2DRead"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 266 | return false; |
| 267 | } |
| 268 | RS::dispatch->AllocationSyncAll = (AllocationSyncAllFnPtr)dlsym(handle, "rsAllocationSyncAll"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 269 | if (RS::dispatch->AllocationSyncAll == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 270 | ALOGV("Couldn't initialize RS::dispatch->AllocationSyncAll"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 271 | return false; |
| 272 | } |
| 273 | RS::dispatch->AllocationResize1D = (AllocationResize1DFnPtr)dlsym(handle, "rsAllocationResize1D"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 274 | if (RS::dispatch->AllocationResize1D == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 275 | ALOGV("Couldn't initialize RS::dispatch->AllocationResize1D"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 276 | return false; |
| 277 | } |
| 278 | RS::dispatch->AllocationCopy2DRange = (AllocationCopy2DRangeFnPtr)dlsym(handle, "rsAllocationCopy2DRange"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 279 | if (RS::dispatch->AllocationCopy2DRange == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 280 | ALOGV("Couldn't initialize RS::dispatch->AllocationCopy2DRange"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 281 | return false; |
| 282 | } |
| 283 | RS::dispatch->AllocationCopy3DRange = (AllocationCopy3DRangeFnPtr)dlsym(handle, "rsAllocationCopy3DRange"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 284 | if (RS::dispatch->AllocationCopy3DRange == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 285 | ALOGV("Couldn't initialize RS::dispatch->AllocationCopy3DRange"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 286 | return false; |
| 287 | } |
| 288 | RS::dispatch->SamplerCreate = (SamplerCreateFnPtr)dlsym(handle, "rsSamplerCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 289 | if (RS::dispatch->SamplerCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 290 | ALOGV("Couldn't initialize RS::dispatch->SamplerCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 291 | return false; |
| 292 | } |
| 293 | RS::dispatch->ScriptBindAllocation = (ScriptBindAllocationFnPtr)dlsym(handle, "rsScriptBindAllocation"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 294 | if (RS::dispatch->ScriptBindAllocation == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 295 | ALOGV("Couldn't initialize RS::dispatch->ScriptBindAllocation"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 296 | return false; |
| 297 | } |
| 298 | RS::dispatch->ScriptSetTimeZone = (ScriptSetTimeZoneFnPtr)dlsym(handle, "rsScriptSetTimeZone"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 299 | if (RS::dispatch->ScriptSetTimeZone == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 300 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetTimeZone"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 301 | return false; |
| 302 | } |
| 303 | RS::dispatch->ScriptInvoke = (ScriptInvokeFnPtr)dlsym(handle, "rsScriptInvoke"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 304 | if (RS::dispatch->ScriptInvoke == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 305 | ALOGV("Couldn't initialize RS::dispatch->ScriptInvoke"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 306 | return false; |
| 307 | } |
| 308 | RS::dispatch->ScriptInvokeV = (ScriptInvokeVFnPtr)dlsym(handle, "rsScriptInvokeV"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 309 | if (RS::dispatch->ScriptInvokeV == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 310 | ALOGV("Couldn't initialize RS::dispatch->ScriptInvokeV"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 311 | return false; |
| 312 | } |
| 313 | RS::dispatch->ScriptForEach = (ScriptForEachFnPtr)dlsym(handle, "rsScriptForEach"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 314 | if (RS::dispatch->ScriptForEach == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 315 | ALOGV("Couldn't initialize RS::dispatch->ScriptForEach"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 316 | return false; |
| 317 | } |
| 318 | RS::dispatch->ScriptSetVarI = (ScriptSetVarIFnPtr)dlsym(handle, "rsScriptSetVarI"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 319 | if (RS::dispatch->ScriptSetVarI == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 320 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarI"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 321 | return false; |
| 322 | } |
| 323 | RS::dispatch->ScriptSetVarObj = (ScriptSetVarObjFnPtr)dlsym(handle, "rsScriptSetVarObj"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 324 | if (RS::dispatch->ScriptSetVarObj == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 325 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarObj"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 326 | return false; |
| 327 | } |
| 328 | RS::dispatch->ScriptSetVarJ = (ScriptSetVarJFnPtr)dlsym(handle, "rsScriptSetVarJ"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 329 | if (RS::dispatch->ScriptSetVarJ == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 330 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarJ"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 331 | return false; |
| 332 | } |
| 333 | RS::dispatch->ScriptSetVarF = (ScriptSetVarFFnPtr)dlsym(handle, "rsScriptSetVarF"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 334 | if (RS::dispatch->ScriptSetVarF == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 335 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarF"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 336 | return false; |
| 337 | } |
| 338 | RS::dispatch->ScriptSetVarD = (ScriptSetVarDFnPtr)dlsym(handle, "rsScriptSetVarD"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 339 | if (RS::dispatch->ScriptSetVarD == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 340 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarD"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 341 | return false; |
| 342 | } |
| 343 | RS::dispatch->ScriptSetVarV = (ScriptSetVarVFnPtr)dlsym(handle, "rsScriptSetVarV"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 344 | if (RS::dispatch->ScriptSetVarV == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 345 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarV"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 346 | return false; |
| 347 | } |
| 348 | RS::dispatch->ScriptGetVarV = (ScriptGetVarVFnPtr)dlsym(handle, "rsScriptGetVarV"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 349 | if (RS::dispatch->ScriptGetVarV == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 350 | ALOGV("Couldn't initialize RS::dispatch->ScriptGetVarV"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 351 | return false; |
| 352 | } |
| 353 | RS::dispatch->ScriptSetVarVE = (ScriptSetVarVEFnPtr)dlsym(handle, "rsScriptSetVarVE"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 354 | if (RS::dispatch->ScriptSetVarVE == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 355 | ALOGV("Couldn't initialize RS::dispatch->ScriptSetVarVE"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 356 | return false; |
| 357 | } |
| 358 | RS::dispatch->ScriptCCreate = (ScriptCCreateFnPtr)dlsym(handle, "rsScriptCCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 359 | if (RS::dispatch->ScriptCCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 360 | ALOGV("Couldn't initialize RS::dispatch->ScriptCCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 361 | return false; |
| 362 | } |
| 363 | RS::dispatch->ScriptIntrinsicCreate = (ScriptIntrinsicCreateFnPtr)dlsym(handle, "rsScriptIntrinsicCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 364 | if (RS::dispatch->ScriptIntrinsicCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 365 | ALOGV("Couldn't initialize RS::dispatch->ScriptIntrinsicCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 366 | return false; |
| 367 | } |
| 368 | RS::dispatch->ScriptKernelIDCreate = (ScriptKernelIDCreateFnPtr)dlsym(handle, "rsScriptKernelIDCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 369 | if (RS::dispatch->ScriptKernelIDCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 370 | ALOGV("Couldn't initialize RS::dispatch->ScriptKernelIDCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 371 | return false; |
| 372 | } |
| 373 | RS::dispatch->ScriptFieldIDCreate = (ScriptFieldIDCreateFnPtr)dlsym(handle, "rsScriptFieldIDCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 374 | if (RS::dispatch->ScriptFieldIDCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 375 | ALOGV("Couldn't initialize RS::dispatch->ScriptFieldIDCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 376 | return false; |
| 377 | } |
| 378 | RS::dispatch->ScriptGroupCreate = (ScriptGroupCreateFnPtr)dlsym(handle, "rsScriptGroupCreate"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 379 | if (RS::dispatch->ScriptGroupCreate == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 380 | ALOGV("Couldn't initialize RS::dispatch->ScriptGroupCreate"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 381 | return false; |
| 382 | } |
| 383 | RS::dispatch->ScriptGroupSetOutput = (ScriptGroupSetOutputFnPtr)dlsym(handle, "rsScriptGroupSetOutput"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 384 | if (RS::dispatch->ScriptGroupSetOutput == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 385 | ALOGV("Couldn't initialize RS::dispatch->ScriptGroupSetOutput"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 386 | return false; |
| 387 | } |
| 388 | RS::dispatch->ScriptGroupSetInput = (ScriptGroupSetInputFnPtr)dlsym(handle, "rsScriptGroupSetInput"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 389 | if (RS::dispatch->ScriptGroupSetInput == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 390 | ALOGV("Couldn't initialize RS::dispatch->ScriptGroupSetInput"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 391 | return false; |
| 392 | } |
| 393 | RS::dispatch->ScriptGroupExecute = (ScriptGroupExecuteFnPtr)dlsym(handle, "rsScriptGroupExecute"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 394 | if (RS::dispatch->ScriptGroupExecute == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 395 | ALOGV("Couldn't initialize RS::dispatch->ScriptGroupExecute"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 396 | return false; |
| 397 | } |
| 398 | RS::dispatch->AllocationIoSend = (AllocationIoSendFnPtr)dlsym(handle, "rsAllocationIoSend"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 399 | if (RS::dispatch->AllocationIoSend == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 400 | ALOGV("Couldn't initialize RS::dispatch->AllocationIoSend"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 401 | return false; |
| 402 | } |
| 403 | RS::dispatch->AllocationIoReceive = (AllocationIoReceiveFnPtr)dlsym(handle, "rsAllocationIoReceive"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 404 | if (RS::dispatch->AllocationIoReceive == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 405 | ALOGV("Couldn't initialize RS::dispatch->AllocationIoReceive"); |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 406 | return false; |
| 407 | } |
Jason Sams | b8a94e2 | 2014-02-24 17:52:32 -0800 | [diff] [blame] | 408 | RS::dispatch->AllocationGetPointer = (AllocationGetPointerFnPtr)dlsym(handle, "rsAllocationGetPointer"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 409 | if (RS::dispatch->AllocationGetPointer == nullptr) { |
Jason Sams | b8a94e2 | 2014-02-24 17:52:32 -0800 | [diff] [blame] | 410 | ALOGV("Couldn't initialize RS::dispatch->AllocationGetPointer"); |
| 411 | //return false; |
| 412 | } |
Tim Murray | 0b8a2be | 2013-07-23 16:25:41 -0700 | [diff] [blame] | 413 | |
| 414 | return true; |
| 415 | } |
| 416 | |
Tim Murray | 75e877d | 2013-09-11 14:45:20 -0700 | [diff] [blame] | 417 | // this will only open API 19+ libRS |
| 418 | // because that's when we changed libRS to extern "C" entry points |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 419 | static bool loadSO(const char* filename) { |
| 420 | void* handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 421 | if (handle == nullptr) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 422 | ALOGV("couldn't dlopen %s, %s", filename, dlerror()); |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 423 | return false; |
| 424 | } |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 425 | |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 426 | if (loadSymbols(handle) == false) { |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 427 | ALOGV("%s init failed!", filename); |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 428 | return false; |
| 429 | } |
Tim Murray | 84e3dea | 2013-09-09 16:12:51 -0700 | [diff] [blame] | 430 | //ALOGE("Successfully loaded %s", filename); |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 431 | return true; |
| 432 | } |
| 433 | |
| 434 | static uint32_t getProp(const char *str) { |
| 435 | #if !defined(RS_SERVER) && defined(HAVE_ANDROID_OS) |
| 436 | char buf[256]; |
| 437 | property_get(str, buf, "0"); |
| 438 | return atoi(buf); |
| 439 | #else |
| 440 | return 0; |
| 441 | #endif |
| 442 | } |
| 443 | |
| 444 | bool RS::initDispatch(int targetApi) { |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 445 | pthread_mutex_lock(&gInitMutex); |
| 446 | if (gInitError) { |
| 447 | goto error; |
| 448 | } else if (gInitialized) { |
Tim Murray | 47666f5 | 2013-07-29 14:32:34 -0700 | [diff] [blame] | 449 | pthread_mutex_unlock(&gInitMutex); |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 450 | return true; |
| 451 | } |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 452 | |
| 453 | RS::dispatch = new dispatchTable; |
Tim Murray | 4a92d12 | 2013-07-22 10:56:18 -0700 | [diff] [blame] | 454 | |
| 455 | // attempt to load libRS, load libRSSupport on failure |
| 456 | // if property is set, proceed directly to libRSSupport |
| 457 | if (getProp("debug.rs.forcecompat") == 0) { |
| 458 | usingNative = loadSO("libRS.so"); |
| 459 | } |
| 460 | if (usingNative == false) { |
| 461 | if (loadSO("libRSSupport.so") == false) { |
| 462 | ALOGE("Failed to load libRS.so and libRSSupport.so"); |
| 463 | goto error; |
| 464 | } |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | gInitialized = true; |
| 468 | |
| 469 | pthread_mutex_unlock(&gInitMutex); |
| 470 | return true; |
| 471 | |
| 472 | error: |
| 473 | gInitError = 1; |
| 474 | pthread_mutex_unlock(&gInitMutex); |
| 475 | return false; |
| 476 | } |
| 477 | |
Tim Murray | caf4126 | 2013-12-13 12:54:37 -0800 | [diff] [blame] | 478 | bool RS::init(std::string &name, int targetApi, uint32_t flags) { |
| 479 | if (mInit) { |
| 480 | return true; |
| 481 | } |
| 482 | |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 483 | if (initDispatch(targetApi) == false) { |
| 484 | ALOGE("Couldn't initialize dispatch table"); |
| 485 | return false; |
| 486 | } |
| 487 | |
Tim Murray | caf4126 | 2013-12-13 12:54:37 -0800 | [diff] [blame] | 488 | mCacheDir = name; |
Tim Murray | caf4126 | 2013-12-13 12:54:37 -0800 | [diff] [blame] | 489 | |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 490 | mDev = RS::dispatch->DeviceCreate(); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 491 | if (mDev == 0) { |
| 492 | ALOGE("Device creation failed"); |
| 493 | return false; |
| 494 | } |
| 495 | |
Jason Sams | bfa5a8e | 2014-05-20 18:16:20 -0700 | [diff] [blame] | 496 | if (flags & ~(RS_CONTEXT_SYNCHRONOUS | RS_CONTEXT_LOW_LATENCY | |
| 497 | RS_CONTEXT_LOW_POWER)) { |
Tim Murray | 84e3dea | 2013-09-09 16:12:51 -0700 | [diff] [blame] | 498 | ALOGE("Invalid flags passed"); |
| 499 | return false; |
| 500 | } |
| 501 | |
| 502 | mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 503 | if (mContext == 0) { |
| 504 | ALOGE("Context creation failed"); |
| 505 | return false; |
| 506 | } |
| 507 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 508 | pid_t mNativeMessageThreadId; |
| 509 | |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 510 | int status = pthread_create(&mMessageThreadId, nullptr, threadProc, this); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 511 | if (status) { |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 512 | ALOGE("Failed to start RS message thread."); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 513 | return false; |
| 514 | } |
| 515 | // Wait for the message thread to be active. |
| 516 | while (!mMessageRun) { |
| 517 | usleep(1000); |
| 518 | } |
| 519 | |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 520 | mInit = true; |
| 521 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 522 | return true; |
| 523 | } |
| 524 | |
Tim Murray | 21fa7a0 | 2013-08-15 16:25:03 -0700 | [diff] [blame] | 525 | void RS::throwError(RSError error, const char *errMsg) { |
| 526 | if (mCurrentError == RS_SUCCESS) { |
| 527 | mCurrentError = error; |
| 528 | ALOGE("RS CPP error: %s", errMsg); |
| 529 | } else { |
| 530 | ALOGE("RS CPP error (masked by previous error): %s", errMsg); |
| 531 | } |
Jason Sams | b2e3dc5 | 2012-02-23 17:14:39 -0800 | [diff] [blame] | 532 | } |
| 533 | |
Tim Murray | 10913a5 | 2013-08-20 17:19:47 -0700 | [diff] [blame] | 534 | RSError RS::getError() { |
| 535 | return mCurrentError; |
| 536 | } |
| 537 | |
Jason Sams | b2e3dc5 | 2012-02-23 17:14:39 -0800 | [diff] [blame] | 538 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 539 | void * RS::threadProc(void *vrsc) { |
| 540 | RS *rs = static_cast<RS *>(vrsc); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 541 | size_t rbuf_size = 256; |
| 542 | void * rbuf = malloc(rbuf_size); |
| 543 | |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 544 | RS::dispatch->ContextInitToClient(rs->mContext); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 545 | rs->mMessageRun = true; |
| 546 | |
| 547 | while (rs->mMessageRun) { |
| 548 | size_t receiveLen = 0; |
| 549 | uint32_t usrID = 0; |
| 550 | uint32_t subID = 0; |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 551 | RsMessageToClientType r = RS::dispatch->ContextPeekMessage(rs->mContext, |
| 552 | &receiveLen, sizeof(receiveLen), |
| 553 | &usrID, sizeof(usrID)); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 554 | |
| 555 | if (receiveLen >= rbuf_size) { |
| 556 | rbuf_size = receiveLen + 32; |
| 557 | rbuf = realloc(rbuf, rbuf_size); |
| 558 | } |
| 559 | if (!rbuf) { |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 560 | ALOGE("RS::message handler realloc error %zu", rbuf_size); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 561 | // No clean way to recover now? |
| 562 | } |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 563 | RS::dispatch->ContextGetMessage(rs->mContext, rbuf, rbuf_size, &receiveLen, sizeof(receiveLen), |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 564 | &subID, sizeof(subID)); |
| 565 | |
| 566 | switch(r) { |
| 567 | case RS_MESSAGE_TO_CLIENT_ERROR: |
| 568 | ALOGE("RS Error %s", (const char *)rbuf); |
Tim Murray | 21fa7a0 | 2013-08-15 16:25:03 -0700 | [diff] [blame] | 569 | rs->throwError(RS_ERROR_RUNTIME_ERROR, "Error returned from runtime"); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 570 | if(rs->mMessageFunc != nullptr) { |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 571 | rs->mErrorFunc(usrID, (const char *)rbuf); |
| 572 | } |
| 573 | break; |
Stephen Hines | 76a1be4 | 2012-11-26 16:26:03 -0800 | [diff] [blame] | 574 | case RS_MESSAGE_TO_CLIENT_NONE: |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 575 | case RS_MESSAGE_TO_CLIENT_EXCEPTION: |
Stephen Hines | 76a1be4 | 2012-11-26 16:26:03 -0800 | [diff] [blame] | 576 | case RS_MESSAGE_TO_CLIENT_RESIZE: |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 577 | // teardown. But we want to avoid starving other threads during |
| 578 | // teardown by yielding until the next line in the destructor can |
Stephen Hines | 76a1be4 | 2012-11-26 16:26:03 -0800 | [diff] [blame] | 579 | // execute to set mRun = false. Note that the FIFO sends an |
| 580 | // empty NONE message when it reaches its destructor. |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 581 | usleep(1000); |
| 582 | break; |
| 583 | case RS_MESSAGE_TO_CLIENT_USER: |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 584 | if(rs->mMessageFunc != nullptr) { |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 585 | rs->mMessageFunc(usrID, rbuf, receiveLen); |
| 586 | } else { |
| 587 | ALOGE("Received a message from the script with no message handler installed."); |
| 588 | } |
| 589 | break; |
| 590 | |
| 591 | default: |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 592 | ALOGE("RS unknown message type %i", r); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | |
| 596 | if (rbuf) { |
| 597 | free(rbuf); |
| 598 | } |
Tim Murray | 87c9d77 | 2013-12-03 12:42:00 -0800 | [diff] [blame] | 599 | ALOGV("RS Message thread exiting."); |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame^] | 600 | return nullptr; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 601 | } |
| 602 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 603 | void RS::setErrorHandler(ErrorHandlerFunc_t func) { |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 604 | mErrorFunc = func; |
| 605 | } |
| 606 | |
Tim Murray | 84bf2b8 | 2012-10-31 16:03:16 -0700 | [diff] [blame] | 607 | void RS::setMessageHandler(MessageHandlerFunc_t func) { |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 608 | mMessageFunc = func; |
| 609 | } |
Tim Murray | baca6c3 | 2012-11-14 16:51:46 -0800 | [diff] [blame] | 610 | |
| 611 | void RS::finish() { |
Tim Murray | a423096 | 2013-07-17 16:50:10 -0700 | [diff] [blame] | 612 | RS::dispatch->ContextFinish(mContext); |
Tim Murray | baca6c3 | 2012-11-14 16:51:46 -0800 | [diff] [blame] | 613 | } |