TranslatorVulkan.h (2201B)
1 // 2 // Copyright 2016 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 // TranslatorVulkan: 7 // A GLSL-based translator that outputs shaders that fit GL_KHR_vulkan_glsl and feeds them into 8 // glslang to spit out SPIR-V. 9 // See: https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt 10 // 11 12 #ifndef COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_ 13 #define COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_ 14 15 #include "compiler/translator/Compiler.h" 16 17 namespace sh 18 { 19 20 class TOutputVulkanGLSL; 21 class SpecConst; 22 class DriverUniform; 23 24 class TranslatorVulkan : public TCompiler 25 { 26 public: 27 TranslatorVulkan(sh::GLenum type, ShShaderSpec spec); 28 29 protected: 30 [[nodiscard]] bool translate(TIntermBlock *root, 31 const ShCompileOptions &compileOptions, 32 PerformanceDiagnostics *perfDiagnostics) override; 33 bool shouldFlattenPragmaStdglInvariantAll() override; 34 35 // Subclass can call this method to transform the AST before writing the final output. 36 // See TranslatorMetal.cpp. 37 [[nodiscard]] bool translateImpl(TInfoSinkBase &sink, 38 TIntermBlock *root, 39 const ShCompileOptions &compileOptions, 40 PerformanceDiagnostics *perfDiagnostics, 41 SpecConst *specConst, 42 DriverUniform *driverUniforms); 43 44 void writeExtensionBehavior(const ShCompileOptions &compileOptions, TInfoSinkBase &sink); 45 46 // Give subclass such as TranslatorMetal a chance to do depth transform before 47 // TranslatorVulkan apply its own transform. 48 [[nodiscard]] virtual bool transformDepthBeforeCorrection(TIntermBlock *root, 49 const DriverUniform *driverUniforms) 50 { 51 return true; 52 } 53 54 // Generate SPIR-V out of intermediate GLSL through glslang. 55 [[nodiscard]] bool compileToSpirv(const TInfoSinkBase &glsl); 56 }; 57 58 } // namespace sh 59 60 #endif // COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_