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> |
| 14 | #include "compiler/translator/Types.h" |
| 15 | |
Jamie Madill | f51639a | 2014-06-25 16:04:57 -0400 | [diff] [blame] | 16 | #include "angle_gl.h" |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 17 | |
Olli Etuaho | f5cfc8d | 2015-08-06 16:36:39 +0300 | [diff] [blame] | 18 | class TName; |
| 19 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 20 | namespace sh |
| 21 | { |
| 22 | |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 23 | // Unique combinations of HLSL Texture type and HLSL Sampler type. |
| 24 | enum HLSLTextureSamplerGroup |
| 25 | { |
| 26 | // Regular samplers |
| 27 | HLSL_TEXTURE_2D, |
| 28 | HLSL_TEXTURE_MIN = HLSL_TEXTURE_2D, |
| 29 | |
| 30 | HLSL_TEXTURE_CUBE, |
| 31 | HLSL_TEXTURE_2D_ARRAY, |
| 32 | HLSL_TEXTURE_3D, |
| 33 | HLSL_TEXTURE_2D_INT4, |
| 34 | HLSL_TEXTURE_3D_INT4, |
| 35 | HLSL_TEXTURE_2D_ARRAY_INT4, |
| 36 | HLSL_TEXTURE_2D_UINT4, |
| 37 | HLSL_TEXTURE_3D_UINT4, |
| 38 | HLSL_TEXTURE_2D_ARRAY_UINT4, |
| 39 | |
| 40 | // Comparison samplers |
| 41 | |
| 42 | HLSL_TEXTURE_2D_COMPARISON, |
| 43 | HLSL_TEXTURE_CUBE_COMPARISON, |
| 44 | HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 45 | |
| 46 | HLSL_COMPARISON_SAMPLER_GROUP_BEGIN = HLSL_TEXTURE_2D_COMPARISON, |
| 47 | HLSL_COMPARISON_SAMPLER_GROUP_END = HLSL_TEXTURE_2D_ARRAY_COMPARISON, |
| 48 | |
| 49 | HLSL_TEXTURE_UNKNOWN, |
| 50 | HLSL_TEXTURE_MAX = HLSL_TEXTURE_UNKNOWN |
| 51 | }; |
| 52 | |
| 53 | HLSLTextureSamplerGroup TextureGroup(const TBasicType type); |
| 54 | TString TextureString(const HLSLTextureSamplerGroup type); |
| 55 | TString TextureString(const TBasicType type); |
| 56 | TString TextureGroupSuffix(const HLSLTextureSamplerGroup type); |
| 57 | TString TextureGroupSuffix(const TBasicType type); |
| 58 | TString TextureTypeSuffix(const TBasicType type); |
| 59 | TString SamplerString(const TBasicType type); |
| 60 | TString SamplerString(HLSLTextureSamplerGroup type); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 61 | // Prepends an underscore to avoid naming clashes |
| 62 | TString Decorate(const TString &string); |
Olli Etuaho | f5cfc8d | 2015-08-06 16:36:39 +0300 | [diff] [blame] | 63 | TString DecorateIfNeeded(const TName &name); |
Olli Etuaho | 59f9a64 | 2015-08-06 20:38:26 +0300 | [diff] [blame] | 64 | // Decorates and also unmangles the function name |
| 65 | TString DecorateFunctionIfNeeded(const TName &name); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 66 | TString DecorateUniform(const TString &string, const TType &type); |
| 67 | TString DecorateField(const TString &string, const TStructure &structure); |
| 68 | TString DecoratePrivate(const TString &privateText); |
| 69 | TString TypeString(const TType &type); |
| 70 | TString StructNameString(const TStructure &structure); |
| 71 | TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking, |
| 72 | bool useStd140Packing); |
| 73 | TString InterpolationString(TQualifier qualifier); |
| 74 | TString QualifierString(TQualifier qualifier); |
Olli Etuaho | 9b4e862 | 2015-12-22 15:53:22 +0200 | [diff] [blame] | 75 | int HLSLTextureCoordsCount(const TBasicType samplerType); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 76 | } |
| 77 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 78 | #endif // COMPILER_TRANSLATOR_UTILSHLSL_H_ |