HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawTargetTask.h
Go to the documentation of this file.
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_DRAW_TARGET_TASK_H
8 #define PXR_IMAGING_HDX_DRAW_TARGET_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
13 
14 #include "pxr/imaging/hd/task.h"
15 
16 #include "pxr/base/gf/vec4f.h"
18 
20 
21 class HdStDrawTarget;
25  = std::shared_ptr<class HdStRenderPassState>;
27  = std::shared_ptr<class HdStSimpleLightingShader>;
29 
30 // Not strictly necessary here.
31 // But without it, would require users of the class to include it anyway
32 
33 class HdxDrawTargetTask : public HdTask
34 {
35 public:
37 
38  HDX_API
39  HdxDrawTargetTask(HdSceneDelegate* delegate, SdfPath const& id);
40 
41  HDX_API
42  ~HdxDrawTargetTask() override;
43 
44  /// Sync the render pass resources
45  HDX_API
46  void Sync(HdSceneDelegate* delegate,
47  HdTaskContext* ctx,
48  HdDirtyBits* dirtyBits) override;
49 
50  /// Prepare the tasks resources
51  HDX_API
52  void Prepare(HdTaskContext* ctx,
53  HdRenderIndex* renderIndex) override;
54 
55  /// Execute render pass task
56  HDX_API
57  void Execute(HdTaskContext* ctx) override;
58 
59  /// Collect Render Tags used by the task.
60  HDX_API
61  const TfTokenVector &GetRenderTags() const override;
62 
63 private:
64  struct _RenderPassInfo;
65  struct _CameraInfo;
66  using _RenderPassInfoVector = std::vector<_RenderPassInfo>;
67 
68  static _RenderPassInfoVector _ComputeRenderPassInfos(
69  HdRenderIndex * renderIndex);
70 
71  static _CameraInfo _ComputeCameraInfo(
72  const HdRenderIndex &renderIndex,
73  const HdStDrawTarget * drawTarget);
74  static void _UpdateLightingContext(
75  const _CameraInfo &cameraInfo,
76  GlfSimpleLightingContextConstRefPtr const &srcContext,
77  GlfSimpleLightingContextRefPtr const &ctx);
78  void _UpdateRenderPassState(
79  const HdRenderIndex &renderIndex,
80  const _CameraInfo &cameraInfo,
81  HdStSimpleLightingShaderSharedPtr const &lightingShader,
82  const HdStDrawTargetRenderPassState *srcState,
83  HdStRenderPassStateSharedPtr const &state) const;
84  static void _UpdateRenderPass(
85  _RenderPassInfo *info);
86 
87  unsigned _currentDrawTargetSetVersion;
88  _RenderPassInfoVector _renderPassesInfo;
89 
90  // Raster State - close match to render task
91  // but doesn't have enableHardwareShading
92  // as that has to be enabled for draw targets.
93 // typedef std::vector<GfVec4d> ClipPlanesVector;
94 // ClipPlanesVector _clipPlanes;
95  GfVec4f _overrideColor;
96  GfVec4f _wireframeColor;
97  bool _enableLighting;
98  float _alphaThreshold;
99 
100  /// Polygon Offset State
101  bool _depthBiasUseDefault;
102  bool _depthBiasEnable;
103  float _depthBiasConstantFactor;
104  float _depthBiasSlopeFactor;
105 
106  HdCompareFunction _depthFunc;
107 
108  // Viewer's Render Style
109  HdCullStyle _cullStyle;
110 
111  // Alpha sample alpha to coverage
112  bool _enableSampleAlphaToCoverage;
113  TfTokenVector _renderTags;
114 
115  HdxDrawTargetTask() = delete;
116  HdxDrawTargetTask(const HdxDrawTargetTask &) = delete;
118 };
119 
121 {
123  : overrideColor(0.0)
124  , wireframeColor(0.0)
125  , enableLighting(false)
126  , alphaThreshold(0.0)
127  , depthBiasUseDefault(true)
128  , depthBiasEnable(false)
130  , depthBiasSlopeFactor(1.0f)
132  // XXX: When rendering draw targets we need alpha to coverage
133  // at least until we support a transparency pass
134  , enableAlphaToCoverage(true)
136  {}
137 
138 // ClipPlanesVector clipPlanes;
143 
144  // Depth Bias Raster State
145  // When use default is true - state
146  // is inherited and onther values are
147  // ignored. Otherwise the raster state
148  // is set using the values specified.
149 
154 
156 
158 
159  // Viewer's Render Style
161 };
162 
163 // VtValue requirements
164 HDX_API
165 std::ostream& operator<<(std::ostream& out, const HdxDrawTargetTaskParams& pv);
166 HDX_API
167 bool operator==(
168  const HdxDrawTargetTaskParams& lhs,
169  const HdxDrawTargetTaskParams& rhs);
170 HDX_API
171 bool operator!=(
172  const HdxDrawTargetTaskParams& lhs,
173  const HdxDrawTargetTaskParams& rhs);
174 
176 
177 #endif // PXR_IMAGING_HDX_DRAW_TARGET_TASK_H
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
HdCompareFunction
Definition: enums.h:19
HdCullStyle
Definition: enums.h:105
uint32_t HdDirtyBits
Definition: types.h:143
HDX_API ~HdxDrawTargetTask() override
#define HDX_API
Definition: api.h:23
TF_DECLARE_REF_PTRS(GlfSimpleLightingContext)
std::shared_ptr< class HdStRenderPassState > HdStRenderPassStateSharedPtr
Definition: commandBuffer.h:28
HDX_API const TfTokenVector & GetRenderTags() const override
Collect Render Tags used by the task.
GLfloat f
Definition: glcorearb.h:1926
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: task.h:43
Definition: path.h:273
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
std::shared_ptr< class HdStSimpleLightingShader > HdStSimpleLightingShaderSharedPtr
Definition: vec4f.h:45
HDX_API std::ostream & operator<<(std::ostream &out, const HdxDrawTargetTaskParams &pv)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
LeafData & operator=(const LeafData &)=delete
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdCompareFunction depthFunc
state
Definition: core.h:2289
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.