rsdCore.h revision 4419977d78018a9933c7f455fe001f644f2d638b
1/* 2 * Copyright (C) 2011-2012 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 27typedef void (* InvokeFunc_t)(void); 28typedef void (* ForEachFunc_t)(void); 29typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); 30 31typedef struct RsdSymbolTableRec { 32 const char * mName; 33 void * mPtr; 34 bool threadable; 35} RsdSymbolTable; 36 37typedef struct ScriptTLSStructRec { 38 android::renderscript::Context * mContext; 39 android::renderscript::Script * mScript; 40} ScriptTLSStruct; 41 42typedef struct RsdHalRec { 43 uint32_t version_major; 44 uint32_t version_minor; 45 bool mHasGraphics; 46 47 struct Workers { 48 volatile int mRunningCount; 49 volatile int mLaunchCount; 50 uint32_t mCount; 51 pthread_t *mThreadId; 52 pid_t *mNativeThreadId; 53 android::renderscript::Signal mCompleteSignal; 54 55 android::renderscript::Signal *mLaunchSignals; 56 WorkerCallback_t mLaunchCallback; 57 void *mLaunchData; 58 }; 59 Workers mWorkers; 60 bool mExit; 61 62 ScriptTLSStruct mTlsStruct; 63 64 RsdGL gl; 65} RsdHal; 66 67extern pthread_key_t rsdgThreadTLSKey; 68extern uint32_t rsdgThreadTLSKeyCount; 69extern pthread_mutex_t rsdgInitMutex; 70 71 72void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data); 73 74#endif 75 76