-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hydra emulation: making tasks also go through emulation. More precise…
…ly, the emulated scene index driven by legacy scene delegates. This fixes the crash reported in #3471 caused by change 2351061. The problem was that the HdxTaskController added a task without going through emulation. But when we received a removed notice (in this case UsdImagingStageSceneIndex removing /), we removed the task without re-adding it. That is, the merging scene index is removing and re-adding prims. But because the task was not properly emulated, it was never re-added when the merging scene index send the prims added notice. Fixes #3471 (Internal change: 2353415)
- Loading branch information
1 parent
7579b91
commit 5973111
Showing
13 changed files
with
281 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// | ||
// Copyright 2025 Pixar | ||
// | ||
// Licensed under the terms set forth in the LICENSE.txt file available at | ||
// https://openusd.org/license. | ||
// | ||
#include "pxr/imaging/hd/dataSourceLegacyTaskPrim.h" | ||
|
||
#include "pxr/imaging/hd/legacyTaskSchema.h" | ||
#include "pxr/imaging/hd/retainedDataSource.h" | ||
#include "pxr/imaging/hd/sceneDelegate.h" | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
namespace { | ||
|
||
class _LegacyTaskSchemaDataSource : public HdContainerDataSource | ||
{ | ||
public: | ||
HD_DECLARE_DATASOURCE(_LegacyTaskSchemaDataSource); | ||
|
||
TfTokenVector GetNames() override { | ||
static const TfTokenVector result = { | ||
HdLegacyTaskSchemaTokens->factory, | ||
HdLegacyTaskSchemaTokens->parameters, | ||
HdLegacyTaskSchemaTokens->collection, | ||
HdLegacyTaskSchemaTokens->renderTags | ||
}; | ||
return result; | ||
} | ||
|
||
HdDataSourceBaseHandle Get(const TfToken &name) override { | ||
if (name == HdLegacyTaskSchemaTokens->factory) { | ||
return _ToTypedDataSource(_factory); | ||
} | ||
|
||
if (name == HdLegacyTaskSchemaTokens->parameters) { | ||
return HdRetainedSampledDataSource::New( | ||
_sceneDelegate->Get(_id, HdTokens->params)); | ||
} | ||
|
||
if (name == HdLegacyTaskSchemaTokens->collection) { | ||
return _Get<HdRprimCollection>(HdTokens->collection); | ||
} | ||
|
||
if (name == HdLegacyTaskSchemaTokens->renderTags) { | ||
return _Get<TfTokenVector>(HdTokens->renderTags); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
private: | ||
_LegacyTaskSchemaDataSource( | ||
const SdfPath& id, | ||
HdSceneDelegate * const sceneDelegate, | ||
HdLegacyTaskFactorySharedPtr factory) | ||
: _id(id) | ||
, _sceneDelegate(sceneDelegate) | ||
, _factory(std::move(factory)) | ||
{ | ||
} | ||
|
||
template<typename T> | ||
static | ||
HdDataSourceBaseHandle | ||
_ToTypedDataSource(const T &v) | ||
{ | ||
return HdRetainedTypedSampledDataSource<T>::New(v); | ||
} | ||
|
||
template<typename T> | ||
HdDataSourceBaseHandle | ||
_Get(const TfToken &key) const { | ||
const VtValue value = _sceneDelegate->Get(_id, key); | ||
if (!value.IsHolding<T>()) { | ||
return nullptr; | ||
} | ||
return _ToTypedDataSource(value.UncheckedGet<T>()); | ||
} | ||
|
||
const SdfPath _id; | ||
HdSceneDelegate * const _sceneDelegate; | ||
HdLegacyTaskFactorySharedPtr const _factory; | ||
}; | ||
|
||
} | ||
|
||
HdDataSourceLegacyTaskPrim::HdDataSourceLegacyTaskPrim( | ||
const SdfPath& id, | ||
HdSceneDelegate * const sceneDelegate, | ||
HdLegacyTaskFactorySharedPtr factory) | ||
: _id(id) | ||
, _sceneDelegate(sceneDelegate) | ||
, _factory(std::move(factory)) | ||
{ | ||
} | ||
|
||
HdDataSourceLegacyTaskPrim::~HdDataSourceLegacyTaskPrim() = default; | ||
|
||
TfTokenVector | ||
HdDataSourceLegacyTaskPrim::GetNames() | ||
{ | ||
static const TfTokenVector result = { | ||
HdLegacyTaskSchemaTokens->task | ||
}; | ||
return result; | ||
} | ||
|
||
HdDataSourceBaseHandle | ||
HdDataSourceLegacyTaskPrim::Get(const TfToken &name) | ||
{ | ||
if (!TF_VERIFY(_sceneDelegate)) { | ||
return nullptr; | ||
} | ||
|
||
if (name == HdLegacyTaskSchemaTokens->task) { | ||
return _LegacyTaskSchemaDataSource::New(_id, _sceneDelegate, _factory); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
|
||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Copyright 2025 Pixar | ||
// | ||
// Licensed under the terms set forth in the LICENSE.txt file available at | ||
// https://openusd.org/license. | ||
// | ||
#ifndef PXR_IMAGING_HD_DATA_SOURCE_LEGACY_TASK_PRIM_H | ||
#define PXR_IMAGING_HD_DATA_SOURCE_LEGACY_TASK_PRIM_H | ||
|
||
#include "pxr/usd/sdf/path.h" | ||
|
||
#include "pxr/imaging/hd/api.h" | ||
#include "pxr/imaging/hd/dataSource.h" | ||
|
||
#include "pxr/pxr.h" | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
using HdLegacyTaskFactorySharedPtr = std::shared_ptr<class HdLegacyTaskFactory>; | ||
class HdSceneDelegate; | ||
|
||
/// \class HdDataSourceLegacyTaskPrim | ||
/// | ||
/// This is an HdContainerDataSource which represents a prim-level data source | ||
/// for a task for adapting HdSceneDelegate calls into the forms defined by | ||
/// HdSchemas during emulation of legacy scene delegates. | ||
/// | ||
class HdDataSourceLegacyTaskPrim : public HdContainerDataSource | ||
{ | ||
public: | ||
HD_DECLARE_DATASOURCE(HdDataSourceLegacyTaskPrim); | ||
|
||
~HdDataSourceLegacyTaskPrim() override; | ||
|
||
TfTokenVector GetNames() override; | ||
HdDataSourceBaseHandle Get(const TfToken &name) override; | ||
|
||
private: | ||
HdDataSourceLegacyTaskPrim( | ||
const SdfPath& id, | ||
HdSceneDelegate *sceneDelegate, | ||
HdLegacyTaskFactorySharedPtr factory); | ||
|
||
const SdfPath _id; | ||
HdSceneDelegate * const _sceneDelegate; | ||
HdLegacyTaskFactorySharedPtr const _factory; | ||
}; | ||
|
||
HD_DECLARE_DATASOURCE_HANDLES(HdDataSourceLegacyTaskPrim); | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.