Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When selection changes mark the prims which are added/removed from the list dirty. #1838

Conversation

williamkrick
Copy link
Contributor

This change also removes the selected repr from proxyRenderDelegate because nothing actually needs it, and adds more Maya profiler events in mesh::Sync.

@@ -572,6 +565,13 @@ void HdVP2BasisCurves::Sync(

const SdfPath& id = GetId();

// Update the selection status if it changed.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was in initRepr, but it is not really any different from other code that has dirty flags so there is not a reason for it to be there.

@@ -1525,11 +1525,6 @@ void HdVP2BasisCurves::_UpdateDrawItem(
*/
HdDirtyBits HdVP2BasisCurves::_PropagateDirtyBits(HdDirtyBits bits) const
{
// Visibility and selection result in highlight changes:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DirtySelection is gone, it was never really used properly. There is now only DirtySelectionHighlight and DirtySelectionMode.

Copy link
Collaborator

@JGamache-autodesk JGamache-autodesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kxl-adsk kxl-adsk requested a review from dj-mcg November 17, 2021 16:58
@williamkrick williamkrick added the vp2renderdelegate Related to VP2RenderDelegate label Nov 17, 2021
@dj-mcg
Copy link
Collaborator

dj-mcg commented Nov 17, 2021

This may be a local issue, and I have yet to test it in our tree, but just running the MayaUSD tests I'm getting a crash when running testVP2RenderDelegateGeomSubset:

pxrInternal_v0_21__pxrReserved__::UsdImagingDelegate::ConvertCachePathToIndexPath(pxrInternal_v0_21__pxrReserved__::SdfPath const&) pxrInternal_v0_21__pxrReserved__::HdVP2Mesh::Sync(pxrInternal_v0_21__pxrReserved__::HdSceneDelegate*, pxrInternal_v0_21__pxrReserved__::HdRenderParam*, unsigned int*, pxrInternal_v0_21__pxrReserved__::TfToken const&) /home/danmcgarry/local/open_source_projects/USD_release/build/inst/lib/libusd_hd.so(+0x265438) [0x7f523fcb1438] /home/danmcgarry/local/open_source_projects/USD_release/build/inst/lib/libusd_hd.so(+0x26c3f1) [0x7f523fcb83f1] /home/danmcgarry/local/open_source_projects/USD_release/build/inst/lib/libusd_hd.so(+0x26caac) [0x7f523fcb8aac] /dist/sw/maya/2022.update2/lib/libtbb.so.2(+0x2d119) [0x7f537dcd8119] /dist/sw/maya/2022.update2/lib/libtbb.so.2(+0x2a73c) [0x7f537dcd573c] /home/danmcgarry/local/open_source_projects/USD_release/build/inst/lib/libusd_hd.so(+0x261255) [0x7f523fcad255] /dist/sw/maya/2022.update2/lib/libtbb.so.2(+0x2d119) [0x7f537dcd8119] pxrInternal_v0_21__pxrReserved__::WorkDispatcher::Wait() pxrInternal_v0_21__pxrReserved__::WorkDispatcher::~WorkDispatcher() /home/danmcgarry/local/open_source_projects/USD_release/build/inst/lib/libusd_hd.so(+0x265983) [0x7f523fcb1983] tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, long) pxrInternal_v0_21__pxrReserved__::HdRenderIndex::SyncAll(std::vector<std::shared_ptr<pxrInternal_v0_21__pxrReserved__::HdTask>, std::allocator<std::shared_ptr<pxrInternal_v0_21__pxrReserved__::HdTask> > >*, std::unordered_map<pxrInternal_v0_21__pxrReserved__::TfToken, pxrInternal_v0_21__pxrReserved__::VtValue, pxrInternal_v0_21__pxrReserved__::TfToken::HashFunctor, std::equal_to<pxrInternal_v0_21__pxrReserved__::TfToken>, std::allocator<std::pair<pxrInternal_v0_21__pxrReserved__::TfToken const, pxrInternal_v0_21__pxrReserved__::VtValue> > >*) pxrInternal_v0_21__pxrReserved__::HdEngine::Execute(pxrInternal_v0_21__pxrReserved__::HdRenderIndex*, std::vector<std::shared_ptr<pxrInternal_v0_21__pxrReserved__::HdTask>, std::allocator<std::shared_ptr<pxrInternal_v0_21__pxrReserved__::HdTask> > >*) pxrInternal_v0_21__pxrReserved__::ProxyRenderDelegate::_Execute(Autodesk::Maya::OpenMaya20220000::MHWRender::MFrameContext const&) pxrInternal_v0_21__pxrReserved__::ProxyRenderDelegate::update(Autodesk::Maya::OpenMaya20220000::MHWRender::MSubSceneContainer&, Autodesk::Maya::OpenMaya20220000::MHWRender::MFrameContext const&) /dist/sw/maya/2022.update2/lib2/libOpenMayaRender.so(+0xdbdef) [0x7f533c5a6def] OGSSubSceneItem::update() OGSMayaSubSceneManager::UpdateAllSubScenes() /dist/sw/maya/2022.update2/lib/libOGSMayaBridge.so(+0x1f0eaf) [0x7f53881a4eaf] /dist/sw/maya/2022.update2/lib/libOGSMayaBridge.so(+0x1f06e7) [0x7f53881a46e7] OGSApplicationBridge::UpdateScene(OGSApplicationUpdateCallback*) OGSMayaRenderer::updateScene(OGSApplicationUpdateCallback*, bool*) OGSMayaBaseRenderer::performSceneRender(OGSMayaSceneOperation*, bool*) TplayblastOGSBridge::grabPixels(unsigned char*&, float*&) /dist/sw/maya/2022.update2/lib/libAnimUISlice.so(+0x1c8094) [0x7f533be55094]

@williamkrick
Copy link
Contributor Author

@dj-mcg I'm able to reproduce the crash too with USD 21.11. I had tried to run the test but I can see from my log I ran with 21.08 twice. I'll dig into it, thanks!

@williamkrick
Copy link
Contributor Author

@dj-mcg the crash is caused by an issue I am not sure how to solve. In HdVP2Mesh::Sync() we're casting the HdSceneDelegate* parameter into a UsdImagingDelegate to be able to call ConvertCachePathToIndexPath. In USD 21.11 I can see that the type of the HdSceneDelegate has changed to HdSceneIndexAdapterSceneDelegate. HdSceneIndexAdapterSceneDelegate has a list of HdSceneDelegates in it, and one of those is the UsdImagingDelegate. I don't see any interface on HdSCeneIndexAdapterSceneDelegate for me to access the HdSceneDelegates it holds, so I think I'm not going to be able to get a UsdImagingDelegate anymore.

Okay, why do I need to call ConvertCachePathToIndexPath? In HdVP2Mesh we collect all the materials for the rprim to build the full set of geometry requirements necessary to draw. When we call HdRprim::GetMaterialId(), the returned SdfPath is an index path that can be passed into renderIndex.GetSprim(), which allows me to access the material required primvars. The problem comes with geom subsets. I access the geom subsets through the HdMeshTopology, and the materialIds stored there are cache paths. So I have to convert them to index paths before calling renderIndex.GetSprim(), so I need the UsdImagingDelegate.

With the debugger attached I can see that the path in the material id is still a cache path, and that the render index holds a map based on the index path, so simply avoiding the call is not going to work.

Is there any other way for me to get an index path to the geom subset material id? Or another way for me to get the UsdImagingDelegate? Maybe HdSceneIndexAdapterSceneDelegate::GetMeshTopology can convert the cache paths to index paths when it builds the topology?

@williamkrick
Copy link
Contributor Author

Tracing thought HdStMesh on how it supports geom subsets I eventually got to PrimUtils.pp HdStGetMaterialNetworkShader, which appears to be passing the cache path into renderIndex directly. But when I open a scene with geom subsets like fender_stratocaster.usdz from the AR kit I see all the geom subset materials. So clearly I am missing something.

@williamkrick
Copy link
Contributor Author

In UsdView the render index holds cache paths for sprims! That means it can loop up the geom subset materials directly, without having to convert to index paths.

UsdImagingIndexProxy::InsertSprim converts the cache path to an index path before calling HdRenderIndex::InsertSprim. It makes a call to ConvertCachePathToIndexPath. When I run in MayaUSD, _cache2indexPath maps /fender_stratocaster/Looks/pxrUsdPreviewSurface1SG to /Proxy_Fender_stratocasterShape_000001CDB4092FC0/fender_stratocaster/StratocasterStand. When I run in UsdView _cache2indexPath maps /fender_stratocaster/Looks/pxrUsdPreviewSurface10SG to /fender_stratocaster/Looks/pxrUsdPreviewSurface10SG! The cache path and the index path are the same!?!

Ah I see. GetDelegateId() returns empty for usdImaging and so the cache path and index path always match! Maybe I can do that too. Or maybe I can write my own ConvertCachePathToIndexPath given that I know the results of GetDelegateId.

dj-mcg
dj-mcg previously approved these changes Nov 18, 2021
Copy link
Collaborator

@dj-mcg dj-mcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and fixes the issue for us! Thanks!

@williamkrick
Copy link
Contributor Author

I logged PixarAnimationStudios/OpenUSD#1687 for the cache path index path mismatch in HdStMesh.

… Create a different back door for us to access the imaging delegate again, so that sub geom material ids can be converted from cache paths to index paths.
@williamkrick williamkrick requested a review from dj-mcg November 22, 2021 13:58
@williamkrick
Copy link
Contributor Author

The new commit uses a different back door to access the UsdImagingDelegate to work around the sub geom material Id issue.

@williamkrick williamkrick added the ready-for-merge Development process is finished, PR is ready for merge label Nov 23, 2021
@kxl-adsk kxl-adsk merged commit b3b5639 into dev Nov 23, 2021
@kxl-adsk kxl-adsk deleted the krickw/MAYA-114247/when_selection_changes_mark_changed_prims_dirty branch November 23, 2021 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MAYA-114247] Selection Highlight doesn't update when changing selection with USD 21.11
5 participants