1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2013 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_NULL
8*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/null/TranslatorNULL.h"
9*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_NULL
10*8975f5c5SAndroid Build Coastguard Worker
11*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_ESSL
12*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/glsl/TranslatorESSL.h"
13*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_ESSL
14*8975f5c5SAndroid Build Coastguard Worker
15*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_GLSL
16*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/glsl/TranslatorGLSL.h"
17*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_GLSL
18*8975f5c5SAndroid Build Coastguard Worker
19*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_HLSL
20*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/hlsl/TranslatorHLSL.h"
21*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_HLSL
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_VULKAN
24*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/spirv/TranslatorSPIRV.h"
25*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_VULKAN
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_METAL
28*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/msl/TranslatorMSL.h"
29*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_METAL
30*8975f5c5SAndroid Build Coastguard Worker
31*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_WGPU
32*8975f5c5SAndroid Build Coastguard Worker # include "compiler/translator/wgsl/TranslatorWGSL.h"
33*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_WGPU
34*8975f5c5SAndroid Build Coastguard Worker
35*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/util.h"
36*8975f5c5SAndroid Build Coastguard Worker
37*8975f5c5SAndroid Build Coastguard Worker namespace sh
38*8975f5c5SAndroid Build Coastguard Worker {
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard Worker //
41*8975f5c5SAndroid Build Coastguard Worker // This function must be provided to create the actual
42*8975f5c5SAndroid Build Coastguard Worker // compile object used by higher level code. It returns
43*8975f5c5SAndroid Build Coastguard Worker // a subclass of TCompiler.
44*8975f5c5SAndroid Build Coastguard Worker //
ConstructCompiler(sh::GLenum type,ShShaderSpec spec,ShShaderOutput output)45*8975f5c5SAndroid Build Coastguard Worker TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
46*8975f5c5SAndroid Build Coastguard Worker {
47*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_NULL
48*8975f5c5SAndroid Build Coastguard Worker if (IsOutputNULL(output))
49*8975f5c5SAndroid Build Coastguard Worker {
50*8975f5c5SAndroid Build Coastguard Worker return new TranslatorNULL(type, spec);
51*8975f5c5SAndroid Build Coastguard Worker }
52*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_NULL
53*8975f5c5SAndroid Build Coastguard Worker
54*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_ESSL
55*8975f5c5SAndroid Build Coastguard Worker if (IsOutputESSL(output))
56*8975f5c5SAndroid Build Coastguard Worker {
57*8975f5c5SAndroid Build Coastguard Worker return new TranslatorESSL(type, spec);
58*8975f5c5SAndroid Build Coastguard Worker }
59*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_ESSL
60*8975f5c5SAndroid Build Coastguard Worker
61*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_GLSL
62*8975f5c5SAndroid Build Coastguard Worker if (IsOutputGLSL(output))
63*8975f5c5SAndroid Build Coastguard Worker {
64*8975f5c5SAndroid Build Coastguard Worker return new TranslatorGLSL(type, spec, output);
65*8975f5c5SAndroid Build Coastguard Worker }
66*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_GLSL
67*8975f5c5SAndroid Build Coastguard Worker
68*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_HLSL
69*8975f5c5SAndroid Build Coastguard Worker if (IsOutputHLSL(output))
70*8975f5c5SAndroid Build Coastguard Worker {
71*8975f5c5SAndroid Build Coastguard Worker return new TranslatorHLSL(type, spec, output);
72*8975f5c5SAndroid Build Coastguard Worker }
73*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_HLSL
74*8975f5c5SAndroid Build Coastguard Worker
75*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_VULKAN
76*8975f5c5SAndroid Build Coastguard Worker if (IsOutputSPIRV(output))
77*8975f5c5SAndroid Build Coastguard Worker {
78*8975f5c5SAndroid Build Coastguard Worker return new TranslatorSPIRV(type, spec);
79*8975f5c5SAndroid Build Coastguard Worker }
80*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_VULKAN
81*8975f5c5SAndroid Build Coastguard Worker
82*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_METAL
83*8975f5c5SAndroid Build Coastguard Worker if (IsOutputMSL(output))
84*8975f5c5SAndroid Build Coastguard Worker {
85*8975f5c5SAndroid Build Coastguard Worker return new TranslatorMSL(type, spec, output);
86*8975f5c5SAndroid Build Coastguard Worker }
87*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_METAL
88*8975f5c5SAndroid Build Coastguard Worker
89*8975f5c5SAndroid Build Coastguard Worker #ifdef ANGLE_ENABLE_WGPU
90*8975f5c5SAndroid Build Coastguard Worker if (IsOutputWGSL(output))
91*8975f5c5SAndroid Build Coastguard Worker {
92*8975f5c5SAndroid Build Coastguard Worker return new TranslatorWGSL(type, spec, output);
93*8975f5c5SAndroid Build Coastguard Worker }
94*8975f5c5SAndroid Build Coastguard Worker #endif // ANGLE_ENABLE_WGPU
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker // Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API.
97*8975f5c5SAndroid Build Coastguard Worker return nullptr;
98*8975f5c5SAndroid Build Coastguard Worker }
99*8975f5c5SAndroid Build Coastguard Worker
100*8975f5c5SAndroid Build Coastguard Worker //
101*8975f5c5SAndroid Build Coastguard Worker // Delete the compiler made by ConstructCompiler
102*8975f5c5SAndroid Build Coastguard Worker //
DeleteCompiler(TCompiler * compiler)103*8975f5c5SAndroid Build Coastguard Worker void DeleteCompiler(TCompiler *compiler)
104*8975f5c5SAndroid Build Coastguard Worker {
105*8975f5c5SAndroid Build Coastguard Worker SafeDelete(compiler);
106*8975f5c5SAndroid Build Coastguard Worker }
107*8975f5c5SAndroid Build Coastguard Worker
108*8975f5c5SAndroid Build Coastguard Worker } // namespace sh
109