blob: 5e3eb1cc054e2c6d6076919af68d88bb722a766a [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);
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080024 case SH_GLSL_CORE_OUTPUT:
25 case SH_GLSL_COMPATIBILITY_OUTPUT:
26 return new TranslatorGLSL(type, spec, output);
27 case SH_HLSL9_OUTPUT:
28 case SH_HLSL11_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010029#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040030 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010031#else
32 // This compiler is not supported in this
33 // configuration. Return NULL per the ShConstructCompiler API.
34 return NULL;
35#endif // ANGLE_ENABLE_HLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080036 default:
Daniel Bratell73941de2015-02-25 14:34:49 +010037 // Unknown format. Return NULL per the ShConstructCompiler API.
zmo@google.com5601ea02011-06-10 18:23:25 +000038 return NULL;
39 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000040}
41
42//
43// Delete the compiler made by ConstructCompiler
44//
45void DeleteCompiler(TCompiler* compiler)
46{
47 delete compiler;
48}