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