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