diff options
author | 2016-03-17 11:35:45 -0700 | |
---|---|---|
committer | 2016-03-17 11:35:45 -0700 | |
commit | 0e1853c89615d14d0d03c87c7e0c604e5285cc54 (patch) | |
tree | e0ffc4b77a62d396b548f6e45fc8b335d3e6ecc1 /src/gpu/gl/GrGLGpuProgramCache.cpp | |
parent | 852f15da7ceb53cfb49b9f728baa6dbc53b27694 (diff) |
Update how we send draws to gpu backend to reduce state setting.
The main change here is that we pull primitive type off of the vertices, we set the gpu state on gpu once per pipeline/prim proc draw batch, and we create the ProgramDescriptor only for the Cache/ProgramBuilder.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1806983002
Review URL: https://codereview.chromium.org/1806983002
Diffstat (limited to 'src/gpu/gl/GrGLGpuProgramCache.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpuProgramCache.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index df8cf60c7b..f37264aa1d 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -108,28 +108,37 @@ int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); } -GrGLProgram* GrGLGpu::ProgramCache::refProgram(const DrawArgs& args) { +GrGLProgram* GrGLGpu::ProgramCache::refProgram(const GrGLGpu* gpu, + const GrPipeline& pipeline, + const GrPrimitiveProcessor& primProc) { #ifdef PROGRAM_CACHE_STATS ++fTotalRequests; #endif + // Get GrGLProgramDesc + GrGLProgramDesc desc; + if (!GrGLProgramDescBuilder::Build(&desc, primProc, pipeline, *gpu->glCaps().glslCaps())) { + GrCapsDebugf(gpu->caps(), "Failed to gl program descriptor!\n"); + return nullptr; + } + Entry* entry = nullptr; - uint32_t hashIdx = args.fDesc->getChecksum(); + uint32_t hashIdx = desc.getChecksum(); hashIdx ^= hashIdx >> 16; if (kHashBits <= 8) { hashIdx ^= hashIdx >> 8; } hashIdx &=((1 << kHashBits) - 1); Entry* hashedEntry = fHashTable[hashIdx]; - if (hashedEntry && hashedEntry->fProgram->getDesc() == *args.fDesc) { + if (hashedEntry && hashedEntry->fProgram->getDesc() == desc) { SkASSERT(hashedEntry->fProgram); entry = hashedEntry; } int entryIdx; if (nullptr == entry) { - entryIdx = this->search(*args.fDesc); + entryIdx = this->search(desc); if (entryIdx >= 0) { entry = fEntries[entryIdx]; #ifdef PROGRAM_CACHE_STATS @@ -143,7 +152,7 @@ GrGLProgram* GrGLGpu::ProgramCache::refProgram(const DrawArgs& args) { #ifdef PROGRAM_CACHE_STATS ++fCacheMisses; #endif - GrGLProgram* program = GrGLProgramBuilder::CreateProgram(args, fGpu); + GrGLProgram* program = GrGLProgramBuilder::CreateProgram(pipeline, primProc, desc, fGpu); if (nullptr == program) { return nullptr; } |