Clean up for DDL program pre-compilation
This CL:
1) Fixes a GrTexture access in GrTextureEffect that was blocking pre-compilation
2) Adds program pre-compilation to the DDL Via - which would've caught the GrTextureEffect problem on the bots
3) Adds some #if'ed out code for collecting program pre-compilation stats
Bug: skia:9455
Change-Id: Ibcb07ae855b7a644e1f22c3427a928f116ab300d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275336
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 8dce76e..4582227 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -2126,7 +2126,7 @@
// Fourth, synchronously render the display lists into the dest tiles
// TODO: it would be cool to not wait until all the tiles are drawn to begin
// drawing to the GPU and composing to the final surface
- tiles.drawAllTiles(context);
+ tiles.precompileAndDrawAllTiles(context);
// Finally, compose the drawn tiles into the result
// Note: the separation between the tiles and the final composition better
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index d6b97a2..b44b518 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -745,6 +745,21 @@
out->appendf("Total number of partial compilation successes %d\n",
fNumPartialCompilationSuccesses);
out->appendf("Total number of compilation successes %d\n", fNumCompilationSuccesses);
+
+ // enable this block to output CSV-style stats for program pre-compilation
+#if 0
+ SkASSERT(fNumInlineCompilationFailures == 0);
+ SkASSERT(fNumPreCompilationFailures == 0);
+ SkASSERT(fNumCompilationFailures == 0);
+ SkASSERT(fNumPartialCompilationSuccesses == 0);
+
+ SkDebugf("%d, %d, %d, %d, %d\n",
+ fInlineProgramCacheStats[(int) Stats::ProgramCacheResult::kHit],
+ fInlineProgramCacheStats[(int) Stats::ProgramCacheResult::kMiss],
+ fPreProgramCacheStats[(int) Stats::ProgramCacheResult::kHit],
+ fPreProgramCacheStats[(int) Stats::ProgramCacheResult::kMiss],
+ fNumCompilationSuccesses);
+#endif
}
void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
diff --git a/src/gpu/effects/GrTextureEffect.cpp b/src/gpu/effects/GrTextureEffect.cpp
index 490aac1..e0bea52 100644
--- a/src/gpu/effects/GrTextureEffect.cpp
+++ b/src/gpu/effects/GrTextureEffect.cpp
@@ -265,8 +265,8 @@
fb->ensureCoords2D(args.fTransformedCoords[0].fVaryingPoint).c_str());
const auto& m = te.fShaderModes;
- const auto* texture = te.fSampler.proxy()->peekTexture();
- bool normCoords = texture->texturePriv().textureType() != GrTextureType::kRectangle;
+ GrTextureType textureType = te.fSampler.proxy()->backendFormat().textureType();
+ bool normCoords = textureType != GrTextureType::kRectangle;
auto filter = te.fSampler.samplerState().filter();
FilterLogic filterLogic[2] = {GetFilterLogic(m[0], filter),
GetFilterLogic(m[1], filter)};
diff --git a/tools/DDLTileHelper.cpp b/tools/DDLTileHelper.cpp
index 45ca86d..7063bc7 100644
--- a/tools/DDLTileHelper.cpp
+++ b/tools/DDLTileHelper.cpp
@@ -84,6 +84,15 @@
fDisplayList = recorder.detach();
}
+void DDLTileHelper::TileData::precompile(GrContext* context) {
+ SkASSERT(fDisplayList);
+
+ SkDeferredDisplayList::ProgramIterator iter(context, fDisplayList.get());
+ for (; !iter.done(); iter.next()) {
+ iter.compile();
+ }
+}
+
void DDLTileHelper::TileData::draw(GrContext* context) {
SkASSERT(fDisplayList && !fImage);
@@ -168,10 +177,7 @@
static void do_gpu_stuff(GrContext* context, DDLTileHelper::TileData* tile) {
// TODO: schedule program compilation as their own tasks
- SkDeferredDisplayList::ProgramIterator iter(context, tile->ddl());
- for (; !iter.done(); iter.next()) {
- iter.compile();
- }
+ tile->precompile(context);
tile->draw(context);
@@ -204,8 +210,9 @@
}
}
-void DDLTileHelper::drawAllTiles(GrContext* context) {
+void DDLTileHelper::precompileAndDrawAllTiles(GrContext* context) {
for (int i = 0; i < this->numTiles(); ++i) {
+ fTiles[i].precompile(context);
fTiles[i].draw(context);
}
}
diff --git a/tools/DDLTileHelper.h b/tools/DDLTileHelper.h
index 4edfe2d..f565db8 100644
--- a/tools/DDLTileHelper.h
+++ b/tools/DDLTileHelper.h
@@ -42,6 +42,9 @@
// Create the DDL for this tile (i.e., fill in 'fDisplayList').
void createDDL();
+ // Precompile all the programs required to draw this tile's DDL
+ void precompile(GrContext*);
+
// Replay the recorded DDL into the tile surface - creating 'fImage'.
void draw(GrContext*);
@@ -84,7 +87,7 @@
void createDDLsInParallel();
- void drawAllTiles(GrContext*);
+ void precompileAndDrawAllTiles(GrContext*);
void composeAllTiles();
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index 4bf2a83..41909db 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -208,7 +208,7 @@
tiles->createDDLsInParallel();
if (!FLAGS_ddlRecordTime) {
- tiles->drawAllTiles(context);
+ tiles->precompileAndDrawAllTiles(context);
flush_with_sync(context, gpuSync);
}