Loading...
Searching...
No Matches
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#include <optional>
43
44PXR_NAMESPACE_OPEN_SCOPE
45
46using HdxRenderSetupTaskSharedPtr =
47 std::shared_ptr<class HdxRenderSetupTask>;
48using HdStRenderPassShaderSharedPtr =
49 std::shared_ptr<class HdStRenderPassShader>;
50using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
51
52using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
53
56
57
69class HdxRenderSetupTask : public HdTask
70{
71public:
72 HDX_API
73 HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id);
74
75 HDX_API
76 ~HdxRenderSetupTask() override;
77
78
79 // APIs used from HdxRenderTask to manage the sync/prepare process.
80 HDX_API
81 void SyncParams(HdSceneDelegate* delegate,
82 HdxRenderTaskParams const &params);
83 HDX_API
84 void PrepareCamera(HdRenderIndex* renderIndex);
85
86 HdRenderPassStateSharedPtr const &GetRenderPassState() const {
87 return _renderPassState;
88 }
89
91 HDX_API
92 void Sync(HdSceneDelegate* delegate,
93 HdTaskContext* ctx,
94 HdDirtyBits* dirtyBits) override;
95
97 HDX_API
98 void Prepare(HdTaskContext* ctx,
99 HdRenderIndex* renderIndex) override;
100
102 HDX_API
103 void Execute(HdTaskContext* ctx) override;
104
105private:
106 HdRenderPassStateSharedPtr _renderPassState;
107 HdStRenderPassShaderSharedPtr _colorRenderPassShader;
108 HdStRenderPassShaderSharedPtr _idRenderPassShader;
109 SdfPath _cameraId;
110 CameraUtilFraming _framing;
111 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
112 // Used when client did not specify the camera framing (more expressive
113 // and preferred).
114 GfVec4d _viewport;
115 HdRenderPassAovBindingVector _aovBindings;
116 HdRenderPassAovBindingVector _aovInputBindings;
117
118 void _SetRenderpassShadersForStorm(
119 HdxRenderTaskParams const& params,
120 HdStRenderPassState *renderPassState);
121
122 HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex);
123
124 void _PrepareAovBindings(HdTaskContext* ctx, HdRenderIndex* renderIndex);
125
126
127 HdxRenderSetupTask() = delete;
128 HdxRenderSetupTask(const HdxRenderSetupTask &) = delete;
129 HdxRenderSetupTask &operator =(const HdxRenderSetupTask &) = delete;
130};
131
137{
139 // Global Params
140 : overrideColor(0.0)
141 , wireframeColor(0.0)
142 , pointColor(GfVec4f(0,0,0,1))
143 , pointSize(3.0)
144 , enableLighting(false)
145 , enableIdRender(false)
146 , alphaThreshold(0.0)
147 , enableSceneMaterials(true)
148 , enableSceneLights(true)
149 , enableClipping(true)
150 // Selection/Masking params
151 , maskColor(1.0f, 0.0f, 0.0f, 1.0f)
152 , indicatorColor(0.0f, 1.0f, 0.0f, 1.0f)
153 , pointSelectedSize(3.0)
154 // Storm render pipeline state
155 , depthBiasUseDefault(true)
156 , depthBiasEnable(false)
157 , depthBiasConstantFactor(0.0f)
158 , depthBiasSlopeFactor(1.0f)
159 , depthFunc(HdCmpFuncLEqual)
160 , depthMaskEnable(true)
161 , stencilFunc(HdCmpFuncAlways)
162 , stencilRef(0)
163 , stencilMask(~0)
164 , stencilFailOp(HdStencilOpKeep)
165 , stencilZFailOp(HdStencilOpKeep)
166 , stencilZPassOp(HdStencilOpKeep)
167 , stencilEnable(false)
168 , blendColorOp(HdBlendOpAdd)
169 , blendColorSrcFactor(HdBlendFactorOne)
170 , blendColorDstFactor(HdBlendFactorZero)
171 , blendAlphaOp(HdBlendOpAdd)
172 , blendAlphaSrcFactor(HdBlendFactorOne)
173 , blendAlphaDstFactor(HdBlendFactorZero)
174 , blendConstantColor(0.0f, 0.0f, 0.0f, 0.0f)
175 , blendEnable(false)
176 , enableAlphaToCoverage(true)
177 , useAovMultiSample(true)
178 , resolveAovMultiSample(true)
179 // Camera framing and viewer state
180 , viewport(0.0)
181 , cullStyle(HdCullStyleBackUnlessDoubleSided)
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::optional<CameraUtilConformWindowPolicy> overrideWindowPolicy;
263};
264
265// VtValue requirements
266HDX_API
267std::ostream& operator<<(std::ostream& out, const HdxRenderTaskParams& pv);
268HDX_API
269bool operator==(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
270HDX_API
271bool operator!=(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
272
273
274PXR_NAMESPACE_CLOSE_SCOPE
275
276#endif //PXR_IMAGING_HDX_RENDER_SETUP_TASK_H
Framing information.
Definition: framing.h:80
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
Adapter class providing data exchange with the client scene graph.
A set of rendering parameters used among render passes.
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:291
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
RenderTask parameters (renderpass state).