Loading...
Searching...
No Matches
drawTargetTask.h
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"
12#include "pxr/imaging/hdx/version.h"
13
14#include "pxr/imaging/hd/task.h"
15
16#include "pxr/base/gf/vec4f.h"
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class HdStDrawTarget;
23using HdStRenderPassStateSharedPtr
24 = std::shared_ptr<class HdStRenderPassState>;
25using HdStSimpleLightingShaderSharedPtr
26 = std::shared_ptr<class HdStSimpleLightingShader>;
27TF_DECLARE_REF_PTRS(GlfSimpleLightingContext);
28
29// Not strictly necessary here.
30// But without it, would require users of the class to include it anyway
31
32class HdxDrawTargetTask : public HdTask
33{
34public:
35 HDX_API
36 HdxDrawTargetTask(HdSceneDelegate* delegate, SdfPath const& id);
37
38 HDX_API
39 ~HdxDrawTargetTask() override;
40
42 HDX_API
43 void Sync(HdSceneDelegate* delegate,
44 HdTaskContext* ctx,
45 HdDirtyBits* dirtyBits) override;
46
48 HDX_API
49 void Prepare(HdTaskContext* ctx,
50 HdRenderIndex* renderIndex) override;
51
53 HDX_API
54 void Execute(HdTaskContext* ctx) override;
55
57 HDX_API
58 const TfTokenVector &GetRenderTags() const override;
59
60private:
61 struct _RenderPassInfo;
62 struct _CameraInfo;
63 using _RenderPassInfoVector = std::vector<_RenderPassInfo>;
64
65 static _RenderPassInfoVector _ComputeRenderPassInfos(
66 HdRenderIndex * renderIndex);
67
68 static _CameraInfo _ComputeCameraInfo(
69 const HdRenderIndex &renderIndex,
70 const HdStDrawTarget * drawTarget);
71 static void _UpdateLightingContext(
72 const _CameraInfo &cameraInfo,
73 GlfSimpleLightingContextConstRefPtr const &srcContext,
74 GlfSimpleLightingContextRefPtr const &ctx);
75 void _UpdateRenderPassState(
76 const HdRenderIndex &renderIndex,
77 const _CameraInfo &cameraInfo,
78 HdStSimpleLightingShaderSharedPtr const &lightingShader,
79 const HdStDrawTargetRenderPassState *srcState,
80 HdStRenderPassStateSharedPtr const &state) const;
81 static void _UpdateRenderPass(
82 _RenderPassInfo *info);
83
84 unsigned _currentDrawTargetSetVersion;
85 _RenderPassInfoVector _renderPassesInfo;
86
87 // Raster State - close match to render task
88 // but doesn't have enableHardwareShading
89 // as that has to be enabled for draw targets.
90// typedef std::vector<GfVec4d> ClipPlanesVector;
91// ClipPlanesVector _clipPlanes;
92 GfVec4f _overrideColor;
93 GfVec4f _wireframeColor;
94 bool _enableLighting;
95 float _alphaThreshold;
96
98 bool _depthBiasUseDefault;
99 bool _depthBiasEnable;
100 float _depthBiasConstantFactor;
101 float _depthBiasSlopeFactor;
102
103 HdCompareFunction _depthFunc;
104
105 // Viewer's Render Style
106 HdCullStyle _cullStyle;
107
108 // Alpha sample alpha to coverage
109 bool _enableSampleAlphaToCoverage;
110 TfTokenVector _renderTags;
111
112 HdxDrawTargetTask() = delete;
113 HdxDrawTargetTask(const HdxDrawTargetTask &) = delete;
114 HdxDrawTargetTask &operator =(const HdxDrawTargetTask &) = delete;
115};
116
117struct HdxDrawTargetTaskParams
118{
119 HdxDrawTargetTaskParams()
120 : overrideColor(0.0)
121 , wireframeColor(0.0)
122 , enableLighting(false)
123 , alphaThreshold(0.0)
124 , depthBiasUseDefault(true)
125 , depthBiasEnable(false)
126 , depthBiasConstantFactor(0.0f)
127 , depthBiasSlopeFactor(1.0f)
128 , depthFunc(HdCmpFuncLEqual)
129 // XXX: When rendering draw targets we need alpha to coverage
130 // at least until we support a transparency pass
131 , enableAlphaToCoverage(true)
132 , cullStyle(HdCullStyleBackUnlessDoubleSided)
133 {}
134
135// ClipPlanesVector clipPlanes;
136 GfVec4f overrideColor;
137 GfVec4f wireframeColor;
138 bool enableLighting;
139 float alphaThreshold;
140
141 // Depth Bias Raster State
142 // When use default is true - state
143 // is inherited and onther values are
144 // ignored. Otherwise the raster state
145 // is set using the values specified.
146
147 bool depthBiasUseDefault;
148 bool depthBiasEnable;
149 float depthBiasConstantFactor;
150 float depthBiasSlopeFactor;
151
152 HdCompareFunction depthFunc;
153
154 bool enableAlphaToCoverage;
155
156 // Viewer's Render Style
157 HdCullStyle cullStyle;
158};
159
160// VtValue requirements
161HDX_API
162std::ostream& operator<<(std::ostream& out, const HdxDrawTargetTaskParams& pv);
163HDX_API
164bool operator==(
165 const HdxDrawTargetTaskParams& lhs,
166 const HdxDrawTargetTaskParams& rhs);
167HDX_API
168bool operator!=(
169 const HdxDrawTargetTaskParams& lhs,
170 const HdxDrawTargetTaskParams& rhs);
171
172PXR_NAMESPACE_CLOSE_SCOPE
173
174#endif // PXR_IMAGING_HDX_DRAW_TARGET_TASK_H
Basic type for a vector of 4 float components.
Definition: vec4f.h:46
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:104
Adapter class providing data exchange with the client scene graph.
Represents an render to texture render pass.
Definition: drawTarget.h:48
Represents common non-gl context specific render pass state for a draw target.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440