Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: src/gpu/gl/GrGpuGL.h

Issue 15252004: Make GrGLProgramDesc's key variable length by compacting the effect key array (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address comments, fix unit test Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.h
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 0f75280178a4b6b9a4eb77705e70775f25329908..8f80a72cbcba3dc2f2f16dd113ec7ff112232283 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;
- public:
- SkAutoTUnref<GrGLProgram> fProgram;
- ProgramHashKey fKey;
- unsigned int fLRUStamp; // Move outside entry?
- };
+ struct ProgDescLess;
+
+ // binary search for 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
};
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698