All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderSetupTask.h
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"
29 #include "pxr/imaging/hdx/version.h"
30 #include "pxr/imaging/hd/task.h"
31 #include "pxr/imaging/hd/tokens.h"
32 #include "pxr/imaging/hd/enums.h"
33 #include "pxr/imaging/hd/renderPassState.h"
34 
35 #include "pxr/imaging/cameraUtil/framing.h"
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 
43 PXR_NAMESPACE_OPEN_SCOPE
44 
45 using HdxRenderSetupTaskSharedPtr =
46  std::shared_ptr<class HdxRenderSetupTask>;
47 using HdStRenderPassShaderSharedPtr =
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 
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,
81  HdxRenderTaskParams const &params);
82  HDX_API
83  void PrepareCamera(HdRenderIndex* renderIndex);
84 
85  HdRenderPassStateSharedPtr const &GetRenderPassState() const {
86  return _renderPassState;
87  }
88 
90  HDX_API
91  void Sync(HdSceneDelegate* delegate,
92  HdTaskContext* ctx,
93  HdDirtyBits* dirtyBits) override;
94 
96  HDX_API
97  void Prepare(HdTaskContext* ctx,
98  HdRenderIndex* renderIndex) override;
99 
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 
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)
156  , depthBiasConstantFactor(0.0f)
157  , depthBiasSlopeFactor(1.0f)
158  , depthFunc(HdCmpFuncLEqual)
159  , depthMaskEnable(true)
160  , stencilFunc(HdCmpFuncAlways)
161  , stencilRef(0)
162  , stencilMask(~0)
163  , stencilFailOp(HdStencilOpKeep)
164  , stencilZFailOp(HdStencilOpKeep)
165  , stencilZPassOp(HdStencilOpKeep)
166  , stencilEnable(false)
167  , blendColorOp(HdBlendOpAdd)
168  , blendColorSrcFactor(HdBlendFactorOne)
169  , blendColorDstFactor(HdBlendFactorZero)
170  , blendAlphaOp(HdBlendOpAdd)
171  , blendAlphaSrcFactor(HdBlendFactorOne)
172  , blendAlphaDstFactor(HdBlendFactorZero)
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)
180  , cullStyle(HdCullStyleBackUnlessDoubleSided)
181  , overrideWindowPolicy{false, CameraUtilFit}
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.
190  GfVec4f overrideColor;
191  GfVec4f wireframeColor;
192  GfVec4f pointColor;
193  float pointSize;
194  bool enableLighting;
195  bool enableIdRender;
196  float alphaThreshold;
197  bool enableSceneMaterials;
198  bool enableSceneLights;
199  bool enableClipping;
200 
201  // Selection/Masking params
202  GfVec4f maskColor;
203  GfVec4f indicatorColor;
204  float pointSelectedSize;
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.
209  HdRenderPassAovBindingVector aovBindings;
210  HdRenderPassAovBindingVector aovInputBindings;
211 
212  // ---------------------------------------------------------------------- //
213  // Render pipeline state for rasterizers.
214  // XXX: These are relevant only for Storm.
215  // ---------------------------------------------------------------------- //
216  bool depthBiasUseDefault; // inherit application GL state
217  bool depthBiasEnable;
218  float depthBiasConstantFactor;
219  float depthBiasSlopeFactor;
220 
221  HdCompareFunction depthFunc;
222  bool depthMaskEnable;
223 
224  // Stencil
225  HdCompareFunction stencilFunc;
226  int stencilRef;
227  int stencilMask;
228  HdStencilOp stencilFailOp;
229  HdStencilOp stencilZFailOp;
230  HdStencilOp stencilZPassOp;
231  bool stencilEnable;
232 
233  // Blending
234  HdBlendOp blendColorOp;
235  HdBlendFactor blendColorSrcFactor;
236  HdBlendFactor blendColorDstFactor;
237  HdBlendOp blendAlphaOp;
238  HdBlendFactor blendAlphaSrcFactor;
239  HdBlendFactor blendAlphaDstFactor;
240  GfVec4f blendConstantColor;
241  bool blendEnable;
242 
243  // AlphaToCoverage
244  bool enableAlphaToCoverage;
245 
246  // If true (default), render into the multi-sampled AOVs (rather than
247  // the resolved AOVs).
248  bool useAovMultiSample;
249 
250  // If true (default), multi-sampled AOVs will be resolved at the end of a
251  // render pass.
252  bool resolveAovMultiSample;
253 
254  // ---------------------------------------------------------------------- //
255  // Viewer & Camera Framing state
256  // ---------------------------------------------------------------------- //
257  SdfPath camera;
258  CameraUtilFraming framing;
259  // Only used if framing is invalid.
260  GfVec4d viewport;
261  HdCullStyle cullStyle;
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 
274 PXR_NAMESPACE_CLOSE_SCOPE
275 
276 #endif //PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:116
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
A set of rendering parameters used among render passes.
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
RenderTask parameters (renderpass state).
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
A task for setting up render pass state (camera, renderpass shader, GL states).
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
Framing information.
Definition: framing.h:79