Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 | a557780 | 2009-07-13 12:20:31 -0700 | [diff] [blame] | 20 | #include "rsUtils.h" |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 21 | #include "rs_hal.h" |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 22 | #include <string.h> |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 23 | |
Alex Sakhartchouk | 77d9f4b | 2011-01-31 14:53:24 -0800 | [diff] [blame] | 24 | #include "rsThreadIO.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 25 | #include "rsScriptC.h" |
Jason Sams | dbe66d6 | 2012-09-17 13:54:41 -0700 | [diff] [blame] | 26 | #include "rsScriptGroup.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | #include "rsSampler.h" |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 28 | |
Stephen Hines | 574854b | 2013-07-10 08:29:51 -0700 | [diff] [blame] | 29 | #if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB) |
Tim Murray | fa85e91 | 2013-05-23 13:19:36 -0700 | [diff] [blame] | 30 | #define ATRACE_TAG ATRACE_TAG_RS |
| 31 | #include "utils/Trace.h" |
Stephen Hines | 574854b | 2013-07-10 08:29:51 -0700 | [diff] [blame] | 32 | #else |
| 33 | #define ATRACE_ENABLED(...) false |
| 34 | #define ATRACE_NAME(...) |
| 35 | #define ATRACE_CALL(...) |
Tim Murray | fa85e91 | 2013-05-23 13:19:36 -0700 | [diff] [blame] | 36 | #endif |
| 37 | |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 38 | #ifndef RS_COMPATIBILITY_LIB |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 39 | #include "rsFont.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | #include "rsProgramFragment.h" |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 41 | #include "rsProgramStore.h" |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 42 | #include "rsProgramRaster.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | #include "rsProgramVertex.h" |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 44 | #include "rsFBOCache.h" |
Tim Murray | fa85e91 | 2013-05-23 13:19:36 -0700 | [diff] [blame] | 45 | |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 46 | #endif |
| 47 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 48 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | // --------------------------------------------------------------------------- |
| 50 | namespace android { |
Mathias Agopian | d4c25e3 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 51 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 52 | namespace renderscript { |
| 53 | |
Alex Sakhartchouk | 4edf030 | 2012-03-09 10:47:27 -0800 | [diff] [blame] | 54 | class Device; |
| 55 | |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 56 | #if 0 |
| 57 | #define CHECK_OBJ(o) { \ |
| 58 | GET_TLS(); \ |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 59 | if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
Steve Block | af12ac6 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 60 | ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 61 | } \ |
| 62 | } |
| 63 | #define CHECK_OBJ_OR_NULL(o) { \ |
| 64 | GET_TLS(); \ |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 65 | if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
Steve Block | af12ac6 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 66 | ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
Jason Sams | 605048a | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 67 | } \ |
| 68 | } |
| 69 | #else |
| 70 | #define CHECK_OBJ(o) |
| 71 | #define CHECK_OBJ_OR_NULL(o) |
| 72 | #endif |
| 73 | |
Tim Murray | fa85e91 | 2013-05-23 13:19:36 -0700 | [diff] [blame] | 74 | |
| 75 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 76 | class Context { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 77 | public: |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 78 | struct Hal { |
| 79 | void * drv; |
| 80 | |
| 81 | RsdHalFunctions funcs; |
Jason Sams | 416f4b6 | 2014-06-25 15:45:36 -0700 | [diff] [blame] | 82 | uint32_t flags; |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 83 | }; |
| 84 | Hal mHal; |
| 85 | |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 86 | static Context * createContext(Device *, const RsSurfaceConfig *sc, |
| 87 | RsContextType ct = RS_CONTEXT_TYPE_NORMAL, |
Tim Murray | 84e3dea | 2013-09-09 16:12:51 -0700 | [diff] [blame] | 88 | uint32_t flags = 0); |
Alex Sakhartchouk | b81a0eb | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 89 | static Context * createContextLite(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 90 | ~Context(); |
| 91 | |
Jason Sams | 4961cce | 2013-04-11 16:11:46 -0700 | [diff] [blame] | 92 | static pthread_mutex_t gMessageMutex; |
Jason Sams | fb03a22 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 93 | static pthread_mutex_t gInitMutex; |
Stephen Hines | ca3f09c | 2011-01-07 15:11:30 -0800 | [diff] [blame] | 94 | // Library mutex (for providing thread-safe calls from the runtime) |
| 95 | static pthread_mutex_t gLibMutex; |
Jason Sams | fb03a22 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 96 | |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 97 | class PushState { |
| 98 | public: |
| 99 | PushState(Context *); |
| 100 | ~PushState(); |
| 101 | |
| 102 | private: |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 103 | #ifndef RS_COMPATIBILITY_LIB |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 104 | ObjectBaseRef<ProgramFragment> mFragment; |
| 105 | ObjectBaseRef<ProgramVertex> mVertex; |
| 106 | ObjectBaseRef<ProgramStore> mStore; |
| 107 | ObjectBaseRef<ProgramRaster> mRaster; |
| 108 | ObjectBaseRef<Font> mFont; |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 109 | #endif |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 110 | Context *mRsc; |
| 111 | }; |
| 112 | |
Jason Sams | 6b8552a | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 113 | RsSurfaceConfig mUserSurfaceConfig; |
Jason Sams | e576910 | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 114 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 115 | ElementState mStateElement; |
| 116 | TypeState mStateType; |
| 117 | SamplerState mStateSampler; |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 118 | |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 119 | bool isSynchronous() {return mSynchronous;} |
| 120 | bool setupCheck(); |
| 121 | |
| 122 | #ifndef RS_COMPATIBILITY_LIB |
| 123 | FBOCache mFBOCache; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 124 | ProgramFragmentState mStateFragment; |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 125 | ProgramStoreState mStateFragmentStore; |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 126 | ProgramRasterState mStateRaster; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 127 | ProgramVertexState mStateVertex; |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 128 | FontState mStateFont; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 129 | |
Tim Murray | 4d252d6 | 2012-11-29 14:37:59 -0800 | [diff] [blame] | 130 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 131 | void swapBuffers(); |
| 132 | void setRootScript(Script *); |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 133 | void setProgramRaster(ProgramRaster *); |
| 134 | void setProgramVertex(ProgramVertex *); |
| 135 | void setProgramFragment(ProgramFragment *); |
| 136 | void setProgramStore(ProgramStore *); |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 137 | void setFont(Font *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 138 | |
| 139 | void updateSurface(void *sur); |
| 140 | |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 141 | ProgramFragment * getProgramFragment() {return mFragment.get();} |
| 142 | ProgramStore * getProgramStore() {return mFragmentStore.get();} |
| 143 | ProgramRaster * getProgramRaster() {return mRaster.get();} |
| 144 | ProgramVertex * getProgramVertex() {return mVertex.get();} |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 145 | Font * getFont() {return mFont.get();} |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 146 | |
Alex Sakhartchouk | 889fe50 | 2010-10-01 10:54:06 -0700 | [diff] [blame] | 147 | void setupProgramStore(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 148 | |
Jason Sams | 86f1b23 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 149 | void pause(); |
| 150 | void resume(); |
Alex Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 151 | void setSurface(uint32_t w, uint32_t h, RsNativeWindow sur); |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 152 | #endif |
Jason Sams | f274827 | 2013-11-26 18:10:59 -0800 | [diff] [blame] | 153 | void finish(); |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 154 | |
Jason Sams | 1583244 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 155 | void setPriority(int32_t p); |
Jason Sams | 741aac9 | 2010-12-24 14:38:39 -0800 | [diff] [blame] | 156 | void destroyWorkerThreadResources(); |
Jason Sams | 86f1b23 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 157 | |
Jason Sams | a4a54e4 | 2009-06-10 18:39:40 -0700 | [diff] [blame] | 158 | void assignName(ObjectBase *obj, const char *name, uint32_t len); |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 159 | void removeName(ObjectBase *obj); |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 160 | |
Jason Sams | 1a4efa3 | 2011-05-17 15:01:29 -0700 | [diff] [blame] | 161 | RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID); |
| 162 | RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen); |
Jason Sams | 87319de | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 163 | bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const; |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 164 | uint32_t runScript(Script *s); |
Jason Sams | 8c401ef | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 165 | |
| 166 | void initToClient(); |
| 167 | void deinitToClient(); |
| 168 | |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 169 | #ifndef RS_COMPATIBILITY_LIB |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 170 | ProgramFragment * getDefaultProgramFragment() const { |
| 171 | return mStateFragment.mDefault.get(); |
| 172 | } |
| 173 | ProgramVertex * getDefaultProgramVertex() const { |
| 174 | return mStateVertex.mDefault.get(); |
| 175 | } |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 176 | ProgramStore * getDefaultProgramStore() const { |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 177 | return mStateFragmentStore.mDefault.get(); |
| 178 | } |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 179 | ProgramRaster * getDefaultProgramRaster() const { |
| 180 | return mStateRaster.mDefault.get(); |
| 181 | } |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 182 | Font* getDefaultFont() const { |
| 183 | return mStateFont.mDefault.get(); |
| 184 | } |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 185 | |
Jason Sams | 771565f | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 186 | uint32_t getWidth() const {return mWidth;} |
| 187 | uint32_t getHeight() const {return mHeight;} |
Jason Sams | e579df4 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 188 | |
Alex Sakhartchouk | a74a8f6 | 2011-11-16 12:22:10 -0800 | [diff] [blame] | 189 | uint32_t getCurrentSurfaceWidth() const; |
| 190 | uint32_t getCurrentSurfaceHeight() const; |
| 191 | |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 192 | void setWatchdogGL(const char *cmd, uint32_t line, const char *file) const { |
| 193 | watchdog.command = cmd; |
| 194 | watchdog.file = file; |
| 195 | watchdog.line = line; |
| 196 | } |
| 197 | #endif |
| 198 | |
Jason Sams | 87319de | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 199 | mutable ThreadIO mIO; |
Jason Sams | fcd3192 | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 200 | |
Jason Sams | 24371d9 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 201 | // Timers |
| 202 | enum Timers { |
| 203 | RS_TIMER_IDLE, |
| 204 | RS_TIMER_INTERNAL, |
| 205 | RS_TIMER_SCRIPT, |
| 206 | RS_TIMER_CLEAR_SWAP, |
| 207 | _RS_TIMER_TOTAL |
| 208 | }; |
| 209 | uint64_t getTime() const; |
| 210 | void timerInit(); |
| 211 | void timerReset(); |
| 212 | void timerSet(Timers); |
| 213 | void timerPrint(); |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 214 | void timerFrame(); |
Jason Sams | 24371d9 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 215 | |
Jason Sams | 1fddd90 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 216 | struct { |
| 217 | bool mLogTimes; |
| 218 | bool mLogScripts; |
| 219 | bool mLogObjects; |
Jason Sams | cd50653 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 220 | bool mLogShaders; |
Alex Sakhartchouk | 886f11a | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 221 | bool mLogShadersAttr; |
| 222 | bool mLogShadersUniforms; |
Alex Sakhartchouk | 0cae59f | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 223 | bool mLogVisual; |
Jason Sams | d1f7da6 | 2012-03-15 19:18:03 -0700 | [diff] [blame] | 224 | uint32_t mDebugMaxThreads; |
Jason Sams | 1fddd90 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 225 | } props; |
Joe Onorato | 76371ff | 2009-09-23 16:37:36 -0700 | [diff] [blame] | 226 | |
Jason Sams | 2382aba | 2011-09-13 15:41:01 -0700 | [diff] [blame] | 227 | mutable struct { |
| 228 | bool inRoot; |
| 229 | const char *command; |
| 230 | const char *file; |
| 231 | uint32_t line; |
| 232 | } watchdog; |
| 233 | static void printWatchdogInfo(void *ctx); |
Jason Sams | 2382aba | 2011-09-13 15:41:01 -0700 | [diff] [blame] | 234 | |
Jason Sams | 13e2634 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 235 | void dumpDebug() const; |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 236 | void setError(RsError e, const char *msg = nullptr) const; |
Jason Sams | 13e2634 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 237 | |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 238 | mutable const ObjectBase * mObjHead; |
| 239 | |
Alex Sakhartchouk | 7b3e9bd | 2011-03-16 19:28:25 -0700 | [diff] [blame] | 240 | uint32_t getDPI() const {return mDPI;} |
| 241 | void setDPI(uint32_t dpi) {mDPI = dpi;} |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 242 | |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 243 | uint32_t getTargetSdkVersion() const {return mTargetSdkVersion;} |
| 244 | void setTargetSdkVersion(uint32_t sdkVer) {mTargetSdkVersion = sdkVer;} |
| 245 | |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 246 | RsContextType getContextType() const { return mContextType; } |
| 247 | void setContextType(RsContextType ct) { mContextType = ct; } |
| 248 | |
Jason Sams | 4efe3d3 | 2015-03-18 18:28:06 -0700 | [diff] [blame^] | 249 | // Check for Fatal errors |
| 250 | // Should be used to prevent work from being launched |
| 251 | // which could take the process down. Maximizes the chance |
| 252 | // the process lives long enough to get the error to the developer |
| 253 | bool hadFatalError() {return mFatalErrorOccured;} |
| 254 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 255 | Device *mDev; |
Miao Wang | f3213d7 | 2015-01-14 10:03:07 -0800 | [diff] [blame] | 256 | |
| 257 | #ifdef RS_COMPATIBILITY_LIB |
| 258 | void setNativeLibDir(const char * libDir, uint32_t length) { |
| 259 | memcpy(nativeLibDir, libDir, length); |
| 260 | } |
| 261 | const char * getNativeLibDir() { |
| 262 | return nativeLibDir; |
| 263 | } |
| 264 | #endif |
| 265 | |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 266 | protected: |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 267 | |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 268 | uint32_t mTargetSdkVersion; |
Alex Sakhartchouk | 7b3e9bd | 2011-03-16 19:28:25 -0700 | [diff] [blame] | 269 | uint32_t mDPI; |
Jason Sams | 613cad1 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 270 | uint32_t mWidth; |
| 271 | uint32_t mHeight; |
Jason Sams | 2dca84d | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 272 | int32_t mThreadPriority; |
Jason Sams | 4820e8b | 2010-02-09 16:05:07 -0800 | [diff] [blame] | 273 | bool mIsGraphicsContext; |
Jason Sams | 613cad1 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 274 | |
Tim Murray | 0e92fa3 | 2012-11-06 14:36:38 -0800 | [diff] [blame] | 275 | bool mForceCpu; |
| 276 | |
Stephen Hines | cca3d6c | 2013-04-15 01:06:39 -0700 | [diff] [blame] | 277 | RsContextType mContextType; |
| 278 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 279 | bool mRunning; |
| 280 | bool mExit; |
Jason Sams | 86f1b23 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 281 | bool mPaused; |
Jason Sams | 4efe3d3 | 2015-03-18 18:28:06 -0700 | [diff] [blame^] | 282 | mutable bool mFatalErrorOccured; |
Jason Sams | 87319de | 2010-11-22 16:20:16 -0800 | [diff] [blame] | 283 | mutable RsError mError; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 284 | |
Jason Sams | 4efe3d3 | 2015-03-18 18:28:06 -0700 | [diff] [blame^] | 285 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 286 | pthread_t mThreadId; |
Jason Sams | 1583244 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 287 | pid_t mNativeThreadId; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 288 | |
| 289 | ObjectBaseRef<Script> mRootScript; |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 290 | #ifndef RS_COMPATIBILITY_LIB |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 291 | ObjectBaseRef<ProgramFragment> mFragment; |
| 292 | ObjectBaseRef<ProgramVertex> mVertex; |
Jason Sams | ccc010b | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 293 | ObjectBaseRef<ProgramStore> mFragmentStore; |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 294 | ObjectBaseRef<ProgramRaster> mRaster; |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 295 | ObjectBaseRef<Font> mFont; |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 296 | #endif |
Jason Sams | 5086938 | 2009-08-18 17:07:09 -0700 | [diff] [blame] | 297 | |
Alex Sakhartchouk | 0cae59f | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 298 | void displayDebugStats(); |
| 299 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 300 | private: |
| 301 | Context(); |
Jason Sams | 5c1c79a | 2010-11-03 14:27:11 -0700 | [diff] [blame] | 302 | bool initContext(Device *, const RsSurfaceConfig *sc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 303 | |
Tim Murray | 4d252d6 | 2012-11-29 14:37:59 -0800 | [diff] [blame] | 304 | bool mSynchronous; |
Jason Sams | 5c1c79a | 2010-11-03 14:27:11 -0700 | [diff] [blame] | 305 | bool initGLThread(); |
Jason Sams | 33b6e3b | 2009-10-27 14:44:31 -0700 | [diff] [blame] | 306 | void deinitEGL(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 307 | |
Jason Sams | 2dca84d | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 308 | uint32_t runRootScript(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 309 | |
Jason Sams | 0ca7cba | 2015-03-11 15:22:38 -0700 | [diff] [blame] | 310 | bool loadRuntime(const char* filename); |
| 311 | bool loadDriver(bool forceDefault); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 312 | static void * threadProc(void *); |
Jason Sams | 7bf29dd | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 313 | static void * helperThreadProc(void *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 314 | |
Alex Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 315 | bool mHasSurface; |
Alex Sakhartchouk | b81a0eb | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 316 | bool mIsContextLite; |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 317 | |
Yang Ni | b8353c5 | 2015-02-14 18:00:59 -0800 | [diff] [blame] | 318 | Vector<ObjectBase *> mNames; |
Jason Sams | 24371d9 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 319 | |
| 320 | uint64_t mTimers[_RS_TIMER_TOTAL]; |
| 321 | Timers mTimerActive; |
| 322 | uint64_t mTimeLast; |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 323 | uint64_t mTimeFrame; |
| 324 | uint64_t mTimeLastFrame; |
Jason Sams | 2dca84d | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 325 | uint32_t mTimeMSLastFrame; |
| 326 | uint32_t mTimeMSLastScript; |
| 327 | uint32_t mTimeMSLastSwap; |
Alex Sakhartchouk | c8fb69e | 2010-10-05 13:23:55 -0700 | [diff] [blame] | 328 | uint32_t mAverageFPSFrameCount; |
| 329 | uint64_t mAverageFPSStartTime; |
| 330 | uint32_t mAverageFPS; |
Miao Wang | f3213d7 | 2015-01-14 10:03:07 -0800 | [diff] [blame] | 331 | #ifdef RS_COMPATIBILITY_LIB |
| 332 | char nativeLibDir[PATH_MAX+1]; |
| 333 | #endif |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 334 | }; |
| 335 | |
Tim Murray | 397b0b1 | 2014-01-07 15:35:08 -0800 | [diff] [blame] | 336 | void LF_ObjDestroy_handcode(const Context *rsc, RsAsyncVoidPtr objPtr); |
| 337 | |
Alex Sakhartchouk | 77d9f4b | 2011-01-31 14:53:24 -0800 | [diff] [blame] | 338 | } // renderscript |
| 339 | } // android |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 340 | #endif |