• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 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 // TextureFunctionHLSL: Class for writing implementations of ESSL texture functions into HLSL
7 // output. Some of the implementations are straightforward and just call the HLSL equivalent of the
8 // ESSL texture function, others do more work to emulate ESSL texture sampling or size query
9 // behavior.
10 //
11 
12 #ifndef COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_
13 #define COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_
14 
15 #include <set>
16 
17 #include "GLSLANG/ShaderLang.h"
18 #include "compiler/translator/BaseTypes.h"
19 #include "compiler/translator/Common.h"
20 #include "compiler/translator/InfoSink.h"
21 
22 namespace sh
23 {
24 
25 class TextureFunctionHLSL final : angle::NonCopyable
26 {
27   public:
28     struct TextureFunction
29     {
30         // See ESSL 3.00.6 section 8.8 for reference about what the different methods below do.
31         enum Method
32         {
33             IMPLICIT,  // Mipmap LOD determined implicitly (standard lookup)
34             BIAS,
35             LOD,
36             LOD0,
37             LOD0BIAS,
38             SIZE,  // textureSize()
39             FETCH,
40             GRAD,
41             GATHER
42         };
43 
44         ImmutableString name() const;
45 
46         bool operator<(const TextureFunction &rhs) const;
47 
48         const char *getReturnType() const;
49 
50         TBasicType sampler;
51         int coords;
52         bool proj;
53         bool offset;
54         Method method;
55     };
56 
57     // Returns the name of the texture function implementation to call.
58     // The name that's passed in is the name of the GLSL texture function that it should implement.
59     ImmutableString useTextureFunction(const ImmutableString &name,
60                                        TBasicType samplerType,
61                                        int coords,
62                                        size_t argumentCount,
63                                        bool lod0,
64                                        sh::GLenum shaderType);
65 
66     void textureFunctionHeader(TInfoSinkBase &out,
67                                const ShShaderOutput outputType,
68                                bool getDimensionsIgnoresBaseLevel);
69 
70   private:
71     typedef std::set<TextureFunction> TextureFunctionSet;
72     TextureFunctionSet mUsesTexture;
73 };
74 
75 }  // namespace sh
76 
77 #endif  // COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_
78