Introduce MemoryProgramCache.
This class will manage GPU binary programs in memory. It will be
owned by the Display, and shared between Contexts. Currently this
CL just refactors the Program binary saving and loading into static
members of this new class.
BUG=angleproject:1897
Change-Id: I34f5afb2c02416f6fd80dd65ba3827a8637ce190
Reviewed-on: https://chromium-review.googlesource.com/522873
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/MemoryProgramCache.h b/src/libANGLE/MemoryProgramCache.h
new file mode 100644
index 0000000..66b8e2a
--- /dev/null
+++ b/src/libANGLE/MemoryProgramCache.h
@@ -0,0 +1,42 @@
+//
+// Copyright 2017 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// MemoryProgramCache: Stores compiled and linked programs in memory so they don't
+// always have to be re-compiled. Can be used in conjunction with the platform
+// layer to warm up the cache from disk.
+
+#ifndef LIBANGLE_MEMORY_PROGRAM_CACHE_H_
+#define LIBANGLE_MEMORY_PROGRAM_CACHE_H_
+
+#include "common/MemoryBuffer.h"
+#include "libANGLE/Error.h"
+
+namespace gl
+{
+class Context;
+class InfoLog;
+class Program;
+class ProgramState;
+
+class MemoryProgramCache final : angle::NonCopyable
+{
+ public:
+ // Writes a program's binary to the output memory buffer.
+ static void Serialize(const Context *context,
+ const Program *program,
+ angle::MemoryBuffer *binaryOut);
+
+ // Loads program state according to the specified binary blob.
+ static LinkResult Deserialize(const Context *context,
+ const Program *program,
+ ProgramState *state,
+ const uint8_t *binary,
+ size_t length,
+ InfoLog &infoLog);
+};
+
+} // namespace gl
+
+#endif // LIBANGLE_MEMORY_PROGRAM_CACHE_H_