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