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

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

Issue 674543004: OptState owns program descriptor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
Index: src/gpu/gl/GrGpuGL_program.cpp
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 6a09ebf64e1564d03e0d54cd7cfed199630610d4..8306852cb62dfbfbb8276e825e68fbde731a699f 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -31,12 +31,12 @@ struct GrGpuGL::ProgramCache::Entry {
};
struct GrGpuGL::ProgramCache::ProgDescLess {
- bool operator() (const GrGLProgramDesc& desc, const Entry* entry) {
+ bool operator() (const GrProgramDesc& desc, const Entry* entry) {
SkASSERT(entry->fProgram.get());
return GrGLProgramDesc::Less(desc, entry->fProgram->getDesc());
}
- bool operator() (const Entry* entry, const GrGLProgramDesc& desc) {
+ bool operator() (const Entry* entry, const GrProgramDesc& desc) {
SkASSERT(entry->fProgram.get());
return GrGLProgramDesc::Less(entry->fProgram->getDesc(), desc);
}
@@ -86,35 +86,33 @@ void GrGpuGL::ProgramCache::abandon() {
fCount = 0;
}
-int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const {
+int GrGpuGL::ProgramCache::search(const GrProgramDesc& desc) const {
ProgDescLess less;
return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
}
-GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
- const GrGLProgramDesc& desc,
- DrawType type) {
+GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, DrawType type) {
#ifdef PROGRAM_CACHE_STATS
++fTotalRequests;
#endif
Entry* entry = NULL;
- uint32_t hashIdx = desc.getChecksum();
+ uint32_t hashIdx = optState.desc().getChecksum();
hashIdx ^= hashIdx >> 16;
if (kHashBits <= 8) {
hashIdx ^= hashIdx >> 8;
}
hashIdx &=((1 << kHashBits) - 1);
Entry* hashedEntry = fHashTable[hashIdx];
- if (hashedEntry && hashedEntry->fProgram->getDesc() == desc) {
+ if (hashedEntry && hashedEntry->fProgram->getDesc() == optState.desc()) {
SkASSERT(hashedEntry->fProgram);
entry = hashedEntry;
}
int entryIdx;
if (NULL == entry) {
- entryIdx = this->search(desc);
+ entryIdx = this->search(optState.desc());
if (entryIdx >= 0) {
entry = fEntries[entryIdx];
#ifdef PROGRAM_CACHE_STATS
@@ -128,7 +126,7 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
#ifdef PROGRAM_CACHE_STATS
++fCacheMisses;
#endif
- GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, desc, type, fGpu);
+ GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, type, fGpu);
if (NULL == program) {
return NULL;
}
@@ -205,7 +203,8 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstCopy) {
SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(this->getDrawState(),
- *this->caps(),
+ this,
+ dstCopy,
type));
if (!optState) {
@@ -238,7 +237,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
return false;
}
- fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(), desc, type));
+ fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(), type));
if (NULL == fCurrentProgram.get()) {
SkDEBUGFAIL("Failed to create program!");
return false;
@@ -277,7 +276,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
SkAutoTUnref<GrOptDrawState> optState(
- GrOptDrawState::Create(this->getDrawState(), *this->caps(),
+ GrOptDrawState::Create(this->getDrawState(), this, info.getDstCopy(),
PrimTypeToDrawType(info.primitiveType())));
// If the optState would is NULL it should have been caught in flushGraphicsState before getting
@@ -359,3 +358,14 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
attribState->disableUnusedArrays(this, usedAttribArraysMask);
}
}
+
+void GrGpuGL::buildKey(const GrOptDrawState* optState,
+ GrGpu::DrawType drawType,
+ const GrDeviceCoordTexture* dstCopy,
+ GrProgramDesc* desc) {
+ SkASSERT(optState);
+ if (!GrGLProgramDesc::Build(*optState, drawType, this, dstCopy,
+ static_cast<GrGLProgramDesc*>(desc))) {
+ SkDEBUGFAIL("Failed to generate GL program descriptor");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698