Skip to content

Commit 6b06038

Browse files
rajabalapixar-oss
authored andcommitted
[hdSt] Refactor scene index plugin registration.
Hardcode input args in _AppendSceneIndex instead of registration. This is part of a series of a changes to remove the use of inputArgs in the registration API as preparatory work to simplify scene index plugin registration in Hydra. (Internal change: 2388899)
1 parent ac303a9 commit 6b06038

File tree

3 files changed

+60
-40
lines changed

3 files changed

+60
-40
lines changed

pxr/imaging/hdSt/implicitSurfaceSceneIndexPlugin.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,10 @@ TF_REGISTRY_FUNCTION(HdSceneIndexPlugin)
2929
{
3030
const HdSceneIndexPluginRegistry::InsertionPhase insertionPhase = 0;
3131

32-
// Configure the scene index to generate the mesh for each of the implicit
33-
// primitives since Storm doesn't natively support any.
34-
HdDataSourceBaseHandle const toMeshSrc =
35-
HdRetainedTypedSampledDataSource<TfToken>::New(
36-
HdsiImplicitSurfaceSceneIndexTokens->toMesh);
37-
38-
HdContainerDataSourceHandle const inputArgs =
39-
HdRetainedContainerDataSource::New(
40-
HdPrimTypeTokens->sphere, toMeshSrc,
41-
HdPrimTypeTokens->cube, toMeshSrc,
42-
HdPrimTypeTokens->cone, toMeshSrc,
43-
HdPrimTypeTokens->cylinder, toMeshSrc,
44-
HdPrimTypeTokens->capsule, toMeshSrc,
45-
HdPrimTypeTokens->plane, toMeshSrc);
46-
4732
HdSceneIndexPluginRegistry::GetInstance().RegisterSceneIndexForRenderer(
4833
_pluginDisplayName,
4934
_tokens->sceneIndexPluginName,
50-
inputArgs,
35+
/* inputArgs = */ nullptr,
5136
insertionPhase,
5237
HdSceneIndexPluginRegistry::InsertionOrderAtStart);
5338
}
@@ -65,7 +50,27 @@ HdSt_ImplicitSurfaceSceneIndexPlugin::_AppendSceneIndex(
6550
const HdSceneIndexBaseRefPtr &inputScene,
6651
const HdContainerDataSourceHandle &inputArgs)
6752
{
68-
return HdsiImplicitSurfaceSceneIndex::New(inputScene, inputArgs);
53+
// Define inputArgs here instead of in the TF_REGISTRY_FUNCTION block.
54+
// In the future, we may consider renaming the inputArgs parameter to
55+
// something like "sceneIndexGraphCreateArgs" to allow the app and renderer
56+
// plugin to provide arguments for scene indices instantiated via the
57+
// scene index plugin system.
58+
// Configure the scene index to generate the mesh for each of the implicit
59+
// primitives since Storm doesn't natively support any.
60+
HdDataSourceBaseHandle const toMeshSrc =
61+
HdRetainedTypedSampledDataSource<TfToken>::New(
62+
HdsiImplicitSurfaceSceneIndexTokens->toMesh);
63+
64+
HdContainerDataSourceHandle const localInputArgs =
65+
HdRetainedContainerDataSource::New(
66+
HdPrimTypeTokens->sphere, toMeshSrc,
67+
HdPrimTypeTokens->cube, toMeshSrc,
68+
HdPrimTypeTokens->cone, toMeshSrc,
69+
HdPrimTypeTokens->cylinder, toMeshSrc,
70+
HdPrimTypeTokens->capsule, toMeshSrc,
71+
HdPrimTypeTokens->plane, toMeshSrc);
72+
73+
return HdsiImplicitSurfaceSceneIndex::New(inputScene, localInputArgs);
6974
}
7075

7176
PXR_NAMESPACE_CLOSE_SCOPE

pxr/imaging/hdSt/unboundMaterialPruningSceneIndexPlugin.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,10 @@ TF_REGISTRY_FUNCTION(HdSceneIndexPlugin)
4848
// scnee index.
4949
const HdSceneIndexPluginRegistry::InsertionPhase insertionPhase = 900;
5050

