HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderSetupTask.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_HDX_RENDER_SETUP_TASK_H
25 #define PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hd/task.h"
31 #include "pxr/imaging/hd/tokens.h"
32 #include "pxr/imaging/hd/enums.h"
34 
36 
37 #include "pxr/base/gf/vec2f.h"
38 #include "pxr/base/gf/vec4f.h"
39 #include "pxr/base/gf/vec4d.h"
40 
41 #include <memory>
42 
44 
46  std::shared_ptr<class HdxRenderSetupTask>;
48  std::shared_ptr<class HdStRenderPassShader>;
49 using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
50 
51 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
52 
53 struct HdxRenderTaskParams;
55 
56 
57 /// \class HdxRenderSetupTask
58 ///
59 /// A task for setting up render pass state (camera, renderpass shader, GL
60 /// states).
61 ///
62 /// HdxRenderTask depends on the output of this task. Applications can choose
63 /// to create a render setup task, and pass it the HdxRenderTaskParams; or they
64 /// can pass the HdxRenderTaskParams directly to the render task, which will
65 /// create a render setup task internally. See the HdxRenderTask documentation
66 /// for details.
67 ///
68 class HdxRenderSetupTask : public HdTask
69 {
70 public:
71  HDX_API
72  HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id);
73 
74  HDX_API
75  ~HdxRenderSetupTask() override;
76 
77 
78  // APIs used from HdxRenderTask to manage the sync/prepare process.
79  HDX_API
80  void SyncParams(HdSceneDelegate* delegate,
82  HDX_API
83  void PrepareCamera(HdRenderIndex* renderIndex);
84 
86  return _renderPassState;
87  }
88 
89  /// Sync the render pass resources
90  HDX_API
91  void Sync(HdSceneDelegate* delegate,
92  HdTaskContext* ctx,
93  HdDirtyBits* dirtyBits) override;
94 
95  /// Prepare the tasks resources
96  HDX_API
97  void Prepare(HdTaskContext* ctx,
98  HdRenderIndex* renderIndex) override;
99 
100  /// Execute render pass task
101  HDX_API
102  void Execute(HdTaskContext* ctx) override;
103 
104 private:
105  HdRenderPassStateSharedPtr _renderPassState;
106  HdStRenderPassShaderSharedPtr _colorRenderPassShader;
107  HdStRenderPassShaderSharedPtr _idRenderPassShader;
108  SdfPath _cameraId;
109  CameraUtilFraming _framing;
110  std::pair<bool, CameraUtilConformWindowPolicy> _overrideWindowPolicy;
111  // Used when client did not specify the camera framing (more expressive
112  // and preferred).
113  GfVec4d _viewport;
114  HdRenderPassAovBindingVector _aovBindings;
115  HdRenderPassAovBindingVector _aovInputBindings;
116 
117  void _SetRenderpassShadersForStorm(
118  HdxRenderTaskParams const& params,
119  HdStRenderPassState *renderPassState);
120 
121  HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex);
122 
123  void _PrepareAovBindings(HdTaskContext* ctx, HdRenderIndex* renderIndex);
124 
125 
126  HdxRenderSetupTask() = delete;
127  HdxRenderSetupTask(const HdxRenderSetupTask &) = delete;
128  HdxRenderSetupTask &operator =(const HdxRenderSetupTask &) = delete;
129 };
130 
131 /// \class HdxRenderTaskParams
132 ///
133 /// RenderTask parameters (renderpass state).
134 ///
136 {
138  // Global Params
139  : overrideColor(0.0)
140  , wireframeColor(0.0)
141  , pointColor(GfVec4f(0,0,0,1))
142  , pointSize(3.0)
143  , enableLighting(false)
144  , enableIdRender(false)
145  , alphaThreshold(0.0)
146  , enableSceneMaterials(true)
147  , enableSceneLights(true)
148  , enableClipping(true)
149  // Selection/Masking params
150  , maskColor(1.0f, 0.0f, 0.0f, 1.0f)
151  , indicatorColor(0.0f, 1.0f, 0.0f, 1.0f)
152  , pointSelectedSize(3.0)
153  // Storm render pipeline state
154  , depthBiasUseDefault(true)
155  , depthBiasEnable(false)
157  , depthBiasSlopeFactor(1.0f)
159  , depthMaskEnable(true)
161  , stencilRef(0)
162  , stencilMask(~0)
166  , stencilEnable(false)
173  , blendConstantColor(0.0f, 0.0f, 0.0f, 0.0f)
174  , blendEnable(false)
175  , enableAlphaToCoverage(true)
176  , useAovMultiSample(true)
177  , resolveAovMultiSample(true)
178  // Camera framing and viewer state
179  , viewport(0.0)
182  {}
183 
184  // ---------------------------------------------------------------------- //
185  // Application rendering state
186  // XXX: Several of the parameters below are specific to (or work only with)
187  // Storm and stem from its integration in Presto and usdview.
188  // ---------------------------------------------------------------------- //
189  // "Global" parameters while rendering.
193  float pointSize;
200 
201  // Selection/Masking params
205 
206  // AOVs to render to
207  // XXX: As a transitional API, if this is empty it indicates the renderer
208  // should write color and depth to the GL framebuffer.
211 
212  // ---------------------------------------------------------------------- //
213  // Render pipeline state for rasterizers.
214  // XXX: These are relevant only for Storm.
215  // ---------------------------------------------------------------------- //
216  bool depthBiasUseDefault; // inherit application GL state
220 
223 
224  // Stencil
232 
233  // Blending
242 
243  // AlphaToCoverage
245 
246  // If true (default), render into the multi-sampled AOVs (rather than
247  // the resolved AOVs).
249 
250  // If true (default), multi-sampled AOVs will be resolved at the end of a
251  // render pass.
253 
254  // ---------------------------------------------------------------------- //
255  // Viewer & Camera Framing state
256  // ---------------------------------------------------------------------- //
259  // Only used if framing is invalid.
262  std::pair<bool, CameraUtilConformWindowPolicy> overrideWindowPolicy;
263 };
264 
265 // VtValue requirements
266 HDX_API
267 std::ostream& operator<<(std::ostream& out, const HdxRenderTaskParams& pv);
268 HDX_API
269 bool operator==(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
270 HDX_API
271 bool operator!=(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
272 
273 
275 
276 #endif //PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
HdBlendFactor blendAlphaDstFactor
HdStencilOp stencilZFailOp
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:42
HdCompareFunction
Definition: enums.h:36
std::shared_ptr< class HdStShaderCode > HdStShaderCodeSharedPtr
HdCullStyle
Definition: enums.h:122
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HdBlendFactor blendAlphaSrcFactor
uint32_t HdDirtyBits
Definition: types.h:158
HdRenderPassAovBindingVector aovInputBindings
HdCompareFunction stencilFunc
HdStencilOp stencilFailOp
Definition: vec4d.h:62
HdBlendFactor
Definition: enums.h:87
#define HDX_API
Definition: api.h:40
GLenum const GLfloat * params
Definition: glcorearb.h:105
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
HdStencilOp stencilZPassOp
std::pair< bool, CameraUtilConformWindowPolicy > overrideWindowPolicy
GLfloat f
Definition: glcorearb.h:1926
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
CameraUtilFraming framing
Definition: task.h:54
Definition: path.h:291
HdStencilOp
Definition: enums.h:54
HDX_API void SyncParams(HdSceneDelegate *delegate, HdxRenderTaskParams const &params)
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
Definition: vec4f.h:62
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HdRenderPassStateSharedPtr const & GetRenderPassState() const
std::shared_ptr< class HdxRenderSetupTask > HdxRenderSetupTaskSharedPtr
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDX_API std::ostream & operator<<(std::ostream &out, const HdxRenderTaskParams &pv)
HdBlendFactor blendColorSrcFactor
HDX_API void PrepareCamera(HdRenderIndex *renderIndex)
HdRenderPassAovBindingVector aovBindings
HdBlendOp
Definition: enums.h:72
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:154
HdCompareFunction depthFunc
HdBlendFactor blendColorDstFactor
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HDX_API ~HdxRenderSetupTask() override
Increase width or height.
Definition: conformWindow.h:50