alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | 2b6008c | 2013-10-08 10:44:05 -0400 | [diff] [blame] | 2 | // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 7 | #ifdef ANGLE_ENABLE_ESSL |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 8 | #include "compiler/translator/TranslatorESSL.h" |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 9 | #endif |
| 10 | |
| 11 | #ifdef ANGLE_ENABLE_GLSL |
Geoff Lang | 2b6008c | 2013-10-08 10:44:05 -0400 | [diff] [blame] | 12 | #include "compiler/translator/TranslatorGLSL.h" |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 13 | #endif |
| 14 | |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 15 | #ifdef ANGLE_ENABLE_HLSL |
Geoff Lang | 2b6008c | 2013-10-08 10:44:05 -0400 | [diff] [blame] | 16 | #include "compiler/translator/TranslatorHLSL.h" |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 17 | #endif // ANGLE_ENABLE_HLSL |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 18 | |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 19 | namespace sh |
| 20 | { |
| 21 | |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 22 | // |
| 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.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 27 | TCompiler* ConstructCompiler( |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 28 | sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 29 | { |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 30 | switch (output) { |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 31 | case SH_ESSL_OUTPUT: |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 32 | #ifdef ANGLE_ENABLE_ESSL |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 33 | return new TranslatorESSL(type, spec); |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 34 | #else |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 35 | // 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 Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 39 | case SH_GLSL_130_OUTPUT: |
Geoff Lang | 8273e00 | 2015-06-15 13:40:19 -0700 | [diff] [blame] | 40 | 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 Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 44 | case SH_GLSL_410_CORE_OUTPUT: |
| 45 | case SH_GLSL_420_CORE_OUTPUT: |
Geoff Lang | 8273e00 | 2015-06-15 13:40:19 -0700 | [diff] [blame] | 46 | case SH_GLSL_430_CORE_OUTPUT: |
| 47 | case SH_GLSL_440_CORE_OUTPUT: |
| 48 | case SH_GLSL_450_CORE_OUTPUT: |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 49 | case SH_GLSL_COMPATIBILITY_OUTPUT: |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 50 | #ifdef ANGLE_ENABLE_GLSL |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 51 | return new TranslatorGLSL(type, spec, output); |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame] | 52 | #else |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 53 | // 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 Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 57 | case SH_HLSL_3_0_OUTPUT: |
| 58 | case SH_HLSL_4_1_OUTPUT: |
| 59 | case SH_HLSL_4_0_FL9_3_OUTPUT: |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 60 | #ifdef ANGLE_ENABLE_HLSL |
Geoff Lang | 2b6008c | 2013-10-08 10:44:05 -0400 | [diff] [blame] | 61 | return new TranslatorHLSL(type, spec, output); |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 62 | #else |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 63 | // 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 Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 67 | default: |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 68 | // Unknown format. Return NULL per the sh::ConstructCompiler API. |
| 69 | return nullptr; |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 70 | } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | // |
| 74 | // Delete the compiler made by ConstructCompiler |
| 75 | // |
| 76 | void DeleteCompiler(TCompiler* compiler) |
| 77 | { |
| 78 | delete compiler; |
| 79 | } |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 80 | |
| 81 | } // namespace sh |