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, |
| 34 | HLSL_TEXTURE_2D_INT4, |
| 35 | HLSL_TEXTURE_3D_INT4, |
| 36 | HLSL_TEXTURE_2D_ARRAY_INT4, |
| 37 | HLSL_TEXTURE_2D_UINT4, |
| 38 | HLSL_TEXTURE_3D_UINT4, |
| 39 | HLSL_TEXTURE_2D_ARRAY_UINT4, |
| 40 | |
| 41 | // Comparison samplers |
| 42 | |
| 43 | HLSL_TEXTURE_2D_COMPARISON, |
| 44 | HLSL_TEXTURE_CUBE_COMPARISON, |
| 45 | HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 46 | |
| 47 | HLSL_COMPARISON_SAMPLER_GROUP_BEGIN = HLSL_TEXTURE_2D_COMPARISON, |
| 48 | HLSL_COMPARISON_SAMPLER_GROUP_END = HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 49 | |
| 50 | HLSL_TEXTURE_UNKNOWN, |
| 51 | HLSL_TEXTURE_MAX = HLSL_TEXTURE_UNKNOWN |
| 52 | }; |
| 53 | |
| 54 | HLSLTextureSamplerGroup TextureGroup(const TBasicType type); |
| 55 | TString TextureString(const HLSLTextureSamplerGroup type); |
| 56 | TString TextureString(const TBasicType type); |
| 57 | TString TextureGroupSuffix(const HLSLTextureSamplerGroup type); |
| 58 | TString TextureGroupSuffix(const TBasicType type); |
| 59 | TString TextureTypeSuffix(const TBasicType type); |
| 60 | TString SamplerString(const TBasicType type); |
| 61 | TString SamplerString(HLSLTextureSamplerGroup type); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 62 | // Prepends an underscore to avoid naming clashes |
| 63 | TString Decorate(const TString &string); |
Olli Etuaho | f5cfc8d | 2015-08-06 16:36:39 +0300 | [diff] [blame] | 64 | TString DecorateIfNeeded(const TName &name); |
Olli Etuaho | 59f9a64 | 2015-08-06 20:38:26 +0300 | [diff] [blame] | 65 | // Decorates and also unmangles the function name |
| 66 | TString DecorateFunctionIfNeeded(const TName &name); |
Olli Etuaho | 9696316 | 2016-03-21 11:54:33 +0200 | [diff] [blame^] | 67 | TString DecorateUniform(const TName &name, const TType &type); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 68 | TString DecorateField(const TString &string, const TStructure &structure); |
| 69 | TString DecoratePrivate(const TString &privateText); |
| 70 | TString TypeString(const TType &type); |
| 71 | TString StructNameString(const TStructure &structure); |
| 72 | TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking, |
| 73 | bool useStd140Packing); |
| 74 | TString InterpolationString(TQualifier qualifier); |
| 75 | TString QualifierString(TQualifier qualifier); |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 76 | int HLSLTextureCoordsCount(const TBasicType samplerType); |
Olli Etuaho | be59c2f | 2016-03-07 11:32:34 +0200 | [diff] [blame] | 77 | // Parameters may need to be included in function names to disambiguate between overloaded |
| 78 | // functions. |
| 79 | TString DisambiguateFunctionName(const TIntermSequence *parameters); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 82 | #endif // COMPILER_TRANSLATOR_UTILSHLSL_H_ |