blob: 4f8d2b085a8a72a714191f7ecf71b93337e68678 [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
Geoff Lang17732822013-08-29 13:46:49 -04007#include "compiler/translator/TranslatorESSL.h"
Geoff Lang2b6008c2013-10-08 10:44:05 -04008#include "compiler/translator/TranslatorGLSL.h"
Daniel Bratell73941de2015-02-25 14:34:49 +01009#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040010#include "compiler/translator/TranslatorHLSL.h"
Daniel Bratell73941de2015-02-25 14:34:49 +010011#endif // ANGLE_ENABLE_HLSL
alokp@chromium.org76b82082010-03-24 17:59:39 +000012
13//
14// This function must be provided to create the actual
15// compile object used by higher level code. It returns
16// a subclass of TCompiler.
17//
zmo@google.com5601ea02011-06-10 18:23:25 +000018TCompiler* ConstructCompiler(
Jamie Madill183bde52014-07-02 15:31:19 -040019 sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org76b82082010-03-24 17:59:39 +000020{
zmo@google.com5601ea02011-06-10 18:23:25 +000021 switch (output) {
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080022 case SH_ESSL_OUTPUT:
zmo@google.com5601ea02011-06-10 18:23:25 +000023 return new TranslatorESSL(type, spec);
Qingqing Dengad0d0792015-04-08 14:25:06 -070024 case SH_GLSL_130_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070025 case SH_GLSL_140_OUTPUT:
26 case SH_GLSL_150_CORE_OUTPUT:
27 case SH_GLSL_330_CORE_OUTPUT:
28 case SH_GLSL_400_CORE_OUTPUT:
Qingqing Dengad0d0792015-04-08 14:25:06 -070029 case SH_GLSL_410_CORE_OUTPUT:
30 case SH_GLSL_420_CORE_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070031 case SH_GLSL_430_CORE_OUTPUT:
32 case SH_GLSL_440_CORE_OUTPUT:
33 case SH_GLSL_450_CORE_OUTPUT:
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080034 case SH_GLSL_COMPATIBILITY_OUTPUT:
35 return new TranslatorGLSL(type, spec, output);
36 case SH_HLSL9_OUTPUT:
37 case SH_HLSL11_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010038#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040039 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010040#else
41 // This compiler is not supported in this
42 // configuration. Return NULL per the ShConstructCompiler API.
43 return NULL;
44#endif // ANGLE_ENABLE_HLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080045 default:
Daniel Bratell73941de2015-02-25 14:34:49 +010046 // Unknown format. Return NULL per the ShConstructCompiler API.
zmo@google.com5601ea02011-06-10 18:23:25 +000047 return NULL;
48 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000049}
50
51//
52// Delete the compiler made by ConstructCompiler
53//
54void DeleteCompiler(TCompiler* compiler)
55{
56 delete compiler;
57}