blob: 75f0d362402e34a0345cf1afc389d394e3948b60 [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"
Jamie Madill80bfe0f2016-11-07 13:50:31 -05009#endif // ANGLE_ENABLE_ESSL
Austin Kinross82b5ab62015-12-11 09:30:15 -080010
11#ifdef ANGLE_ENABLE_GLSL
Geoff Lang2b6008c2013-10-08 10:44:05 -040012#include "compiler/translator/TranslatorGLSL.h"
Jamie Madill80bfe0f2016-11-07 13:50:31 -050013#endif // ANGLE_ENABLE_GLSL
Austin Kinross82b5ab62015-12-11 09:30:15 -080014
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"
Jamie Madill80bfe0f2016-11-07 13:50:31 -050017#endif // ANGLE_ENABLE_HLSL
alokp@chromium.org76b82082010-03-24 17:59:39 +000018
Jamie Madille794cd82017-01-13 17:29:51 -050019#ifdef ANGLE_ENABLE_VULKAN
20#include "compiler/translator/TranslatorVulkan.h"
21#endif // ANGLE_ENABLE_VULKAN
22
Jamie Madillacb4b812016-11-07 13:50:29 -050023namespace sh
24{
25
alokp@chromium.org76b82082010-03-24 17:59:39 +000026//
27// This function must be provided to create the actual
28// compile object used by higher level code. It returns
29// a subclass of TCompiler.
30//
Jamie Madill80bfe0f2016-11-07 13:50:31 -050031TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org76b82082010-03-24 17:59:39 +000032{
Jamie Madill80bfe0f2016-11-07 13:50:31 -050033 switch (output)
34 {
35 case SH_ESSL_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080036#ifdef ANGLE_ENABLE_ESSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050037 return new TranslatorESSL(type, spec);
Austin Kinross82b5ab62015-12-11 09:30:15 -080038#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050039 // This compiler is not supported in this configuration. Return NULL per the
40 // sh::ConstructCompiler API.
41 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050042#endif // ANGLE_ENABLE_ESSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050043
44 case SH_GLSL_130_OUTPUT:
45 case SH_GLSL_140_OUTPUT:
46 case SH_GLSL_150_CORE_OUTPUT:
47 case SH_GLSL_330_CORE_OUTPUT:
48 case SH_GLSL_400_CORE_OUTPUT:
49 case SH_GLSL_410_CORE_OUTPUT:
50 case SH_GLSL_420_CORE_OUTPUT:
51 case SH_GLSL_430_CORE_OUTPUT:
52 case SH_GLSL_440_CORE_OUTPUT:
53 case SH_GLSL_450_CORE_OUTPUT:
54 case SH_GLSL_COMPATIBILITY_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080055#ifdef ANGLE_ENABLE_GLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050056 return new TranslatorGLSL(type, spec, output);
Austin Kinross82b5ab62015-12-11 09:30:15 -080057#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050058 // This compiler is not supported in this configuration. Return NULL per the
59 // sh::ConstructCompiler API.
60 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050061#endif // ANGLE_ENABLE_GLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050062
63 case SH_HLSL_3_0_OUTPUT:
64 case SH_HLSL_4_1_OUTPUT:
65 case SH_HLSL_4_0_FL9_3_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010066#ifdef ANGLE_ENABLE_HLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050067 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010068#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050069 // This compiler is not supported in this configuration. Return NULL per the
70 // sh::ConstructCompiler API.
71 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050072#endif // ANGLE_ENABLE_HLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050073
Jamie Madille09bd5d2016-11-29 16:20:35 -050074 case SH_GLSL_VULKAN_OUTPUT:
Jamie Madille794cd82017-01-13 17:29:51 -050075#ifdef ANGLE_ENABLE_VULKAN
76 return new TranslatorVulkan(type, spec);
77#else
78 // This compiler is not supported in this configuration. Return NULL per the
79 // ShConstructCompiler API.
Jamie Madille09bd5d2016-11-29 16:20:35 -050080 return nullptr;
Jamie Madille794cd82017-01-13 17:29:51 -050081#endif // ANGLE_ENABLE_VULKAN
Jamie Madille09bd5d2016-11-29 16:20:35 -050082
Jamie Madill80bfe0f2016-11-07 13:50:31 -050083 default:
84 // Unknown format. Return NULL per the sh::ConstructCompiler API.
85 return nullptr;
zmo@google.com5601ea02011-06-10 18:23:25 +000086 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000087}
88
89//
90// Delete the compiler made by ConstructCompiler
91//
Jamie Madill80bfe0f2016-11-07 13:50:31 -050092void DeleteCompiler(TCompiler *compiler)
alokp@chromium.org76b82082010-03-24 17:59:39 +000093{
Jamie Madill80bfe0f2016-11-07 13:50:31 -050094 SafeDelete(compiler);
alokp@chromium.org76b82082010-03-24 17:59:39 +000095}
Jamie Madillacb4b812016-11-07 13:50:29 -050096
97} // namespace sh