• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2013 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 
7 #ifdef ANGLE_ENABLE_ESSL
8 #    include "compiler/translator/TranslatorESSL.h"
9 #endif  // ANGLE_ENABLE_ESSL
10 
11 #ifdef ANGLE_ENABLE_GLSL
12 #    include "compiler/translator/TranslatorGLSL.h"
13 #endif  // ANGLE_ENABLE_GLSL
14 
15 #ifdef ANGLE_ENABLE_HLSL
16 #    include "compiler/translator/TranslatorHLSL.h"
17 #endif  // ANGLE_ENABLE_HLSL
18 
19 #ifdef ANGLE_ENABLE_VULKAN
20 #    include "compiler/translator/TranslatorVulkan.h"
21 #endif  // ANGLE_ENABLE_VULKAN
22 
23 #ifdef ANGLE_ENABLE_METAL
24 #    include "compiler/translator/TranslatorMetal.h"
25 #endif  // ANGLE_ENABLE_METAL
26 
27 #include "compiler/translator/util.h"
28 
29 namespace sh
30 {
31 
32 //
33 // This function must be provided to create the actual
34 // compile object used by higher level code.  It returns
35 // a subclass of TCompiler.
36 //
ConstructCompiler(sh::GLenum type,ShShaderSpec spec,ShShaderOutput output)37 TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
38 {
39 #ifdef ANGLE_ENABLE_ESSL
40     if (IsOutputESSL(output))
41     {
42         return new TranslatorESSL(type, spec);
43     }
44 #endif  // ANGLE_ENABLE_ESSL
45 
46 #ifdef ANGLE_ENABLE_GLSL
47     if (IsOutputGLSL(output))
48     {
49         return new TranslatorGLSL(type, spec, output);
50     }
51 #endif  // ANGLE_ENABLE_GLSL
52 
53 #ifdef ANGLE_ENABLE_HLSL
54     if (IsOutputHLSL(output))
55     {
56         return new TranslatorHLSL(type, spec, output);
57     }
58 #endif  // ANGLE_ENABLE_HLSL
59 
60 #ifdef ANGLE_ENABLE_VULKAN
61     if (IsOutputVulkan(output))
62     {
63         return new TranslatorVulkan(type, spec);
64     }
65 #endif  // ANGLE_ENABLE_VULKAN
66 
67 #ifdef ANGLE_ENABLE_METAL
68     if (IsOutputMetal(output))
69     {
70         return new TranslatorMetal(type, spec);
71     }
72 #endif  // ANGLE_ENABLE_METAL
73 
74     // Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API.
75     return nullptr;
76 }
77 
78 //
79 // Delete the compiler made by ConstructCompiler
80 //
DeleteCompiler(TCompiler * compiler)81 void DeleteCompiler(TCompiler *compiler)
82 {
83     SafeDelete(compiler);
84 }
85 
86 }  // namespace sh
87