Brian Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 1 | /* |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 2 | * Copyright 2019 Google LLC |
Brian Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkData.h" |
| 12 | #include "include/private/GrTypesPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/sksl/ir/SkSLProgram.h" |
Brian Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 14 | |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 15 | class SkReadBuffer; |
| 16 | |
Brian Osman | a5a010b | 2019-04-08 15:01:32 -0400 | [diff] [blame] | 17 | // 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 Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 20 | namespace GrPersistentCacheUtils { |
| 21 | |
Brian Osman | 4524e84 | 2019-09-24 16:03:41 -0400 | [diff] [blame] | 22 | struct ShaderMetadata { |
| 23 | SkSL::Program::Settings* fSettings = nullptr; |
| 24 | SkTArray<SkSL::String> fAttributeNames; |
| 25 | bool fHasCustomColorOutput = false; |
| 26 | bool fHasSecondaryColorOutput = false; |
Jim Van Verth | 36a814b | 2021-03-12 16:02:29 -0500 | [diff] [blame] | 27 | sk_sp<SkData> fPlatformData; |
Brian Osman | 4524e84 | 2019-09-24 16:03:41 -0400 | [diff] [blame] | 28 | }; |
| 29 | |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 30 | int GetCurrentVersion(); |
Brian Osman | 1facd5e | 2020-03-16 16:21:24 -0400 | [diff] [blame] | 31 | |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 32 | sk_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 Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 37 | |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 38 | SkFourByteTag GetType(SkReadBuffer* reader); |
Brian Osman | 4524e84 | 2019-09-24 16:03:41 -0400 | [diff] [blame] | 39 | |
John Stiles | f2c2d30 | 2021-04-09 17:56:58 -0400 | [diff] [blame] | 40 | bool UnpackCachedShaders(SkReadBuffer* reader, |
| 41 | SkSL::String shaders[], |
| 42 | SkSL::Program::Inputs inputs[], |
| 43 | int numInputs, |
| 44 | ShaderMetadata* meta = nullptr); |
Brian Osman | a5a010b | 2019-04-08 15:01:32 -0400 | [diff] [blame] | 45 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 46 | } // namespace GrPersistentCacheUtils |
Brian Osman | 6b797fe | 2019-04-08 13:56:36 -0400 | [diff] [blame] | 47 | |
| 48 | #endif |