Hide binaryArchive use in Viewer behind a flag.

Still needs more testing before we can enable this all the time.

Bug: skia:10804
Change-Id: I6d8416fa072054d2f44e337641ed5d8379e81559
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337216
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2020-11-20 15:30:25 -05:00 committed by Skia Commit-Bot
parent aa4e59eba8
commit ecc9108d87
3 changed files with 25 additions and 15 deletions

View File

@ -21,6 +21,7 @@ struct DisplayParams {
, fSurfaceProps(0, kRGB_H_SkPixelGeometry)
, fDisableVsync(false)
, fDelayDrawableAcquisition(false)
, fEnableBinaryArchive(false)
{}
SkColorType fColorType;
@ -30,6 +31,7 @@ struct DisplayParams {
SkSurfaceProps fSurfaceProps;
bool fDisableVsync;
bool fDelayDrawableAcquisition;
bool fEnableBinaryArchive;
};
} // namespace sk_app

View File

@ -57,21 +57,25 @@ void MetalWindowContext::initializeContext() {
fValid = this->onInitializeContext();
#if GR_METAL_SDK_VERSION >= 230
if (@available(macOS 11.0, iOS 14.0, *)) {
MTLBinaryArchiveDescriptor* desc = [MTLBinaryArchiveDescriptor new];
desc.url = CacheURL(); // try to load
NSError* error;
fPipelineArchive = [fDevice newBinaryArchiveWithDescriptor:desc error:&error];
if (!fPipelineArchive) {
desc.url = nil; // create new
if (fDisplayParams.fEnableBinaryArchive) {
if (@available(macOS 11.0, iOS 14.0, *)) {
MTLBinaryArchiveDescriptor* desc = [MTLBinaryArchiveDescriptor new];
desc.url = CacheURL(); // try to load
NSError* error;
fPipelineArchive = [fDevice newBinaryArchiveWithDescriptor:desc error:&error];
if (!fPipelineArchive) {
SkDebugf("Error creating MTLBinaryArchive:\n%s\n",
error.debugDescription.UTF8String);
desc.url = nil; // create new
NSError* error;
fPipelineArchive = [fDevice newBinaryArchiveWithDescriptor:desc error:&error];
if (!fPipelineArchive) {
SkDebugf("Error creating MTLBinaryArchive:\n%s\n",
error.debugDescription.UTF8String);
}
}
[desc release];
}
[desc release];
} else {
fPipelineArchive = nil;
}
#endif
@ -171,11 +175,13 @@ void MetalWindowContext::activate(bool isActive) {
if (!isActive) {
#if GR_METAL_SDK_VERSION >= 230
if (@available(macOS 11.0, iOS 14.0, *)) {
NSError* error;
[fPipelineArchive serializeToURL:CacheURL() error:&error];
if (error) {
SkDebugf("Error storing MTLBinaryArchive:\n%s\n",
error.debugDescription.UTF8String);
if (fPipelineArchive) {
NSError* error;
[fPipelineArchive serializeToURL:CacheURL() error:&error];
if (error) {
SkDebugf("Error storing MTLBinaryArchive:\n%s\n",
error.debugDescription.UTF8String);
}
}
}
#endif

View File

@ -169,6 +169,7 @@ static DEFINE_bool(skvm, false, "Force skvm blitters for raster.");
static DEFINE_bool(jit, true, "JIT SkVM?");
static DEFINE_bool(dylib, false, "JIT via dylib (much slower compile but easier to debug/profile)");
static DEFINE_bool(stats, false, "Display stats overlay on startup.");
static DEFINE_bool(binaryarchive, false, "Enable MTLBinaryArchive use (if available).");
#ifndef SK_GL
static_assert(false, "viewer requires GL backend for raster.")
@ -363,6 +364,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
DisplayParams displayParams;
displayParams.fMSAASampleCount = FLAGS_msaa;
displayParams.fEnableBinaryArchive = FLAGS_binaryarchive;
SetCtxOptionsFromCommonFlags(&displayParams.fGrContextOptions);
displayParams.fGrContextOptions.fPersistentCache = &fPersistentCache;
displayParams.fGrContextOptions.fShaderCacheStrategy =