Shader serialization experiment (with Mali Offline Compiler analysis)
1) Adds a --writeShaders option to fm. When that's included, the GPU
backend is run with a persistent cache (and no binary caching).
Then we dump all of the fragment shaders (GLSL for now) that were
created to the passed-in directory, along with a JSON digest listing
the number of times each one was referenced in the cache.
2) Adds a python script that invokes the Mali Offline Compiler on a
directory generated from #1, scraping the output of each compile for
cycle counts and writing the collated information to stdout.
Change-Id: Ie4b58ddac4f62e936707c6fec44f4fe605c213fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206162
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/tools/gpu/MemoryCache.h b/tools/gpu/MemoryCache.h
index dea1ccd..119ea8d 100644
--- a/tools/gpu/MemoryCache.h
+++ b/tools/gpu/MemoryCache.h
@@ -33,6 +33,8 @@
int numCacheMisses() const { return fCacheMissCnt; }
void resetNumCacheMisses() { fCacheMissCnt = 0; }
+ void writeShadersToDisk(const char* path, GrBackendApi backend);
+
private:
struct Key {
Key() = default;
@@ -46,6 +48,18 @@
sk_sp<const SkData> fKey;
};
+ struct Value {
+ Value() = default;
+ Value(const SkData& data)
+ : fData(SkData::MakeWithCopy(data.data(), data.size()))
+ , fHitCount(1) {}
+ Value(const Value& that) = default;
+ Value& operator=(const Value&) = default;
+
+ sk_sp<SkData> fData;
+ int fHitCount;
+ };
+
struct Hash {
using argument_type = Key;
using result_type = uint32_t;
@@ -55,7 +69,7 @@
};
int fCacheMissCnt = 0;
- std::unordered_map<Key, sk_sp<SkData>, Hash> fMap;
+ std::unordered_map<Key, Value, Hash> fMap;
};
} // namespace sk_gpu_test