Always explicitly allocate except in Android Framework (take 2)
This will turn on explicit allocation (w/o opList sorting) in Chrome. It leaves the old allocation system in place in Android Framework and some of Skia's older bots.
We want:
Flutter and Chrome to always explicitly allocate but not sort opLists outside of DDLs
Android to never explicitly allocate and, thus, automatically never sort opLists
This cannot land until after the following Chrome CL lands:
https://chromium-review.googlesource.com/c/chromium/src/+/1516096 (Disable opList sorting within Skia)
Change-Id: Ic7d6a1a77a08f2fe42324773f62cccf8175ab3d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/199931
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gn/flutter_defines.gni b/gn/flutter_defines.gni
index bd0b95d..dd19743 100644
--- a/gn/flutter_defines.gni
+++ b/gn/flutter_defines.gni
@@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
flutter_defines = [
- "SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION",
+ "SK_DISABLE_OPLIST_SORTING",
"SK_LEGACY_SKCODEC_NONE_ENUM",
# Flutter always wants this https://github.com/flutter/flutter/issues/11402
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index e12fd13..a73be43 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -145,15 +145,8 @@
Enable fUseDrawInsteadOfClear = Enable::kDefault;
/**
- * Allow Ganesh to explicitly allocate resources at flush time rather than incrementally while
- * drawing. This will eventually just be the way it is but, for now, it is optional.
- */
- Enable fExplicitlyAllocateGPUResources = Enable::kDefault;
-
- /**
* Allow Ganesh to sort the opLists prior to allocating resources. This is an optional
- * behavior that is only relevant when 'fExplicitlyAllocateGPUResources' is enabled.
- * Eventually this will just be what is done and will not be optional.
+ * behavior but, eventually, this will just be what is done and will not be optional.
*/
Enable fSortRenderTargets = Enable::kDefault;
diff --git a/include/private/GrContext_Base.h b/include/private/GrContext_Base.h
index 141a6d5..c51bd8d 100644
--- a/include/private/GrContext_Base.h
+++ b/include/private/GrContext_Base.h
@@ -8,6 +8,16 @@
#ifndef GrContext_Base_DEFINED
#define GrContext_Base_DEFINED
+// Perform old-style (non-explicit) allocation in the Android Framework and on older
+// (non-Vulkan supporting) Android devices. The latter is to, at least, have some of
+// Skia's bots exercise the old allocation scheme.
+#if !defined(SK_OLD_STYLE_RESOURCE_ALLOCATION)
+ #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) || \
+ (defined(SK_BUILD_FOR_ANDROID) && !defined(SK_VULKAN))
+ #define SK_OLD_STYLE_RESOURCE_ALLOCATION
+ #endif
+#endif
+
#include "SkRefCnt.h"
#include "GrContextOptions.h"
#include "GrTypes.h"
diff --git a/src/gpu/GrContext_Base.cpp b/src/gpu/GrContext_Base.cpp
index 7c45267..3d194a0 100644
--- a/src/gpu/GrContext_Base.cpp
+++ b/src/gpu/GrContext_Base.cpp
@@ -11,12 +11,6 @@
#include "GrCaps.h"
#include "GrSkSLFPFactoryCache.h"
-#ifdef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
-static const bool kDefaultExplicitlyAllocateGPUResources = false;
-#else
-static const bool kDefaultExplicitlyAllocateGPUResources = true;
-#endif
-
static int32_t next_id() {
static std::atomic<int32_t> nextID{1};
int32_t id;
@@ -45,15 +39,11 @@
}
bool GrContext_Base::explicitlyAllocateGPUResources() const {
- if (GrContextOptions::Enable::kNo == fOptions.fExplicitlyAllocateGPUResources) {
- return false;
- }
-
- if (GrContextOptions::Enable::kYes == fOptions.fExplicitlyAllocateGPUResources) {
- return true;
- }
-
- return kDefaultExplicitlyAllocateGPUResources;
+#ifdef SK_OLD_STYLE_RESOURCE_ALLOCATION
+ return false;
+#else
+ return true;
+#endif
}
const GrCaps* GrContext_Base::caps() const { return fCaps.get(); }
diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp
index cfe81a1..6836e46 100644
--- a/src/gpu/GrDDLContext.cpp
+++ b/src/gpu/GrDDLContext.cpp
@@ -53,8 +53,7 @@
}
// 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).
+ // explicit resource allocation is always on (regardless of how Skia is compiled).
this->setupDrawingManager(true, true);
SkASSERT(this->caps());
diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp
index 75fb6e1..d5bce1b 100644
--- a/src/gpu/GrLegacyDirectContext.cpp
+++ b/src/gpu/GrLegacyDirectContext.cpp
@@ -24,6 +24,12 @@
#include "vk/GrVkGpu.h"
#endif
+#ifdef SK_DISABLE_OPLIST_SORTING
+static const bool kDefaultSortOpLists = false;
+#else
+static const bool kDefaultSortOpLists = true;
+#endif
+
class SK_API GrLegacyDirectContext : public GrContext {
public:
GrLegacyDirectContext(GrBackendApi backend, const GrContextOptions& options)
@@ -73,7 +79,7 @@
return false;
}
- bool sortOpLists = this->explicitlyAllocateGPUResources();
+ bool sortOpLists = kDefaultSortOpLists;
if (GrContextOptions::Enable::kNo == this->options().fSortRenderTargets) {
sortOpLists = false;
} else if (GrContextOptions::Enable::kYes == this->options().fSortRenderTargets) {
diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp
index 1e7b962..be569f8 100644
--- a/tools/flags/SkCommonFlags.cpp
+++ b/tools/flags/SkCommonFlags.cpp
@@ -166,7 +166,6 @@
"[~]none [~]dashline [~]nvpr [~]ccpr [~]aahairline [~]aaconvex [~]aalinearizing "
"[~]small [~]tess] [~]all");
-DEFINE_bool(disableExplicitAlloc, false, "Disable explicit allocation of GPU resources");
DEFINE_bool(reduceOpListSplitting, false, "Improve opList sorting");
void SetCtxOptionsFromCommonFlags(GrContextOptions* ctxOptions) {
@@ -178,12 +177,6 @@
ctxOptions->fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
ctxOptions->fDisableDriverCorrectnessWorkarounds = FLAGS_disableDriverCorrectnessWorkarounds;
- if (FLAGS_disableExplicitAlloc) {
- ctxOptions->fExplicitlyAllocateGPUResources = GrContextOptions::Enable::kNo;
- // Can't have sorting enabled when explicit allocation is disabled.
- ctxOptions->fSortRenderTargets = GrContextOptions::Enable::kNo;
- }
-
if (FLAGS_reduceOpListSplitting) {
ctxOptions->fReduceOpListSplitting = GrContextOptions::Enable::kYes;
}
diff --git a/tools/flags/SkCommonFlagsGpu.h b/tools/flags/SkCommonFlagsGpu.h
index 23672dd..d546078 100644
--- a/tools/flags/SkCommonFlagsGpu.h
+++ b/tools/flags/SkCommonFlagsGpu.h
@@ -16,7 +16,6 @@
DECLARE_bool(cachePathMasks);
DECLARE_bool(noGS);
DECLARE_string(pr);
-DECLARE_bool(disableExplicitAlloc);
DECLARE_bool(reduceOpListSplitting);
inline GpuPathRenderers get_named_pathrenderers_flags(const char* name) {