Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [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_SHADER_CACHE_H |
| 18 | #define ANDROID_SHADER_CACHE_H |
| 19 | |
| 20 | |
| 21 | #include "rsObjectBase.h" |
| 22 | #include "rsVertexArray.h" |
| 23 | |
| 24 | // --------------------------------------------------------------------------- |
| 25 | namespace android { |
| 26 | namespace renderscript { |
| 27 | |
| 28 | |
| 29 | // An element is a group of Components that occupies one cell in a structure. |
| 30 | class ShaderCache |
| 31 | { |
| 32 | public: |
| 33 | ShaderCache(); |
| 34 | virtual ~ShaderCache(); |
| 35 | |
Jason Sams | 5dad8b4 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 36 | bool lookup(Context *rsc, ProgramVertex *, ProgramFragment *); |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 37 | |
| 38 | void cleanupVertex(uint32_t id); |
| 39 | void cleanupFragment(uint32_t id); |
| 40 | |
| 41 | void cleanupAll(); |
| 42 | |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 43 | int32_t vtxAttribSlot(const String8 &attrName) const; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 44 | int32_t vtxUniformSlot(uint32_t a) const {return mCurrent->mVtxUniformSlots[a];} |
| 45 | int32_t fragAttribSlot(uint32_t a) const {return mCurrent->mFragAttribSlots[a];} |
| 46 | int32_t fragUniformSlot(uint32_t a) const {return mCurrent->mFragUniformSlots[a];} |
| 47 | |
| 48 | protected: |
| 49 | typedef struct { |
| 50 | uint32_t vtx; |
| 51 | uint32_t frag; |
| 52 | uint32_t program; |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 53 | uint32_t vtxAttrCount; |
| 54 | const char* mVtxAttribNames[Program::MAX_ATTRIBS]; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 55 | int32_t mVtxAttribSlots[Program::MAX_ATTRIBS]; |
| 56 | int32_t mVtxUniformSlots[Program::MAX_UNIFORMS]; |
| 57 | int32_t mFragAttribSlots[Program::MAX_ATTRIBS]; |
| 58 | int32_t mFragUniformSlots[Program::MAX_UNIFORMS]; |
Jason Sams | 156cce6 | 2010-03-03 13:03:18 -0800 | [diff] [blame] | 59 | bool mIsValid; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 60 | } entry_t; |
Alex Sakhartchouk | feede2a | 2010-10-01 10:54:06 -0700 | [diff] [blame] | 61 | //entry_t *mEntries; |
| 62 | Vector<entry_t*> mEntries; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 63 | entry_t *mCurrent; |
| 64 | |
Alex Sakhartchouk | feede2a | 2010-10-01 10:54:06 -0700 | [diff] [blame] | 65 | /*uint32_t mEntryCount; |
| 66 | uint32_t mEntryAllocationCount;*/ |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 67 | |
| 68 | }; |
| 69 | |
| 70 | |
| 71 | |
| 72 | } |
| 73 | } |
| 74 | #endif //ANDROID_SHADER_CACHE_H |
| 75 | |
| 76 | |
| 77 | |
| 78 | |