Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / d3d / ShaderD3D.h
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
7 // ShaderD3D.h: Defines the rx::ShaderD3D class which implements rx::ShaderImpl.
8
9 #ifndef LIBGLESV2_RENDERER_SHADERD3D_H_
10 #define LIBGLESV2_RENDERER_SHADERD3D_H_
11
12 #include "libGLESv2/renderer/ShaderImpl.h"
13 #include "libGLESv2/renderer/Workarounds.h"
14 #include "libGLESv2/Shader.h"
15
16 #include <map>
17
18 namespace rx
19 {
20 class DynamicHLSL;
21 class Renderer;
22
23 class ShaderD3D : public ShaderImpl
24 {
25     friend class DynamicHLSL;
26
27   public:
28     ShaderD3D(GLenum type, rx::Renderer *renderer);
29     virtual ~ShaderD3D();
30
31     static ShaderD3D *makeShaderD3D(ShaderImpl *impl);
32     static const ShaderD3D *makeShaderD3D(const ShaderImpl *impl);
33
34     // ShaderImpl implementation
35     virtual const std::string &getInfoLog() const { return mInfoLog; }
36     virtual const std::string &getTranslatedSource() const { return mHlsl; }
37     virtual std::string getDebugInfo() const;
38
39     // D3D-specific methods
40     virtual void uncompile();
41     void resetVaryingsRegisterAssignment();
42     unsigned int getUniformRegister(const std::string &uniformName) const;
43     unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
44     int getSemanticIndex(const std::string &attributeName) const;
45     void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
46
47     rx::D3DWorkaroundType getD3DWorkarounds() const;
48     int getShaderVersion() const { return mShaderVersion; }
49     bool usesDepthRange() const { return mUsesDepthRange; }
50     bool usesPointSize() const { return mUsesPointSize; }
51
52     static void releaseCompiler();
53     static ShShaderOutput getCompilerOutputType(GLenum shader);
54
55     virtual bool compile(const std::string &source);
56
57   private:
58     DISALLOW_COPY_AND_ASSIGN(ShaderD3D);
59
60     void compileToHLSL(void *compiler, const std::string &source);
61     void parseVaryings(void *compiler);
62
63     void initializeCompiler();
64     void parseAttributes(void *compiler);
65     void *getCompiler();
66
67     static bool compareVarying(const gl::PackedVarying &x, const gl::PackedVarying &y);
68
69     static void *mFragmentCompiler;
70     static void *mVertexCompiler;
71
72     GLenum mType;
73     rx::Renderer *mRenderer;
74
75     int mShaderVersion;
76
77     bool mUsesMultipleRenderTargets;
78     bool mUsesFragColor;
79     bool mUsesFragData;
80     bool mUsesFragCoord;
81     bool mUsesFrontFacing;
82     bool mUsesPointSize;
83     bool mUsesPointCoord;
84     bool mUsesDepthRange;
85     bool mUsesFragDepth;
86     bool mUsesDiscardRewriting;
87     bool mUsesNestedBreak;
88
89     std::string mHlsl;
90     std::string mInfoLog;
91     std::string mDebugInfo;
92     std::map<std::string, unsigned int> mUniformRegisterMap;
93     std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
94 };
95
96 }
97
98 #endif // LIBGLESV2_RENDERER_SHADERD3D_H_