All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawTargetTask.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_DRAW_TARGET_TASK_H
25 #define HDX_DRAW_TARGET_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/hdx/drawTargetRenderPass.h"
31 
32 #include "pxr/imaging/hd/task.h"
33 
34 #include "pxr/base/gf/vec2f.h"
35 #include "pxr/base/gf/vec4f.h"
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 class HdStDrawTarget;
40 
41 
42 typedef std::unique_ptr<HdxDrawTargetRenderPass> HdxDrawTargetRenderPassUniquePtr;
43 typedef boost::shared_ptr<class HdxSimpleLightingShader> HdxSimpleLightingShaderSharedPtr;
44 
45 // Not strictly necessary here.
46 // But without it, would require users of the class to include it anyway
47 
48 class HdxDrawTargetTask : public HdTask {
49 public:
50  HDX_API
51  HdxDrawTargetTask(HdSceneDelegate* delegate, SdfPath const& id);
52 
53  HDX_API
54  virtual ~HdxDrawTargetTask();
55 
57  HDX_API
58  virtual void Sync(HdSceneDelegate* delegate,
59  HdTaskContext* ctx,
60  HdDirtyBits* dirtyBits) override;
61 
63  HDX_API
64  virtual void Prepare(HdTaskContext* ctx,
65  HdRenderIndex* renderIndex) override;
66 
68  HDX_API
69  virtual void Execute(HdTaskContext* ctx) override;
70 
72  HDX_API
73  virtual const TfTokenVector &GetRenderTags() const override;
74 
75 private:
76  struct RenderPassInfo {
77  HdStRenderPassStateSharedPtr renderPassState;
78  HdxSimpleLightingShaderSharedPtr simpleLightingShader;
79  const HdStDrawTarget *target;
80  unsigned int version;
81  };
82  unsigned _currentDrawTargetSetVersion;
83 
84  typedef std::vector< RenderPassInfo > RenderPassInfoArray;
85  RenderPassInfoArray _renderPassesInfo;
86  std::vector< HdxDrawTargetRenderPassUniquePtr > _renderPasses;
87 
88  // Raster State - close match to render task
89  // but doesn't have enableHardwareShading
90  // as that has to be enabled for draw targets.
91 // typedef std::vector<GfVec4d> ClipPlanesVector;
92 // ClipPlanesVector _clipPlanes;
93  GfVec4f _overrideColor;
94  GfVec4f _wireframeColor;
95  bool _enableLighting;
96  float _alphaThreshold;
97 
99  bool _depthBiasUseDefault;
100  bool _depthBiasEnable;
101  float _depthBiasConstantFactor;
102  float _depthBiasSlopeFactor;
103 
104  HdCompareFunction _depthFunc;
105 
106  // Viewer's Render Style
107  HdCullStyle _cullStyle;
108 
109  // Alpha sample alpha to coverage
110  bool _enableSampleAlphaToCoverage;
111  TfTokenVector _renderTags;
112 
113  HdxDrawTargetTask() = delete;
114  HdxDrawTargetTask(const HdxDrawTargetTask &) = delete;
115  HdxDrawTargetTask &operator =(const HdxDrawTargetTask &) = delete;
116 };
117 
118 struct HdxDrawTargetTaskParams
119 {
120  HdxDrawTargetTaskParams()
121  : overrideColor(0.0)
122  , wireframeColor(0.0)
123  , enableLighting(false)
124  , alphaThreshold(0.0)
125  , depthBiasUseDefault(true)
126  , depthBiasEnable(false)
127  , depthBiasConstantFactor(0.0f)
128  , depthBiasSlopeFactor(1.0f)
129  , depthFunc(HdCmpFuncLEqual)
130  , cullStyle(HdCullStyleBackUnlessDoubleSided)
131  {}
132 
133 // ClipPlanesVector clipPlanes;
134  GfVec4f overrideColor;
135  GfVec4f wireframeColor;
136  bool enableLighting;
137  float alphaThreshold;
138 
139  // Depth Bias Raster State
140  // When use default is true - state
141  // is inherited and onther values are
142  // ignored. Otherwise the raster state
143  // is set using the values specified.
144 
145  bool depthBiasUseDefault;
146  bool depthBiasEnable;
147  float depthBiasConstantFactor;
148  float depthBiasSlopeFactor;
149 
150  HdCompareFunction depthFunc;
151 
152  // Viewer's Render Style
153  HdCullStyle cullStyle;
154 };
155 
156 // VtValue requirements
157 HDX_API
158 std::ostream& operator<<(std::ostream& out, const HdxDrawTargetTaskParams& pv);
159 HDX_API
160 bool operator==(const HdxDrawTargetTaskParams& lhs, const HdxDrawTargetTaskParams& rhs);
161 HDX_API
162 bool operator!=(const HdxDrawTargetTaskParams& lhs, const HdxDrawTargetTaskParams& rhs);
163 
164 
165 PXR_NAMESPACE_CLOSE_SCOPE
166 
167 #endif // HDX_DRAW_TARGET_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
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].
Represents an render to texture render pass.
Definition: drawTarget.h:74