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 
41 TF_DECLARE_PUBLIC_TOKENS(HdLegacyPrimTypeTokens, HD_API,
43 
44 /// \class HdExtComputationCallbackDataSource
45 ///
46 /// This is a data source which holds a legacy ext computation. It is used
47 /// only during emulation of legacy scene delegates but is exposed here as it
48 /// is used by HdSceneIndexAdapterSceneDelegate for emulation of legacy
49 /// render delegates.
50 ///
52 {
53 public:
55 
57  const SdfPath &id, HdSceneDelegate *sceneDelegate)
58  : _id(id), _sceneDelegate(sceneDelegate) {}
59 
60  HD_API
61  void Invoke(HdExtComputationContext *context);
62 
63 private:
64  SdfPath _id;
65  HdSceneDelegate *_sceneDelegate;
66 };
67 
69 
70 /// \class HdDataSourceLegacyPrim
71 ///
72 /// This is an HdContainerDataSource which represents a prim-level data source
73 /// for adapting HdSceneDelegate calls into the forms defined by HdSchemas
74 /// during emulation of legacy scene delegates.
75 ///
77 {
78 public:
80 
81  TfTokenVector GetNames() override;
82  HdDataSourceBaseHandle Get(const TfToken &name) override;
83 
84  /// This clears internal cached values and is currently called only by
85  /// HdLegacyPrimSceneIndex in response to its own DirtyPrims method
86  void PrimDirtied(const HdDataSourceLocatorSet &locators);
87 
88  /// Return which locators PrimDirtied will respond to...
90 
91 private:
93  SdfPath id,
94  TfToken type,
95  HdSceneDelegate *sceneDelegate);
96 
97  HdDataSourceBaseHandle _GetPrimvarsDataSource();
98  HdDataSourceBaseHandle _GetExtComputationPrimvarsDataSource();
99  HdDataSourceBaseHandle _GetMaterialBindingsDataSource();
100  HdDataSourceBaseHandle _GetXformDataSource();
101  HdDataSourceBaseHandle _GetMaterialDataSource();
102  HdDataSourceBaseHandle _GetIntegratorDataSource();
103  HdDataSourceBaseHandle _GetSampleFilterDataSource();
104  HdDataSourceBaseHandle _GetDisplayFilterDataSource();
105  HdDataSourceBaseHandle _GetDisplayStyleDataSource();
106  HdDataSourceBaseHandle _GetInstancedByDataSource();
107  HdDataSourceBaseHandle _GetDataSharingDataSource();
108  HdDataSourceBaseHandle _GetInstancerTopologyDataSource();
109  HdDataSourceBaseHandle _GetVolumeFieldBindingDataSource();
110  HdDataSourceBaseHandle _GetCoordSysBindingDataSource();
111  HdDataSourceBaseHandle _GetVisibilityDataSource();
112  HdDataSourceBaseHandle _GetPurposeDataSource();
113  HdDataSourceBaseHandle _GetExtentDataSource();
114  HdDataSourceBaseHandle _GetCategoriesDataSource();
115  HdDataSourceBaseHandle _GetInstanceCategoriesDataSource();
116  HdDataSourceBaseHandle _GetPrmanParamsDataSource();
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:442
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:291
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#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)