Home | History | Annotate | Download | only in driver
      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                                 uint32_t x1, uint32_t x2,
     33                                 uint32_t instep, uint32_t outstep);
     34 
     35 typedef struct RsdSymbolTableRec {
     36     const char * mName;
     37     void * mPtr;
     38     bool threadable;
     39 } RsdSymbolTable;
     40 
     41 typedef struct ScriptTLSStructRec {
     42     android::renderscript::Context * mContext;
     43     android::renderscript::Script * mScript;
     44 } ScriptTLSStruct;
     45 
     46 typedef struct RsdHalRec {
     47     uint32_t version_major;
     48     uint32_t version_minor;
     49 
     50     struct Workers {
     51         volatile int mRunningCount;
     52         volatile int mLaunchCount;
     53         uint32_t mCount;
     54         pthread_t *mThreadId;
     55         pid_t *mNativeThreadId;
     56         android::renderscript::Signal mCompleteSignal;
     57 
     58         android::renderscript::Signal *mLaunchSignals;
     59         WorkerCallback_t mLaunchCallback;
     60         void *mLaunchData;
     61     };
     62     Workers mWorkers;
     63     bool mExit;
     64 
     65     outer_foreach_t mForEachLaunch[32];
     66 
     67     ScriptTLSStruct mTlsStruct;
     68 
     69     RsdGL gl;
     70 } RsdHal;
     71 
     72 extern pthread_key_t rsdgThreadTLSKey;
     73 extern uint32_t rsdgThreadTLSKeyCount;
     74 extern pthread_mutex_t rsdgInitMutex;
     75 
     76 
     77 void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
     78 
     79 #endif
     80 
     81