dataSourceLegacyPrim.h
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 
27 #include "pxr/imaging/hd/sceneIndex.h"
28 #include "pxr/imaging/hd/api.h"
30 
31 PXR_NAMESPACE_OPEN_SCOPE
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,
42  HD_LEGACY_PRIMTYPE_TOKENS);
43 
52 {
53 public:
54  HD_DECLARE_DATASOURCE(HdExtComputationCallbackDataSource);
55 
57  const SdfPath &id, HdSceneDelegate *sceneDelegate)
58  : _id(id), _sceneDelegate(sceneDelegate) {}
59 
60  void Invoke(HdExtComputationContext *context);
61 
62 private:
63  SdfPath _id;
64  HdSceneDelegate *_sceneDelegate;
65 };
66 
67 HD_DECLARE_DATASOURCE_HANDLES(HdExtComputationCallbackDataSource);
68 
76 {
77 public:
78  HD_DECLARE_DATASOURCE(HdDataSourceLegacyPrim);
79 
80  bool Has(const TfToken &name) override;
81  TfTokenVector GetNames() override;
82  HdDataSourceBaseHandle Get(const TfToken &name) override;
83 
86  void PrimDirtied(const HdDataSourceLocatorSet &locators);
87 
90 
91 private:
93  SdfPath id,
94  TfToken type,
95  HdSceneDelegate *sceneDelegate);
96 
97  HdDataSourceBaseHandle _GetPrimvarsDataSource();
98  HdDataSourceBaseHandle _GetExtComputationPrimvarsDataSource();
99  HdDataSourceBaseHandle _GetMaterialBindingDataSource();
100  HdDataSourceBaseHandle _GetXformDataSource();
101  HdDataSourceBaseHandle _GetMaterialDataSource();
102  HdDataSourceBaseHandle _GetSampleFilterDataSource();
103  HdDataSourceBaseHandle _GetDisplayStyleDataSource();
104  HdDataSourceBaseHandle _GetInstancedByDataSource();
105  HdDataSourceBaseHandle _GetInstancerTopologyDataSource();
106  HdDataSourceBaseHandle _GetVolumeFieldBindingDataSource();
107  HdDataSourceBaseHandle _GetCoordSysBindingDataSource();
108  HdDataSourceBaseHandle _GetVisibilityDataSource();
109  HdDataSourceBaseHandle _GetPurposeDataSource();
110  HdDataSourceBaseHandle _GetExtentDataSource();
111  HdDataSourceBaseHandle _GetCategoriesDataSource();
112  HdDataSourceBaseHandle _GetInstanceCategoriesDataSource();
113  HdDataSourceBaseHandle _GetPrmanParamsDataSource();
114 
115 private:
116  SdfPath _id;
117  TfToken _type;
118  HdSceneDelegate *_sceneDelegate;
119 
120  std::atomic_bool _primvarsBuilt;
121  bool _extComputationPrimvarsBuilt : 1;
122 
123  HdContainerDataSourceAtomicHandle _primvars;
124  HdContainerDataSourceHandle _extComputationPrimvars;
125 
126  // Note: _instancerTopology needs to be an atomic handle, since
127  // some downstream customers of it (render index sync, hdSt instancer sync)
128  // are not threadsafe.
129  HdContainerDataSourceAtomicHandle _instancerTopology;
130 };
131 
132 HD_DECLARE_DATASOURCE_HANDLES(HdDataSourceLegacyPrim);
133 
134 bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType);
135 
136 PXR_NAMESPACE_CLOSE_SCOPE
137 
138 #endif
Interface class that defines the execution environment for the client to run a computation.
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:102
void PrimDirtied(const HdDataSourceLocatorSet &locators)
This clears internal cached values and is currently called only by HdLegacyPrimSceneIndex in response...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
static const HdDataSourceLocatorSet & GetCachedLocators()
Return which locators PrimDirtied will respond to...
Adapter class providing data exchange with the client scene graph.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
Represents a set of data source locators closed under descendancy.
HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Represents an object which can produce scene data.
Definition: dataSource.h:84
bool Has(const TfToken &name) override
Returns true if the container has a child datasource of the given name, in which case Get(name) is ex...
This file defines some macros that are useful for declaring and using static TfTokens.
This is an HdContainerDataSource which represents a prim-level data source for adapting HdSceneDelega...
This is a data source which holds a legacy ext computation.
TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.