1//
2// Copyright 2022 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// CompiledShaderState.h:
7// Defines a struct containing any data that is needed to build
8// a ShaderState from a TCompiler.
9//
10
11#ifndef COMMON_COMPILEDSHADERSTATE_H_
12#define COMMON_COMPILEDSHADERSTATE_H_
13
14#include "common/BinaryStream.h"
15#include "common/Optional.h"
16#include "common/PackedEnums.h"
17
18#include <GLSLANG/ShaderLang.h>
19#include <GLSLANG/ShaderVars.h>
20
21#include <string>
22
23namespace sh
24{
25struct BlockMemberInfo;
26}
27
28namespace gl
29{
30
31// @todo this type is also defined in compiler/Compiler.h and libANGLE/renderer_utils.h. Move this
32// to a single common definition?
33using SpecConstUsageBits = angle::PackedEnumBitSet<sh::vk::SpecConstUsage, uint32_t>;
34
35// Helper functions for serializing shader variables
36void WriteShaderVar(gl::BinaryOutputStream *stream, const sh::ShaderVariable &var);
37void LoadShaderVar(gl::BinaryInputStream *stream, sh::ShaderVariable *var);
38
39void WriteShInterfaceBlock(gl::BinaryOutputStream *stream, const sh::InterfaceBlock &block);
40void LoadShInterfaceBlock(gl::BinaryInputStream *stream, sh::InterfaceBlock *block);
41
42bool CompareShaderVar(const sh::ShaderVariable &x, const sh::ShaderVariable &y);
43
44struct CompiledShaderState
45{
46 CompiledShaderState(gl::ShaderType shaderType);
47 ~CompiledShaderState();
48
49 void buildCompiledShaderState(const ShHandle compilerHandle, const bool isBinaryOutput);
50
51 void serialize(gl::BinaryOutputStream &stream) const;
52 void deserialize(gl::BinaryInputStream &stream);
53
54 const gl::ShaderType shaderType;
55
56 int shaderVersion;
57 std::string translatedSource;
58 sh::BinaryBlob compiledBinary;
59 sh::WorkGroupSize localSize;
60
61 std::vector<sh::ShaderVariable> inputVaryings;
62 std::vector<sh::ShaderVariable> outputVaryings;
63 std::vector<sh::ShaderVariable> uniforms;
64 std::vector<sh::InterfaceBlock> uniformBlocks;
65 std::vector<sh::InterfaceBlock> shaderStorageBlocks;
66 std::vector<sh::ShaderVariable> allAttributes;
67 std::vector<sh::ShaderVariable> activeAttributes;
68 std::vector<sh::ShaderVariable> activeOutputVariables;
69
70 bool hasClipDistance;
71 bool hasDiscard;
72 bool enablesPerSampleShading;
73 gl::BlendEquationBitSet advancedBlendEquations;
74 SpecConstUsageBits specConstUsageBits;
75
76 // GL_OVR_multiview / GL_OVR_multiview2
77 int numViews;
78
79 // Geometry Shader
80 Optional<gl::PrimitiveMode> geometryShaderInputPrimitiveType;
81 Optional<gl::PrimitiveMode> geometryShaderOutputPrimitiveType;
82 Optional<GLint> geometryShaderMaxVertices;
83 int geometryShaderInvocations;
84
85 // Tessellation Shader
86 int tessControlShaderVertices;
87 GLenum tessGenMode;
88 GLenum tessGenSpacing;
89 GLenum tessGenVertexOrder;
90 GLenum tessGenPointMode;
91};
92} // namespace gl
93
94#endif // COMMON_COMPILEDSHADERSTATE_H_
95

source code of flutter_engine/third_party/angle/src/common/CompiledShaderState.h