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

Unified Diff: src/gpu/gl/GrGpuGL_program.cpp

Issue 777673003: move program descriptor generation to flush (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 6 years 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
Index: src/gpu/gl/GrGpuGL_program.cpp
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index cb8810cc79600450945d8db98f2c11079ff5710f..368cebe03786be85bd9b106d222bb907024b690e 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -91,28 +91,30 @@ int GrGpuGL::ProgramCache::search(const GrProgramDesc& desc) const {
return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
}
-GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, DrawType type) {
+GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
+ const GrProgramDesc& desc,
+ DrawType type) {
#ifdef PROGRAM_CACHE_STATS
++fTotalRequests;
#endif
Entry* entry = NULL;
- uint32_t hashIdx = optState.programDesc().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() == optState.programDesc()) {
+ if (hashedEntry && hashedEntry->fProgram->getDesc() == desc) {
SkASSERT(hashedEntry->fProgram);
entry = hashedEntry;
}
int entryIdx;
if (NULL == entry) {
- entryIdx = this->search(optState.programDesc());
+ entryIdx = this->search(desc);
if (entryIdx >= 0) {
entry = fEntries[entryIdx];
#ifdef PROGRAM_CACHE_STATS
@@ -126,7 +128,7 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, D
#ifdef PROGRAM_CACHE_STATS
++fCacheMisses;
#endif
- GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, type, fGpu);
+ GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, desc, type, fGpu);
if (NULL == program) {
return NULL;
}
@@ -201,7 +203,9 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, D
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
-bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type) {
+bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState,
+ const GrProgramDesc& desc,
+ DrawType type) {
// GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
SkASSERT(optState.getRenderTarget());
@@ -216,7 +220,7 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type)
GrBlendCoeff srcCoeff = optState.getSrcBlendCoeff();
GrBlendCoeff dstCoeff = optState.getDstBlendCoeff();
- fCurrentProgram.reset(fProgramCache->getProgram(optState, type));
+ fCurrentProgram.reset(fProgramCache->getProgram(optState, desc, type));
if (NULL == fCurrentProgram.get()) {
SkDEBUGFAIL("Failed to create program!");
return false;
@@ -302,10 +306,9 @@ void GrGpuGL::setupGeometry(const GrOptDrawState& optState,
}
void GrGpuGL::buildProgramDesc(const GrOptDrawState& optState,
- const GrProgramDesc::DescInfo& descInfo,
GrGpu::DrawType drawType,
GrProgramDesc* desc) {
- if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, desc)) {
+ if (!GrGLProgramDescBuilder::Build(optState, drawType, this, desc)) {
SkDEBUGFAIL("Failed to generate GL program descriptor");
}
}

Powered by Google App Engine
This is Rietveld 408576698