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  HD_API
61  void Invoke(HdExtComputationContext *context);
62 
63 private:
64  SdfPath _id;
65  HdSceneDelegate *_sceneDelegate;
66 };
67 
68 HD_DECLARE_DATASOURCE_HANDLES(HdExtComputationCallbackDataSource);
69 
77 {
78 public:
79  HD_DECLARE_DATASOURCE(HdDataSourceLegacyPrim);
80 
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 _GetDisplayFilterDataSource();
104  HdDataSourceBaseHandle _GetDisplayStyleDataSource();
105  HdDataSourceBaseHandle _GetInstancedByDataSource();
106  HdDataSourceBaseHandle _GetInstancerTopologyDataSource();
107  HdDataSourceBaseHandle _GetVolumeFieldBindingDataSource();
108  HdDataSourceBaseHandle _GetCoordSysBindingDataSource();
109  HdDataSourceBaseHandle _GetVisibilityDataSource();
110  HdDataSourceBaseHandle _GetPurposeDataSource();
111  HdDataSourceBaseHandle _GetExtentDataSource();
112  HdDataSourceBaseHandle _GetCategoriesDataSource();
113  HdDataSourceBaseHandle _GetInstanceCategoriesDataSource();
114  HdDataSourceBaseHandle _GetPrmanParamsDataSource();
115 
116  bool _IsLight();
117 
118 private:
119  SdfPath _id;
120  TfToken _type;
121  HdSceneDelegate *_sceneDelegate;
122 
123  std::atomic_bool _primvarsBuilt;
124  bool _extComputationPrimvarsBuilt : 1;
125 
126  HdContainerDataSourceAtomicHandle _primvars;
127  HdContainerDataSourceHandle _extComputationPrimvars;
128 
129  // Note: _instancerTopology needs to be an atomic handle, since
130  // some downstream customers of it (render index sync, hdSt instancer sync)
131  // are not threadsafe.
132  HdContainerDataSourceAtomicHandle _instancerTopology;
133 };
134 
135 HD_DECLARE_DATASOURCE_HANDLES(HdDataSourceLegacyPrim);
136 
137 bool HdLegacyPrimTypeIsVolumeField(TfToken const &primType);
138 
139 PXR_NAMESPACE_CLOSE_SCOPE
140 
141 #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:110
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:92
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.