Reland "Redesign program key construction"
This is a reland of bbbf1a7f50a303bd76163793bd5968c72f5f4432
Original change's description:
> 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>
Bug: skia:11372
Cq-Include-Trybots: luci.skia.skia.primary:Test-Win10-MSVC-Golo-GPU-QuadroP400-x86_64-Debug-All-Vulkan
Change-Id: I179ed581bc9ba772191e727274ac0ac6979ebdf3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378778
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/gpu/MemoryCache.h b/tools/gpu/MemoryCache.h
index f70cf13..cf7d284 100644
--- a/tools/gpu/MemoryCache.h
+++ b/tools/gpu/MemoryCache.h
@@ -33,7 +33,7 @@
}
sk_sp<SkData> load(const SkData& key) override;
- void store(const SkData& key, const SkData& data) override;
+ void store(const SkData& key, const SkData& data, const SkString& description) override;
int numCacheMisses() const { return fCacheMissCnt; }
int numCacheStores() const { return fCacheStoreCnt; }
void resetCacheStats() {
@@ -46,7 +46,7 @@
template <typename Fn>
void foreach(Fn&& fn) {
for (auto it = fMap.begin(); it != fMap.end(); ++it) {
- fn(it->first.fKey, it->second.fData, it->second.fHitCount);
+ fn(it->first.fKey, it->second.fData, it->second.fDescription, it->second.fHitCount);
}
}
@@ -65,14 +65,16 @@
struct Value {
Value() = default;
- Value(const SkData& data)
+ Value(const SkData& data, const SkString& description)
: fData(SkData::MakeWithCopy(data.data(), data.size()))
+ , fDescription(description)
, fHitCount(1) {}
Value(const Value& that) = default;
Value& operator=(const Value&) = default;
sk_sp<SkData> fData;
- int fHitCount;
+ SkString fDescription;
+ int fHitCount;
};
struct Hash {