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.
7 // ShaderD3D.h: Defines the rx::ShaderD3D class which implements rx::ShaderImpl.
9 #ifndef LIBGLESV2_RENDERER_SHADERD3D_H_
10 #define LIBGLESV2_RENDERER_SHADERD3D_H_
12 #include "libGLESv2/renderer/ShaderImpl.h"
13 #include "libGLESv2/renderer/Workarounds.h"
14 #include "libGLESv2/Shader.h"
23 class ShaderD3D : public ShaderImpl
25 friend class DynamicHLSL;
28 ShaderD3D(GLenum type, rx::Renderer *renderer);
31 static ShaderD3D *makeShaderD3D(ShaderImpl *impl);
32 static const ShaderD3D *makeShaderD3D(const ShaderImpl *impl);
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;
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; }
47 rx::D3DWorkaroundType getD3DWorkarounds() const;
48 int getShaderVersion() const { return mShaderVersion; }
49 bool usesDepthRange() const { return mUsesDepthRange; }
50 bool usesPointSize() const { return mUsesPointSize; }
52 static void releaseCompiler();
53 static ShShaderOutput getCompilerOutputType(GLenum shader);
55 virtual bool compile(const std::string &source);
58 DISALLOW_COPY_AND_ASSIGN(ShaderD3D);
60 void compileToHLSL(void *compiler, const std::string &source);
61 void parseVaryings(void *compiler);
63 void initializeCompiler();
64 void parseAttributes(void *compiler);
67 static bool compareVarying(const gl::PackedVarying &x, const gl::PackedVarying &y);
69 static void *mFragmentCompiler;
70 static void *mVertexCompiler;
73 rx::Renderer *mRenderer;
77 bool mUsesMultipleRenderTargets;
81 bool mUsesFrontFacing;
86 bool mUsesDiscardRewriting;
87 bool mUsesNestedBreak;
91 std::string mDebugInfo;
92 std::map<std::string, unsigned int> mUniformRegisterMap;
93 std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
98 #endif // LIBGLESV2_RENDERER_SHADERD3D_H_