blob: f099bccf15df745886b1b32c09822a3a0e98debb [file] [log] [blame]
alokp@chromium.org76b82082010-03-24 17:59:39 +00001//
Geoff Lang2b6008c2013-10-08 10:44:05 -04002// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org76b82082010-03-24 17:59:39 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Austin Kinross82b5ab62015-12-11 09:30:15 -08007#ifdef ANGLE_ENABLE_ESSL
Geoff Lang17732822013-08-29 13:46:49 -04008#include "compiler/translator/TranslatorESSL.h"
Austin Kinross82b5ab62015-12-11 09:30:15 -08009#endif
10
11#ifdef ANGLE_ENABLE_GLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040012#include "compiler/translator/TranslatorGLSL.h"
Austin Kinross82b5ab62015-12-11 09:30:15 -080013#endif
14
Daniel Bratell73941de2015-02-25 14:34:49 +010015#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040016#include "compiler/translator/TranslatorHLSL.h"
Daniel Bratell73941de2015-02-25 14:34:49 +010017#endif // ANGLE_ENABLE_HLSL
alokp@chromium.org76b82082010-03-24 17:59:39 +000018
19//
20// This function must be provided to create the actual
21// compile object used by higher level code. It returns
22// a subclass of TCompiler.
23//
zmo@google.com5601ea02011-06-10 18:23:25 +000024TCompiler* ConstructCompiler(
Jamie Madill183bde52014-07-02 15:31:19 -040025 sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org76b82082010-03-24 17:59:39 +000026{
zmo@google.com5601ea02011-06-10 18:23:25 +000027 switch (output) {
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080028 case SH_ESSL_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080029#ifdef ANGLE_ENABLE_ESSL
zmo@google.com5601ea02011-06-10 18:23:25 +000030 return new TranslatorESSL(type, spec);
Austin Kinross82b5ab62015-12-11 09:30:15 -080031#else
32 // This compiler is not supported in this
33 // configuration. Return NULL per the ShConstructCompiler API.
34 return nullptr;
35#endif // ANGLE_ENABLE_ESSL
Qingqing Dengad0d0792015-04-08 14:25:06 -070036 case SH_GLSL_130_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070037 case SH_GLSL_140_OUTPUT:
38 case SH_GLSL_150_CORE_OUTPUT:
39 case SH_GLSL_330_CORE_OUTPUT:
40 case SH_GLSL_400_CORE_OUTPUT:
Qingqing Dengad0d0792015-04-08 14:25:06 -070041 case SH_GLSL_410_CORE_OUTPUT:
42 case SH_GLSL_420_CORE_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070043 case SH_GLSL_430_CORE_OUTPUT:
44 case SH_GLSL_440_CORE_OUTPUT:
45 case SH_GLSL_450_CORE_OUTPUT:
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080046 case SH_GLSL_COMPATIBILITY_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080047#ifdef ANGLE_ENABLE_GLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080048 return new TranslatorGLSL(type, spec, output);
Austin Kinross82b5ab62015-12-11 09:30:15 -080049#else
50 // This compiler is not supported in this
51 // configuration. Return NULL per the ShConstructCompiler API.
52 return nullptr;
53#endif // ANGLE_ENABLE_GLSL
Olli Etuaho9b4e8622015-12-22 15:53:22 +020054 case SH_HLSL_3_0_OUTPUT:
55 case SH_HLSL_4_1_OUTPUT:
56 case SH_HLSL_4_0_FL9_3_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010057#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040058 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010059#else
60 // This compiler is not supported in this
61 // configuration. Return NULL per the ShConstructCompiler API.
Corentin Wallez700ad282015-12-07 15:57:47 -050062 return nullptr;
Daniel Bratell73941de2015-02-25 14:34:49 +010063#endif // ANGLE_ENABLE_HLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080064 default:
Daniel Bratell73941de2015-02-25 14:34:49 +010065 // Unknown format. Return NULL per the ShConstructCompiler API.
Corentin Wallez700ad282015-12-07 15:57:47 -050066 return nullptr;
zmo@google.com5601ea02011-06-10 18:23:25 +000067 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000068}
69
70//
71// Delete the compiler made by ConstructCompiler
72//
73void DeleteCompiler(TCompiler* compiler)
74{
75 delete compiler;
76}