Home | History | Annotate | Download | only in driver
      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 
     27 typedef void (* InvokeFunc_t)(void);
     28 typedef void (* ForEachFunc_t)(void);
     29 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
     30 
     31 typedef struct RsdSymbolTableRec {
     32     const char * mName;
     33     void * mPtr;
     34     bool threadable;
     35 } RsdSymbolTable;
     36 
     37 typedef struct ScriptTLSStructRec {
     38     android::renderscript::Context * mContext;
     39     android::renderscript::Script * mScript;
     40 } ScriptTLSStruct;
     41 
     42 typedef struct RsdHalRec {
     43     uint32_t version_major;
     44     uint32_t version_minor;
     45     bool mHasGraphics;
     46     bool mInForEach;
     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     ScriptTLSStruct mTlsStruct;
     64 
     65     RsdGL gl;
     66 } RsdHal;
     67 
     68 extern pthread_key_t rsdgThreadTLSKey;
     69 extern uint32_t rsdgThreadTLSKeyCount;
     70 extern pthread_mutex_t rsdgInitMutex;
     71 
     72 
     73 void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
     74 
     75 #endif
     76 
     77