• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     ANGLE_NO_DISCARD bool translate(TIntermBlock *root,
31                                     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     ANGLE_NO_DISCARD bool translateImpl(TInfoSinkBase &sink,
38                                         TIntermBlock *root,
39                                         ShCompileOptions compileOptions,
40                                         PerformanceDiagnostics *perfDiagnostics,
41                                         SpecConst *specConst,
42                                         DriverUniform *driverUniforms);
43 
44     void writeExtensionBehavior(ShCompileOptions compileOptions, TInfoSinkBase &sink);
45 
46     // Give subclass such as TranslatorMetal a chance to do depth transform before
47     // TranslatorVulkan apply its own transform.
transformDepthBeforeCorrection(TIntermBlock * root,const DriverUniform * driverUniforms)48     ANGLE_NO_DISCARD virtual bool transformDepthBeforeCorrection(
49         TIntermBlock *root,
50         const DriverUniform *driverUniforms)
51     {
52         return true;
53     }
54 
55     // Generate SPIR-V out of intermediate GLSL through glslang.
56     ANGLE_NO_DISCARD bool compileToSpirv(const TInfoSinkBase &glsl);
57 };
58 
59 }  // namespace sh
60 
61 #endif  // COMPILER_TRANSLATOR_TRANSLATORVULKAN_H_
62