rsContext.h revision f166d9b5a280f0ec2ce7e089471c20a1477e2dbb
1d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams/*
2d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * Copyright (C) 2009 The Android Open Source Project
3d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams *
4d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * Licensed under the Apache License, Version 2.0 (the "License");
5d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * you may not use this file except in compliance with the License.
6d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * You may obtain a copy of the License at
7d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams *
8d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams *      http://www.apache.org/licenses/LICENSE-2.0
9d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams *
10d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * Unless required by applicable law or agreed to in writing, software
11d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * distributed under the License is distributed on an "AS IS" BASIS,
12d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * See the License for the specific language governing permissions and
14d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams * limitations under the License.
15d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams */
16d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
17d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#ifndef ANDROID_RS_CONTEXT_H
18d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#define ANDROID_RS_CONTEXT_H
19d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
20399bfce299210ef9c2fc1e932202223253e2384aJason Sams#include "rsUtils.h"
21c1d726c2d62424867ec14f2cde16b00fe0ddfee1Jason Sams#include "rsMutex.h"
22399bfce299210ef9c2fc1e932202223253e2384aJason Sams
23bc948dedcee57a66fe2cb38d4c79d04a10c7efb3Jason Sams#include "rsThreadIO.h"
24d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsType.h"
25d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsMatrix.h"
26d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsAllocation.h"
277c878f3a8379daf21dca6de7aa722ff75328afbeJason Sams#include "rsMesh.h"
28d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsDevice.h"
29d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsScriptC.h"
30d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsAllocation.h"
31d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsAdapter.h"
32d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsSampler.h"
33ee41112e1539de95596600fd2c6dada5d275217fJason Sams#include "rsLight.h"
349b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk#include "rsFont.h"
35d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsProgramFragment.h"
3654db59c3594e887a412a24713fc3daa1c2404593Jason Sams#include "rsProgramStore.h"
37ebfb436a49673693b98469683451bd9ede797557Jason Sams#include "rsProgramRaster.h"
38d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsProgramVertex.h"
39bb51c40d89c7dbdee7d7507fdfe0a64e8f4f87a9Jason Sams#include "rsShaderCache.h"
40bb51c40d89c7dbdee7d7507fdfe0a64e8f4f87a9Jason Sams#include "rsVertexArray.h"
41d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
42d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsgApiStructs.h"
43d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#include "rsLocklessFifo.h"
44d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
455cbb940cf6b1fd2b44d66bc40e5c3e8429bbd741Mathias Agopian#include <ui/egl/android_natives.h>
46d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
47d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams// ---------------------------------------------------------------------------
48d19f10d43aa400e1183aa21a97099d02074131a2Jason Samsnamespace android {
49000479f9e325b4e426a67033abd92d47da412725Mathias Agopian
50d19f10d43aa400e1183aa21a97099d02074131a2Jason Samsnamespace renderscript {
51d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
52f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#if 0
53f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#define CHECK_OBJ(o) { \
54f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    GET_TLS(); \
55f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    if(!ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
56f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
57f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    } \
58f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams}
59f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#define CHECK_OBJ_OR_NULL(o) { \
60f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    GET_TLS(); \
61f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    if(o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
62f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
63f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    } \
64f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams}
65f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#else
66f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#define CHECK_OBJ(o)
67f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#define CHECK_OBJ_OR_NULL(o)
68f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams#endif
69f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams
709bee51c42eb8c3daffe7d6fa483edbb1689b94d2Jason Samsclass Context
71d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams{
72d19f10d43aa400e1183aa21a97099d02074131a2Jason Samspublic:
73704ff64b099406bb328898a7443921f22dbffd6dJason Sams    Context(Device *, bool isGraphics, bool useDepth);
74d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ~Context();
75d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
76462d11b880cba72584c135397c0a82618ab63217Jason Sams    static pthread_key_t gThreadTLSKey;
7741c19db90e250e2b7cb438904f0e96a0ef455d6dJason Sams    static uint32_t gThreadTLSKeyCount;
787136220b54e68e0c7faac30577ed20b7482481fdJason Sams    static uint32_t gGLContextCount;
7941c19db90e250e2b7cb438904f0e96a0ef455d6dJason Sams    static pthread_mutex_t gInitMutex;
8041c19db90e250e2b7cb438904f0e96a0ef455d6dJason Sams
81462d11b880cba72584c135397c0a82618ab63217Jason Sams    struct ScriptTLSStruct {
82462d11b880cba72584c135397c0a82618ab63217Jason Sams        Context * mContext;
83462d11b880cba72584c135397c0a82618ab63217Jason Sams        Script * mScript;
84462d11b880cba72584c135397c0a82618ab63217Jason Sams    };
85f166d9b5a280f0ec2ce7e089471c20a1477e2dbbJason Sams    ScriptTLSStruct *mTlsStruct;
86462d11b880cba72584c135397c0a82618ab63217Jason Sams
878e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
88d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
89d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    //StructuredAllocationContext mStateAllocation;
90d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ElementState mStateElement;
91d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    TypeState mStateType;
92d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    SamplerState mStateSampler;
93d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ProgramFragmentState mStateFragment;
9454db59c3594e887a412a24713fc3daa1c2404593Jason Sams    ProgramStoreState mStateFragmentStore;
95ebfb436a49673693b98469683451bd9ede797557Jason Sams    ProgramRasterState mStateRaster;
96d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ProgramVertexState mStateVertex;
97bba134c8a1dcfe0c8473307a95899a02c9553504Jason Sams    LightState mStateLight;
98bb51c40d89c7dbdee7d7507fdfe0a64e8f4f87a9Jason Sams    VertexArrayState mStateVertexArray;
999b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    FontState mStateFont;
100d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
101d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ScriptCState mScriptC;
102bb51c40d89c7dbdee7d7507fdfe0a64e8f4f87a9Jason Sams    ShaderCache mShaderCache;
103d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
104d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    void swapBuffers();
105d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    void setRootScript(Script *);
106ebfb436a49673693b98469683451bd9ede797557Jason Sams    void setRaster(ProgramRaster *);
107d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    void setVertex(ProgramVertex *);
108d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    void setFragment(ProgramFragment *);
10954db59c3594e887a412a24713fc3daa1c2404593Jason Sams    void setFragmentStore(ProgramStore *);
1109b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    void setFont(Font *);
111d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
112d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    void updateSurface(void *sur);
113d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
114d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    const ProgramFragment * getFragment() {return mFragment.get();}
11554db59c3594e887a412a24713fc3daa1c2404593Jason Sams    const ProgramStore * getFragmentStore() {return mFragmentStore.get();}
116ebfb436a49673693b98469683451bd9ede797557Jason Sams    const ProgramRaster * getRaster() {return mRaster.get();}
117b0ec1b46d6f5b5612e33fe43a828abea79b87a00Jason Sams    const ProgramVertex * getVertex() {return mVertex.get();}
1189b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    Font * getFont() {return mFont.get();}
119d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
120156cce698093023d9e79a4ff4fb96f4e4d3019dbJason Sams    bool setupCheck();
1213b7d39bb51f851ddee441fa34884495217e477f9Jason Sams    bool checkDriver() const {return mEGL.mSurface != 0;}
122d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
12365e7aa56f56097418d617663683544c25b3988eaJason Sams    void pause();
12465e7aa56f56097418d617663683544c25b3988eaJason Sams    void resume();
1258b49bd1a2f8117e1c22884f0150e72cbcf838f32Dianne Hackborn    void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur);
1267d787b4722eaeb79cab42c36060336e092b77b5fJason Sams    void setPriority(int32_t p);
12765e7aa56f56097418d617663683544c25b3988eaJason Sams
128d5680f9ba95ec7ce212e8025774914e79982a1eeJason Sams    void assignName(ObjectBase *obj, const char *name, uint32_t len);
1293eaa338e11a3b0d6b87d705e5bb95625e82347bdJason Sams    void removeName(ObjectBase *obj);
1309c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams
131516c31911578db8ce53529483c3ded918ac7dc6bJason Sams    uint32_t getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait);
132516c31911578db8ce53529483c3ded918ac7dc6bJason Sams    bool sendMessageToClient(void *data, uint32_t cmdID, size_t len, bool waitForSpace);
133f17bccc9050498f51a32a2ee78f5d5a306008e3dJason Sams    uint32_t runScript(Script *s);
134516c31911578db8ce53529483c3ded918ac7dc6bJason Sams
135516c31911578db8ce53529483c3ded918ac7dc6bJason Sams    void initToClient();
136516c31911578db8ce53529483c3ded918ac7dc6bJason Sams    void deinitToClient();
137516c31911578db8ce53529483c3ded918ac7dc6bJason Sams
1389c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams    ProgramFragment * getDefaultProgramFragment() const {
1399c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams        return mStateFragment.mDefault.get();
1409c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams    }
1419c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams    ProgramVertex * getDefaultProgramVertex() const {
1429c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams        return mStateVertex.mDefault.get();
1439c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams    }
14454db59c3594e887a412a24713fc3daa1c2404593Jason Sams    ProgramStore * getDefaultProgramStore() const {
1459c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams        return mStateFragmentStore.mDefault.get();
1469c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams    }
147ebfb436a49673693b98469683451bd9ede797557Jason Sams    ProgramRaster * getDefaultProgramRaster() const {
148ebfb436a49673693b98469683451bd9ede797557Jason Sams        return mStateRaster.mDefault.get();
149ebfb436a49673693b98469683451bd9ede797557Jason Sams    }
1509b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    Font* getDefaultFont() const {
1519b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk        return mStateFont.mDefault.get();
1529b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    }
1539c54bdbf458e3c9433d237ae71cf47c4ec47d852Jason Sams
154f603d212552485c634e25f3556f847dc2b022bd5Jason Sams    uint32_t getWidth() const {return mWidth;}
155f603d212552485c634e25f3556f847dc2b022bd5Jason Sams    uint32_t getHeight() const {return mHeight;}
15640a29e8e28772b37ab0f9fe9708ecdcba24abb84Jason Sams
157bc948dedcee57a66fe2cb38d4c79d04a10c7efb3Jason Sams
158bc948dedcee57a66fe2cb38d4c79d04a10c7efb3Jason Sams    ThreadIO mIO;
159bc948dedcee57a66fe2cb38d4c79d04a10c7efb3Jason Sams
160f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    // Timers
161f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    enum Timers {
162f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams        RS_TIMER_IDLE,
163f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams        RS_TIMER_INTERNAL,
164f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams        RS_TIMER_SCRIPT,
165f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams        RS_TIMER_CLEAR_SWAP,
166f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams        _RS_TIMER_TOTAL
167f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    };
168f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    uint64_t getTime() const;
169f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    void timerInit();
170f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    void timerReset();
171f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    void timerSet(Timers);
172f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    void timerPrint();
1732525a815220652b37e2e390fe8c62394a6d0e574Jason Sams    void timerFrame();
174f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams
17566b2771d745aa66df5cf80b300b5ba0f936ff22eJason Sams    struct {
17666b2771d745aa66df5cf80b300b5ba0f936ff22eJason Sams        bool mLogTimes;
17766b2771d745aa66df5cf80b300b5ba0f936ff22eJason Sams        bool mLogScripts;
17866b2771d745aa66df5cf80b300b5ba0f936ff22eJason Sams        bool mLogObjects;
1795dad8b4d1fda37b7b4763ef7361c5eb92131cb7eJason Sams        bool mLogShaders;
1804378f1175546616c76ecb7f0b1159940ab22d5f4Alex Sakhartchouk        bool mLogShadersAttr;
1814378f1175546616c76ecb7f0b1159940ab22d5f4Alex Sakhartchouk        bool mLogShadersUniforms;
1826de555001bc9b3ea6baf8ce1293e6c366a9bd6ceAlex Sakhartchouk        bool mLogVisual;
18366b2771d745aa66df5cf80b300b5ba0f936ff22eJason Sams    } props;
1849ac2c66f0171593113238635c6a7921c41215e77Joe Onorato
1859dab667e03632181e487a04a8a170b3fa0bd5037Jason Sams    void dumpDebug() const;
186718cd1f322ee5b62b6a49cb36195bcb18a5ab711Jason Sams    void checkError(const char *) const;
187156cce698093023d9e79a4ff4fb96f4e4d3019dbJason Sams    const char * getError(RsError *);
188f468700b6dd02cf68d4424567a8288a24084f51aJason Sams    void setError(RsError e, const char *msg = NULL);
1899dab667e03632181e487a04a8a170b3fa0bd5037Jason Sams
190a9e7a05b84470257637c97d65f6562aa832c66efJason Sams    mutable const ObjectBase * mObjHead;
191a9e7a05b84470257637c97d65f6562aa832c66efJason Sams
1922978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1Jason Sams    bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;}
1934378f1175546616c76ecb7f0b1159940ab22d5f4Alex Sakhartchouk    float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; }
194b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk    uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;}
195b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk    uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;}
196b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk    uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;}
1972978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1Jason Sams
1988e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    void launchThreads(WorkerCallback_t cbk, void *data);
199f3470edc8a929d73797789656ce840aff918dcd0Jason Sams    uint32_t getWorkerPoolSize() const {return (uint32_t)mWorkers.mCount;}
2008e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams
201d19f10d43aa400e1183aa21a97099d02074131a2Jason Samsprotected:
202d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    Device *mDev;
203d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
204b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams    struct {
205b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLint mNumConfigs;
206b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLint mMajorVersion;
207b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLint mMinorVersion;
208b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLConfig mConfig;
209b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLContext mContext;
210b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLSurface mSurface;
211b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        EGLDisplay mDisplay;
212b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams    } mEGL;
213b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams
214b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams    struct {
215b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        const uint8_t * mVendor;
216b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        const uint8_t * mRenderer;
217b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        const uint8_t * mVersion;
218b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        const uint8_t * mExtensions;
219b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams
220b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        uint32_t mMajorVersion;
221b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams        uint32_t mMinorVersion;
222b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams
2230011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxVaryingVectors;
2240011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxTextureImageUnits;
2250011bcf57ff711a221a3a4c73f2a79125111647dJason Sams
2260011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxFragmentTextureImageUnits;
2270011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxFragmentUniformVectors;
2280011bcf57ff711a221a3a4c73f2a79125111647dJason Sams
2290011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxVertexAttribs;
2300011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxVertexUniformVectors;
2310011bcf57ff711a221a3a4c73f2a79125111647dJason Sams        int32_t mMaxVertexTextureUnits;
2322978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1Jason Sams
2332978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1Jason Sams        bool OES_texture_npot;
2344378f1175546616c76ecb7f0b1159940ab22d5f4Alex Sakhartchouk        float EXT_texture_max_aniso;
235b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams    } mGL;
236d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
2373bc47d438171dce294e816366d53bc9eca772c5bJason Sams    uint32_t mWidth;
2383bc47d438171dce294e816366d53bc9eca772c5bJason Sams    uint32_t mHeight;
239b9d5c574ff11a9470b92c5b9a62da6a655d9ef7aJason Sams    int32_t mThreadPriority;
240704ff64b099406bb328898a7443921f22dbffd6dJason Sams    bool mIsGraphicsContext;
2413bc47d438171dce294e816366d53bc9eca772c5bJason Sams
242d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    bool mRunning;
243d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    bool mExit;
244b13ada5071f55c96054c47bbd88d8801cd2c0f15Jason Sams    bool mUseDepth;
24565e7aa56f56097418d617663683544c25b3988eaJason Sams    bool mPaused;
246156cce698093023d9e79a4ff4fb96f4e4d3019dbJason Sams    RsError mError;
247156cce698093023d9e79a4ff4fb96f4e4d3019dbJason Sams    const char *mErrorMsg;
248d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
249d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    pthread_t mThreadId;
2507d787b4722eaeb79cab42c36060336e092b77b5fJason Sams    pid_t mNativeThreadId;
251d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
2528e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    struct Workers {
2538e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        volatile int mRunningCount;
2548e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        volatile int mLaunchCount;
2558e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        uint32_t mCount;
2568e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        pthread_t *mThreadId;
2578e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        pid_t *mNativeThreadId;
2588e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        Signal mCompleteSignal;
2598e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams
2608e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        Signal *mLaunchSignals;
2618e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        WorkerCallback_t mLaunchCallback;
2628e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams        void *mLaunchData;
2638e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    };
2648e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    Workers mWorkers;
2658e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams
266d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ObjectBaseRef<Script> mRootScript;
267d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ObjectBaseRef<ProgramFragment> mFragment;
268d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    ObjectBaseRef<ProgramVertex> mVertex;
26954db59c3594e887a412a24713fc3daa1c2404593Jason Sams    ObjectBaseRef<ProgramStore> mFragmentStore;
270ebfb436a49673693b98469683451bd9ede797557Jason Sams    ObjectBaseRef<ProgramRaster> mRaster;
2719b949fce39f0f39ce9275b71d7c347210775e7a8Alex Sakhartchouk    ObjectBaseRef<Font> mFont;
272730ee65d4ddb307898053b623120bad1655fadadJason Sams
2736de555001bc9b3ea6baf8ce1293e6c366a9bd6ceAlex Sakhartchouk    void displayDebugStats();
2746de555001bc9b3ea6baf8ce1293e6c366a9bd6ceAlex Sakhartchouk
275d19f10d43aa400e1183aa21a97099d02074131a2Jason Samsprivate:
276d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    Context();
277d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
278bb51c40d89c7dbdee7d7507fdfe0a64e8f4f87a9Jason Sams    void initEGL(bool useGL2);
2797136220b54e68e0c7faac30577ed20b7482481fdJason Sams    void deinitEGL();
280d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
281b9d5c574ff11a9470b92c5b9a62da6a655d9ef7aJason Sams    uint32_t runRootScript();
282d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
283d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams    static void * threadProc(void *);
2848e6c17fcc40bfb2391dcadecb397431239ab8a18Jason Sams    static void * helperThreadProc(void *);
285d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
2868b49bd1a2f8117e1c22884f0150e72cbcf838f32Dianne Hackborn    ANativeWindow *mWndSurface;
2873eaa338e11a3b0d6b87d705e5bb95625e82347bdJason Sams
2883eaa338e11a3b0d6b87d705e5bb95625e82347bdJason Sams    Vector<ObjectBase *> mNames;
289f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams
290f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    uint64_t mTimers[_RS_TIMER_TOTAL];
291f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    Timers mTimerActive;
292f4d160653fe405eba9d6f55448ac4599c6cadd77Jason Sams    uint64_t mTimeLast;
2932525a815220652b37e2e390fe8c62394a6d0e574Jason Sams    uint64_t mTimeFrame;
2942525a815220652b37e2e390fe8c62394a6d0e574Jason Sams    uint64_t mTimeLastFrame;
295b9d5c574ff11a9470b92c5b9a62da6a655d9ef7aJason Sams    uint32_t mTimeMSLastFrame;
296b9d5c574ff11a9470b92c5b9a62da6a655d9ef7aJason Sams    uint32_t mTimeMSLastScript;
297b9d5c574ff11a9470b92c5b9a62da6a655d9ef7aJason Sams    uint32_t mTimeMSLastSwap;
298d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams};
299d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams
300d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams}
301d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams}
302d19f10d43aa400e1183aa21a97099d02074131a2Jason Sams#endif
303