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 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_DATA_SOURCE_LEGACY_PRIM_H
25 #define PXR_IMAGING_HD_DATA_SOURCE_LEGACY_PRIM_H
26 
28 #include "pxr/imaging/hd/api.h"
30 
32 
33 class HdSceneDelegate;
35 
36 #define HD_LEGACY_PRIMTYPE_TOKENS \
37  /* Bprims */ \
38  (openvdbAsset) \
39  (field3dAsset) \
40  (houdiniFieldAsset)
41 
42 TF_DECLARE_PUBLIC_TOKENS(HdLegacyPrimTypeTokens, HD_API,
44 
45 /// \class HdExtComputationCallbackDataSource
46 ///
47 /// This is a data source which holds a legacy ext computation. It is used
48 /// only during emulation of legacy scene delegates but is exposed here as it
49 /// is used by HdSceneIndexAdapterSceneDelegate for emulation of legacy
50 /// render delegates.
51 ///
53 {
54 public:
56 
58  const SdfPath &id, HdSceneDelegate *sceneDelegate)
59  : _id(id), _sceneDelegate(sceneDelegate) {}
60 
61  HD_API
62  void Invoke(HdExtComputationContext *context);
63 
64 private:
65  SdfPath _id;
66  HdSceneDelegate *_sceneDelegate;
67 };
68 
70 
71 /// \class HdDataSourceLegacyPrim
72 ///
73 /// This is an HdContainerDataSource which represents a prim-level data source
74 /// for adapting HdSceneDelegate calls into the forms defined by HdSchemas
75 /// during emulation of legacy scene delegates.
76 ///
78 {
79 public:
81 
82  TfTokenVector GetNames() override;
83  HdDataSourceBaseHandle Get(const TfToken &name) override;
84 
85  /// This clears internal cached values and is currently called only by
86  /// HdLegacyPrimSceneIndex in response to its own DirtyPrims method
87  void PrimDirtied(const HdDataSourceLocatorSet &locators);
88 
89  /// Return which locators PrimDirtied will respond to...
91 
92 private:
94  SdfPath id,
95  TfToken type,
96  HdSceneDelegate *sceneDelegate);
97 
98  HdDataSourceBaseHandle _GetPrimvarsDataSource();
99  HdDataSourceBaseHandle _GetExtComputationPrimvarsDataSource();
100  HdDataSourceBaseHandle _GetMaterialBindingsDataSource();
101  HdDataSourceBaseHandle _GetXformDataSource();
102  HdDataSourceBaseHandle _GetMaterialDataSource();
103  HdDataSourceBaseHandle _GetIntegratorDataSource();
104  HdDataSourceBaseHandle _GetSampleFilterDataSource();
105  HdDataSourceBaseHandle _GetDisplayFilterDataSource();
106  HdDataSourceBaseHandle _GetDisplayStyleDataSource();
107  HdDataSourceBaseHandle _GetInstancedByDataSource();
108  HdDataSourceBaseHandle _GetDataSharingDataSource();
109  HdDataSourceBaseHandle _GetInstancerTopologyDataSource();
110  HdDataSourceBaseHandle _GetVolumeFieldBindingDataSource();
111  HdDataSourceBaseHandle _GetCoordSysBindingDataSource();
112  HdDataSourceBaseHandle _GetVisibilityDataSource();
113  HdDataSourceBaseHandle _GetPurposeDataSource();
114  HdDataSourceBaseHandle _GetExtentDataSource();
115  HdDataSourceBaseHandle _GetCategoriesDataSource();
116  HdDataSourceBaseHandle _GetInstanceCategoriesDataSource();
117 
118  bool _IsLight();
119  bool _IsInstanceable();
120 
121 private:
122  SdfPath _id;
123  TfToken _type;
124  HdSceneDelegate *_sceneDelegate;
125 
126  std::atomic_bool _primvarsBuilt;
127  bool _extComputationPrimvarsBuilt : 1;
128 
129  HdContainerDataSourceAtomicHandle _primvars;
130  HdContainerDataSourceHandle _extComputationPrimvars;
131 
132  // Note: _instancerTopology needs to be an atomic handle, since
133  // some downstream customers of it (render index sync, hdSt instancer sync)
134  // are not threadsafe.
135  HdContainerDataSourceAtomicHandle _instancerTopology;
136 };
137 
139 
140 bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType);
141 
143 
144 #endif
TfTokenVector GetNames() override
HdExtComputationCallbackDataSource(const SdfPath &id, HdSceneDelegate *sceneDelegate)
void PrimDirtied(const HdDataSourceLocatorSet &locators)
#define HD_API
Definition: api.h:40
HD_API void Invoke(HdExtComputationContext *context)
Definition: token.h:87
HdDataSourceBaseHandle Get(const TfToken &name) override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:290
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define HD_LEGACY_PRIMTYPE_TOKENS
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
TF_DECLARE_PUBLIC_TOKENS(HdLegacyPrimTypeTokens, HD_API, HD_LEGACY_PRIMTYPE_TOKENS)
bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType)
HD_DECLARE_DATASOURCE(HdExtComputationCallbackDataSource)
HD_DECLARE_DATASOURCE(HdDataSourceLegacyPrim)
static const HdDataSourceLocatorSet & GetCachedLocators()
Return which locators PrimDirtied will respond to...
type
Definition: core.h:1059
HD_DECLARE_DATASOURCE_HANDLES(HdExtComputationCallbackDataSource)