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 HDX_RENDER_SETUP_TASK_H
25 #define 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/base/gf/vec2f.h"
36 #include "pxr/base/gf/vec4f.h"
37 #include "pxr/base/gf/vec4d.h"
38 
39 #include <boost/shared_ptr.hpp>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 
44 typedef boost::shared_ptr<class HdStRenderPassShader> HdStRenderPassShaderSharedPtr;
45 typedef boost::shared_ptr<class HdRenderPassState> HdRenderPassStateSharedPtr;
46 typedef boost::shared_ptr<class HdxRenderSetupTask> HdxRenderSetupTaskSharedPtr;
47 typedef boost::shared_ptr<class HdStShaderCode> HdStShaderCodeSharedPtr;
48 struct HdxRenderTaskParams;
50 
51 
63 class HdxRenderSetupTask : public HdTask {
64 public:
65  HDX_API
66  HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id);
67 
68  HDX_API
69  virtual ~HdxRenderSetupTask();
70 
71 
72  // APIs used from HdxRenderTask to manage the sync/prepare process.
73  HDX_API
74  void SyncParams(HdSceneDelegate* delegate,
75  HdxRenderTaskParams const &params);
76  HDX_API
77  void PrepareCamera(HdRenderIndex* renderIndex);
78 
79  HdRenderPassStateSharedPtr const &GetRenderPassState() const {
80  return _renderPassState;
81  }
82 
84  HDX_API
85  virtual void Sync(HdSceneDelegate* delegate,
86  HdTaskContext* ctx,
87  HdDirtyBits* dirtyBits) override;
88 
90  HDX_API
91  virtual void Prepare(HdTaskContext* ctx,
92  HdRenderIndex* renderIndex) override;
93 
95  HDX_API
96  virtual void Execute(HdTaskContext* ctx) override;
97 
98 private:
99  HdRenderPassStateSharedPtr _renderPassState;
100  HdStRenderPassShaderSharedPtr _colorRenderPassShader;
101  HdStRenderPassShaderSharedPtr _idRenderPassShader;
102  GfVec4d _viewport;
103  SdfPath _cameraId;
104  HdRenderPassAovBindingVector _aovBindings;
105 
106  static HdStShaderCodeSharedPtr _overrideShader;
107 
108  static void _CreateOverrideShader();
109 
110  void _SetHdStRenderPassState(HdxRenderTaskParams const& params,
111  HdStRenderPassState *renderPassState);
112 
113  HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex);
114 
115  void _PrepareAovBindings(HdTaskContext* ctx, HdRenderIndex* renderIndex);
116 
117 
118  HdxRenderSetupTask() = delete;
119  HdxRenderSetupTask(const HdxRenderSetupTask &) = delete;
120  HdxRenderSetupTask &operator =(const HdxRenderSetupTask &) = delete;
121 };
122 
128 {
130  : overrideColor(0.0)
131  , wireframeColor(0.0)
132  , maskColor(1.0f, 0.0f, 0.0f, 1.0f)
133  , indicatorColor(0.0f, 1.0f, 0.0f, 1.0f)
134  , pointColor(GfVec4f(0,0,0,1))
135  , pointSize(3.0)
136  , pointSelectedSize(3.0)
137  , enableLighting(false)
138  , enableIdRender(false)
139  , alphaThreshold(0.0)
140  , enableSceneMaterials(true)
141  , depthBiasUseDefault(true)
142  , depthBiasEnable(false)
143  , depthBiasConstantFactor(0.0f)
144  , depthBiasSlopeFactor(1.0f)
145  , depthFunc(HdCmpFuncLEqual)
146  , depthMaskEnable(true)
147  , stencilFunc(HdCmpFuncAlways)
148  , stencilRef(0)
149  , stencilMask(~0)
150  , stencilFailOp(HdStencilOpKeep)
151  , stencilZFailOp(HdStencilOpKeep)
152  , stencilZPassOp(HdStencilOpKeep)
153  , stencilEnable(false)
154  , blendColorOp(HdBlendOpAdd)
155  , blendColorSrcFactor(HdBlendFactorOne)
156  , blendColorDstFactor(HdBlendFactorZero)
157  , blendAlphaOp(HdBlendOpAdd)
158  , blendAlphaSrcFactor(HdBlendFactorOne)
159  , blendAlphaDstFactor(HdBlendFactorZero)
160  , blendConstantColor(0.0f, 0.0f, 0.0f, 0.0f)
161  , blendEnable(false)
162  , enableAlphaToCoverage(true)
163  , cullStyle(HdCullStyleBackUnlessDoubleSided)
164  , aovBindings()
165  , camera()
166  , viewport(0.0)
167  {}
168 
169  // XXX: Several of the params below should move to global application state.
170  GfVec4f overrideColor;
171  GfVec4f wireframeColor;
172  GfVec4f maskColor;
173  GfVec4f indicatorColor;
174  GfVec4f pointColor;
175  float pointSize;
176  float pointSelectedSize;
177  bool enableLighting;
178  bool enableIdRender;
179  float alphaThreshold;
180  bool enableSceneMaterials;
181 
182  // Depth Bias Raster State
183  // When use default is true - state
184  // is inherited and onther values are
185  // ignored. Otherwise the raster state
186  // is set using the values specified.
187  bool depthBiasUseDefault;
188  bool depthBiasEnable;
189  float depthBiasConstantFactor;
190  float depthBiasSlopeFactor;
191 
192  HdCompareFunction depthFunc;
193  bool depthMaskEnable;
194 
195  // Stencil
196  HdCompareFunction stencilFunc;
197  int stencilRef;
198  int stencilMask;
199  HdStencilOp stencilFailOp;
200  HdStencilOp stencilZFailOp;
201  HdStencilOp stencilZPassOp;
202  bool stencilEnable;
203 
204  // Blending
205  HdBlendOp blendColorOp;
206  HdBlendFactor blendColorSrcFactor;
207  HdBlendFactor blendColorDstFactor;
208  HdBlendOp blendAlphaOp;
209  HdBlendFactor blendAlphaSrcFactor;
210  HdBlendFactor blendAlphaDstFactor;
211  GfVec4f blendConstantColor;
212  bool blendEnable;
213 
214  // AlphaToCoverage
215  bool enableAlphaToCoverage;
216 
217  // Viewer's Render Style
218  HdCullStyle cullStyle;
219 
220  // AOV bindings.
221  // XXX: As a transitional API, if this is empty it indicates the renderer
222  // should write color and depth to the GL framebuffer.
223  HdRenderPassAovBindingVector aovBindings;
224 
225  // RasterState index objects
226  SdfPath camera;
227  GfVec4d viewport;
228 };
229 
230 // VtValue requirements
231 HDX_API
232 std::ostream& operator<<(std::ostream& out, const HdxRenderTaskParams& pv);
233 HDX_API
234 bool operator==(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
235 HDX_API
236 bool operator!=(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
237 
238 
239 PXR_NAMESPACE_CLOSE_SCOPE
240 
241 #endif //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:119
virtual 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:287
A task for setting up render pass state (camera, renderpass shader, GL states).
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].
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.