blob: 748b3513e6995bddadb41193b63dc1d257c59ccd [file] [log] [blame]
Jamie Madill033dae62014-06-18 12:56:28 -04001//
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 Lang0a73dd82014-11-19 16:18:08 -050010#ifndef COMPILER_TRANSLATOR_UTILSHLSL_H_
11#define COMPILER_TRANSLATOR_UTILSHLSL_H_
Jamie Madill033dae62014-06-18 12:56:28 -040012
13#include <vector>
Olli Etuahobe59c2f2016-03-07 11:32:34 +020014#include "compiler/translator/IntermNode.h"
Jamie Madill033dae62014-06-18 12:56:28 -040015#include "compiler/translator/Types.h"
16
Jamie Madillf51639a2014-06-25 16:04:57 -040017#include "angle_gl.h"
Jamie Madill033dae62014-06-18 12:56:28 -040018
Olli Etuahof5cfc8d2015-08-06 16:36:39 +030019class TName;
20
Jamie Madill033dae62014-06-18 12:56:28 -040021namespace sh
22{
23
Olli Etuaho9b4e8622015-12-22 15:53:22 +020024// Unique combinations of HLSL Texture type and HLSL Sampler type.
25enum 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
54HLSLTextureSamplerGroup TextureGroup(const TBasicType type);
55TString TextureString(const HLSLTextureSamplerGroup type);
56TString TextureString(const TBasicType type);
57TString TextureGroupSuffix(const HLSLTextureSamplerGroup type);
58TString TextureGroupSuffix(const TBasicType type);
59TString TextureTypeSuffix(const TBasicType type);
60TString SamplerString(const TBasicType type);
61TString SamplerString(HLSLTextureSamplerGroup type);
Jamie Madill033dae62014-06-18 12:56:28 -040062// Prepends an underscore to avoid naming clashes
63TString Decorate(const TString &string);
Olli Etuahof5cfc8d2015-08-06 16:36:39 +030064TString DecorateIfNeeded(const TName &name);
Olli Etuaho59f9a642015-08-06 20:38:26 +030065// Decorates and also unmangles the function name
66TString DecorateFunctionIfNeeded(const TName &name);
Olli Etuaho96963162016-03-21 11:54:33 +020067TString DecorateUniform(const TName &name, const TType &type);
Jamie Madill033dae62014-06-18 12:56:28 -040068TString DecorateField(const TString &string, const TStructure &structure);
69TString DecoratePrivate(const TString &privateText);
70TString TypeString(const TType &type);
71TString StructNameString(const TStructure &structure);
72TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking,
73 bool useStd140Packing);
74TString InterpolationString(TQualifier qualifier);
75TString QualifierString(TQualifier qualifier);
Olli Etuahobe59c2f2016-03-07 11:32:34 +020076// Parameters may need to be included in function names to disambiguate between overloaded
77// functions.
78TString DisambiguateFunctionName(const TIntermSequence *parameters);
Jamie Madill033dae62014-06-18 12:56:28 -040079}
80
Geoff Lang0a73dd82014-11-19 16:18:08 -050081#endif // COMPILER_TRANSLATOR_UTILSHLSL_H_