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 // ProgramD3D.h: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
      8 
      9 #ifndef LIBGLESV2_RENDERER_PROGRAMD3D_H_
     10 #define LIBGLESV2_RENDERER_PROGRAMD3D_H_
     11 
     12 #include "libGLESv2/renderer/ProgramImpl.h"
     13 
     14 #include <string>
     15 #include <vector>
     16 
     17 namespace gl
     18 {
     19 struct LinkedUniform;
     20 struct VariableLocation;
     21 struct VertexFormat;
     22 }
     23 
     24 namespace rx
     25 {
     26 
     27 class UniformStorage;
     28 
     29 class ProgramD3D : public ProgramImpl
     30 {
     31   public:
     32     ProgramD3D(rx::Renderer *renderer);
     33     virtual ~ProgramD3D();
     34 
     35     static ProgramD3D *makeProgramD3D(ProgramImpl *impl);
     36     static const ProgramD3D *makeProgramD3D(const ProgramImpl *impl);
     37 
     38     Renderer *getRenderer() { return mRenderer; }
     39     DynamicHLSL *getDynamicHLSL() { return mDynamicHLSL; }
     40     const std::vector<rx::PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; }
     41 
     42     GLenum getBinaryFormat() { return GL_PROGRAM_BINARY_ANGLE; }
     43     bool load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream);
     44     bool save(gl::BinaryOutputStream *stream);
     45 
     46     ShaderExecutable *getPixelExecutableForOutputLayout(gl::InfoLog &infoLog, const std::vector<GLenum> &outputSignature,
     47                                                         const std::vector<gl::LinkedVarying> &transformFeedbackLinkedVaryings,
     48                                                         bool separatedOutputBuffers);
     49     ShaderExecutable *getVertexExecutableForInputLayout(gl::InfoLog &infoLog,
     50                                                         const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS],
     51                                                         const sh::Attribute shaderAttributes[],
     52                                                         const std::vector<gl::LinkedVarying> &transformFeedbackLinkedVaryings,
     53                                                         bool separatedOutputBuffers);
     54 
     55     bool link(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
     56               const std::vector<std::string> &transformFeedbackVaryings, int *registers,
     57               std::vector<gl::LinkedVarying> *linkedVaryings, std::map<int, gl::VariableLocation> *outputVariables);
     58 
     59     // D3D only
     60     void initializeUniformStorage(const std::vector<gl::LinkedUniform*> &uniforms);
     61 
     62     const UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
     63     const UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
     64 
     65     void reset();
     66 
     67   private:
     68     DISALLOW_COPY_AND_ASSIGN(ProgramD3D);
     69 
     70     Renderer *mRenderer;
     71     DynamicHLSL *mDynamicHLSL;
     72 
     73     std::string mVertexHLSL;
     74     rx::D3DWorkaroundType mVertexWorkarounds;
     75 
     76     std::string mPixelHLSL;
     77     rx::D3DWorkaroundType mPixelWorkarounds;
     78     bool mUsesFragDepth;
     79     std::vector<rx::PixelShaderOutputVariable> mPixelShaderKey;
     80 
     81     UniformStorage *mVertexUniformStorage;
     82     UniformStorage *mFragmentUniformStorage;
     83 };
     84 
     85 }
     86 
     87 #endif // LIBGLESV2_RENDERER_PROGRAMD3D_H_
     88