HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataSourceLegacyPrim.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 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_DATA_SOURCE_LEGACY_PRIM_H
8 #define PXR_IMAGING_HD_DATA_SOURCE_LEGACY_PRIM_H
9 
10 #include "pxr/imaging/hd/api.h"
13 
14 #include "pxr/usd/sdf/path.h"
15 
16 #include "pxr/base/tf/spinMutex.h"
18 #include "pxr/base/tf/token.h"
19 
20 #include "pxr/pxr.h"
21 
22 #include <atomic>
23 
25 
26 class HdSceneDelegate;
27 
28 #define HD_LEGACY_PRIMTYPE_TOKENS \
29  /* Bprims */ \
30  (openvdbAsset) \
31  (field3dAsset) \
32  (houdiniFieldAsset)
33 
34 TF_DECLARE_PUBLIC_TOKENS(HdLegacyPrimTypeTokens, HD_API,
36 
37 /// Instancers from scene delegates ignore visibility.
38 /// This fixes that usdImaging does not update the visibility of an instancer
39 /// properly.
40 #define HD_LEGACY_FLAG_TOKENS \
41  (isLegacyInstancer)
42 
43 TF_DECLARE_PUBLIC_TOKENS(HdLegacyFlagTokens, HD_API,
45 
46 /// \class HdDataSourceLegacyPrim
47 ///
48 /// This is an HdContainerDataSource which represents a prim-level data source
49 /// for adapting HdSceneDelegate calls into the forms defined by HdSchemas
50 /// during emulation of legacy scene delegates.
51 ///
53 {
54 public:
56 
57  TfTokenVector GetNames() override;
58  HdDataSourceBaseHandle Get(const TfToken &name) override;
59 
60  /// This clears internal cached values and is currently called only by
61  /// HdLegacyPrimSceneIndex in response to its own DirtyPrims method
62  void PrimDirtied(const HdDataSourceLocatorSet &locators);
63 
64  /// Return which locators PrimDirtied will respond to...
66 
67 protected:
69  const SdfPath& id,
70  const TfToken& type,
71  HdSceneDelegate *sceneDelegate);
72 
73 private:
74  HdDataSourceBaseHandle _GetPrimvarsDataSource();
75  HdDataSourceBaseHandle _GetExtComputationPrimvarsDataSource();
76  HdDataSourceBaseHandle _GetMaterialBindingsDataSource();
77  HdDataSourceBaseHandle _GetXformDataSource();
78  HdDataSourceBaseHandle _GetMaterialDataSource();
79  HdDataSourceBaseHandle _GetIntegratorDataSource();
80  HdDataSourceBaseHandle _GetSampleFilterDataSource();
81  HdDataSourceBaseHandle _GetDisplayFilterDataSource();
82  HdDataSourceBaseHandle _GetDisplayStyleDataSource();
83  HdDataSourceBaseHandle _GetInstancedByDataSource();
84  HdDataSourceBaseHandle _GetDataSharingDataSource();
85  HdDataSourceBaseHandle _GetInstancerTopologyDataSource();
86  HdDataSourceBaseHandle _GetVolumeFieldBindingDataSource();
87  HdDataSourceBaseHandle _GetCoordSysBindingDataSource();
88  HdDataSourceBaseHandle _GetVisibilityDataSource();
89  HdDataSourceBaseHandle _GetPurposeDataSource();
90  HdDataSourceBaseHandle _GetExtentDataSource();
91  HdDataSourceBaseHandle _GetCategoriesDataSource();
92  HdDataSourceBaseHandle _GetInstanceCategoriesDataSource();
93 
94  bool _IsLight();
95  bool _IsInstanceable();
96 
97 protected:
101 
102 private:
103  std::atomic_bool _primvarsBuilt;
104  TfSpinMutex _primvarsMutex;
105  bool _extComputationPrimvarsBuilt : 1;
106 
107  HdContainerDataSourceAtomicHandle _primvars;
108  HdContainerDataSourceHandle _extComputationPrimvars;
109 
110  // Note: _instancerTopology needs to be an atomic handle, since
111  // some downstream customers of it (render index sync, hdSt instancer sync)
112  // are not threadsafe.
113  HdContainerDataSourceAtomicHandle _instancerTopology;
114 };
115 
117 
118 bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType);
119 
121 
122 #endif
TfTokenVector GetNames() override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
void PrimDirtied(const HdDataSourceLocatorSet &locators)
#define HD_API
Definition: api.h:23
HdDataSourceLegacyPrim(const SdfPath &id, const TfToken &type, HdSceneDelegate *sceneDelegate)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
Definition: token.h:70
HdDataSourceBaseHandle Get(const TfToken &name) override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:280
HdSceneDelegate * _sceneDelegate
#define HD_LEGACY_FLAG_TOKENS
#define HD_LEGACY_PRIMTYPE_TOKENS
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TF_DECLARE_PUBLIC_TOKENS(HdLegacyPrimTypeTokens, HD_API, HD_LEGACY_PRIMTYPE_TOKENS)
bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType)
HD_DECLARE_DATASOURCE(HdDataSourceLegacyPrim)
static const HdDataSourceLocatorSet & GetCachedLocators()
Return which locators PrimDirtied will respond to...
HD_DECLARE_DATASOURCE_HANDLES(HdDataSourceLegacyPrim)