1 // 2 // Copyright 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 LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_ 10 #define LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_ 11 12 #include <string> 13 #include <vector> 14 15 #include "compiler/translator/hlsl/blocklayoutHLSL.h" 16 #include "libANGLE/Constants.h" 17 #include "libANGLE/formatutils.h" 18 #include "libANGLE/renderer/ProgramImpl.h" 19 #include "libANGLE/renderer/d3d/ProgramExecutableD3D.h" 20 #include "libANGLE/renderer/d3d/RendererD3D.h" 21 #include "libANGLE/renderer/d3d/ShaderD3D.h" 22 #include "platform/autogen/FeaturesD3D_autogen.h" 23 24 namespace rx 25 { 26 class RendererD3D; 27 28 class ProgramD3DMetadata final : angle::NonCopyable 29 { 30 public: 31 ProgramD3DMetadata(RendererD3D *renderer, 32 const gl::SharedCompiledShaderState &fragmentShader, 33 const gl::ShaderMap<SharedCompiledShaderStateD3D> &attachedShaders, 34 EGLenum clientType, 35 int shaderVersion); 36 ~ProgramD3DMetadata(); 37 38 int getRendererMajorShaderModel() const; 39 bool usesBroadcast(const gl::Version &clientVersion) const; 40 bool usesSecondaryColor() const; 41 bool usesPointCoord() const; 42 bool usesFragCoord() const; 43 bool usesPointSize() const; 44 bool usesInsertedPointCoordValue() const; 45 bool usesViewScale() const; 46 bool hasMultiviewEnabled() const; 47 bool usesVertexID() const; 48 bool usesViewID() const; 49 bool canSelectViewInVertexShader() const; 50 bool addsPointCoordToVertexShader() const; 51 bool usesTransformFeedbackGLPosition() const; 52 bool usesSystemValuePointSize() const; 53 bool usesMultipleFragmentOuts() const; 54 bool usesCustomOutVars() const; 55 bool usesSampleMask() const; 56 const gl::SharedCompiledShaderState &getFragmentShader() const; 57 FragDepthUsage getFragDepthUsage() const; 58 uint8_t getClipDistanceArraySize() const; 59 uint8_t getCullDistanceArraySize() const; 60 61 private: 62 const int mRendererMajorShaderModel; 63 const std::string mShaderModelSuffix; 64 const bool mUsesInstancedPointSpriteEmulation; 65 const bool mUsesViewScale; 66 const bool mCanSelectViewInVertexShader; 67 gl::SharedCompiledShaderState mFragmentShader; 68 const gl::ShaderMap<SharedCompiledShaderStateD3D> &mAttachedShaders; 69 const EGLenum mClientType; 70 int mShaderVersion; 71 }; 72 73 class ProgramD3D : public ProgramImpl 74 { 75 public: 76 ProgramD3D(const gl::ProgramState &data, RendererD3D *renderer); 77 ~ProgramD3D() override; 78 79 void destroy(const gl::Context *context) override; 80 81 angle::Result load(const gl::Context *context, 82 gl::BinaryInputStream *stream, 83 std::shared_ptr<LinkTask> *loadTaskOut, 84 egl::CacheGetResult *resultOut) override; 85 void save(const gl::Context *context, gl::BinaryOutputStream *stream) override; 86 void setBinaryRetrievableHint(bool retrievable) override; 87 void setSeparable(bool separable) override; 88 89 void prepareForLink(const gl::ShaderMap<ShaderImpl *> &shaders) override; 90 angle::Result link(const gl::Context *context, std::shared_ptr<LinkTask> *linkTaskOut) override; 91 GLboolean validate(const gl::Caps &caps) override; 92 getState()93 const gl::ProgramState &getState() const { return mState; } 94 getExecutable()95 const ProgramExecutableD3D *getExecutable() const 96 { 97 return GetImplAs<ProgramExecutableD3D>(&mState.getExecutable()); 98 } getExecutable()99 ProgramExecutableD3D *getExecutable() 100 { 101 return GetImplAs<ProgramExecutableD3D>(&mState.getExecutable()); 102 } 103 104 private: 105 class GetVertexExecutableTask; 106 class GetPixelExecutableTask; 107 class GetGeometryExecutableTask; 108 class GetComputeExecutableTask; 109 class LinkLoadTaskD3D; 110 class LinkTaskD3D; 111 class LoadTaskD3D; 112 113 friend class LinkTaskD3D; 114 friend class LoadTaskD3D; 115 116 angle::Result linkJobImpl(d3d::Context *context, 117 const gl::Caps &caps, 118 const gl::Version &clientVersion, 119 EGLenum clientType, 120 const gl::ProgramLinkedResources &resources, 121 const gl::ProgramMergedVaryings &mergedVaryings); getAttachedShader(gl::ShaderType shaderType)122 const SharedCompiledShaderStateD3D &getAttachedShader(gl::ShaderType shaderType) 123 { 124 return getExecutable()->mAttachedShaders[shaderType]; 125 } 126 127 void linkResources(const gl::ProgramLinkedResources &resources); 128 129 RendererD3D *mRenderer; 130 }; 131 } // namespace rx 132 133 #endif // LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_ 134