Loading...
Searching...
No Matches
renderSetupTask.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
8#define PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdx/api.h"
12#include "pxr/imaging/hdx/version.h"
13#include "pxr/imaging/hd/task.h"
14#include "pxr/imaging/hd/tokens.h"
15#include "pxr/imaging/hd/enums.h"
16#include "pxr/imaging/hd/renderPassState.h"
17
18#include "pxr/imaging/cameraUtil/framing.h"
19
20#include "pxr/base/gf/vec2f.h"
21#include "pxr/base/gf/vec4f.h"
22#include "pxr/base/gf/vec4d.h"
23
24#include <memory>
25#include <optional>
26
27PXR_NAMESPACE_OPEN_SCOPE
28
29using HdxRenderSetupTaskSharedPtr =
30 std::shared_ptr<class HdxRenderSetupTask>;
31using HdStRenderPassShaderSharedPtr =
32 std::shared_ptr<class HdStRenderPassShader>;
33using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
34
35using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
36
39
40
53{
54public:
56
57 HDX_API
58 HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id);
59
60 HDX_API
61 ~HdxRenderSetupTask() override;
62
63
64 // APIs used from HdxRenderTask to manage the sync/prepare process.
65 HDX_API
66 void SyncParams(HdSceneDelegate* delegate,
67 HdxRenderTaskParams const &params);
68 HDX_API
69 void PrepareCamera(HdRenderIndex* renderIndex);
70
71 HdRenderPassStateSharedPtr const &GetRenderPassState() const {
72 return _renderPassState;
73 }
74
76 HDX_API
77 void Sync(HdSceneDelegate* delegate,
78 HdTaskContext* ctx,
79 HdDirtyBits* dirtyBits) override;
80
82 HDX_API
83 void Prepare(HdTaskContext* ctx,
84 HdRenderIndex* renderIndex) override;
85
87 HDX_API
88 void Execute(HdTaskContext* ctx) override;
89
90private:
91 HdRenderPassStateSharedPtr _renderPassState;
92 HdStRenderPassShaderSharedPtr _colorRenderPassShader;
93 SdfPath _cameraId;
94 CameraUtilFraming _framing;
95 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
96 // Used when client did not specify the camera framing (more expressive
97 // and preferred).
98 GfVec4d _viewport;
99 HdRenderPassAovBindingVector _aovBindings;
100 HdRenderPassAovBindingVector _aovInputBindings;
101
102 void _SetRenderpassShadersForStorm(
103 HdStRenderPassState *renderPassState,
104 HdResourceRegistrySharedPtr const &resourceRegistry);
105
106 HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex);
107
108 void _PrepareAovBindings(HdTaskContext* ctx, HdRenderIndex* renderIndex);
109
110
111 HdxRenderSetupTask() = delete;
112 HdxRenderSetupTask(const HdxRenderSetupTask &) = delete;
113 HdxRenderSetupTask &operator =(const HdxRenderSetupTask &) = delete;
114};
115
121{
123 // Global Params
124 : overrideColor(0.0)
125 , wireframeColor(0.0)
126 , pointColor(GfVec4f(0,0,0,1))
127 , pointSize(3.0)
128 , enableLighting(false)
129 , alphaThreshold(0.0)
130 , enableSceneMaterials(true)
131 , enableSceneLights(true)
132 , enableClipping(true)
133 // Selection/Masking params
134 , maskColor(1.0f, 0.0f, 0.0f, 1.0f)
135 , indicatorColor(0.0f, 1.0f, 0.0f, 1.0f)
136 , pointSelectedSize(3.0)
137 // Storm render pipeline state
138 , depthBiasUseDefault(true)
139 , depthBiasEnable(false)
140 , depthBiasConstantFactor(0.0f)
141 , depthBiasSlopeFactor(1.0f)
142 , depthFunc(HdCmpFuncLEqual)
143 , depthMaskEnable(true)
144 , stencilFunc(HdCmpFuncAlways)
145 , stencilRef(0)
146 , stencilMask(~0)
147 , stencilFailOp(HdStencilOpKeep)
148 , stencilZFailOp(HdStencilOpKeep)
149 , stencilZPassOp(HdStencilOpKeep)
150 , stencilEnable(false)
151 , blendColorOp(HdBlendOpAdd)
152 , blendColorSrcFactor(HdBlendFactorOne)
153 , blendColorDstFactor(HdBlendFactorZero)
154 , blendAlphaOp(HdBlendOpAdd)
155 , blendAlphaSrcFactor(HdBlendFactorOne)
156 , blendAlphaDstFactor(HdBlendFactorZero)
157 , blendConstantColor(0.0f, 0.0f, 0.0f, 0.0f)
158 , blendEnable(false)
159 , enableAlphaToCoverage(true)
160 , useAovMultiSample(true)
161 , resolveAovMultiSample(true)
162 // Camera framing and viewer state
163 , viewport(0.0)
164 , cullStyle(HdCullStyleBackUnlessDoubleSided)
165 {}
166
167 // ---------------------------------------------------------------------- //
168 // Application rendering state
169 // XXX: Several of the parameters below are specific to (or work only with)
170 // Storm and stem from its integration in Presto and usdview.
171 // ---------------------------------------------------------------------- //
172 // "Global" parameters while rendering.
173 GfVec4f overrideColor;
174 GfVec4f wireframeColor;
175 GfVec4f pointColor;
176 float pointSize;
177 bool enableLighting;
178 float alphaThreshold;
179 bool enableSceneMaterials;
180 bool enableSceneLights;
181 bool enableClipping;
182
183 // Selection/Masking params
184 GfVec4f maskColor;
185 GfVec4f indicatorColor;
186 float pointSelectedSize;
187
188 // AOVs to render to
189 // XXX: As a transitional API, if this is empty it indicates the renderer
190 // should write color and depth to the GL framebuffer.
191 HdRenderPassAovBindingVector aovBindings;
192 HdRenderPassAovBindingVector aovInputBindings;
193
194 // ---------------------------------------------------------------------- //
195 // Render pipeline state for rasterizers.
196 // XXX: These are relevant only for Storm.
197 // ---------------------------------------------------------------------- //
198 bool depthBiasUseDefault; // inherit application GL state
199 bool depthBiasEnable;
200 float depthBiasConstantFactor;
201 float depthBiasSlopeFactor;
202
203 HdCompareFunction depthFunc;
204 bool depthMaskEnable;
205
206 // Stencil
207 HdCompareFunction stencilFunc;
208 int stencilRef;
209 int stencilMask;
210 HdStencilOp stencilFailOp;
211 HdStencilOp stencilZFailOp;
212 HdStencilOp stencilZPassOp;
213 bool stencilEnable;
214
215 // Blending
216 HdBlendOp blendColorOp;
217 HdBlendFactor blendColorSrcFactor;
218 HdBlendFactor blendColorDstFactor;
219 HdBlendOp blendAlphaOp;
220 HdBlendFactor blendAlphaSrcFactor;
221 HdBlendFactor blendAlphaDstFactor;
222 GfVec4f blendConstantColor;
223 bool blendEnable;
224
225 // AlphaToCoverage
226 bool enableAlphaToCoverage;
227
228 // If true (default), render into the multi-sampled AOVs (rather than
229 // the resolved AOVs).
230 bool useAovMultiSample;
231
232 // If true (default), multi-sampled AOVs will be resolved at the end of a
233 // render pass.
234 bool resolveAovMultiSample;
235
236 // ---------------------------------------------------------------------- //
237 // Viewer & Camera Framing state
238 // ---------------------------------------------------------------------- //
239 SdfPath camera;
240 CameraUtilFraming framing;
241 // Only used if framing is invalid.
242 GfVec4d viewport;
243 HdCullStyle cullStyle;
244 std::optional<CameraUtilConformWindowPolicy> overrideWindowPolicy;
245};
246
247// VtValue requirements
248HDX_API
249std::ostream& operator<<(std::ostream& out, const HdxRenderTaskParams& pv);
250HDX_API
251bool operator==(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
252HDX_API
253bool operator!=(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
254
255
256PXR_NAMESPACE_CLOSE_SCOPE
257
258#endif //PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
Framing information.
Definition: framing.h:63
Basic type for a vector of 4 double components.
Definition: vec4d.h:46
Basic type for a vector of 4 float components.
Definition: vec4f.h:46
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
Adapter class providing data exchange with the client scene graph.
A set of rendering parameters used among render passes.
HdTask represents a unit of work to perform during a Hydra render.
Definition: task.h:43
A task for setting up render pass state (camera, renderpass shader, GL states).
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
RenderTask parameters (renderpass state).