blob: 6bf6dc5310a9944bbf97b4b081849dd1cfc48b2d [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
Jamie Madillacb4b812016-11-07 13:50:29 -050019namespace sh
20{
21
alokp@chromium.org76b82082010-03-24 17:59:39 +000022//
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//
zmo@google.com5601ea02011-06-10 18:23:25 +000027TCompiler* ConstructCompiler(
Jamie Madill183bde52014-07-02 15:31:19 -040028 sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org76b82082010-03-24 17:59:39 +000029{
zmo@google.com5601ea02011-06-10 18:23:25 +000030 switch (output) {
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080031 case SH_ESSL_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080032#ifdef ANGLE_ENABLE_ESSL
zmo@google.com5601ea02011-06-10 18:23:25 +000033 return new TranslatorESSL(type, spec);
Austin Kinross82b5ab62015-12-11 09:30:15 -080034#else
Jamie Madillacb4b812016-11-07 13:50:29 -050035 // This compiler is not supported in this configuration. Return NULL per the
36 // sh::ConstructCompiler API.
37 return nullptr;
38#endif // ANGLE_ENABLE_ESSL
Qingqing Dengad0d0792015-04-08 14:25:06 -070039 case SH_GLSL_130_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070040 case SH_GLSL_140_OUTPUT:
41 case SH_GLSL_150_CORE_OUTPUT:
42 case SH_GLSL_330_CORE_OUTPUT:
43 case SH_GLSL_400_CORE_OUTPUT:
Qingqing Dengad0d0792015-04-08 14:25:06 -070044 case SH_GLSL_410_CORE_OUTPUT:
45 case SH_GLSL_420_CORE_OUTPUT:
Geoff Lang8273e002015-06-15 13:40:19 -070046 case SH_GLSL_430_CORE_OUTPUT:
47 case SH_GLSL_440_CORE_OUTPUT:
48 case SH_GLSL_450_CORE_OUTPUT:
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080049 case SH_GLSL_COMPATIBILITY_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080050#ifdef ANGLE_ENABLE_GLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080051 return new TranslatorGLSL(type, spec, output);
Austin Kinross82b5ab62015-12-11 09:30:15 -080052#else
Jamie Madillacb4b812016-11-07 13:50:29 -050053 // This compiler is not supported in this configuration. Return NULL per the
54 // sh::ConstructCompiler API.
55 return nullptr;
56#endif // ANGLE_ENABLE_GLSL
Olli Etuaho9b4e8622015-12-22 15:53:22 +020057 case SH_HLSL_3_0_OUTPUT:
58 case SH_HLSL_4_1_OUTPUT:
59 case SH_HLSL_4_0_FL9_3_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010060#ifdef ANGLE_ENABLE_HLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040061 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010062#else
Jamie Madillacb4b812016-11-07 13:50:29 -050063 // This compiler is not supported in this configuration. Return NULL per the
64 // sh::ConstructCompiler API.
65 return nullptr;
66#endif // ANGLE_ENABLE_HLSL
Zhenyao Mo05b6b7f2015-03-02 17:08:09 -080067 default:
Jamie Madillacb4b812016-11-07 13:50:29 -050068 // Unknown format. Return NULL per the sh::ConstructCompiler API.
69 return nullptr;
zmo@google.com5601ea02011-06-10 18:23:25 +000070 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000071}
72
73//
74// Delete the compiler made by ConstructCompiler
75//
76void DeleteCompiler(TCompiler* compiler)
77{
78 delete compiler;
79}
Jamie Madillacb4b812016-11-07 13:50:29 -050080
81} // namespace sh