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_SPIRV_GENERATION_THROUGH_GLSLANG) 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 ANGLE_INLINE void GlslangFinalize() {} 35 ANGLE_INLINE bool GlslangCompileToSpirv(const ShBuiltInResources &resources, 36 sh::GLenum shaderType, 37 const std::string &shaderSource, 38 angle::spirv::Blob *spirvBlobOut) 39 { 40 UNREACHABLE(); 41 return false; 42 } 43 #endif // defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL) 44 } // namespace sh 45 46 #endif // COMPILER_TRANSLATOR_GLSLANG_WRAPPER_H_ 47