blob: 10809e8d7f3266d31d130a21dc9d0df63fdbbb98 [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) {
Geoff Lang2b6008c2013-10-08 10:44:05 -040022 case SH_ESSL_OUTPUT:
zmo@google.com5601ea02011-06-10 18:23:25 +000023 return new TranslatorESSL(type, spec);
Geoff Lang2b6008c2013-10-08 10:44:05 -040024 case SH_GLSL_OUTPUT:
25 return new TranslatorGLSL(type, spec);
26 case SH_HLSL9_OUTPUT:
27 case SH_HLSL11_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010028#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040029 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010030#else
31 // This compiler is not supported in this
32 // configuration. Return NULL per the ShConstructCompiler API.
33 return NULL;
34#endif // ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040035 default:
Daniel Bratell73941de2015-02-25 14:34:49 +010036 // Unknown format. Return NULL per the ShConstructCompiler API.
zmo@google.com5601ea02011-06-10 18:23:25 +000037 return NULL;
38 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000039}
40
41//
42// Delete the compiler made by ConstructCompiler
43//
44void DeleteCompiler(TCompiler* compiler)
45{
46 delete compiler;
47}