1 //
2 // Copyright (c) 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 #include "compiler/translator/util.h"
24 
25 namespace sh
26 {
27 
28 //
29 // This function must be provided to create the actual
30 // compile object used by higher level code.  It returns
31 // a subclass of TCompiler.
32 //
ConstructCompiler(sh::GLenum type,ShShaderSpec spec,ShShaderOutput output)33 TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
34 {
35 #ifdef ANGLE_ENABLE_ESSL
36     if (IsOutputESSL(output))
37     {
38         return new TranslatorESSL(type, spec);
39     }
40 #endif  // ANGLE_ENABLE_ESSL
41 
42 #ifdef ANGLE_ENABLE_GLSL
43     if (IsOutputGLSL(output))
44     {
45         return new TranslatorGLSL(type, spec, output);
46     }
47 #endif  // ANGLE_ENABLE_GLSL
48 
49 #ifdef ANGLE_ENABLE_HLSL
50     if (IsOutputHLSL(output))
51     {
52         return new TranslatorHLSL(type, spec, output);
53     }
54 #endif  // ANGLE_ENABLE_HLSL
55 
56 #ifdef ANGLE_ENABLE_VULKAN
57     if (IsOutputVulkan(output))
58     {
59         return new TranslatorVulkan(type, spec);
60     }
61 #endif  // ANGLE_ENABLE_VULKAN
62 
63     // Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API.
64     return nullptr;
65 }
66 
67 //
68 // Delete the compiler made by ConstructCompiler
69 //
DeleteCompiler(TCompiler * compiler)70 void DeleteCompiler(TCompiler *compiler)
71 {
72     SafeDelete(compiler);
73 }
74 
75 }  // namespace sh
76