• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2021 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 // glslang_wrapper:
7 //   A wrapper to compile GLSL strings to SPIR-V blobs.  glslang here refers to the Khronos
8 //   compiler.
9 //
10 
11 #ifndef COMPILER_TRANSLATOR_GLSLANG_WRAPPER_H_
12 #define COMPILER_TRANSLATOR_GLSLANG_WRAPPER_H_
13 
14 #include "GLSLANG/ShaderLang.h"
15 #include "common/PackedEnums.h"
16 #include "common/spirv/spirv_types.h"
17 
18 #include <string>
19 #include <vector>
20 
21 namespace sh
22 {
23 #if defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)
24 void GlslangInitialize();
25 void GlslangFinalize();
26 
27 // Generate SPIR-V out of intermediate GLSL through glslang.
28 ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources,
29                                             sh::GLenum shaderType,
30                                             const std::string &shaderSource,
31                                             angle::spirv::Blob *spirvBlobOut);
32 #else
33 ANGLE_INLINE void GlslangInitialize()
34 {
35     UNREACHABLE();
36 }
37 ANGLE_INLINE void GlslangFinalize()
38 {
39     UNREACHABLE();
40 }
41 #endif  // defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)
42 }  // namespace sh
43 
44 #endif  // COMPILER_TRANSLATOR_GLSLANG_WRAPPER_H_
45