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

EMSUSD-59 make error messages more clear #3310

Merged
merged 1 commit into from
Sep 6, 2023
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
84 changes: 58 additions & 26 deletions lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2242,27 +2242,35 @@ void HdVP2Mesh::_UpdateDrawItem(
MHWRender::MVertexBufferArray vertexBuffers;

std::set<TfToken> 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<MHWRender::MVertexBuffer*>(
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<MHWRender::MVertexBuffer*>(
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);
Expand All @@ -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!
Expand All @@ -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());
}
}
}

Expand All @@ -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) {
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down