• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
SpecConstMetal(TSymbolTable * symbolTable,ShCompileOptions compileOptions,GLenum shaderType)31     SpecConstMetal(TSymbolTable *symbolTable, ShCompileOptions compileOptions, GLenum shaderType)
32         : SpecConst(symbolTable, compileOptions, shaderType)
33     {}
~SpecConstMetal()34     ~SpecConstMetal() override {}
35 
36   private:
37 };
38 
39 class TranslatorMetal : public TranslatorVulkan
40 {
41   public:
42     TranslatorMetal(sh::GLenum type, ShShaderSpec spec);
43 
44   protected:
45     ANGLE_NO_DISCARD bool translate(TIntermBlock *root,
46                                     ShCompileOptions compileOptions,
47                                     PerformanceDiagnostics *perfDiagnostics) override;
48 
49     ANGLE_NO_DISCARD bool transformDepthBeforeCorrection(
50         TIntermBlock *root,
51         const DriverUniform *driverUniforms) override;
52 
53     ANGLE_NO_DISCARD bool insertSampleMaskWritingLogic(TInfoSinkBase &sink,
54                                                        TIntermBlock *root,
55                                                        const DriverUniformMetal *driverUniforms);
56     ANGLE_NO_DISCARD bool insertRasterizerDiscardLogic(TInfoSinkBase &sink, TIntermBlock *root);
57 };
58 
59 }  // namespace sh
60 
61 #endif /* LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_ */
62