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