blob: 05ca13bb35a2bbf60ce3a685033dc4c1bedbc09f [file] [log] [blame]
Jason Samsbad80742011-03-16 16:29:28 -07001/*
Stephen Hinesee7aa2e2012-01-12 18:56:23 -08002 * Copyright (C) 2011-2012 The Android Open Source Project
Jason Samsbad80742011-03-16 16:29:28 -07003 *
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>
Jason Samsbad80742011-03-16 16:29:28 -070021
Jason Samscdfdb8f2011-03-17 16:12:47 -070022#include "rsMutex.h"
23#include "rsSignal.h"
Jason Samsbad80742011-03-16 16:29:28 -070024
Jason Sams4b3de472011-04-06 17:52:23 -070025#include "rsdGL.h"
Jason Samscdfdb8f2011-03-17 16:12:47 -070026
27typedef void (* InvokeFunc_t)(void);
Stephen Hines44199772012-02-21 20:13:12 -080028typedef void (* ForEachFunc_t)(void);
Jason Samscdfdb8f2011-03-17 16:12:47 -070029typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
30
Jason Sams87fe59a2011-04-20 15:09:01 -070031typedef struct RsdSymbolTableRec {
32 const char * mName;
33 void * mPtr;
34 bool threadable;
35} RsdSymbolTable;
36
Jason Sams83c451a2011-04-21 11:46:50 -070037typedef struct ScriptTLSStructRec {
38 android::renderscript::Context * mContext;
39 android::renderscript::Script * mScript;
40} ScriptTLSStruct;
41
Jason Sams87fe59a2011-04-20 15:09:01 -070042typedef struct RsdHalRec {
Jason Samsbad80742011-03-16 16:29:28 -070043 uint32_t version_major;
44 uint32_t version_minor;
Jason Sams9719bd42012-01-12 14:22:21 -080045 bool mHasGraphics;
Jason Samsbad80742011-03-16 16:29:28 -070046
Jason Samscdfdb8f2011-03-17 16:12:47 -070047 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;
Jason Samsbad80742011-03-16 16:29:28 -070054
Jason Samscdfdb8f2011-03-17 16:12:47 -070055 android::renderscript::Signal *mLaunchSignals;
56 WorkerCallback_t mLaunchCallback;
57 void *mLaunchData;
58 };
59 Workers mWorkers;
60 bool mExit;
Jason Sams4b3de472011-04-06 17:52:23 -070061
Jason Sams83c451a2011-04-21 11:46:50 -070062 ScriptTLSStruct mTlsStruct;
63
Jason Sams4b3de472011-04-06 17:52:23 -070064 RsdGL gl;
Jason Sams87fe59a2011-04-20 15:09:01 -070065} RsdHal;
Jason Samsbad80742011-03-16 16:29:28 -070066
Jason Sams83c451a2011-04-21 11:46:50 -070067extern pthread_key_t rsdgThreadTLSKey;
68extern uint32_t rsdgThreadTLSKeyCount;
69extern pthread_mutex_t rsdgInitMutex;
Jason Samsbad80742011-03-16 16:29:28 -070070
71
Jason Samscdfdb8f2011-03-17 16:12:47 -070072void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
Jason Samsbad80742011-03-16 16:29:28 -070073
74#endif
75