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 LIBANGLE_RENDERER_D3D_SHADERD3D_H_
10 #define LIBANGLE_RENDERER_D3D_SHADERD3D_H_
11 
12 #include "libANGLE/renderer/ShaderImpl.h"
13 
14 #include <map>
15 
16 namespace angle
17 {
18 struct CompilerWorkaroundsD3D;
19 struct WorkaroundsD3D;
20 }
21 
22 namespace gl
23 {
24 struct Extensions;
25 }
26 
27 namespace rx
28 {
29 class DynamicHLSL;
30 class RendererD3D;
31 struct D3DUniform;
32 
33 class ShaderD3D : public ShaderImpl
34 {
35   public:
36     ShaderD3D(const gl::ShaderState &data,
37               const angle::WorkaroundsD3D &workarounds,
38               const gl::Extensions &extensions);
39     ~ShaderD3D() override;
40 
41     // ShaderImpl implementation
42     ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
43                                                    std::string *sourcePath) override;
44     bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
45     std::string getDebugInfo() const override;
46 
47     // D3D-specific methods
48     void uncompile();
49 
50     bool hasUniform(const std::string &name) const;
51 
52     // Query regular uniforms with their name. Query sampler fields of structs with field selection
53     // using dot (.) operator.
54     unsigned int getUniformRegister(const std::string &uniformName) const;
55 
56     unsigned int getUniformBlockRegister(const std::string &blockName) const;
appendDebugInfo(const std::string & info)57     void appendDebugInfo(const std::string &info) const { mDebugInfo += info; }
58 
59     void generateWorkarounds(angle::CompilerWorkaroundsD3D *workarounds) const;
60 
usesMultipleRenderTargets()61     bool usesMultipleRenderTargets() const { return mUsesMultipleRenderTargets; }
usesFragColor()62     bool usesFragColor() const { return mUsesFragColor; }
usesFragData()63     bool usesFragData() const { return mUsesFragData; }
usesFragCoord()64     bool usesFragCoord() const { return mUsesFragCoord; }
usesFrontFacing()65     bool usesFrontFacing() const { return mUsesFrontFacing; }
usesPointSize()66     bool usesPointSize() const { return mUsesPointSize; }
usesPointCoord()67     bool usesPointCoord() const { return mUsesPointCoord; }
usesDepthRange()68     bool usesDepthRange() const { return mUsesDepthRange; }
usesFragDepth()69     bool usesFragDepth() const { return mUsesFragDepth; }
usesViewID()70     bool usesViewID() const { return mUsesViewID; }
hasANGLEMultiviewEnabled()71     bool hasANGLEMultiviewEnabled() const { return mHasANGLEMultiviewEnabled; }
72 
73     ShShaderOutput getCompilerOutputType() const;
74 
75   private:
76     bool mUsesMultipleRenderTargets;
77     bool mUsesFragColor;
78     bool mUsesFragData;
79     bool mUsesFragCoord;
80     bool mUsesFrontFacing;
81     bool mUsesPointSize;
82     bool mUsesPointCoord;
83     bool mUsesDepthRange;
84     bool mUsesFragDepth;
85     bool mHasANGLEMultiviewEnabled;
86     bool mUsesViewID;
87     bool mUsesDiscardRewriting;
88     bool mUsesNestedBreak;
89     bool mRequiresIEEEStrictCompiling;
90 
91     ShShaderOutput mCompilerOutputType;
92     mutable std::string mDebugInfo;
93     std::map<std::string, unsigned int> mUniformRegisterMap;
94     std::map<std::string, unsigned int> mUniformBlockRegisterMap;
95     ShCompileOptions mAdditionalOptions;
96 };
97 }  // namespace rx
98 
99 #endif  // LIBANGLE_RENDERER_D3D_SHADERD3D_H_
100