51-
const HdTokenArrayDataSourceHandle bindingPurposesDs =
52-
HdRetainedTypedSampledDataSource<VtArray<TfToken>>::New(
53-
VtArray<TfToken>({
54-
HdTokens->preview,
55-
HdMaterialBindingsSchemaTokens->allPurpose,
56-
}));
57-
58-
const HdContainerDataSourceHandle inputArgs =
59-
HdRetainedContainerDataSource::New(
60-
HdsiUnboundMaterialPruningSceneIndexTokens->materialBindingPurposes,
61-
bindingPurposesDs);
62-
6351
HdSceneIndexPluginRegistry::GetInstance().RegisterSceneIndexForRenderer(
6452
_pluginDisplayName,
6553
_tokens->sceneIndexPluginName,
66-
inputArgs,
54+
/* inputArgs = */ nullptr,
6755
insertionPhase,
6856
HdSceneIndexPluginRegistry::InsertionOrderAtStart);
6957
}
@@ -76,10 +64,29 @@ HdSt_UnboundMaterialPruningSceneIndexPlugin::_AppendSceneIndex(
7664
const HdSceneIndexBaseRefPtr &inputScene,
7765
const HdContainerDataSourceHandle &inputArgs)
7866
{
79-
if (_IsEnabled()) {
80-
return HdsiUnboundMaterialPruningSceneIndex::New(inputScene, inputArgs);
67+
if (!_IsEnabled()) {
68+
return inputScene;
8169
}
82-
return inputScene;
70+
71+
// Define inputArgs here instead of in the TF_REGISTRY_FUNCTION block.
72+
// In the future, we may consider renaming the inputArgs parameter to
73+
// something like "sceneIndexGraphCreateArgs" to allow the app and renderer
74+
// plugin to provide arguments for scene indices instantiated via the
75+
// scene index plugin system.
76+
static const HdTokenArrayDataSourceHandle bindingPurposesDs =
77+
HdRetainedTypedSampledDataSource<VtArray<TfToken>>::New(
78+
VtArray<TfToken>({
79+
HdTokens->preview,
80+
HdMaterialBindingsSchemaTokens->allPurpose,
81+
}));
82+
83+
static const HdContainerDataSourceHandle localInputArgs =
84+
HdRetainedContainerDataSource::New(
85+
HdsiUnboundMaterialPruningSceneIndexTokens->materialBindingPurposes,
86+
bindingPurposesDs);
87+
88+
return HdsiUnboundMaterialPruningSceneIndex::New(
89+
inputScene, localInputArgs);
8390
}
8491

8592
PXR_NAMESPACE_CLOSE_SCOPE

pxr/imaging/hdSt/velocityMotionResolvingSceneIndexPlugin.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@ TF_REGISTRY_FUNCTION(HdSceneIndexPlugin)
3737
{
3838
// This one should go after implicit surface conversion
3939
static const HdSceneIndexPluginRegistry::InsertionPhase insertionPhase = 0;
40-
const HdContainerDataSourceHandle inputArgs =
41-
HdRetainedContainerDataSource::New(
42-
_tokens->fps,
43-
// TODO: Get real framerate!
44-
HdRetainedTypedSampledDataSource<float>::New(24.0));
40+
4541
HdSceneIndexPluginRegistry::GetInstance().RegisterSceneIndexForRenderer(
4642
_pluginDisplayName,
4743
_tokens->sceneIndexPluginName,
48-
inputArgs,
44+
/* inputArgs = */ nullptr,
4945
insertionPhase,
5046
HdSceneIndexPluginRegistry::InsertionOrderAtEnd);
5147
}
@@ -58,7 +54,19 @@ HdSt_VelocityMotionResolvingSceneIndexPlugin::_AppendSceneIndex(
5854
const HdSceneIndexBaseRefPtr& inputScene,
5955
const HdContainerDataSourceHandle& inputArgs)
6056
{
61-
return HdsiVelocityMotionResolvingSceneIndex::New(inputScene, inputArgs);
57+
// Define inputArgs here instead of in the TF_REGISTRY_FUNCTION block.
58+
// In the future, we may consider renaming the inputArgs parameter to
59+
// something like "sceneIndexGraphCreateArgs" to allow the app and renderer
60+
// plugin to provide arguments for scene indices instantiated via the
61+
// scene index plugin system.
62+
const HdContainerDataSourceHandle localInputArgs =
63+
HdRetainedContainerDataSource::New(
64+
_tokens->fps,
65+
// TODO: Get real framerate!
66+
HdRetainedTypedSampledDataSource<float>::New(24.0));
67+
68+
return HdsiVelocityMotionResolvingSceneIndex::New(
69+
inputScene, localInputArgs);
6270
}
6371

6472
PXR_NAMESPACE_CLOSE_SCOPE

0 commit comments

Comments
 (0)