drawTarget.h
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"
29 #include "pxr/imaging/hdSt/drawTargetRenderPassState.h"
30 #include "pxr/imaging/hd/rprimCollection.h"
31 #include "pxr/imaging/hd/sprim.h"
32 
33 #include "pxr/usd/sdf/path.h"
35 
36 #include <vector>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 #define HDST_DRAW_TARGET_TOKENS \
42  (camera) \
43  (collection) \
44  (drawTargetSet) \
45  (enable) \
46  (resolution) \
47  (aovBindings) \
48  (depthPriority)
49 
50 TF_DECLARE_PUBLIC_TOKENS(HdStDrawTargetTokens, HDST_API, HDST_DRAW_TARGET_TOKENS);
51 
52 class HdCamera;
53 class HdRenderIndex;
54 using HdStDrawTargetPtrVector = std::vector<class HdStDrawTarget *>;
55 
63 class HdStDrawTarget : public HdSprim
64 {
65 public:
66  HDST_API
67  HdStDrawTarget(SdfPath const & id);
68  HDST_API
69  ~HdStDrawTarget() override;
70 
76  enum DirtyBits : HdDirtyBits {
77  Clean = 0,
78  DirtyDTEnable = 1 << 0,
79  DirtyDTCamera = 1 << 1,
80  DirtyDTResolution = 1 << 2,
81  DirtyDTAovBindings = 1 << 4,
82  DirtyDTDepthPriority = 1 << 6,
83  DirtyDTCollection = 1 << 7,
84  AllDirty = (DirtyDTEnable
85  |DirtyDTCamera
86  |DirtyDTResolution
87  |DirtyDTAovBindings
88  |DirtyDTDepthPriority
89  |DirtyDTCollection)
90  };
91 
93  HDST_API
94  void Sync(HdSceneDelegate *sceneDelegate,
95  HdRenderParam *renderParam,
96  HdDirtyBits *dirtyBits) override;
97 
101  HDST_API
102  HdDirtyBits GetInitialDirtyBitsMask() const override;
103 
104 
105  // ---------------------------------------------------------------------- //
107  // ---------------------------------------------------------------------- //
108  bool IsEnabled() const { return _enabled; }
109  const HdStDrawTargetRenderPassState *GetDrawTargetRenderPassState() const
110  {
111  return &_drawTargetRenderPassState;
112  }
113 
115  HDST_API
116  HdRprimCollection const &GetCollection() const { return _collection; }
117 
119  HDST_API
120  static void GetDrawTargets(HdRenderIndex* renderIndex,
121  HdStDrawTargetPtrVector *drawTargets);
122 
127  const GfVec2i &GetResolution() const {
128  return _resolution;
129  }
130 
131 private:
132  bool _enabled;
133  GfVec2i _resolution;
134  HdRprimCollection _collection;
135 
136  HdStDrawTargetRenderPassState _drawTargetRenderPassState;
137 
138  // No copy
139  HdStDrawTarget() = delete;
140  HdStDrawTarget(const HdStDrawTarget &) = delete;
141  HdStDrawTarget &operator =(const HdStDrawTarget &) = delete;
142 };
143 
144 
145 PXR_NAMESPACE_CLOSE_SCOPE
146 
147 #endif // PXR_IMAGING_HD_ST_DRAW_TARGET_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:118
HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
Basic type for a vector of 2 int components.
Definition: vec2i.h:61
DirtyBits
Dirty bits for the HdStDrawTarget object.
Definition: drawTarget.h:76
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:85
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
const GfVec2i & GetResolution() const
Resolution.
Definition: drawTarget.h:127
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
HDST_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Synchronizes state from the delegate to this object.
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:52
This file defines some macros that are useful for declaring and using static TfTokens.
Represents an render to texture render pass.
Definition: drawTarget.h:63
HDST_API HdRprimCollection const & GetCollection() const
Returns collection of rprims the draw target draws.
Definition: drawTarget.h:116
static HDST_API void GetDrawTargets(HdRenderIndex *renderIndex, HdStDrawTargetPtrVector *drawTargets)
returns all HdStDrawTargets in the render index
Represents common non-gl context specific render pass state for a draw target.