From 0dc364cd75e6abe8a0b271d80f1df138df7e0d54 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Wed, 6 Sep 2023 11:24:13 -0400 Subject: [PATCH] EMSUSD-59 make error messages more clear Some error checking logging was confusing for the user. Some failures were reported as the cryptic: "Failed verification: ' result == MStatus::kSuccess '". This leads users to think we are reporting a success. (Technically we were reporting failure to succeed, but the message was worded confusingly.) Change those failure verification messages to use explicit warning messages instead. This provides clearer failure diagnostics. --- lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 84 +++++++++++++------ .../vp2RenderDelegate/proxyRenderDelegate.cpp | 4 +- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index 1d6b78340d..83780111fc 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2242,27 +2242,35 @@ void HdVP2Mesh::_UpdateDrawItem( MHWRender::MVertexBufferArray vertexBuffers; std::set addedPrimvars; - auto addPrimvar = - [primvarInfo, &vertexBuffers, &addedPrimvars, isBBoxItem, &sharedBBoxGeom]( - const TfToken& p) { - auto entry = primvarInfo->find(p); - if (entry == primvarInfo->cend()) { - // No primvar by that name. - return; - } - MHWRender::MVertexBuffer* primvarBuffer = nullptr; - if (isBBoxItem && p == HdTokens->points) { - primvarBuffer = const_cast( - sharedBBoxGeom.GetPositionBuffer()); - } else { - primvarBuffer = entry->second->_buffer.get(); - } - if (primvarBuffer) { // this filters out the separate color & alpha entries - MStatus result = vertexBuffers.addBuffer(p.GetText(), primvarBuffer); - TF_VERIFY(result == MStatus::kSuccess); + auto addPrimvar = [primvarInfo, + &vertexBuffers, + &addedPrimvars, + isBBoxItem, + &sharedBBoxGeom, + &renderItem](const TfToken& p) { + auto entry = primvarInfo->find(p); + if (entry == primvarInfo->cend()) { + // No primvar by that name. + return; + } + MHWRender::MVertexBuffer* primvarBuffer = nullptr; + if (isBBoxItem && p == HdTokens->points) { + primvarBuffer = const_cast( + sharedBBoxGeom.GetPositionBuffer()); + } else { + primvarBuffer = entry->second->_buffer.get(); + } + if (primvarBuffer) { // this filters out the separate color & alpha entries + MStatus result = vertexBuffers.addBuffer(p.GetText(), primvarBuffer); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not create primvar [%s] buffer for [%s].", + p.GetText(), + renderItem->name().asChar()); } - addedPrimvars.insert(p); - }; + } + addedPrimvars.insert(p); + }; // Points and normals always are at the beginning of vertex requirements: addPrimvar(HdTokens->points); @@ -2288,7 +2296,11 @@ void HdVP2Mesh::_UpdateDrawItem( // - Trigger consolidation/instancing update. result = drawScene.setGeometryForRenderItem( *renderItem, vertexBuffers, *indexBuffer, stateToCommit._boundingBox); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not create OGS geometry for [%s], maybe it has no geometry?", + renderItem->name().asChar()); + } } // Important, update instance transforms after setting geometry on render items! @@ -2306,12 +2318,20 @@ void HdVP2Mesh::_UpdateDrawItem( // VP2 defines instance ID of the first instance to be 1. result = drawScene.updateInstanceTransform( *renderItem, i + 1, (*stateToCommit._instanceTransforms)[i]); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not update the instance transform for [%s].", + renderItem->name().asChar()); + } } } else { result = drawScene.setInstanceTransformArray( *renderItem, *stateToCommit._instanceTransforms); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not update the instance transform for [%s].", + renderItem->name().asChar()); + } } } @@ -2323,13 +2343,21 @@ void HdVP2Mesh::_UpdateDrawItem( *renderItem, stateToCommit._instanceColorParam, *stateToCommit._instanceColors); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not set the instance color for [%s].", + renderItem->name().asChar()); + } } } else if (newInstanceCount >= 1) { if (stateToCommit._instanceTransforms) { result = drawScene.setInstanceTransformArray( *renderItem, *stateToCommit._instanceTransforms); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not update the instance transform for [%s].", + renderItem->name().asChar()); + } } if (stateToCommit._instanceColors && stateToCommit._instanceColors->length() > 0) { @@ -2340,7 +2368,11 @@ void HdVP2Mesh::_UpdateDrawItem( *renderItem, stateToCommit._instanceColorParam, *stateToCommit._instanceColors); - TF_VERIFY(result == MStatus::kSuccess); + if (result != MStatus::kSuccess) { + TF_WARN( + "Could not set the instance color for [%s].", + renderItem->name().asChar()); + } } stateToCommit._renderItemData._usingInstancedDraw = true; diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index ef719ff369..e633349e64 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -1228,7 +1228,9 @@ void ProxyRenderDelegate::update(MSubSceneContainer& container, const MFrameCont if (selectionInfo) { bool oldSnapToSelectedObjects = _snapToSelectedObjects; _snapToSelectedObjects = selectionInfo->snapToActive(&status); - TF_VERIFY(status == MStatus::kSuccess); + if (status != MStatus::kSuccess) { + TF_WARN("Could not snap selected object."); + } if (_snapToSelectedObjects != oldSnapToSelectedObjects) { _selectionModeChanged = true; }