blob: 4f4ccd3ec8c47e229584fac8e906373ecb6c42ee [file] [log] [blame]
Brian Osman6b797fe2019-04-08 13:56:36 -04001/*
John Stilesf2c2d302021-04-09 17:56:58 -04002 * Copyright 2019 Google LLC
Brian Osman6b797fe2019-04-08 13:56:36 -04003 *
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkData.h"
12#include "include/private/GrTypesPriv.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/sksl/ir/SkSLProgram.h"
Brian Osman6b797fe2019-04-08 13:56:36 -040014
John Stilesf2c2d302021-04-09 17:56:58 -040015class SkReadBuffer;
16
Brian Osmana5a010b2019-04-08 15:01:32 -040017// The GrPersistentCache stores opaque blobs, as far as clients are concerned. It's helpful to
18// inspect certain kinds of cached data within our tools, so for those cases (GLSL, SPIR-V), we
19// put the serialization logic here, to be shared by the backend code and the tool code.
Brian Osman6b797fe2019-04-08 13:56:36 -040020namespace GrPersistentCacheUtils {
21
Brian Osman4524e842019-09-24 16:03:41 -040022struct ShaderMetadata {
23 SkSL::Program::Settings* fSettings = nullptr;
24 SkTArray<SkSL::String> fAttributeNames;
25 bool fHasCustomColorOutput = false;
26 bool fHasSecondaryColorOutput = false;
Jim Van Verth36a814b2021-03-12 16:02:29 -050027 sk_sp<SkData> fPlatformData;
Brian Osman4524e842019-09-24 16:03:41 -040028};
29
John Stilesf2c2d302021-04-09 17:56:58 -040030int GetCurrentVersion();
Brian Osman1facd5e2020-03-16 16:21:24 -040031
John Stilesf2c2d302021-04-09 17:56:58 -040032sk_sp<SkData> PackCachedShaders(SkFourByteTag shaderType,
33 const SkSL::String shaders[],
34 const SkSL::Program::Inputs inputs[],
35 int numInputs,
36 const ShaderMetadata* meta = nullptr);
Brian Osman6b797fe2019-04-08 13:56:36 -040037
John Stilesf2c2d302021-04-09 17:56:58 -040038SkFourByteTag GetType(SkReadBuffer* reader);
Brian Osman4524e842019-09-24 16:03:41 -040039
John Stilesf2c2d302021-04-09 17:56:58 -040040bool UnpackCachedShaders(SkReadBuffer* reader,
41 SkSL::String shaders[],
42 SkSL::Program::Inputs inputs[],
43 int numInputs,
44 ShaderMetadata* meta = nullptr);
Brian Osmana5a010b2019-04-08 15:01:32 -040045
John Stilesa6841be2020-08-06 14:11:56 -040046} // namespace GrPersistentCacheUtils
Brian Osman6b797fe2019-04-08 13:56:36 -040047
48#endif