Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 ANDROID_RS_CONTEXT_H |
| 18 | #define ANDROID_RS_CONTEXT_H |
| 19 | |
Jason Sams | 399bfce | 2009-07-13 12:20:31 -0700 | [diff] [blame] | 20 | #include "rsUtils.h" |
Jason Sams | c1d726c | 2010-03-18 11:39:44 -0700 | [diff] [blame] | 21 | #include "rsMutex.h" |
Jason Sams | 399bfce | 2009-07-13 12:20:31 -0700 | [diff] [blame] | 22 | |
Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 23 | #include "rsThreadIO.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 24 | #include "rsType.h" |
| 25 | #include "rsMatrix.h" |
| 26 | #include "rsAllocation.h" |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 27 | #include "rsMesh.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | #include "rsDevice.h" |
| 29 | #include "rsScriptC.h" |
| 30 | #include "rsAllocation.h" |
| 31 | #include "rsAdapter.h" |
| 32 | #include "rsSampler.h" |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 33 | #include "rsFont.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | #include "rsProgramFragment.h" |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 35 | #include "rsProgramStore.h" |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 36 | #include "rsProgramRaster.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | #include "rsProgramVertex.h" |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 38 | #include "rsShaderCache.h" |
| 39 | #include "rsVertexArray.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | |
| 41 | #include "rsgApiStructs.h" |
| 42 | #include "rsLocklessFifo.h" |
| 43 | |
Mathias Agopian | 5cbb940 | 2010-02-12 12:00:38 -0800 | [diff] [blame] | 44 | #include <ui/egl/android_natives.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 45 | |
| 46 | // --------------------------------------------------------------------------- |
| 47 | namespace android { |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 48 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | namespace renderscript { |
| 50 | |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 51 | #if 0 |
| 52 | #define CHECK_OBJ(o) { \ |
| 53 | GET_TLS(); \ |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 54 | if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 55 | LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
| 56 | } \ |
| 57 | } |
| 58 | #define CHECK_OBJ_OR_NULL(o) { \ |
| 59 | GET_TLS(); \ |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 60 | if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 61 | LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
| 62 | } \ |
| 63 | } |
| 64 | #else |
| 65 | #define CHECK_OBJ(o) |
| 66 | #define CHECK_OBJ_OR_NULL(o) |
| 67 | #endif |
| 68 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 69 | class Context { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 70 | public: |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame] | 71 | static Context * createContext(Device *, const RsSurfaceConfig *sc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 72 | ~Context(); |
| 73 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 74 | static pthread_key_t gThreadTLSKey; |
Jason Sams | 41c19db9 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 75 | static uint32_t gThreadTLSKeyCount; |
Jason Sams | 7136220 | 2009-10-27 14:44:31 -0700 | [diff] [blame] | 76 | static uint32_t gGLContextCount; |
Jason Sams | 41c19db9 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 77 | static pthread_mutex_t gInitMutex; |
Stephen Hines | 1ac9da6 | 2011-01-07 15:11:30 -0800 | [diff] [blame] | 78 | // Library mutex (for providing thread-safe calls from the runtime) |
| 79 | static pthread_mutex_t gLibMutex; |
Jason Sams | 41c19db9 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 80 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 81 | struct ScriptTLSStruct { |
| 82 | Context * mContext; |
| 83 | Script * mScript; |
| 84 | }; |
Jason Sams | a17af04 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 85 | |
| 86 | class PushState { |
| 87 | public: |
| 88 | PushState(Context *); |
| 89 | ~PushState(); |
| 90 | |
| 91 | private: |
| 92 | ObjectBaseRef<ProgramFragment> mFragment; |
| 93 | ObjectBaseRef<ProgramVertex> mVertex; |
| 94 | ObjectBaseRef<ProgramStore> mStore; |
| 95 | ObjectBaseRef<ProgramRaster> mRaster; |
| 96 | ObjectBaseRef<Font> mFont; |
| 97 | Context *mRsc; |
| 98 | }; |
| 99 | |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 100 | ScriptTLSStruct *mTlsStruct; |
Jason Sams | 11c8af9 | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 101 | RsSurfaceConfig mUserSurfaceConfig; |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 102 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 103 | typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 104 | |
| 105 | //StructuredAllocationContext mStateAllocation; |
| 106 | ElementState mStateElement; |
| 107 | TypeState mStateType; |
| 108 | SamplerState mStateSampler; |
| 109 | ProgramFragmentState mStateFragment; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 110 | ProgramStoreState mStateFragmentStore; |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 111 | ProgramRasterState mStateRaster; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 112 | ProgramVertexState mStateVertex; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 113 | VertexArrayState mStateVertexArray; |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 114 | FontState mStateFont; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 115 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 116 | ScriptCState mScriptC; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 117 | ShaderCache mShaderCache; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 118 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 119 | void swapBuffers(); |
| 120 | void setRootScript(Script *); |
Jason Sams | a17af04 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 121 | void setProgramRaster(ProgramRaster *); |
| 122 | void setProgramVertex(ProgramVertex *); |
| 123 | void setProgramFragment(ProgramFragment *); |
| 124 | void setProgramStore(ProgramStore *); |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 125 | void setFont(Font *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 126 | |
| 127 | void updateSurface(void *sur); |
| 128 | |
Jason Sams | a17af04 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 129 | ProgramFragment * getProgramFragment() {return mFragment.get();} |
| 130 | ProgramStore * getProgramStore() {return mFragmentStore.get();} |
| 131 | ProgramRaster * getProgramRaster() {return mRaster.get();} |
| 132 | ProgramVertex * getProgramVertex() {return mVertex.get();} |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 133 | Font * getFont() {return mFont.get();} |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 134 | |
Jason Sams | 156cce6 | 2010-03-03 13:03:18 -0800 | [diff] [blame] | 135 | bool setupCheck(); |
Alex Sakhartchouk | feede2a | 2010-10-01 10:54:06 -0700 | [diff] [blame] | 136 | void setupProgramStore(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 137 | |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 138 | void pause(); |
| 139 | void resume(); |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 140 | void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur); |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 141 | void setPriority(int32_t p); |
Jason Sams | 5c68a71 | 2010-12-24 14:38:39 -0800 | [diff] [blame] | 142 | void destroyWorkerThreadResources(); |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 143 | |
Jason Sams | d5680f9 | 2009-06-10 18:39:40 -0700 | [diff] [blame] | 144 | void assignName(ObjectBase *obj, const char *name, uint32_t len); |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 145 | void removeName(ObjectBase *obj); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 146 | |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 147 | RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID, bool wait); |
| 148 | RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait); |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 149 | bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const; |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 150 | uint32_t runScript(Script *s); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 151 | |
| 152 | void initToClient(); |
| 153 | void deinitToClient(); |
| 154 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 155 | ProgramFragment * getDefaultProgramFragment() const { |
| 156 | return mStateFragment.mDefault.get(); |
| 157 | } |
| 158 | ProgramVertex * getDefaultProgramVertex() const { |
| 159 | return mStateVertex.mDefault.get(); |
| 160 | } |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 161 | ProgramStore * getDefaultProgramStore() const { |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 162 | return mStateFragmentStore.mDefault.get(); |
| 163 | } |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 164 | ProgramRaster * getDefaultProgramRaster() const { |
| 165 | return mStateRaster.mDefault.get(); |
| 166 | } |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 167 | Font* getDefaultFont() const { |
| 168 | return mStateFont.mDefault.get(); |
| 169 | } |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 170 | |
Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 171 | uint32_t getWidth() const {return mWidth;} |
| 172 | uint32_t getHeight() const {return mHeight;} |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 173 | |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 174 | mutable ThreadIO mIO; |
Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 175 | |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 176 | // Timers |
| 177 | enum Timers { |
| 178 | RS_TIMER_IDLE, |
| 179 | RS_TIMER_INTERNAL, |
| 180 | RS_TIMER_SCRIPT, |
| 181 | RS_TIMER_CLEAR_SWAP, |
| 182 | _RS_TIMER_TOTAL |
| 183 | }; |
| 184 | uint64_t getTime() const; |
| 185 | void timerInit(); |
| 186 | void timerReset(); |
| 187 | void timerSet(Timers); |
| 188 | void timerPrint(); |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 189 | void timerFrame(); |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 190 | |
Jason Sams | 66b2771 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 191 | struct { |
| 192 | bool mLogTimes; |
| 193 | bool mLogScripts; |
| 194 | bool mLogObjects; |
Jason Sams | 5dad8b4 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 195 | bool mLogShaders; |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 196 | bool mLogShadersAttr; |
| 197 | bool mLogShadersUniforms; |
Alex Sakhartchouk | 6de5550 | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 198 | bool mLogVisual; |
Jason Sams | 66b2771 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 199 | } props; |
Joe Onorato | 9ac2c66 | 2009-09-23 16:37:36 -0700 | [diff] [blame] | 200 | |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 201 | void dumpDebug() const; |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 202 | void checkError(const char *, bool isFatal = false) const; |
| 203 | void setError(RsError e, const char *msg = NULL) const; |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 204 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 205 | mutable const ObjectBase * mObjHead; |
| 206 | |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 207 | bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;} |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 208 | bool ext_GL_NV_texture_npot_2D_mipmap() const {return mGL.GL_NV_texture_npot_2D_mipmap;} |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 209 | float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; } |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 210 | uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;} |
| 211 | uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;} |
| 212 | uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;} |
Alex Sakhartchouk | 6b5222d | 2010-12-13 14:48:21 -0800 | [diff] [blame] | 213 | uint32_t getMaxVertexAttributes() const {return mGL.mMaxVertexAttribs;} |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 214 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 215 | void launchThreads(WorkerCallback_t cbk, void *data); |
Jason Sams | f3470ed | 2010-09-28 14:41:22 -0700 | [diff] [blame] | 216 | uint32_t getWorkerPoolSize() const {return (uint32_t)mWorkers.mCount;} |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 217 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 218 | protected: |
| 219 | Device *mDev; |
| 220 | |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 221 | struct { |
| 222 | EGLint mNumConfigs; |
| 223 | EGLint mMajorVersion; |
| 224 | EGLint mMinorVersion; |
| 225 | EGLConfig mConfig; |
| 226 | EGLContext mContext; |
| 227 | EGLSurface mSurface; |
Jason Sams | 11c8af9 | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 228 | EGLSurface mSurfaceDefault; |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 229 | EGLDisplay mDisplay; |
| 230 | } mEGL; |
| 231 | |
| 232 | struct { |
| 233 | const uint8_t * mVendor; |
| 234 | const uint8_t * mRenderer; |
| 235 | const uint8_t * mVersion; |
| 236 | const uint8_t * mExtensions; |
| 237 | |
| 238 | uint32_t mMajorVersion; |
| 239 | uint32_t mMinorVersion; |
| 240 | |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 241 | int32_t mMaxVaryingVectors; |
| 242 | int32_t mMaxTextureImageUnits; |
| 243 | |
| 244 | int32_t mMaxFragmentTextureImageUnits; |
| 245 | int32_t mMaxFragmentUniformVectors; |
| 246 | |
| 247 | int32_t mMaxVertexAttribs; |
| 248 | int32_t mMaxVertexUniformVectors; |
| 249 | int32_t mMaxVertexTextureUnits; |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 250 | |
| 251 | bool OES_texture_npot; |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 252 | bool GL_NV_texture_npot_2D_mipmap; |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 253 | float EXT_texture_max_aniso; |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 254 | } mGL; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 255 | |
Jason Sams | 3bc47d4 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 256 | uint32_t mWidth; |
| 257 | uint32_t mHeight; |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 258 | int32_t mThreadPriority; |
Jason Sams | 704ff64 | 2010-02-09 16:05:07 -0800 | [diff] [blame] | 259 | bool mIsGraphicsContext; |
Jason Sams | 3bc47d4 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 260 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 261 | bool mRunning; |
| 262 | bool mExit; |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 263 | bool mPaused; |
Jason Sams | add9d96 | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 264 | mutable RsError mError; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 265 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 266 | pthread_t mThreadId; |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 267 | pid_t mNativeThreadId; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 268 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 269 | struct Workers { |
| 270 | volatile int mRunningCount; |
| 271 | volatile int mLaunchCount; |
| 272 | uint32_t mCount; |
| 273 | pthread_t *mThreadId; |
| 274 | pid_t *mNativeThreadId; |
| 275 | Signal mCompleteSignal; |
| 276 | |
| 277 | Signal *mLaunchSignals; |
| 278 | WorkerCallback_t mLaunchCallback; |
| 279 | void *mLaunchData; |
| 280 | }; |
| 281 | Workers mWorkers; |
| 282 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 283 | ObjectBaseRef<Script> mRootScript; |
| 284 | ObjectBaseRef<ProgramFragment> mFragment; |
| 285 | ObjectBaseRef<ProgramVertex> mVertex; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 286 | ObjectBaseRef<ProgramStore> mFragmentStore; |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 287 | ObjectBaseRef<ProgramRaster> mRaster; |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 288 | ObjectBaseRef<Font> mFont; |
Jason Sams | 730ee65 | 2009-08-18 17:07:09 -0700 | [diff] [blame] | 289 | |
Alex Sakhartchouk | 6de5550 | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 290 | void displayDebugStats(); |
| 291 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 292 | private: |
| 293 | Context(); |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame] | 294 | bool initContext(Device *, const RsSurfaceConfig *sc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 295 | |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame] | 296 | |
| 297 | bool initGLThread(); |
Jason Sams | 7136220 | 2009-10-27 14:44:31 -0700 | [diff] [blame] | 298 | void deinitEGL(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 299 | |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 300 | uint32_t runRootScript(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 301 | |
| 302 | static void * threadProc(void *); |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 303 | static void * helperThreadProc(void *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 304 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 305 | ANativeWindow *mWndSurface; |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 306 | |
| 307 | Vector<ObjectBase *> mNames; |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 308 | |
| 309 | uint64_t mTimers[_RS_TIMER_TOTAL]; |
| 310 | Timers mTimerActive; |
| 311 | uint64_t mTimeLast; |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 312 | uint64_t mTimeFrame; |
| 313 | uint64_t mTimeLastFrame; |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 314 | uint32_t mTimeMSLastFrame; |
| 315 | uint32_t mTimeMSLastScript; |
| 316 | uint32_t mTimeMSLastSwap; |
Alex Sakhartchouk | 76322af | 2010-10-05 13:23:55 -0700 | [diff] [blame] | 317 | uint32_t mAverageFPSFrameCount; |
| 318 | uint64_t mAverageFPSStartTime; |
| 319 | uint32_t mAverageFPS; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | #endif |