blob: 37edce40edac94a058e7c3864d655b5f44c56cde [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,
Olli Etuaho92db39e2017-02-15 12:11:04 +000034 HLSL_TEXTURE_2D_MS,
Olli Etuaho9b4e8622015-12-22 15:53:22 +020035 HLSL_TEXTURE_2D_INT4,
36 HLSL_TEXTURE_3D_INT4,
37 HLSL_TEXTURE_2D_ARRAY_INT4,
Olli Etuaho92db39e2017-02-15 12:11:04 +000038 HLSL_TEXTURE_2D_MS_INT4,
Olli Etuaho9b4e8622015-12-22 15:53:22 +020039 HLSL_TEXTURE_2D_UINT4,
40 HLSL_TEXTURE_3D_UINT4,
41 HLSL_TEXTURE_2D_ARRAY_UINT4,
Olli Etuaho92db39e2017-02-15 12:11:04 +000042 HLSL_TEXTURE_2D_MS_UINT4,
Olli Etuaho9b4e8622015-12-22 15:53:22 +020043
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
57HLSLTextureSamplerGroup TextureGroup(const TBasicType type);
58TString TextureString(const HLSLTextureSamplerGroup type);
59TString TextureString(const TBasicType type);
60TString TextureGroupSuffix(const HLSLTextureSamplerGroup type);
61TString TextureGroupSuffix(const TBasicType type);
62TString TextureTypeSuffix(const TBasicType type);
63TString SamplerString(const TBasicType type);
64TString SamplerString(HLSLTextureSamplerGroup type);
Jamie Madill033dae62014-06-18 12:56:28 -040065// Prepends an underscore to avoid naming clashes
66TString Decorate(const TString &string);
Olli Etuahof5cfc8d2015-08-06 16:36:39 +030067TString DecorateIfNeeded(const TName &name);
Olli Etuaho96963162016-03-21 11:54:33 +020068TString DecorateUniform(const TName &name, const TType &type);
Jamie Madill033dae62014-06-18 12:56:28 -040069TString DecorateField(const TString &string, const TStructure &structure);
70TString DecoratePrivate(const TString &privateText);
71TString TypeString(const TType &type);
72TString StructNameString(const TStructure &structure);
Jamie Madilld7b1ab52016-12-12 14:42:19 -050073TString QualifiedStructNameString(const TStructure &structure,
74 bool useHLSLRowMajorPacking,
Jamie Madill033dae62014-06-18 12:56:28 -040075 bool useStd140Packing);
76TString InterpolationString(TQualifier qualifier);
77TString QualifierString(TQualifier qualifier);
Olli Etuahobe59c2f2016-03-07 11:32:34 +020078// Parameters may need to be included in function names to disambiguate between overloaded
79// functions.
80TString DisambiguateFunctionName(const TIntermSequence *parameters);
Jamie Madill033dae62014-06-18 12:56:28 -040081}
82
Jamie Madilld7b1ab52016-12-12 14:42:19 -050083#endif // COMPILER_TRANSLATOR_UTILSHLSL_H_