Skip to content

Commit ce53760

Browse files
committed
HYDRA-2274 : more fixes for usd 26.05 unit tests
1 parent 6ee3828 commit ce53760

23 files changed

Lines changed: 181 additions & 40 deletions

File tree

lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp

Lines changed: 95 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <pxr/base/vt/value.h>
2828
#include <pxr/imaging/hd/materialSchema.h>
2929
#include <pxr/imaging/hd/materialBindingsSchema.h>
30+
#include <pxr/imaging/hd/primOriginSchema.h>
3031

3132
#include <gtest/gtest.h>
3233

@@ -37,9 +38,64 @@
3738
#include <QVBoxLayout>
3839
#include <iostream>
3940
#include <regex>
41+
#include <set>
4042
#include <stack>
4143
#include <vector>
4244

45+
namespace {
46+
47+
// Matches HduiDataSourceTreeWidget's name ordering.
48+
std::vector<PXR_NS::TfToken>
49+
GetSortedContainerChildNames(const PXR_NS::HdContainerDataSourceHandle& container)
50+
{
51+
const PXR_NS::TfTokenVector names = container->GetNames();
52+
const std::set<PXR_NS::TfToken, PXR_NS::TfDictionaryLessThan> sortedNames(
53+
names.begin(), names.end());
54+
return std::vector<PXR_NS::TfToken>(sortedNames.begin(), sortedNames.end());
55+
}
56+
57+
void PushSortedContainerChildrenOnStack(
58+
const PXR_NS::HdContainerDataSourceHandle& container,
59+
const PXR_NS::HdDataSourceLocator& parentLocator,
60+
std::stack<DataSourceEntry>& dataSourceStack)
61+
{
62+
const std::vector<PXR_NS::TfToken> sortedChildNames = GetSortedContainerChildNames(container);
63+
for (auto itChildNames = sortedChildNames.rbegin(); itChildNames != sortedChildNames.rend();
64+
++itChildNames) {
65+
const PXR_NS::TfToken& childName = *itChildNames;
66+
if (PXR_NS::HdDataSourceBaseHandle childDataSource = container->Get(childName)) {
67+
dataSourceStack.push(
68+
{ childName, childDataSource, parentLocator.Append(childName) });
69+
}
70+
}
71+
}
72+
73+
std::stack<DataSourceEntry> BuildInitialDataSourceStack(
74+
const PXR_NS::SdfPath& primPath, const PXR_NS::HdSceneIndexPrim& prim)
75+
{
76+
std::stack<DataSourceEntry> dataSourceStack;
77+
78+
#if PXR_VERSION >= 2511
79+
// HduiDataSourceTreeWidget::SetPrimDataSource lists sorted container children
80+
// as top-level items instead of the prim data source container itself.
81+
if (PXR_NS::HdContainerDataSourceHandle container
82+
= PXR_NS::HdContainerDataSource::Cast(prim.dataSource)) {
83+
PushSortedContainerChildrenOnStack(
84+
container, PXR_NS::HdDataSourceLocator(), dataSourceStack);
85+
} else if (prim.dataSource) {
86+
dataSourceStack.push(
87+
{ primPath.GetNameToken(), prim.dataSource, PXR_NS::HdDataSourceLocator() });
88+
}
89+
#else
90+
dataSourceStack.push(
91+
{ primPath.GetNameToken(), prim.dataSource, PXR_NS::HdDataSourceLocator() });
92+
#endif
93+
94+
return dataSourceStack;
95+
}
96+
97+
} // namespace
98+
4399
template <class ChildType> ChildType* FindFirstChild(QObject* qObject)
44100
{
45101
for (QObject* child : qObject->children()) {
@@ -132,31 +188,33 @@ void AdskHydraSceneBrowserTestFixture::ComparePrimHierarchy(
132188
// Compare data source
133189
if (compareDataSourceHierarchy) {
134190
_primHierarchyWidget->setCurrentItem(primQtItem);
135-
CompareDataSourceHierarchy( primPath,
136-
{ primPath.GetNameToken(), prim.dataSource, PXR_NS::HdDataSourceLocator() }, compareDataSourceValues);
191+
CompareDataSourceHierarchy(primPath, BuildInitialDataSourceStack(primPath, prim),
192+
compareDataSourceValues);
137193
}
138194

139195
// Prepare next step (need to pop the stack before pushing the next elements)
140196
itPrimsTreeWidget++;
141197
primPathsStack.pop();
142198

143-
// Push child paths on the stack
144-
PXR_NS::SdfPathVector childPaths = sceneIndex->GetChildPrimPaths(primPath);
145-
for (auto itChildPaths = childPaths.rbegin(); itChildPaths != childPaths.rend();
146-
itChildPaths++) {
199+
// Push child paths on the stack in the same sorted order used by
200+
// HduiSceneIndexTreeWidget.
201+
const PXR_NS::SdfPathVector childPathVec = sceneIndex->GetChildPrimPaths(primPath);
202+
const PXR_NS::SdfPathSet sortedChildPaths(childPathVec.begin(), childPathVec.end());
203+
for (auto itChildPaths = sortedChildPaths.rbegin(); itChildPaths != sortedChildPaths.rend();
204+
++itChildPaths) {
147205
primPathsStack.push(*itChildPaths);
148206
}
149207
}
150208
}
151209

152210
void AdskHydraSceneBrowserTestFixture::CompareDataSourceHierarchy(
153-
const PXR_NS::SdfPath& primPath,
154-
DataSourceEntry rootDataSourceEntry,
155-
bool compareValues)
211+
const PXR_NS::SdfPath& primPath,
212+
std::stack<DataSourceEntry> initialDataSourceStack,
213+
bool compareValues)
156214
{
157215
// Setup traversal data structures (depth-first search)
158216
QTreeWidgetItemIterator itDataSourceTreeWidget = GetIteratorForTree(_dataSourceHierarchyWidget);
159-
std::stack<DataSourceEntry> dataSourceStack({ rootDataSourceEntry });
217+
std::stack<DataSourceEntry> dataSourceStack = std::move(initialDataSourceStack);
160218

161219
// Traverse hierarchy and compare (depth-first search)
162220
while (*itDataSourceTreeWidget && !dataSourceStack.empty()) {
@@ -183,15 +241,8 @@ void AdskHydraSceneBrowserTestFixture::CompareDataSourceHierarchy(
183241
// Push child data sources on the stack
184242
if (auto containerDataSource
185243
= PXR_NS::HdContainerDataSource::Cast(dataSourceEntry.dataSource)) {
186-
PXR_NS::TfTokenVector childNames = containerDataSource->GetNames();
187-
for (auto itChildNames = childNames.rbegin(); itChildNames != childNames.rend();
188-
itChildNames++) {
189-
PXR_NS::TfToken dataSourceName = *itChildNames;
190-
PXR_NS::HdDataSourceBaseHandle dataSource = containerDataSource->Get(dataSourceName);
191-
if (dataSource) {
192-
dataSourceStack.push({ dataSourceName, dataSource, dataSourceEntry.locator.Append(dataSourceName) });
193-
}
194-
}
244+
PushSortedContainerChildrenOnStack(
245+
containerDataSource, dataSourceEntry.locator, dataSourceStack);
195246
} else if (
196247
auto vectorDataSource = PXR_NS::HdVectorDataSource::Cast(dataSourceEntry.dataSource)) {
197248
for (size_t iElement = 0; iElement < vectorDataSource->GetNumElements(); iElement++) {
@@ -298,8 +349,31 @@ void AdskHydraSceneBrowserTestFixture::CompareValueContent(const PXR_NS::VtValue
298349
for (PXR_NS::SdfPath const& path : paths) {
299350
valueStream << path << "\n";
300351
}
301-
}
302-
else {
352+
} else if (value.IsHolding<PXR_NS::HdPrimOriginSchema::OriginPath>()) {
353+
// Special case for HdPrimOriginSchema::OriginPath: mirror the display
354+
// logic in HduiDataSourceValueTreeView, which has always called
355+
// .GetPath() directly to show just the wrapped SdfPath (e.g.
356+
// "/USDCylinder").
357+
//
358+
// Before USD 26.05, HdPrimOriginSchema::OriginPath was not a
359+
// registered core Vt value type, so VtValue::operator<< fell through
360+
// to Vt_StreamOutGeneric and emitted the fallback format
361+
// "<'HdPrimOriginSchema::OriginPath' @ 0x...>". That pattern was
362+
// caught by MatchesFallbackTextOutput and the comparison was skipped.
363+
//
364+
// Starting with USD 26.05, "Hydra Scene Debugger now supports all
365+
// registered core Vt value types rather than a hard-coded subset"
366+
// (see OpenUSD CHANGELOG [26.05]). OriginPath became a registered
367+
// type, so VtValue::operator<< now correctly calls
368+
// operator<<(stream, OriginPath const& p)
369+
// which emits "HdPrimOriginSchema::OriginPath(<path>)". That string
370+
// no longer matches the fallback regex, causing the exact-match
371+
// EXPECT_EQ to fail against the widget's simpler ".GetPath()" output.
372+
//
373+
// The fix is to always compute expectedValue the same way the widget
374+
// does, regardless of how operator<< formats the VtValue.
375+
valueStream << value.UncheckedGet<PXR_NS::HdPrimOriginSchema::OriginPath>().GetPath();
376+
} else {
303377
valueStream << value;
304378
}
305379
#endif

lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include <gtest/gtest.h>
2828

29+
#include <stack>
30+
2931
#include <dataSourceTreeWidget.h>
3032
#include <dataSourceValueTreeView.h>
3133
#include <sceneIndexDebuggerWidget.h>
@@ -54,8 +56,10 @@ class AdskHydraSceneBrowserTestFixture : public ::testing::Test
5456
bool compareDataSourceHierarchy = false,
5557
bool compareDataSourceValues = false);
5658

57-
void
58-
CompareDataSourceHierarchy(const PXR_NS::SdfPath& primPath, DataSourceEntry rootDataSourceEntry, bool compareValues = false);
59+
void CompareDataSourceHierarchy(
60+
const PXR_NS::SdfPath& primPath,
61+
std::stack<DataSourceEntry> initialDataSourceStack,
62+
bool compareValues = false);
5963

6064
void
6165
CompareDataSourceName(const PXR_NS::SdfPath& primPath, const QTreeWidgetItem* dataSourceQtItem, const DataSourceEntry& dataSourceEntry);

lib/mayaHydra/mayaPlugin/renderOverride.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,7 @@ void MtohRenderOverride::_CreateSceneIndicesChainAfterMergingSceneIndex(const MH
17981798
const bool pruneTextures = !(drawContext.getDisplayStyle() & MHWRender::MFrameContext::kTextured);
17991799
_lastFilteringSceneIndexBeforeCustomFiltering = _pruneTexturesSceneIndex =
18001800
Fvp::PruneTexturesSceneIndex::New(_lastFilteringSceneIndexBeforeCustomFiltering, pruneTextures);
1801+
_currentlyTextured = !pruneTextures;
18011802

18021803
// Add default material scene index
18031804
_lastFilteringSceneIndexBeforeCustomFiltering = _defaultMaterialSceneIndex = Fvp::DefaultMaterialSceneIndex::New(_lastFilteringSceneIndexBeforeCustomFiltering,

test/lib/mayaUsd/render/mayaToHydra/ArnoldLightsTest/usd2511+/allLights.png renamed to test/lib/mayaUsd/render/mayaToHydra/ArnoldLightsTest/usd25.11/allLights.png

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# USD 26.05+ Baselines — ArnoldLightsTest
2+
3+
| Image | Source |
4+
|-------|--------|
5+
| `allLights.png` | **New in USD 26.05** — updated baseline from failing preflight |
6+
7+
## Why unchanged images are copied here instead of relying on usd25.11/
8+
9+
The test framework's `resolveRefImage` builds the baseline path as
10+
`<testDir>/<imageVersion>/<imageName>` with no fallback to the parent folder.
11+
If `imageVersion` is set to `"usd26.05+"` and a file is missing from this folder,
12+
the test will fail with a missing file error rather than falling back to `usd25.11/`.
13+
Therefore all images that this test compares with `imageVersion` must be present here,
14+
even those whose pixel content is identical to the `usd25.11/` version.
46.6 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# USD 26.05+ Baselines — TexturedModeTest
2+
3+
| Image | Source |
4+
|-------|--------|
5+
| `untextured.png` | **New in USD 26.05** — updated baseline from failing preflight |
6+
| `textured.png` | Copied from `TexturedModeTest/` root — no visual change in USD 26.05 |
7+
8+
## Why unchanged images are copied here instead of relying on the root folder
9+
10+
The test framework's `resolveRefImage` builds the baseline path as
11+
`<testDir>/<imageVersion>/<imageName>` with no fallback to the parent folder.
12+
If `imageVersion` is set to `"usd26.05+"` and a file is missing from this folder,
13+
the test will fail with a missing file error rather than falling back to the root
14+
`TexturedModeTest/` directory.
15+
Therefore all images that this test compares with `imageVersion` must be present here,
16+
even those whose pixel content is identical to the root version.
29.2 KB
Loading
8.26 KB
Loading

test/lib/mayaUsd/render/mayaToHydra/USDLightsTest/usd2511+/allLights.png renamed to test/lib/mayaUsd/render/mayaToHydra/USDLightsTest/usd25.11/allLights.png

File renamed without changes.

0 commit comments

Comments
 (0)