Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // UtilsHLSL.h: |
| 7 | // Utility methods for GLSL to HLSL translation. |
| 8 | // |
| 9 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 10 | #ifndef COMPILER_TRANSLATOR_UTILSHLSL_H_ |
| 11 | #define COMPILER_TRANSLATOR_UTILSHLSL_H_ |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 12 | |
| 13 | #include <vector> |
Olli Etuaho | be59c2f | 2016-03-07 11:32:34 +0200 | [diff] [blame] | 14 | #include "compiler/translator/IntermNode.h" |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 15 | #include "compiler/translator/Types.h" |
| 16 | |
Jamie Madill | f51639a | 2014-06-25 16:04:57 -0400 | [diff] [blame] | 17 | #include "angle_gl.h" |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 18 | |
Olli Etuaho | f5cfc8d | 2015-08-06 16:36:39 +0300 | [diff] [blame] | 19 | class TName; |
| 20 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 21 | namespace sh |
| 22 | { |
| 23 | |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 24 | // Unique combinations of HLSL Texture type and HLSL Sampler type. |
| 25 | enum HLSLTextureSamplerGroup |
| 26 | { |
| 27 | // Regular samplers |
| 28 | HLSL_TEXTURE_2D, |
| 29 | HLSL_TEXTURE_MIN = HLSL_TEXTURE_2D, |
| 30 | |
| 31 | HLSL_TEXTURE_CUBE, |
| 32 | HLSL_TEXTURE_2D_ARRAY, |
| 33 | HLSL_TEXTURE_3D, |
Olli Etuaho | 92db39e | 2017-02-15 12:11:04 +0000 | [diff] [blame] | 34 | HLSL_TEXTURE_2D_MS, |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 35 | HLSL_TEXTURE_2D_INT4, |
| 36 | HLSL_TEXTURE_3D_INT4, |
| 37 | HLSL_TEXTURE_2D_ARRAY_INT4, |
Olli Etuaho | 92db39e | 2017-02-15 12:11:04 +0000 | [diff] [blame] | 38 | HLSL_TEXTURE_2D_MS_INT4, |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 39 | HLSL_TEXTURE_2D_UINT4, |
| 40 | HLSL_TEXTURE_3D_UINT4, |
| 41 | HLSL_TEXTURE_2D_ARRAY_UINT4, |
Olli Etuaho | 92db39e | 2017-02-15 12:11:04 +0000 | [diff] [blame] | 42 | HLSL_TEXTURE_2D_MS_UINT4, |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 43 | |
| 44 | // Comparison samplers |
| 45 | |
| 46 | HLSL_TEXTURE_2D_COMPARISON, |
| 47 | HLSL_TEXTURE_CUBE_COMPARISON, |
| 48 | HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 49 | |
| 50 | HLSL_COMPARISON_SAMPLER_GROUP_BEGIN = HLSL_TEXTURE_2D_COMPARISON, |
| 51 | HLSL_COMPARISON_SAMPLER_GROUP_END = HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 52 | |
| 53 | HLSL_TEXTURE_UNKNOWN, |
| 54 | HLSL_TEXTURE_MAX = HLSL_TEXTURE_UNKNOWN |
| 55 | }; |
| 56 | |
| 57 | HLSLTextureSamplerGroup TextureGroup(const TBasicType type); |
| 58 | TString TextureString(const HLSLTextureSamplerGroup type); |
| 59 | TString TextureString(const TBasicType type); |
| 60 | TString TextureGroupSuffix(const HLSLTextureSamplerGroup type); |
| 61 | TString TextureGroupSuffix(const TBasicType type); |
| 62 | TString TextureTypeSuffix(const TBasicType type); |
| 63 | TString SamplerString(const TBasicType type); |
| 64 | TString SamplerString(HLSLTextureSamplerGroup type); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 65 | // Prepends an underscore to avoid naming clashes |
| 66 | TString Decorate(const TString &string); |
Olli Etuaho | f5cfc8d | 2015-08-06 16:36:39 +0300 | [diff] [blame] | 67 | TString DecorateIfNeeded(const TName &name); |
Olli Etuaho | 9696316 | 2016-03-21 11:54:33 +0200 | [diff] [blame] | 68 | TString DecorateUniform(const TName &name, const TType &type); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 69 | TString DecorateField(const TString &string, const TStructure &structure); |
| 70 | TString DecoratePrivate(const TString &privateText); |
| 71 | TString TypeString(const TType &type); |
| 72 | TString StructNameString(const TStructure &structure); |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 73 | TString QualifiedStructNameString(const TStructure &structure, |
| 74 | bool useHLSLRowMajorPacking, |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 75 | bool useStd140Packing); |
| 76 | TString InterpolationString(TQualifier qualifier); |
| 77 | TString QualifierString(TQualifier qualifier); |
Olli Etuaho | be59c2f | 2016-03-07 11:32:34 +0200 | [diff] [blame] | 78 | // Parameters may need to be included in function names to disambiguate between overloaded |
| 79 | // functions. |
| 80 | TString DisambiguateFunctionName(const TIntermSequence *parameters); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 81 | } |
| 82 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 83 | #endif // COMPILER_TRANSLATOR_UTILSHLSL_H_ |