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. 8 // The shaders are then fed into glslang to spit out SPIR-V (libANGLE-side). 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 22 class TranslatorVulkan : public TCompiler 23 { 24 public: 25 TranslatorVulkan(sh::GLenum type, ShShaderSpec spec); 26 27 protected: 28 ANGLE_NO_DISCARD bool translate(TIntermBlock *root, 29 ShCompileOptions compileOptions, 30 PerformanceDiagnostics *perfDiagnostics) override; 31 bool shouldFlattenPragmaStdglInvariantAll() override; 32 33 TIntermBinary *getDriverUniformNegViewportYScaleRef(const TVariable *driverUniforms) const; 34 TIntermBinary *getDriverUniformDepthRangeReservedFieldRef( 35 const TVariable *driverUniforms) const; 36 // Subclass can call this method to transform the AST before writing the final output. 37 // See TranslatorMetal.cpp. 38 ANGLE_NO_DISCARD bool translateImpl(TIntermBlock *root, 39 ShCompileOptions compileOptions, 40 PerformanceDiagnostics *perfDiagnostics, 41 const TVariable **driverUniformsOut, 42 TOutputVulkanGLSL *outputGLSL); 43 44 // Give subclass such as TranslatorMetal a chance to do depth transform before 45 // TranslatorVulkan apply its own transform. transformDepthBeforeCorrection(TIntermBlock * root,const TVariable * driverUniforms)46 ANGLE_NO_DISCARD virtual bool transformDepthBeforeCorrection(TIntermBlock *root, 47 const TVariable *driverUniforms) 48 { 49 return true; 50 } 51 }; 52 53 } // namespace sh 54 55 #endif // COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_ 56