HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sprim.h
Go to the documentation of this file.
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_HD_SPRIM_H
8 #define PXR_IMAGING_HD_SPRIM_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
13 #include "pxr/imaging/hd/types.h"
14 
15 #include "pxr/usd/sdf/path.h"
16 
18 
19 class HdSceneDelegate;
20 class HdRenderParam;
21 
22 /// \class HdSprim
23 ///
24 /// Sprim (state prim) is a base class of managing state for non-drawable
25 /// scene entity (e.g. camera, light). Similar to Rprim, Sprim communicates
26 /// scene delegate and tracks the changes through change tracker, then updates
27 /// data cached in Hd (either on CPU or GPU).
28 ///
29 /// Unlike Rprim, Sprim doesn't produce draw items. The data cached in HdSprim
30 /// may be used by HdTask or by HdShader.
31 ///
32 /// The lifetime of HdSprim is owned by HdRenderIndex.
33 ///
34 class HdSprim
35 {
36 public:
37  HD_API
38  HdSprim(SdfPath const & id);
39  HD_API
40  virtual ~HdSprim();
41 
42  /// Returns the identifier by which this state is known. This
43  /// identifier is a common associative key used by the SceneDelegate,
44  /// RenderIndex, and for binding to the state (e.g. camera, light)
45  SdfPath const& GetId() const { return _id; }
46 
47  /// Synchronizes state from the delegate to this object.
48  /// @param[in, out] dirtyBits: On input specifies which state is
49  /// is dirty and can be pulled from the scene
50  /// delegate.
51  /// On output specifies which bits are still
52  /// dirty and were not cleaned by the sync.
53  ///
54  virtual void Sync(HdSceneDelegate *sceneDelegate,
55  HdRenderParam *renderParam,
56  HdDirtyBits *dirtyBits) = 0;
57 
58  /// Finalizes object resources. This function might not delete resources,
59  /// but it should deal with resource ownership so that the sprim is
60  /// deletable.
61  HD_API
62  virtual void Finalize(HdRenderParam *renderParam);
63 
64  /// Returns the minimal set of dirty bits to place in the
65  /// change tracker for use in the first sync of this prim.
66  /// Typically this would be all dirty bits.
67  virtual HdDirtyBits GetInitialDirtyBitsMask() const = 0;
68 
69 private:
70  SdfPath _id;
71 };
72 
73 
75 
76 #endif // PXR_IMAGING_HD_SPRIM_H
SdfPath const & GetId() const
Definition: sprim.h:45
uint32_t HdDirtyBits
Definition: types.h:143
#define HD_API
Definition: api.h:23
HD_API HdSprim(SdfPath const &id)
virtual HD_API ~HdSprim()
Definition: path.h:273
virtual HdDirtyBits GetInitialDirtyBitsMask() const =0
Definition: sprim.h:34
virtual HD_API void Finalize(HdRenderParam *renderParam)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits)=0