Redesign program key construction
This does two things:
1) Moves responsibility for bit-packing portions of the key into the key
itself. A new GrKeyBuilder type manages adding bits, with asserts to
ensure a value always fits in the requested number. In theory this
will let us generate smaller keys overall, at the expense of slightly
more complex code during construction.
2) Adds a string label parameter for key methods that fold in data. For
new methods, the label is required. To ease migration, the old add32
does not require a label (yet). This will let us generate detailed,
human readable keys, either based on SK_DEBUG, or a runtime option
(if we're comfortable paying the cost).
Bug: skia:11372
Change-Id: Ib0f941551e0dbadabbd2a7de912b00e9e766b166
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377876
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index cb14885..63d4c35 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -166,6 +166,7 @@
return;
}
sk_sp<SkData> key = SkData::MakeWithoutCopy(this->desc().asKey(), this->desc().keyLength());
+ const SkString& description = this->desc().description();
if (fGpu->glCaps().programBinarySupport()) {
// binary cache
GrGLsizei length = 0;
@@ -186,7 +187,7 @@
writer.writePad32(binary.get(), length);
auto data = writer.snapshotAsData();
- this->gpu()->getContext()->priv().getPersistentCache()->store(*key, *data);
+ this->gpu()->getContext()->priv().getPersistentCache()->store(*key, *data, description);
}
} else {
// source cache, plus metadata to allow for a complete precompile
@@ -203,7 +204,7 @@
auto data = GrPersistentCacheUtils::PackCachedShaders(isSkSL ? kSKSL_Tag : kGLSL_Tag,
shaders, &inputs, 1, &meta);
- this->gpu()->getContext()->priv().getPersistentCache()->store(*key, *data);
+ this->gpu()->getContext()->priv().getPersistentCache()->store(*key, *data, description);
}
}