Chromium Code Reviews| Index: src/gpu/gl/GrGpuGL.h |
| diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h |
| index 0f75280178a4b6b9a4eb77705e70775f25329908..02149368ee9b81baf359ff1522d25352cf45c53d 100644 |
| --- a/src/gpu/gl/GrGpuGL.h |
| +++ b/src/gpu/gl/GrGpuGL.h |
| @@ -177,47 +177,36 @@ private: |
| void abandon(); |
| GrGLProgram* getProgram(const GrGLProgramDesc& desc, const GrEffectStage* stages[]); |
| + |
| private: |
| enum { |
| - kKeySize = sizeof(GrGLProgramDesc), |
| // We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
| // shader before evicting from the cache. |
| - kMaxEntries = 32 |
| + kMaxEntries = 32, |
| + kHashBits = 6, |
| }; |
| - class Entry; |
| - // The value of the hash key is based on the ProgramDesc. |
| - typedef GrTBinHashKey<Entry, kKeySize> ProgramHashKey; |
| - |
| - class Entry : public ::GrNoncopyable { |
| - public: |
| - Entry() : fProgram(NULL), fLRUStamp(0) {} |
| - Entry& operator = (const Entry& entry) { |
| - GrSafeRef(entry.fProgram.get()); |
| - fProgram.reset(entry.fProgram.get()); |
| - fKey = entry.fKey; |
| - fLRUStamp = entry.fLRUStamp; |
| - return *this; |
| - } |
| - int compare(const ProgramHashKey& key) const { |
| - return fKey.compare(key); |
| - } |
| + struct Entry; |
|
robertphillips
2013/05/21 19:22:37
Do we need this pre-declare?
bsalomon
2013/05/22 14:11:25
It has to have access to GrGpuGL::ProgramCache::En
|
| - public: |
| - SkAutoTUnref<GrGLProgram> fProgram; |
| - ProgramHashKey fKey; |
| - unsigned int fLRUStamp; // Move outside entry? |
| - }; |
| + struct ProgDescLess; |
| + |
|
robertphillips
2013/05/21 19:22:37
of -> for?
bsalomon
2013/05/22 14:11:25
Done.
|
| + // binary search of entry matching desc. returns index into fEntries that matches desc or ~ |
| + // of the index of where it should be inserted. |
| + int search(const GrGLProgramDesc& desc) const; |
| - GrTHashTable<Entry, ProgramHashKey, 8> fHashCache; |
| + // sorted array of all the entries |
| + Entry* fEntries[kMaxEntries]; |
| + // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
| + // searching fEntries. |
| + Entry* fHashTable[1 << kHashBits]; |
| - Entry fEntries[kMaxEntries]; |
| int fCount; |
| unsigned int fCurrLRUStamp; |
| const GrGLContext& fGL; |
| #ifdef PROGRAM_CACHE_STATS |
| int fTotalRequests; |
| int fCacheMisses; |
| + int fHashMisses; // cache hit but hash table missed |
| #endif |
| }; |