HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawTarget.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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_HD_ST_DRAW_TARGET_H
8 #define PXR_IMAGING_HD_ST_DRAW_TARGET_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
14 #include "pxr/imaging/hd/sprim.h"
15 
16 #include "pxr/usd/sdf/path.h"
17 #include "pxr/base/gf/vec2i.h"
19 
20 #include <vector>
21 
23 
24 
25 #define HDST_DRAW_TARGET_TOKENS \
26  (camera) \
27  (collection) \
28  (enable) \
29  (resolution) \
30  (aovBindings) \
31  (depthPriority)
32 
34 
35 class HdCamera;
36 class HdRenderIndex;
37 using HdStDrawTargetPtrVector = std::vector<class HdStDrawTarget *>;
38 
39 /// \class HdStDrawTarget
40 ///
41 /// Represents an render to texture render pass.
42 ///
43 /// \note This is a temporary API to aid transition to Storm, and is subject
44 /// to major changes.
45 ///
46 class HdStDrawTarget : public HdSprim
47 {
48 public:
49  HDST_API
50  HdStDrawTarget(SdfPath const & id);
51  HDST_API
52  ~HdStDrawTarget() override;
53 
54  /// Dirty bits for the HdStDrawTarget object
55  ///
56  /// When GetUseStormTextureSystem() is true, "Legacy" dirty
57  /// bits are ignored.
58  ///
60  Clean = 0,
61  DirtyDTEnable = 1 << 0,
62  DirtyDTCamera = 1 << 1,
73  };
74 
75  /// Synchronizes state from the delegate to this object.
76  HDST_API
77  void Sync(HdSceneDelegate *sceneDelegate,
78  HdRenderParam *renderParam,
79  HdDirtyBits *dirtyBits) override;
80 
81  /// Returns the minimal set of dirty bits to place in the
82  /// change tracker for use in the first sync of this prim.
83  /// Typically this would be all dirty bits.
84  HDST_API
85  HdDirtyBits GetInitialDirtyBitsMask() const override;
86 
87 
88  // ---------------------------------------------------------------------- //
89  /// \name Draw Target API
90  // ---------------------------------------------------------------------- //
91  bool IsEnabled() const { return _enabled; }
93  {
94  return &_drawTargetRenderPassState;
95  }
96 
97  /// Returns collection of rprims the draw target draws.
98  HDST_API
99  HdRprimCollection const &GetCollection() const { return _collection; }
100 
101  /// returns all HdStDrawTargets in the render index
102  HDST_API
103  static void GetDrawTargets(HdRenderIndex* renderIndex,
104  HdStDrawTargetPtrVector *drawTargets);
105 
106  /// Resolution.
107  ///
108  /// Set during sync.
109  ///
110  const GfVec2i &GetResolution() const {
111  return _resolution;
112  }
113 
114  void Finalize(HdRenderParam *) override;
115 
116 private:
117  bool _enabled;
118  GfVec2i _resolution;
119  HdRprimCollection _collection;
120 
121  HdStDrawTargetRenderPassState _drawTargetRenderPassState;
122 
123  // No copy
124  HdStDrawTarget() = delete;
125  HdStDrawTarget(const HdStDrawTarget &) = delete;
126  HdStDrawTarget &operator =(const HdStDrawTarget &) = delete;
127 };
128 
129 
131 
132 #endif // PXR_IMAGING_HD_ST_DRAW_TARGET_H
std::vector< class HdStDrawTarget * > HdStDrawTargetPtrVector
Definition: drawTarget.h:37
Definition: vec2i.h:43
HDST_API HdRprimCollection const & GetCollection() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:99
uint32_t HdDirtyBits
Definition: types.h:143
const GfVec2i & GetResolution() const
Definition: drawTarget.h:110
bool IsEnabled() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:91
TF_DECLARE_PUBLIC_TOKENS(HdStDrawTargetTokens, HDST_API, HDST_DRAW_TARGET_TOKENS)
HDST_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Synchronizes state from the delegate to this object.
void Finalize(HdRenderParam *) override
Returns collection of rprims the draw target draws.
HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
const HdStDrawTargetRenderPassState * GetDrawTargetRenderPassState() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:92
Definition: path.h:273
static HDST_API void GetDrawTargets(HdRenderIndex *renderIndex, HdStDrawTargetPtrVector *drawTargets)
returns all HdStDrawTargets in the render index
Definition: sprim.h:34
HDST_API ~HdStDrawTarget() override
#define HDST_DRAW_TARGET_TOKENS
Definition: drawTarget.h:25
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74