HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderPassState.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_ST_RENDER_PASS_STATE_H
25 #define PXR_IMAGING_HD_ST_RENDER_PASS_STATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
31 
32 #include <memory>
33 
35 
36 using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
37 using HdStRenderPassStateSharedPtr = std::shared_ptr<class HdStRenderPassState>;
38 
39 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
40 
41 using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
42 using HdStLightingShaderSharedPtr = std::shared_ptr<class HdStLightingShader>;
44  std::shared_ptr<class HdStRenderPassShader>;
46  std::shared_ptr<class HdSt_FallbackLightingShader>;
47 using HdStShaderCodeSharedPtrVector = std::vector<HdStShaderCodeSharedPtr>;
48 class HdRenderIndex;
49 
50 /// \class HdStRenderPassState
51 ///
52 /// A set of rendering parameters used among render passes.
53 ///
54 /// Parameters are expressed as GL states, uniforms or shaders.
55 ///
57 {
58 public:
59  HDST_API
61  HDST_API
63  HDST_API
64  ~HdStRenderPassState() override;
65 
66  HDST_API
67  void
68  Prepare(HdResourceRegistrySharedPtr const &resourceRegistry) override;
69 
70  /// XXX: Bind and Unbind set./restore the following GL state.
71  /// This will be reworked to use Hgi in the near future.
72  /// Following states may be changed and restored to
73  /// the GL default at Unbind().
74  /// glEnable(GL_BLEND);
75  /// glEnable(GL_CULL_FACE);
76  /// glEnable(GL_POLYGON_OFFSET_FILL)
77  /// glEnable(GL_PROGRAM_POINT_SIZE);
78  /// glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
79  /// glEnable(GL_DEPTH_TEST);
80  /// glEnable(GL_STENCIL_TEST);
81  /// glPolygonOffset()
82  /// glBlend*()
83  /// glColorMask()
84  /// glCullFace()
85  /// glDepthFunc()
86  /// glDepthMask()
87  /// glLineWidth()
88  /// glStencilFunc()
89  /// glStencilOp()
90  HDST_API
91  void Bind();
92  HDST_API
93  void Unbind();
94 
95  /// If set to true (default) and the render pass is rendering into a
96  /// multi-sampled aovs, the aovs will be resolved at the end of the render
97  /// pass. If false or the aov is not multi-sampled or the render pass is not
98  /// rendering into the multi-sampled aov, no resolution takes place.
99  HD_API
100  void SetResolveAovMultiSample(bool state);
101  HD_API
102  bool GetResolveAovMultiSample() const;
103 
104  /// Set lighting shader
105  HDST_API
106  void SetLightingShader(HdStLightingShaderSharedPtr const &lightingShader);
108  return _lightingShader;
109  }
110 
111  /// renderpass shader
112  HDST_API
113  void SetRenderPassShader(HdStRenderPassShaderSharedPtr const &renderPassShader);
115  return _renderPassShader;
116  }
117 
118  /// scene materials
119  HDST_API
120  void SetUseSceneMaterials(bool state);
121  bool GetUseSceneMaterials() const {
122  return _useSceneMaterials;
123  }
124 
125  /// returns shaders (lighting/renderpass)
126  HDST_API
128 
129  HDST_API
130  size_t GetShaderHash() const;
131 
132  /// Camera setter API
133  /// Option 1: Specify matrices, viewport and clipping planes (defined in
134  /// camera space) directly.
135  HD_API
136  void SetCameraFramingState(GfMatrix4d const &worldToViewMatrix,
137  GfMatrix4d const &projectionMatrix,
138  GfVec4d const &viewport,
139  ClipPlanesVector const & clipPlanes);
140 
141  // Helper to get graphics cmds descriptor describing textures
142  // we render into and the blend state, constructed from
143  // AOV bindings.
144  //
145  HDST_API
147 
148 private:
149  bool _UseAlphaMask() const;
150 
151  // ---------------------------------------------------------------------- //
152  // Shader Objects
153  // ---------------------------------------------------------------------- //
154  HdStRenderPassShaderSharedPtr _renderPassShader;
155  HdSt_FallbackLightingShaderSharedPtr _fallbackLightingShader;
156  HdStLightingShaderSharedPtr _lightingShader;
157 
158  HdBufferArrayRangeSharedPtr _renderPassStateBar;
159  size_t _clipPlanesBufferSize;
160  float _alphaThresholdCurrent;
161  bool _resolveMultiSampleAov;
162  bool _useSceneMaterials;
163 };
164 
166 
167 #endif // PXR_IMAGING_HD_ST_RENDER_PASS_STATE_H
HDST_API HgiGraphicsCmdsDesc MakeGraphicsCmdsDesc(const HdRenderIndex *) const
HDST_API ~HdStRenderPassState() override
HDST_API void SetUseSceneMaterials(bool state)
scene materials
HDST_API void SetLightingShader(HdStLightingShaderSharedPtr const &lightingShader)
Set lighting shader.
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
std::shared_ptr< class HdStLightingShader > HdStLightingShaderSharedPtr
HDST_API void SetRenderPassShader(HdStRenderPassShaderSharedPtr const &renderPassShader)
renderpass shader
HDST_API size_t GetShaderHash() const
#define HD_API
Definition: api.h:40
HD_API bool GetResolveAovMultiSample() const
Definition: vec4d.h:63
HdStLightingShaderSharedPtr const & GetLightingShader() const
std::shared_ptr< class HdSt_FallbackLightingShader > HdSt_FallbackLightingShaderSharedPtr
std::shared_ptr< class HdStRenderPassState > HdStRenderPassStateSharedPtr
Definition: commandBuffer.h:45
std::vector< GfVec4d > ClipPlanesVector
HDST_API void Bind()
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
GLuint shader
Definition: glcorearb.h:784
HDST_API HdStRenderPassState()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
HDST_API void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry) override
#define HDST_API
Definition: api.h:40
std::vector< HdStShaderCodeSharedPtr > HdStShaderCodeSharedPtrVector
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:45
HD_API void SetCameraFramingState(GfMatrix4d const &worldToViewMatrix, GfMatrix4d const &projectionMatrix, GfVec4d const &viewport, ClipPlanesVector const &clipPlanes)
HDST_API void Unbind()
bool GetUseSceneMaterials() const
HdStRenderPassShaderSharedPtr const & GetRenderPassShader() const
std::shared_ptr< class HdStShaderCode > HdStShaderCodeSharedPtr
Definition: drawItem.h:34
HDST_API HdStShaderCodeSharedPtrVector GetShaders() const
returns shaders (lighting/renderpass)
HD_API void SetResolveAovMultiSample(bool state)