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 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_DRAW_TARGET_TASK_H
25 #define PXR_IMAGING_HDX_DRAW_TARGET_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
30 
31 #include "pxr/imaging/hd/task.h"
32 
33 #include "pxr/base/gf/vec4f.h"
35 
37 
38 class HdStDrawTarget;
41  = std::shared_ptr<class HdStRenderPassState>;
43  = std::shared_ptr<class HdStSimpleLightingShader>;
45 
46 // Not strictly necessary here.
47 // But without it, would require users of the class to include it anyway
48 
49 class HdxDrawTargetTask : public HdTask
50 {
51 public:
52  HDX_API
53  HdxDrawTargetTask(HdSceneDelegate* delegate, SdfPath const& id);
54 
55  HDX_API
56  ~HdxDrawTargetTask() override;
57 
58  /// Sync the render pass resources
59  HDX_API
60  void Sync(HdSceneDelegate* delegate,
61  HdTaskContext* ctx,
62  HdDirtyBits* dirtyBits) override;
63 
64  /// Prepare the tasks resources
65  HDX_API
66  void Prepare(HdTaskContext* ctx,
67  HdRenderIndex* renderIndex) override;
68 
69  /// Execute render pass task
70  HDX_API
71  void Execute(HdTaskContext* ctx) override;
72 
73  /// Collect Render Tags used by the task.
74  HDX_API
75  const TfTokenVector &GetRenderTags() const override;
76 
77 private:
78  struct _RenderPassInfo;
79  struct _CameraInfo;
80  using _RenderPassInfoVector = std::vector<_RenderPassInfo>;
81 
82  static _RenderPassInfoVector _ComputeRenderPassInfos(
83  HdRenderIndex * renderIndex);
84 
85  static _CameraInfo _ComputeCameraInfo(
86  const HdRenderIndex &renderIndex,
87  const HdStDrawTarget * drawTarget);
88  static void _UpdateLightingContext(
89  const _CameraInfo &cameraInfo,
90  GlfSimpleLightingContextConstRefPtr const &srcContext,
91  GlfSimpleLightingContextRefPtr const &ctx);
92  void _UpdateRenderPassState(
93  const HdRenderIndex &renderIndex,
94  const _CameraInfo &cameraInfo,
95  HdStSimpleLightingShaderSharedPtr const &lightingShader,
96  const HdStDrawTargetRenderPassState *srcState,
97  HdStRenderPassStateSharedPtr const &state) const;
98  static void _UpdateRenderPass(
99  _RenderPassInfo *info);
100 
101  unsigned _currentDrawTargetSetVersion;
102  _RenderPassInfoVector _renderPassesInfo;
103 
104  // Raster State - close match to render task
105  // but doesn't have enableHardwareShading
106  // as that has to be enabled for draw targets.
107 // typedef std::vector<GfVec4d> ClipPlanesVector;
108 // ClipPlanesVector _clipPlanes;
109  GfVec4f _overrideColor;
110  GfVec4f _wireframeColor;
111  bool _enableLighting;
112  float _alphaThreshold;
113 
114  /// Polygon Offset State
115  bool _depthBiasUseDefault;
116  bool _depthBiasEnable;
117  float _depthBiasConstantFactor;
118  float _depthBiasSlopeFactor;
119 
120  HdCompareFunction _depthFunc;
121 
122  // Viewer's Render Style
123  HdCullStyle _cullStyle;
124 
125  // Alpha sample alpha to coverage
126  bool _enableSampleAlphaToCoverage;
127  TfTokenVector _renderTags;
128 
129  HdxDrawTargetTask() = delete;
130  HdxDrawTargetTask(const HdxDrawTargetTask &) = delete;
131  HdxDrawTargetTask &operator =(const HdxDrawTargetTask &) = delete;
132 };
133 
135 {
137  : overrideColor(0.0)
138  , wireframeColor(0.0)
139  , enableLighting(false)
140  , alphaThreshold(0.0)
141  , depthBiasUseDefault(true)
142  , depthBiasEnable(false)
144  , depthBiasSlopeFactor(1.0f)
146  // XXX: When rendering draw targets we need alpha to coverage
147  // at least until we support a transparency pass
148  , enableAlphaToCoverage(true)
150  {}
151 
152 // ClipPlanesVector clipPlanes;
157 
158  // Depth Bias Raster State
159  // When use default is true - state
160  // is inherited and onther values are
161  // ignored. Otherwise the raster state
162  // is set using the values specified.
163 
168 
170 
172 
173  // Viewer's Render Style
175 };
176 
177 // VtValue requirements
178 HDX_API
179 std::ostream& operator<<(std::ostream& out, const HdxDrawTargetTaskParams& pv);
180 HDX_API
181 bool operator==(
182  const HdxDrawTargetTaskParams& lhs,
183  const HdxDrawTargetTaskParams& rhs);
184 HDX_API
185 bool operator!=(
186  const HdxDrawTargetTaskParams& lhs,
187  const HdxDrawTargetTaskParams& rhs);
188 
190 
191 #endif // PXR_IMAGING_HDX_DRAW_TARGET_TASK_H
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
HdCompareFunction
Definition: enums.h:36
HdCullStyle
Definition: enums.h:122
uint32_t HdDirtyBits
Definition: types.h:158
HDX_API ~HdxDrawTargetTask() override
#define HDX_API
Definition: api.h:40
TF_DECLARE_REF_PTRS(GlfSimpleLightingContext)
std::shared_ptr< class HdStRenderPassState > HdStRenderPassStateSharedPtr
Definition: commandBuffer.h:45
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:442
Definition: task.h:54
Definition: path.h:291
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
std::shared_ptr< class HdStSimpleLightingShader > HdStSimpleLightingShaderSharedPtr
Definition: vec4f.h:62
HDX_API std::ostream & operator<<(std::ostream &out, const HdxDrawTargetTaskParams &pv)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HdCompareFunction depthFunc
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.