Line data Source code
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 : namespace sh
20 : {
21 :
22 : //
23 : // This function must be provided to create the actual
24 : // compile object used by higher level code. It returns
25 : // a subclass of TCompiler.
26 : //
27 0 : TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
28 : {
29 0 : switch (output)
30 : {
31 : case SH_ESSL_OUTPUT:
32 : #ifdef ANGLE_ENABLE_ESSL
33 0 : return new TranslatorESSL(type, spec);
34 : #else
35 : // This compiler is not supported in this configuration. Return NULL per the
36 : // sh::ConstructCompiler API.
37 : return nullptr;
38 : #endif // ANGLE_ENABLE_ESSL
39 :
40 : case SH_GLSL_130_OUTPUT:
41 : case SH_GLSL_140_OUTPUT:
42 : case SH_GLSL_150_CORE_OUTPUT:
43 : case SH_GLSL_330_CORE_OUTPUT:
44 : case SH_GLSL_400_CORE_OUTPUT:
45 : case SH_GLSL_410_CORE_OUTPUT:
46 : case SH_GLSL_420_CORE_OUTPUT:
47 : case SH_GLSL_430_CORE_OUTPUT:
48 : case SH_GLSL_440_CORE_OUTPUT:
49 : case SH_GLSL_450_CORE_OUTPUT:
50 : case SH_GLSL_COMPATIBILITY_OUTPUT:
51 : #ifdef ANGLE_ENABLE_GLSL
52 0 : return new TranslatorGLSL(type, spec, output);
53 : #else
54 : // This compiler is not supported in this configuration. Return NULL per the
55 : // sh::ConstructCompiler API.
56 : return nullptr;
57 : #endif // ANGLE_ENABLE_GLSL
58 :
59 : case SH_HLSL_3_0_OUTPUT:
60 : case SH_HLSL_4_1_OUTPUT:
61 : case SH_HLSL_4_0_FL9_3_OUTPUT:
62 : #ifdef ANGLE_ENABLE_HLSL
63 0 : return new TranslatorHLSL(type, spec, output);
64 : #else
65 : // This compiler is not supported in this configuration. Return NULL per the
66 : // sh::ConstructCompiler API.
67 : return nullptr;
68 : #endif // ANGLE_ENABLE_HLSL
69 :
70 : default:
71 : // Unknown format. Return NULL per the sh::ConstructCompiler API.
72 0 : return nullptr;
73 : }
74 : }
75 :
76 : //
77 : // Delete the compiler made by ConstructCompiler
78 : //
79 0 : void DeleteCompiler(TCompiler *compiler)
80 : {
81 0 : SafeDelete(compiler);
82 0 : }
83 :
84 : } // namespace sh
|