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 
35 #include "pxr/base/gf/vec2f.h"
36 #include "pxr/base/gf/vec4f.h"
37 #include "pxr/base/gf/vec4d.h"
38 
39 #include <memory>
40 
42 
44  std::shared_ptr<class HdxRenderSetupTask>;
46  std::shared_ptr<class HdStRenderPassShader>;
47 using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
48 
49 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
50 
51 struct HdxRenderTaskParams;
53 
54 
55 /// \class HdxRenderSetupTask
56 ///
57 /// A task for setting up render pass state (camera, renderpass shader, GL
58 /// states).
59 ///
60 /// HdxRenderTask depends on the output of this task. Applications can choose
61 /// to create a render setup task, and pass it the HdxRenderTaskParams; or they
62 /// can pass the HdxRenderTaskParams directly to the render task, which will
63 /// create a render setup task internally. See the HdxRenderTask documentation
64 /// for details.
65 ///
66 class HdxRenderSetupTask : public HdTask {
67 public:
68  HDX_API
69  HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id);
70 
71  HDX_API
72  virtual ~HdxRenderSetupTask();
73 
74 
75  // APIs used from HdxRenderTask to manage the sync/prepare process.
76  HDX_API
77  void SyncParams(HdSceneDelegate* delegate,
79  HDX_API
80  void PrepareCamera(HdRenderIndex* renderIndex);
81 
83  return _renderPassState;
84  }
85 
86  /// Sync the render pass resources
87  HDX_API
88  virtual void Sync(HdSceneDelegate* delegate,
89  HdTaskContext* ctx,
90  HdDirtyBits* dirtyBits) override;
91 
92  /// Prepare the tasks resources
93  HDX_API
94  virtual void Prepare(HdTaskContext* ctx,
95  HdRenderIndex* renderIndex) override;
96 
97  /// Execute render pass task
98  HDX_API
99  virtual void Execute(HdTaskContext* ctx) override;
100 
101 private:
102  HdRenderPassStateSharedPtr _renderPassState;
103  HdStRenderPassShaderSharedPtr _colorRenderPassShader;
104  HdStRenderPassShaderSharedPtr _idRenderPassShader;
105  GfVec4d _viewport;
106  SdfPath _cameraId;
107  HdRenderPassAovBindingVector _aovBindings;
108 
109  static HdStShaderCodeSharedPtr _overrideShader;
110 
111  static void _CreateOverrideShader();
112 
113  void _SetHdStRenderPassState(HdxRenderTaskParams const& params,
114  HdStRenderPassState *renderPassState);
115 
116  HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex);
117 
118  void _PrepareAovBindings(HdTaskContext* ctx, HdRenderIndex* renderIndex);
119 
120 
121  HdxRenderSetupTask() = delete;
122  HdxRenderSetupTask(const HdxRenderSetupTask &) = delete;
123  HdxRenderSetupTask &operator =(const HdxRenderSetupTask &) = delete;
124 };
125 
126 /// \class HdxRenderTaskParams
127 ///
128 /// RenderTask parameters (renderpass state).
129 ///
131 {
133  : overrideColor(0.0)
134  , wireframeColor(0.0)
135  , maskColor(1.0f, 0.0f, 0.0f, 1.0f)
136  , indicatorColor(0.0f, 1.0f, 0.0f, 1.0f)
137  , pointColor(GfVec4f(0,0,0,1))
138  , pointSize(3.0)
139  , pointSelectedSize(3.0)
140  , enableLighting(false)
141  , enableIdRender(false)
142  , alphaThreshold(0.0)
143  , enableSceneMaterials(true)
144  , depthBiasUseDefault(true)
145  , depthBiasEnable(false)
147  , depthBiasSlopeFactor(1.0f)
149  , depthMaskEnable(true)
151  , stencilRef(0)
152  , stencilMask(~0)
156  , stencilEnable(false)
163  , blendConstantColor(0.0f, 0.0f, 0.0f, 0.0f)
164  , blendEnable(false)
165  , enableAlphaToCoverage(true)
167  , aovBindings()
168  , camera()
169  , viewport(0.0)
170  {}
171 
172  // XXX: Several of the params below should move to global application state.
178  float pointSize;
184 
185  // Depth Bias Raster State
186  // When use default is true - state
187  // is inherited and onther values are
188  // ignored. Otherwise the raster state
189  // is set using the values specified.
194 
197 
198  // Stencil
206 
207  // Blending
216 
217  // AlphaToCoverage
219 
220  // Viewer's Render Style
222 
223  // AOV bindings.
224  // XXX: As a transitional API, if this is empty it indicates the renderer
225  // should write color and depth to the GL framebuffer.
227 
228  // RasterState index objects
231 };
232 
233 // VtValue requirements
234 HDX_API
235 std::ostream& operator<<(std::ostream& out, const HdxRenderTaskParams& pv);
236 HDX_API
237 bool operator==(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
238 HDX_API
239 bool operator!=(const HdxRenderTaskParams& lhs, const HdxRenderTaskParams& rhs);
240 
241 
243 
244 #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
HdCullStyle
Definition: enums.h:122
HdBlendFactor blendAlphaSrcFactor
uint32_t HdDirtyBits
Definition: types.h:127
HdCompareFunction stencilFunc
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
HdStencilOp stencilFailOp
Definition: vec4d.h:63
HdBlendFactor
Definition: enums.h:87
#define HDX_API
Definition: api.h:40
HdStencilOp stencilZPassOp
GLclampf f
Definition: glew.h:3499
virtual HDX_API ~HdxRenderSetupTask()
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
Definition: task.h:54
Definition: path.h:288
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
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:73
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
Definition: vec4f.h:63
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
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
const GLfloat * params
Definition: glew.h:1531
HDX_API void PrepareCamera(HdRenderIndex *renderIndex)
HdRenderPassAovBindingVector aovBindings
HdBlendOp
Definition: enums.h:72
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:147
HdCompareFunction depthFunc
HdBlendFactor blendColorDstFactor
std::shared_ptr< class HdStShaderCode > HdStShaderCodeSharedPtr
Definition: drawItem.h:34
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:549