TranslatorMetal.h (2314B)
1 // 2 // Copyright 2019 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 // TranslatorMetal: 7 // A GLSL-based translator that outputs shaders that fit GL_KHR_vulkan_glsl. 8 // It takes into account some considerations for Metal backend also. 9 // The shaders are then fed into glslang to spit out SPIR-V. 10 // See: https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt 11 // 12 // The SPIR-V will then be translated to Metal Shading Language later in Metal backend. 13 // 14 15 #ifndef LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_ 16 #define LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_ 17 18 #include "compiler/translator/DriverUniformMetal.h" 19 #include "compiler/translator/TranslatorVulkan.h" 20 #include "compiler/translator/tree_util/DriverUniform.h" 21 #include "compiler/translator/tree_util/SpecializationConstant.h" 22 23 namespace sh 24 { 25 26 // TODO: http://anglebug.com/5339 Implement it using actual specialization constant. For now we are 27 // redirecting to driver uniforms 28 class SpecConstMetal : public SpecConst 29 { 30 public: 31 SpecConstMetal(TSymbolTable *symbolTable, 32 const ShCompileOptions &compileOptions, 33 GLenum shaderType) 34 : SpecConst(symbolTable, compileOptions, shaderType) 35 {} 36 ~SpecConstMetal() override {} 37 38 private: 39 }; 40 41 class TranslatorMetal : public TranslatorVulkan 42 { 43 public: 44 TranslatorMetal(sh::GLenum type, ShShaderSpec spec); 45 46 protected: 47 [[nodiscard]] bool translate(TIntermBlock *root, 48 const ShCompileOptions &compileOptions, 49 PerformanceDiagnostics *perfDiagnostics) override; 50 51 [[nodiscard]] bool transformDepthBeforeCorrection(TIntermBlock *root, 52 const DriverUniform *driverUniforms) override; 53 54 [[nodiscard]] bool insertSampleMaskWritingLogic(TInfoSinkBase &sink, 55 TIntermBlock *root, 56 const DriverUniformMetal *driverUniforms); 57 [[nodiscard]] bool insertRasterizerDiscardLogic(TInfoSinkBase &sink, TIntermBlock *root); 58 }; 59 60 } // namespace sh 61 62 #endif /* LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_ */