-
Notifications
You must be signed in to change notification settings - Fork 13
HYDRA-1975 - fix aov sharing crash #345
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
Changes from all commits
5d20373
8802517
9a16062
a4271fe
f5bb82b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +1 −0 | include/hvt/engine/taskManager.h | |
| +16 −1 | source/engine/framePass.cpp | |
| +6 −1 | source/engine/renderBufferManager.cpp | |
| +10 −3 | source/engine/taskManager.cpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -679,9 +679,28 @@ TfTokenVector MtohRenderOverride::GetAvailableFramePassAovs(int passIndex) | |
| for (auto* instance : _allInstances) { | ||
| if (instance->_initializationSucceeded | ||
| && passIndex < static_cast<int>(instance->_framePassesData.size())) { | ||
| UsdImagingGLEngine engine( | ||
| instance->_hgiDriver, instance->_framePassesData[passIndex]->_rendererName); | ||
| auto currAovs = engine.GetRendererAovs(); | ||
| // Can't rely on UsdImagingGLEngine::GetRenderAovs() as creating a temp UsdImagingGLEngine with same hgi | ||
| // may interfere with the current renderer, just copy the same implementation here | ||
| TfTokenVector currAovs; | ||
| const auto renderIndex = instance->renderIndex(passIndex); | ||
| if (renderIndex && renderIndex->IsBprimTypeSupported(HdPrimTypeTokens->renderBuffer)) { | ||
|
|
||
| static const TfToken candidates[] = { HdAovTokens->primId, | ||
| HdAovTokens->depth, | ||
| HdAovTokens->normal, | ||
| #if PXR_VERSION > 2411 | ||
| HdAovTokens->Neye, | ||
| #endif | ||
| HdAovTokensMakePrimvar(TfToken("st")) }; | ||
|
|
||
| currAovs = { HdAovTokens->color }; | ||
| for (auto const& aov : candidates) { | ||
| if (renderIndex->GetRenderDelegate()->GetDefaultAovDescriptor(aov).format | ||
| != HdFormatInvalid) { | ||
| currAovs.push_back(aov); | ||
| } | ||
| } | ||
| } | ||
| aovs.insert(aovs.end(), currAovs.begin(), currAovs.end()); | ||
| } | ||
| } | ||
|
|
@@ -970,7 +989,7 @@ MStatus MtohRenderOverride::Render( | |
| const MIntArray& framePassesVisible = | ||
| MayaHydraSetVisibleFramePasses::getVisibleFramePasses(); | ||
| int numVisibleFramePasses = framePassesVisible.length(); | ||
| const MStringArray& visibleAOVNames = MayaHydraSetVisibleFramePasses::getAovNames(); | ||
| const MStringArray& visibleAOVNames = MayaHydraSetVisibleFramePasses::getAovNames(); | ||
| const int numFramePasses = _GetNumFramePasses(); | ||
| if (numVisibleFramePasses > numFramePasses) { | ||
| numVisibleFramePasses | ||
|
|
@@ -998,8 +1017,13 @@ MStatus MtohRenderOverride::Render( | |
| currentPass->params().enablePresentation = isLastVisiblePass; | ||
|
|
||
| // Set the AOV to visualize for the current pass if it exists | ||
| const TfToken aovName = TfToken(visibleAOVNames[visibleIdx].asChar()); | ||
| const bool aovNameExists = currentPass->GetRenderBuffer(aovName) != nullptr; | ||
| const TfToken aovName = TfToken(visibleAOVNames[visibleIdx].asChar()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is wrong in the sense that you only have hardcoded AOVs : But the render delegate , like Arnold, has some other AOVs available that the user may want to use for display. I don't think we should check in the visibleAOVs name if it exists sibnce this list is hardcoded.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same code used in UsdImagingGLEngine::GetRenderAovs() , yes, a better way is required in the future, before that, we have to copy that piece of code here as using UsdImagingGLEngine::GetRenderAovs() will affect the current rendering. |
||
| // Can't rely on GetRenderBuffer(aovName) here as the AOV may not have been created yet | ||
| const auto renderDelegate = _GetRenderDelegate(actualPassIndex); | ||
| const bool aovNameExists | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we are doing the same test as in visibleAOVNames, if it is in AOVNames then this will always be true since we tested for the same thing in MtohRenderOverride::GetAvailableFramePassAovs. But I don't think we should use this hardcoded list.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to validate if the AOV is supported by a renderer here, as user may specify a non-supported AOV by the commad and we didn't validate the user input.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok thanks. I was confused and thought we needed to have the diaplsy aov be part of the hardcoded list which is not the case. |
||
| = renderDelegate ? | ||
| renderDelegate->GetDefaultAovDescriptor(aovName).format != HdFormatInvalid | ||
| : false; | ||
| currentPass->params().visualizeAOV | ||
| = (aovNameExists) | ||
| ? aovName | ||
|
|
@@ -1031,12 +1055,18 @@ MStatus MtohRenderOverride::Render( | |
| const int previousPassIndex = (visibleIdx > 0) ?framePassesVisible[visibleIdx - 1] : 0; | ||
| hvt::FramePassPtr& previousPass = _GetFramePass(previousPassIndex); | ||
| if (previousPass) { | ||
| hvt::RenderBufferBindings inputAOVs = previousPass->GetRenderBufferBindingsForNextPass( | ||
| { PXR_NS::HdAovTokens->color, PXR_NS::HdAovTokens->depth } | ||
| ); | ||
|
|
||
| HdTaskSharedPtrVector passTasks = currentPass->GetRenderTasks(inputAOVs); | ||
|
|
||
| std::vector<TfToken> inputAOVs; | ||
| const auto& preVisualizedAOV = previousPass->params().visualizeAOV; | ||
| // If a non-color AOV was visualized previously, HVT expects to share only that one | ||
| if (preVisualizedAOV == HdAovTokens->color) { | ||
| inputAOVs = { HdAovTokens->color, HdAovTokens->depth }; | ||
| } | ||
| else { | ||
| inputAOVs = { preVisualizedAOV }; | ||
| } | ||
| const hvt::RenderBufferBindings aovBindings = previousPass->GetRenderBufferBindingsForNextPass(inputAOVs); | ||
| HdTaskSharedPtrVector passTasks = currentPass->GetRenderTasks(aovBindings); | ||
|
|
||
| /*Debug code left here if needed later | ||
| hvt::FramePass& framePassToDebug = *currentPass; | ||
| std::ostringstream content; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse same hgi/hgiDriver in a new engine may interfere with the existing engine