blob: f9f50c4fe50661cdb30bc020b10ff2c76cf60444 [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 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//
Jamie Madill80bfe0f2016-11-07 13:50:31 -050027TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org76b82082010-03-24 17:59:39 +000028{
Jamie Madill80bfe0f2016-11-07 13:50:31 -050029 switch (output)
30 {
31 case SH_ESSL_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080032#ifdef ANGLE_ENABLE_ESSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050033 return new TranslatorESSL(type, spec);
Austin Kinross82b5ab62015-12-11 09:30:15 -080034#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050035 // This compiler is not supported in this configuration. Return NULL per the
36 // sh::ConstructCompiler API.
37 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050038#endif // ANGLE_ENABLE_ESSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050039
40 case SH_GLSL_130_OUTPUT:
41 case SH_GLSL_140_OUTPUT:
42 case SH_GLSL_150_CORE_OUTPUT:
43 case SH_GLSL_330_CORE_OUTPUT:
44 case SH_GLSL_400_CORE_OUTPUT:
45 case SH_GLSL_410_CORE_OUTPUT:
46 case SH_GLSL_420_CORE_OUTPUT:
47 case SH_GLSL_430_CORE_OUTPUT:
48 case SH_GLSL_440_CORE_OUTPUT:
49 case SH_GLSL_450_CORE_OUTPUT:
50 case SH_GLSL_COMPATIBILITY_OUTPUT:
Austin Kinross82b5ab62015-12-11 09:30:15 -080051#ifdef ANGLE_ENABLE_GLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050052 return new TranslatorGLSL(type, spec, output);
Austin Kinross82b5ab62015-12-11 09:30:15 -080053#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050054 // This compiler is not supported in this configuration. Return NULL per the
55 // sh::ConstructCompiler API.
56 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050057#endif // ANGLE_ENABLE_GLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050058
59 case SH_HLSL_3_0_OUTPUT:
60 case SH_HLSL_4_1_OUTPUT:
61 case SH_HLSL_4_0_FL9_3_OUTPUT:
Daniel Bratell73941de2015-02-25 14:34:49 +010062#ifdef ANGLE_ENABLE_HLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050063 return new TranslatorHLSL(type, spec, output);
Daniel Bratell73941de2015-02-25 14:34:49 +010064#else
Jamie Madill80bfe0f2016-11-07 13:50:31 -050065 // This compiler is not supported in this configuration. Return NULL per the
66 // sh::ConstructCompiler API.
67 return nullptr;
Jamie Madillacb4b812016-11-07 13:50:29 -050068#endif // ANGLE_ENABLE_HLSL
Jamie Madill80bfe0f2016-11-07 13:50:31 -050069
Jamie Madille09bd5d2016-11-29 16:20:35 -050070 case SH_GLSL_VULKAN_OUTPUT:
71 UNIMPLEMENTED();
72 // TODO(jmadill): Vulkan GLSL
73 return nullptr;
74
Jamie Madill80bfe0f2016-11-07 13:50:31 -050075 default:
76 // Unknown format. Return NULL per the sh::ConstructCompiler API.
77 return nullptr;
zmo@google.com5601ea02011-06-10 18:23:25 +000078 }
alokp@chromium.org76b82082010-03-24 17:59:39 +000079}
80
81//
82// Delete the compiler made by ConstructCompiler
83//
Jamie Madill80bfe0f2016-11-07 13:50:31 -050084void DeleteCompiler(TCompiler *compiler)
alokp@chromium.org76b82082010-03-24 17:59:39 +000085{
Jamie Madill80bfe0f2016-11-07 13:50:31 -050086 SafeDelete(compiler);
alokp@chromium.org76b82082010-03-24 17:59:39 +000087}
Jamie Madillacb4b812016-11-07 13:50:29 -050088
89} // namespace sh