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 | |
| 19 | // |
| 20 | // This function must be provided to create the actual |
| 21 | // compile object used by higher level code. It returns |
| 22 | // a subclass of TCompiler. |
| 23 | // |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 24 | TCompiler* ConstructCompiler( |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 25 | sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 26 | { |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 27 | switch (output) { |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 28 | case SH_ESSL_OUTPUT: |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame^] | 29 | #ifdef ANGLE_ENABLE_ESSL |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 30 | return new TranslatorESSL(type, spec); |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame^] | 31 | #else |
| 32 | // This compiler is not supported in this |
| 33 | // configuration. Return NULL per the ShConstructCompiler API. |
| 34 | return nullptr; |
| 35 | #endif // ANGLE_ENABLE_ESSL |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 36 | case SH_GLSL_130_OUTPUT: |
Geoff Lang | 8273e00 | 2015-06-15 13:40:19 -0700 | [diff] [blame] | 37 | case SH_GLSL_140_OUTPUT: |
| 38 | case SH_GLSL_150_CORE_OUTPUT: |
| 39 | case SH_GLSL_330_CORE_OUTPUT: |
| 40 | case SH_GLSL_400_CORE_OUTPUT: |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 41 | case SH_GLSL_410_CORE_OUTPUT: |
| 42 | case SH_GLSL_420_CORE_OUTPUT: |
Geoff Lang | 8273e00 | 2015-06-15 13:40:19 -0700 | [diff] [blame] | 43 | case SH_GLSL_430_CORE_OUTPUT: |
| 44 | case SH_GLSL_440_CORE_OUTPUT: |
| 45 | case SH_GLSL_450_CORE_OUTPUT: |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 46 | case SH_GLSL_COMPATIBILITY_OUTPUT: |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame^] | 47 | #ifdef ANGLE_ENABLE_GLSL |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 48 | return new TranslatorGLSL(type, spec, output); |
Austin Kinross | 82b5ab6 | 2015-12-11 09:30:15 -0800 | [diff] [blame^] | 49 | #else |
| 50 | // This compiler is not supported in this |
| 51 | // configuration. Return NULL per the ShConstructCompiler API. |
| 52 | return nullptr; |
| 53 | #endif // ANGLE_ENABLE_GLSL |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 54 | case SH_HLSL9_OUTPUT: |
| 55 | case SH_HLSL11_OUTPUT: |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 56 | #ifdef ANGLE_ENABLE_HLSL |
Geoff Lang | 2b6008c | 2013-10-08 10:44:05 -0400 | [diff] [blame] | 57 | return new TranslatorHLSL(type, spec, output); |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 58 | #else |
| 59 | // This compiler is not supported in this |
| 60 | // configuration. Return NULL per the ShConstructCompiler API. |
Corentin Wallez | 700ad28 | 2015-12-07 15:57:47 -0500 | [diff] [blame] | 61 | return nullptr; |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 62 | #endif // ANGLE_ENABLE_HLSL |
Zhenyao Mo | 05b6b7f | 2015-03-02 17:08:09 -0800 | [diff] [blame] | 63 | default: |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 64 | // Unknown format. Return NULL per the ShConstructCompiler API. |
Corentin Wallez | 700ad28 | 2015-12-07 15:57:47 -0500 | [diff] [blame] | 65 | return nullptr; |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 66 | } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | // |
| 70 | // Delete the compiler made by ConstructCompiler |
| 71 | // |
| 72 | void DeleteCompiler(TCompiler* compiler) |
| 73 | { |
| 74 | delete compiler; |
| 75 | } |