1 /* 2 * Copyright (C) 2011 The Android Open Source Project 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 #ifndef RSD_CORE_H 18 #define RSD_CORE_H 19 20 #include <rs_hal.h> 21 22 #include "rsMutex.h" 23 #include "rsSignal.h" 24 25 #include "rsdGL.h" 26 27 typedef void (* InvokeFunc_t)(void); 28 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); 29 30 typedef void (*outer_foreach_t)(const void *, 31 const android::renderscript::RsForEachStubParamStruct *); 32 33 typedef struct RsdSymbolTableRec { 34 const char * mName; 35 void * mPtr; 36 bool threadable; 37 } RsdSymbolTable; 38 39 typedef struct ScriptTLSStructRec { 40 android::renderscript::Context * mContext; 41 android::renderscript::Script * mScript; 42 } ScriptTLSStruct; 43 44 typedef struct RsdHalRec { 45 uint32_t version_major; 46 uint32_t version_minor; 47 48 struct Workers { 49 volatile int mRunningCount; 50 volatile int mLaunchCount; 51 uint32_t mCount; 52 pthread_t *mThreadId; 53 pid_t *mNativeThreadId; 54 android::renderscript::Signal mCompleteSignal; 55 56 android::renderscript::Signal *mLaunchSignals; 57 WorkerCallback_t mLaunchCallback; 58 void *mLaunchData; 59 }; 60 Workers mWorkers; 61 bool mExit; 62 63 outer_foreach_t mForEachLaunch[32]; 64 65 ScriptTLSStruct mTlsStruct; 66 67 RsdGL gl; 68 } RsdHal; 69 70 extern pthread_key_t rsdgThreadTLSKey; 71 extern uint32_t rsdgThreadTLSKeyCount; 72 extern pthread_mutex_t rsdgInitMutex; 73 74 75 void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data); 76 77 #endif 78 79