Add a work indication to SkDeferredDisplayList::ProgramIterator::compile

Chrome hopes to use this as a heuristic for when to yield. I.e., if no work is done, keep going but yield after each compile that did work.

Change-Id: I9524ca03078af3cd60f0042b2e8b0ec4c628e5f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288176
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-05-06 13:34:45 -04:00 committed by Skia Commit-Bot
parent 29c2f71cb8
commit 43e7e4f3e1
5 changed files with 21 additions and 14 deletions

View File

@ -44,7 +44,8 @@ public:
ProgramIterator(GrContext*, SkDeferredDisplayList*);
~ProgramIterator();
void compile();
// This returns true if any work was done. Getting a cache hit does not count as work.
bool compile();
bool done() const;
void next();

View File

@ -48,12 +48,12 @@ SkDeferredDisplayList::ProgramIterator::ProgramIterator(GrContext* context,
SkDeferredDisplayList::ProgramIterator::~ProgramIterator() {}
void SkDeferredDisplayList::ProgramIterator::compile() {
bool SkDeferredDisplayList::ProgramIterator::compile() {
if (!fContext || fIndex < 0 || fIndex >= (int) fProgramData.size()) {
return;
return false;
}
fContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info());
return fContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info());
}
bool SkDeferredDisplayList::ProgramIterator::done() const {

View File

@ -69,13 +69,13 @@ void GrContextPriv::copyRenderTasksFromDDL(const SkDeferredDisplayList* ddl,
fContext->drawingManager()->copyRenderTasksFromDDL(ddl, newDest);
}
void GrContextPriv::compile(const GrProgramDesc& desc, const GrProgramInfo& info) {
bool GrContextPriv::compile(const GrProgramDesc& desc, const GrProgramInfo& info) {
GrGpu* gpu = this->getGpu();
if (!gpu) {
return;
return false;
}
gpu->compile(desc, info);
return gpu->compile(desc, info);
}

View File

@ -123,7 +123,7 @@ public:
void moveRenderTasksToDDL(SkDeferredDisplayList*);
void copyRenderTasksFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest);
void compile(const GrProgramDesc&, const GrProgramInfo&);
bool compile(const GrProgramDesc&, const GrProgramInfo&);
GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const {

View File

@ -139,8 +139,14 @@ public:
void deleteBackendTexture(const GrBackendTexture&) override;
bool compile(const GrProgramDesc& desc, const GrProgramInfo& programInfo) override {
sk_sp<GrGLProgram> tmp = fProgramCache->findOrCreateProgram(desc, programInfo);
return SkToBool(tmp);
Stats::ProgramCacheResult stat;
sk_sp<GrGLProgram> tmp = fProgramCache->findOrCreateProgram(desc, programInfo, &stat);
if (!tmp) {
return false;
}
return stat != Stats::ProgramCacheResult::kHit;
}
bool precompileShader(const SkData& key, const SkData& data) override {
@ -333,13 +339,13 @@ private:
void reset();
sk_sp<GrGLProgram> findOrCreateProgram(GrRenderTarget*, const GrProgramInfo&);
sk_sp<GrGLProgram> findOrCreateProgram(const GrProgramDesc& desc,
const GrProgramInfo& programInfo) {
Stats::ProgramCacheResult stat;
sk_sp<GrGLProgram> tmp = this->findOrCreateProgram(nullptr, desc, programInfo, &stat);
const GrProgramInfo& programInfo,
Stats::ProgramCacheResult* stat) {
sk_sp<GrGLProgram> tmp = this->findOrCreateProgram(nullptr, desc, programInfo, stat);
if (!tmp) {
fGpu->fStats.incNumPreCompilationFailures();
} else {
fGpu->fStats.incNumPreProgramCacheResult(stat);
fGpu->fStats.incNumPreProgramCacheResult(*stat);
}
return tmp;