Use MemoryProgramCache.
Add the member functions for saving and loading from the binary cache,
and hook them into the Program class. Requires that the Renderer
supports the program binary extension.
BUG=angleproject:1897
Change-Id: I2dc8d21b02da705ded58c5cd1943562c9c97c49b
Reviewed-on: https://chromium-review.googlesource.com/522874
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index af64838..52b8720 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -616,6 +616,20 @@
unlink();
+ ProgramHash programHash;
+ auto *cache = context->getMemoryProgramCache();
+ if (cache)
+ {
+ ANGLE_TRY_RESULT(cache->getProgram(context, this, &mState, &programHash), mLinked);
+ }
+
+ if (mLinked)
+ {
+ return NoError();
+ }
+
+ // Cache load failed, fall through to normal linking.
+ unlink();
mInfoLog.reset();
const Caps &caps = data.getCaps();
@@ -747,6 +761,13 @@
gatherInterfaceBlockInfo(context);
+ // Save to the program cache.
+ if (cache && (mState.mLinkedTransformFeedbackVaryings.empty() ||
+ !context->getWorkarounds().disableProgramCachingForTransformFeedback))
+ {
+ cache->putProgram(programHash, context, this);
+ }
+
return NoError();
}
@@ -797,6 +818,10 @@
const uint8_t *bytes = reinterpret_cast<const uint8_t *>(binary);
ANGLE_TRY_RESULT(
MemoryProgramCache::Deserialize(context, this, &mState, bytes, length, mInfoLog), mLinked);
+
+ // Currently we require the full shader text to compute the program hash.
+ // TODO(jmadill): Store the binary in the internal program cache.
+
return NoError();
#endif // #if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_ENABLED
}