aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-11-01 15:45:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-02 13:07:41 +0000
commitd1b2eec0d0f95977b52669025cb25038618c0335 (patch)
tree6e3bae30a741d09fd1cddb6448276f98b5adadf1 /include
parentb693fbf0fac5978650b2677cae7647128ddb52ab (diff)
API to cache shader binaries between runs of Skia.
This CL does not include an actual implementation of said cache. Stan is working on the cache implementation on the Android side of things. Bug: skia: Change-Id: Iabe4f19b2dbacaaa1ead8bb3fa68d88c687b9a84 Reviewed-on: https://skia-review.googlesource.com/54780 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrContext.h6
-rw-r--r--include/gpu/GrContextOptions.h25
-rw-r--r--include/gpu/gl/GrGLFunctions.h3
-rw-r--r--include/gpu/gl/GrGLInterface.h7
4 files changed, 38 insertions, 3 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index e5f568c9e9..41d00a6802 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -15,10 +15,10 @@
#include "SkTypes.h"
#include "../private/GrAuditTrail.h"
#include "../private/GrSingleOwner.h"
+#include "GrContextOptions.h"
class GrAtlasGlyphCache;
class GrBackendSemaphore;
-struct GrContextOptions;
class GrContextPriv;
class GrContextThreadSafeProxy;
class GrDrawingManager;
@@ -334,6 +334,8 @@ public:
GrAuditTrail* getAuditTrail() { return &fAuditTrail; }
+ GrContextOptions::PersistentCache* getPersistentCache() { return fPersistentCache; }
+
/** This is only useful for debug purposes */
SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } )
@@ -379,6 +381,8 @@ private:
GrBackend fBackend;
+ GrContextOptions::PersistentCache* fPersistentCache;
+
// TODO: have the GrClipStackClip use renderTargetContexts and rm this friending
friend class GrContextPriv;
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 894813b5cc..7aa85e0ed3 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -8,10 +8,13 @@
#ifndef GrContextOptions_DEFINED
#define GrContextOptions_DEFINED
+#include "SkData.h"
#include "SkTypes.h"
#include "GrTypes.h"
#include "../private/GrTypesPriv.h"
+#include <vector>
+
class SkExecutor;
struct GrContextOptions {
@@ -26,6 +29,23 @@ struct GrContextOptions {
kDefault
};
+ /**
+ * Abstract class which stores Skia data in a cache that persists between sessions. Currently,
+ * Skia stores compiled shader binaries (only when glProgramBinary / glGetProgramBinary are
+ * supported) when provided a persistent cache, but this may extend to other data in the future.
+ */
+ class PersistentCache {
+ public:
+ virtual ~PersistentCache() {}
+
+ /**
+ * Returns the data for the key if it exists in the cache, otherwise returns null.
+ */
+ virtual sk_sp<SkData> load(const SkData& key) = 0;
+
+ virtual void store(const SkData& key, const SkData& data) = 0;
+ };
+
GrContextOptions() {}
// Suppress prints for the GrContext.
@@ -105,6 +125,11 @@ struct GrContextOptions {
*/
Enable fUseDrawInsteadOfGLClear = Enable::kDefault;
+ /**
+ * Cache in which to store compiled shader binaries between runs.
+ */
+ PersistentCache* fPersistentCache = nullptr;
+
#if GR_TEST_UTILS
/**
* Private options that are only meant for testing within Skia's tools.
diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h
index 90c3de1caa..3ccfb62a4d 100644
--- a/include/gpu/gl/GrGLFunctions.h
+++ b/include/gpu/gl/GrGLFunctions.h
@@ -91,6 +91,7 @@ typedef GrGLenum (* GrGLGetErrorProc)();
typedef GrGLvoid (* GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
typedef GrGLvoid (* GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
typedef GrGLvoid (* GrGLGetMultisamplefvProc)(GrGLenum pname, GrGLuint index, GrGLfloat* val);
+typedef GrGLvoid (* GrGLGetProgramBinaryProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, GrGLenum *binaryFormat, void *binary);
typedef GrGLvoid (* GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
typedef GrGLvoid (* GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
typedef GrGLvoid (* GrGLGetQueryivProc)(GrGLenum GLtarget, GrGLenum pname, GrGLint *params);
@@ -125,6 +126,8 @@ typedef GrGLvoid* (* GrGLMemoryBarrierByRegionProc)(GrGLbitfield barriers);
typedef GrGLvoid (* GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
typedef GrGLvoid (* GrGLPolygonModeProc)(GrGLenum face, GrGLenum mode);
typedef GrGLvoid (* GrGLPopGroupMarkerProc)();
+typedef GrGLvoid (* GrGLProgramBinaryProc)(GrGLuint program, GrGLenum binaryFormat, void *binary, GrGLsizei length);
+typedef GrGLvoid (* GrGLProgramParameteriProc)(GrGLuint program, GrGLenum pname, GrGLint value);
typedef GrGLvoid (* GrGLPushGroupMarkerProc)(GrGLsizei length, const char* marker);
typedef GrGLvoid (* GrGLQueryCounterProc)(GrGLuint id, GrGLenum target);
typedef GrGLvoid (* GrGLRasterSamplesProc)(GrGLuint samples, GrGLboolean fixedsamplelocations);
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index f1785326fb..e752c2d6e8 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -177,13 +177,14 @@ public:
GrGLFunction<GrGLGetFramebufferAttachmentParameterivProc> fGetFramebufferAttachmentParameteriv;
GrGLFunction<GrGLGetIntegervProc> fGetIntegerv;
GrGLFunction<GrGLGetMultisamplefvProc> fGetMultisamplefv;
+ GrGLFunction<GrGLGetProgramBinaryProc> fGetProgramBinary;
+ GrGLFunction<GrGLGetProgramInfoLogProc> fGetProgramInfoLog;
+ GrGLFunction<GrGLGetProgramivProc> fGetProgramiv;
GrGLFunction<GrGLGetQueryObjecti64vProc> fGetQueryObjecti64v;
GrGLFunction<GrGLGetQueryObjectivProc> fGetQueryObjectiv;
GrGLFunction<GrGLGetQueryObjectui64vProc> fGetQueryObjectui64v;
GrGLFunction<GrGLGetQueryObjectuivProc> fGetQueryObjectuiv;
GrGLFunction<GrGLGetQueryivProc> fGetQueryiv;
- GrGLFunction<GrGLGetProgramInfoLogProc> fGetProgramInfoLog;
- GrGLFunction<GrGLGetProgramivProc> fGetProgramiv;
GrGLFunction<GrGLGetRenderbufferParameterivProc> fGetRenderbufferParameteriv;
GrGLFunction<GrGLGetShaderInfoLogProc> fGetShaderInfoLog;
GrGLFunction<GrGLGetShaderivProc> fGetShaderiv;
@@ -202,6 +203,8 @@ public:
GrGLFunction<GrGLIsTextureProc> fIsTexture;
GrGLFunction<GrGLLineWidthProc> fLineWidth;
GrGLFunction<GrGLLinkProgramProc> fLinkProgram;
+ GrGLFunction<GrGLProgramBinaryProc> fProgramBinary;
+ GrGLFunction<GrGLProgramParameteriProc> fProgramParameteri;
GrGLFunction<GrGLMapBufferProc> fMapBuffer;
GrGLFunction<GrGLMapBufferRangeProc> fMapBufferRange;
GrGLFunction<GrGLMapBufferSubDataProc> fMapBufferSubData;