Make DDL contexts/drawing managers always sort opLists
We want:
DDLs to always be sorted
Live rendering to still be sorted w/in Skia
Live rendering to still not be sorted in Chrome and Android
Additionally, we want reduced-opList-splitting to only be enabled on some of Skia's bots.
Change-Id: I15e7d69c7e109749665a86a0169ad918c993dc77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/199244
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/private/GrRecordingContext.h b/include/private/GrRecordingContext.h
index 485b512..48e673f 100644
--- a/include/private/GrRecordingContext.h
+++ b/include/private/GrRecordingContext.h
@@ -32,6 +32,7 @@
GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
bool init(sk_sp<const GrCaps>, sk_sp<GrSkSLFPFactoryCache>) override;
+ void setupDrawingManager(bool explicitlyAllocate, bool sortOpLists);
void abandonContext() override;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 05b0239..9713beb 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -70,7 +70,6 @@
return false;
}
- SkASSERT(this->drawingManager());
SkASSERT(this->caps());
SkASSERT(this->getGrStrikeCache());
SkASSERT(this->getTextBlobCache());
diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp
index 1373e43..cfe81a1 100644
--- a/src/gpu/GrDDLContext.cpp
+++ b/src/gpu/GrDDLContext.cpp
@@ -52,6 +52,11 @@
return false;
}
+ // DDL contexts/drawing managers always sort the oplists. This, in turn, implies that
+ // explicit resource allocation is always on (regardless of whatever the client specified
+ // in their context options).
+ this->setupDrawingManager(true, true);
+
SkASSERT(this->caps());
return true;
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index ae49d0a..b6d45ff 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -34,16 +34,9 @@
#include "ccpr/GrCoverageCountingPathRenderer.h"
#include "text/GrTextContext.h"
-GrDrawingManager::OpListDAG::OpListDAG(bool explicitlyAllocating,
- GrContextOptions::Enable sortOpLists) {
- if (GrContextOptions::Enable::kNo == sortOpLists) {
- fSortOpLists = false;
- } else if (GrContextOptions::Enable::kYes == sortOpLists) {
- fSortOpLists = true;
- } else {
- // By default we always enable sorting when we're explicitly allocating GPU resources
- fSortOpLists = explicitlyAllocating;
- }
+GrDrawingManager::OpListDAG::OpListDAG(bool explicitlyAllocating, bool sortOpLists)
+ : fSortOpLists(sortOpLists) {
+ SkASSERT(!sortOpLists || explicitlyAllocating);
}
GrDrawingManager::OpListDAG::~OpListDAG() {}
@@ -151,7 +144,7 @@
const GrPathRendererChain::Options& optionsForPathRendererChain,
const GrTextContext::Options& optionsForTextContext,
bool explicitlyAllocating,
- GrContextOptions::Enable sortOpLists,
+ bool sortOpLists,
GrContextOptions::Enable reduceOpListSplitting)
: fContext(context)
, fOptionsForPathRendererChain(optionsForPathRendererChain)
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index dabf77a..3f2245e 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -91,7 +91,7 @@
// This class encapsulates maintenance and manipulation of the drawing manager's DAG of opLists.
class OpListDAG {
public:
- OpListDAG(bool explicitlyAllocating, GrContextOptions::Enable sortOpLists);
+ OpListDAG(bool explicitlyAllocating, bool sortOpLists);
~OpListDAG();
// Currently, when explicitly allocating resources, this call will topologically sort the
@@ -138,7 +138,8 @@
GrDrawingManager(GrRecordingContext*, const GrPathRendererChain::Options&,
const GrTextContext::Options&,
- bool explicitlyAllocating, GrContextOptions::Enable sortRenderTargets,
+ bool explicitlyAllocating,
+ bool sortOpLists,
GrContextOptions::Enable reduceOpListSplitting);
bool wasAbandoned() const;
diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp
index e580ac8..75fb6e1 100644
--- a/src/gpu/GrLegacyDirectContext.cpp
+++ b/src/gpu/GrLegacyDirectContext.cpp
@@ -73,6 +73,15 @@
return false;
}
+ bool sortOpLists = this->explicitlyAllocateGPUResources();
+ if (GrContextOptions::Enable::kNo == this->options().fSortRenderTargets) {
+ sortOpLists = false;
+ } else if (GrContextOptions::Enable::kYes == this->options().fSortRenderTargets) {
+ sortOpLists = true;
+ }
+
+ this->setupDrawingManager(this->explicitlyAllocateGPUResources(), sortOpLists);
+
SkASSERT(this->caps());
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index 23f25cd..9c25f33 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -61,6 +61,10 @@
fTextBlobCache.reset(new GrTextBlobCache(textblobcache_overbudget_CB, this,
this->contextID()));
+ return true;
+}
+
+void GrRecordingContext::setupDrawingManager(bool explicitlyAllocate, bool sortOpLists) {
GrPathRendererChain::Options prcOptions;
prcOptions.fAllowPathMaskCaching = this->options().fAllowPathMaskCaching;
#if GR_TEST_UTILS
@@ -90,13 +94,16 @@
}
#endif
+ // SHORT TERM TODO: until intermediate flushes at allocation time are added we need to obey the
+ // reduceOpListSplitting flag. Once that lands we should always reduce opList splitting in
+ // DDL contexts/drawing managers. We should still obey the options for non-DDL drawing managers
+ // until predictive intermediate flushes are added (i.e., we can't reorder forever).
fDrawingManager.reset(new GrDrawingManager(this,
- prcOptions,
- textContextOptions,
- this->explicitlyAllocateGPUResources(),
- this->options().fSortRenderTargets,
- this->options().fReduceOpListSplitting));
- return true;
+ prcOptions,
+ textContextOptions,
+ explicitlyAllocate,
+ sortOpLists,
+ this->options().fReduceOpListSplitting));
}
void GrRecordingContext::abandonContext() {