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

MAYA-112834 Make sure that the render item name stored in HdVP2DrawItem exactly … #1597

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/mayaUsd/render/vp2RenderDelegate/draw_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ HdVP2DrawItem::~HdVP2DrawItem()
MSubSceneContainer* subSceneContainer = param ? param->GetContainer() : nullptr;
if (subSceneContainer) {
for (const auto& renderItemData : _renderItems) {
subSceneContainer->remove(renderItemData._renderItemName);
TF_VERIFY(renderItemData._renderItemName == renderItemData._renderItem->name());
subSceneContainer->remove(renderItemData._renderItem->name());
}
}
}
Expand All @@ -57,15 +58,15 @@ HdVP2DrawItem::~HdVP2DrawItem()
HdVP2DrawItem::RenderItemData&
HdVP2DrawItem::AddRenderItem(MHWRender::MRenderItem* item, const HdGeomSubset* geomSubset)
{
TF_VERIFY(item);

_renderItems.emplace_back();
RenderItemData& renderItemData = _renderItems.back();

renderItemData._renderItem = item;
renderItemData._renderItemName = _drawItemName;
renderItemData._renderItemName = item->name();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name stored in the _renderItemData must exactly match the name of the MRenderItem. We use the name to remove the item from the subscene container. If the names do not match we'll leak items into the container and forget about them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I changed the code a bit more so that we don't rely on _renderItemName. That member is meant for debugging only.

if (geomSubset) {
renderItemData._geomSubset = *geomSubset;
renderItemData._renderItemName += std::string(1, VP2_RENDER_DELEGATE_SEPARATOR).c_str();
renderItemData._renderItemName += geomSubset->id.GetString().c_str();
}

renderItemData._indexBuffer.reset(
Expand Down
8 changes: 7 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,8 +2671,14 @@ HdVP2DrawItem::RenderItemData& HdVP2Mesh::_CreateSmoothHullRenderItem(
MSubSceneContainer& subSceneContainer,
const HdGeomSubset* geomSubset) const
{
MString itemName = name;
if (geomSubset) {
itemName += std::string(1, VP2_RENDER_DELEGATE_SEPARATOR).c_str();
itemName += geomSubset->id.GetString().c_str();
}

MHWRender::MRenderItem* const renderItem = MHWRender::MRenderItem::Create(
name, MHWRender::MRenderItem::MaterialSceneItem, MHWRender::MGeometry::kTriangles);
itemName, MHWRender::MRenderItem::MaterialSceneItem, MHWRender::MGeometry::kTriangles);

constexpr MHWRender::MGeometry::DrawMode drawMode = static_cast<MHWRender::MGeometry::DrawMode>(
MHWRender::MGeometry::kShaded | MHWRender::MGeometry::kTextured);
Expand Down