HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialPrimvarTransferSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 #ifndef PXR_IMAGING_HDSI_MATERIAL_PRIMVAR_TRANSFER_SCENE_INDEX_H
7 #define PXR_IMAGING_HDSI_MATERIAL_PRIMVAR_TRANSFER_SCENE_INDEX_H
8 
9 #include "pxr/imaging/hdsi/api.h"
11 
12 #include "pxr/pxr.h"
13 
15 
17 
18 /// Transfers primvars present on the locally bound material. Any matching
19 /// primvar already present will have a stronger opinion.
20 ///
21 /// As it's expected that primvars inherited by the destination location
22 /// should have a stronger opinion than those transfered here, inherited
23 /// primvars must be flattened in advance of this scene index.
24 ///
25 /// This is in support of shading workflows.
26 ///
27 /// This also declares dependencies to ensure invalidation if a
28 /// HdDependencyForwardingSceneIndex is present downstream. (Because those
29 /// dependencies are computed on demand, no meaningful additional work is done
30 /// otherwise.)
31 ///
32 /// Some renderers have special syntax and semantics for how attributes
33 /// may be combined. To accommmodate this, an optional ComposeFn may be
34 /// provided to implement this behavior.
35 ///
38 {
39 public:
40  // Type signature for function used to compose a single primvar
41  // using the primvars from geometry and a bound material.
42  // The first argument is the container data source for the
43  // geometry primvars, the second is the container data source
44  // for the material primvars, and the third is the primvar name.
45  // Note that this composes just the single named primvar,
46  // returning a data source for that primvar.
47  using ComposeFn = std::function<
48  HdDataSourceBaseHandle(
49  HdContainerDataSourceHandle const&,
50  HdContainerDataSourceHandle const&,
51  TfToken const&)>;
52 
53  // The default compose function used if none is provided.
54  HDSI_API
55  static HdDataSourceBaseHandle
57  HdContainerDataSourceHandle const& dsStrong,
58  HdContainerDataSourceHandle const& dsWeak,
59  const TfToken& name);
60 
61  HDSI_API
62  static HdsiMaterialPrimvarTransferSceneIndexRefPtr
63  New(const HdSceneIndexBaseRefPtr& inputSceneIndex,
64  const ComposeFn& composeFn = ComposeFn());
65 
66 public: // HdSceneIndex overrides
67  HDSI_API
68  HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override;
69 
70  HDSI_API
71  SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override;
72 
73 protected: // HdSingleInputFilteringSceneIndexBase overrides
74  void _PrimsAdded(
75  const HdSceneIndexBase& sender,
76  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
77  void _PrimsRemoved(
78  const HdSceneIndexBase& sender,
79  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
80  void _PrimsDirtied(
81  const HdSceneIndexBase& sender,
82  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
83 
84 private:
86  const HdSceneIndexBaseRefPtr& inputSceneIndex,
87  const ComposeFn& composeFn);
89 
90  const ComposeFn _composeFn;
91 };
92 
94 
95 #endif
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Definition: token.h:70
std::vector< class SdfPath > SdfPathVector
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:280
#define HDSI_API
Definition: api.h:23
std::function< HdDataSourceBaseHandle(HdContainerDataSourceHandle const &, HdContainerDataSourceHandle const &, TfToken const &)> ComposeFn
static HDSI_API HdsiMaterialPrimvarTransferSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputSceneIndex, const ComposeFn &composeFn=ComposeFn())
static HDSI_API HdDataSourceBaseHandle DefaultComposeFn(HdContainerDataSourceHandle const &dsStrong, HdContainerDataSourceHandle const &dsWeak, const TfToken &name)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(HdsiMaterialPrimvarTransferSceneIndex)