blob: 42444e3a569604c0ac0a33bef8d2ad8f1ab66458 [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>
14#include "compiler/translator/Types.h"
15
Jamie Madillf51639a2014-06-25 16:04:57 -040016#include "angle_gl.h"
Jamie Madill033dae62014-06-18 12:56:28 -040017
Olli Etuahof5cfc8d2015-08-06 16:36:39 +030018class TName;
19
Jamie Madill033dae62014-06-18 12:56:28 -040020namespace sh
21{
22
Olli Etuaho9b4e8622015-12-22 15:53:22 +020023// Unique combinations of HLSL Texture type and HLSL Sampler type.
24enum 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
53HLSLTextureSamplerGroup TextureGroup(const TBasicType type);
54TString TextureString(const HLSLTextureSamplerGroup type);
55TString TextureString(const TBasicType type);
56TString TextureGroupSuffix(const HLSLTextureSamplerGroup type);
57TString TextureGroupSuffix(const TBasicType type);
58TString TextureTypeSuffix(const TBasicType type);
59TString SamplerString(const TBasicType type);
60TString SamplerString(HLSLTextureSamplerGroup type);
Jamie Madill033dae62014-06-18 12:56:28 -040061// Prepends an underscore to avoid naming clashes
62TString Decorate(const TString &string);
Olli Etuahof5cfc8d2015-08-06 16:36:39 +030063TString DecorateIfNeeded(const TName &name);
Olli Etuaho59f9a642015-08-06 20:38:26 +030064// Decorates and also unmangles the function name
65TString DecorateFunctionIfNeeded(const TName &name);
Jamie Madill033dae62014-06-18 12:56:28 -040066TString DecorateUniform(const TString &string, const TType &type);
67TString DecorateField(const TString &string, const TStructure &structure);
68TString DecoratePrivate(const TString &privateText);
69TString TypeString(const TType &type);
70TString StructNameString(const TStructure &structure);
71TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking,
72 bool useStd140Packing);
73TString InterpolationString(TQualifier qualifier);
74TString QualifierString(TQualifier qualifier);
Olli Etuaho9b4e8622015-12-22 15:53:22 +020075int HLSLTextureCoordsCount(const TBasicType samplerType);
Jamie Madill033dae62014-06-18 12:56:28 -040076}
77
Geoff Lang0a73dd82014-11-19 16:18:08 -050078#endif // COMPILER_TRANSLATOR_UTILSHLSL_H_