• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GrPersistentCacheEntry_DEFINED
9 #define GrPersistentCacheEntry_DEFINED
10 
11 #include "include/core/SkData.h"
12 #include "include/private/base/SkTArray.h"
13 #include "include/private/gpu/ganesh/GrTypesPriv.h"
14 #include "src/sksl/ir/SkSLProgram.h"
15 
16 #include <string>
17 
18 class SkReadBuffer;
19 namespace SkSL { struct ProgramSettings; }
20 
21 // The GrPersistentCache stores opaque blobs, as far as clients are concerned. It's helpful to
22 // inspect certain kinds of cached data within our tools, so for those cases (GLSL, SPIR-V), we
23 // put the serialization logic here, to be shared by the backend code and the tool code.
24 namespace GrPersistentCacheUtils {
25 
26 struct ShaderMetadata {
27     SkSL::ProgramSettings* fSettings = nullptr;
28     SkTArray<std::string> fAttributeNames;
29     bool fHasSecondaryColorOutput = false;
30     sk_sp<SkData> fPlatformData;
31 };
32 
33 int GetCurrentVersion();
34 
35 sk_sp<SkData> PackCachedShaders(SkFourByteTag shaderType,
36                                 const std::string shaders[],
37                                 const SkSL::Program::Inputs inputs[],
38                                 int numInputs,
39                                 const ShaderMetadata* meta = nullptr);
40 
41 SkFourByteTag GetType(SkReadBuffer* reader);
42 
43 bool UnpackCachedShaders(SkReadBuffer* reader,
44                          std::string shaders[],
45                          SkSL::Program::Inputs inputs[],
46                          int numInputs,
47                          ShaderMetadata* meta = nullptr);
48 
49 }  // namespace GrPersistentCacheUtils
50 
51 #endif
52