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 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_HD_ST_DRAW_TARGET_H
25 #define PXR_IMAGING_HD_ST_DRAW_TARGET_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
31 #include "pxr/imaging/hd/sprim.h"
32 
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/base/gf/vec2i.h"
36 
37 #include <vector>
38 
40 
41 
42 #define HDST_DRAW_TARGET_TOKENS \
43  (camera) \
44  (collection) \
45  (drawTargetSet) \
46  (enable) \
47  (resolution) \
48  (aovBindings) \
49  (depthPriority)
50 
52 
53 class HdCamera;
54 class HdRenderIndex;
55 using HdStDrawTargetPtrVector = std::vector<class HdStDrawTarget *>;
56 
57 /// \class HdStDrawTarget
58 ///
59 /// Represents an render to texture render pass.
60 ///
61 /// \note This is a temporary API to aid transition to Storm, and is subject
62 /// to major changes.
63 ///
64 class HdStDrawTarget : public HdSprim
65 {
66 public:
67  HDST_API
68  HdStDrawTarget(SdfPath const & id);
69  HDST_API
70  ~HdStDrawTarget() override;
71 
72  /// Dirty bits for the HdStDrawTarget object
73  ///
74  /// When GetUseStormTextureSystem() is true, "Legacy" dirty
75  /// bits are ignored.
76  ///
78  Clean = 0,
79  DirtyDTEnable = 1 << 0,
80  DirtyDTCamera = 1 << 1,
91  };
92 
93  /// Synchronizes state from the delegate to this object.
94  HDST_API
95  void Sync(HdSceneDelegate *sceneDelegate,
96  HdRenderParam *renderParam,
97  HdDirtyBits *dirtyBits) override;
98 
99  /// Returns the minimal set of dirty bits to place in the
100  /// change tracker for use in the first sync of this prim.
101  /// Typically this would be all dirty bits.
102  HDST_API
103  HdDirtyBits GetInitialDirtyBitsMask() const override;
104 
105 
106  // ---------------------------------------------------------------------- //
107  /// \name Draw Target API
108  // ---------------------------------------------------------------------- //
109  bool IsEnabled() const { return _enabled; }
111  {
112  return &_drawTargetRenderPassState;
113  }
114 
115  /// Returns collection of rprims the draw target draws.
116  HDST_API
117  HdRprimCollection const &GetCollection() const { return _collection; }
118 
119  /// returns all HdStDrawTargets in the render index
120  HDST_API
121  static void GetDrawTargets(HdRenderIndex* renderIndex,
122  HdStDrawTargetPtrVector *drawTargets);
123 
124  /// Resolution.
125  ///
126  /// Set during sync.
127  ///
128  const GfVec2i &GetResolution() const {
129  return _resolution;
130  }
131 
132 private:
133  bool _enabled;
134  GfVec2i _resolution;
135  HdRprimCollection _collection;
136 
137  HdStDrawTargetRenderPassState _drawTargetRenderPassState;
138 
139  // No copy
140  HdStDrawTarget() = delete;
141  HdStDrawTarget(const HdStDrawTarget &) = delete;
142  HdStDrawTarget &operator =(const HdStDrawTarget &) = delete;
143 };
144 
145 
147 
148 #endif // PXR_IMAGING_HD_ST_DRAW_TARGET_H
std::vector< class HdStDrawTarget * > HdStDrawTargetPtrVector
Definition: drawTarget.h:55
Definition: vec2i.h:60
HDST_API HdRprimCollection const & GetCollection() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:117
uint32_t HdDirtyBits
Definition: types.h:158
const GfVec2i & GetResolution() const
Definition: drawTarget.h:128
bool IsEnabled() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:109
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.
HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
const HdStDrawTargetRenderPassState * GetDrawTargetRenderPassState() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:110
Definition: path.h:291
static HDST_API void GetDrawTargets(HdRenderIndex *renderIndex, HdStDrawTargetPtrVector *drawTargets)
returns all HdStDrawTargets in the render index
Definition: sprim.h:51
HDST_API ~HdStDrawTarget() override
#define HDST_DRAW_TARGET_TOKENS
Definition: drawTarget.h:42
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define HDST_API
Definition: api.h:40
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91