Debian Codegraph @

src/gpu/ganesh/GrPersistentCacheUtils.h

raw
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/core/SkFourByteTag.h"
13 #include "include/core/SkRefCnt.h"
14 #include "include/core/SkTypes.h"
15 #include "include/private/base/SkTArray.h"
16 #include "src/sksl/ir/SkSLProgram.h"
17
18 #include <string>
19
20 class SkReadBuffer;
21 namespace SkSL {
22 struct NativeShader;
23 struct ProgramSettings;
24 } // namespace SkSL
25
26 // The GrPersistentCache stores opaque blobs, as far as clients are concerned. It's helpful to
27 // inspect certain kinds of cached data within our tools, so for those cases (GLSL, SPIR-V), we
28 // put the serialization logic here, to be shared by the backend code and the tool code.
29 namespace GrPersistentCacheUtils {
30
31 struct ShaderMetadata {
32 SkSL::ProgramSettings* fSettings = nullptr;
33 skia_private::TArray<std::string> fAttributeNames;
34 bool fHasSecondaryColorOutput = false;
35 sk_sp<SkData> fPlatformData;
36 };
37
38 int GetCurrentVersion();
39
40 sk_sp<SkData> PackCachedShaders(SkFourByteTag shaderType,
41 const SkSL::NativeShader shaders[],
42 const SkSL::Program::Interface[],
43 int numInterfaces,
44 const ShaderMetadata* meta = nullptr);
45
46 SkFourByteTag GetType(SkReadBuffer* reader);
47
48 bool UnpackCachedShaders(SkReadBuffer* reader,
49 SkSL::NativeShader shaders[],
50 bool areShadersBinary,
51 SkSL::Program::Interface[],
52 int numInterfaces,
53 ShaderMetadata* meta = nullptr);
54
55 } // namespace GrPersistentCacheUtils
56
57 #endif