-
Notifications
You must be signed in to change notification settings - Fork 203
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
VP2RenderDelegate support for USD curves #228
Conversation
Usability Tests ( conducted in Windows 10, latest maya beta with VS2017 for compiler, and this PR merged with latest dev branch commits ) :
Christopher |
@mattyjams Will you have time to review this PR please? If not, I can remove you from reviewers because William and Krystian has reviewed it. Thanks. |
The displayColor now seems to come through. Sorry, can't share the data set publically, but wanted to mention the issue. Thanks! Christopher |
@cfmoore007 Thanks for testing. Could you log the instanced curve issue please? I need to switch to some other task at the moment and in the meantime I will also collect all feedbacks about curve before further planning. Appreciated your help and test scenes. |
@kxl-adsk Ready to merge. |
@cfmoore007 I wonder how to make it more visible that there was validation done by BlueSky. Maybe I can just set you as a reviewer and once you are happy with your testing you approve it? |
@kxl-adsk - we tested on our own data set in house. I just tested if it was visible in the viewport, looked 'roughly correct' ( we did not do direct before/after, point by point analysis ), and selection. Still have to test manipulation ( will try that later this evening ) As for visual example - we'll work on a simple example for both this, and the instanced selection problem that we can share here. |
BasisCurves Example : Tests conducted :
|
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.
Approving based on internal testing.
int curveIndex = 0; | ||
TF_FOR_ALL(itCounts, vertexCounts) { | ||
for(int i = 0; i < *itCounts; i+= 2) { | ||
indices.push_back(GfVec2i(vertexIndex, vertexIndex + 1)); |
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.
indices.emplace_back(vertexIndex, vertexIndex + 1);
However that is still a pretty terrible way to populate an array :(
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.
The utility functions are copied from HdSt:
I think the code can be kept the same for now and when we need to make necessary change to these functions we can then refine them.
v0 = v1; | ||
} | ||
if(wrap) { | ||
indices.push_back(GfVec2i(v0, firstVert)); |
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.
indices.emplace_back(v0, firstVert);
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.
The utility functions are copied from HdSt:
I think the code can be kept the same for now and when we need to make necessary change to these functions we can then refine them.
indices.push_back(GfVec2i(v0, v1)); | ||
} | ||
v0 = v1; | ||
} |
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.
This for loop is pretty unpleasant. For a start, if you are testing skipFirstAndLastSegs on every single iteration, and that was set prior to the first loop, then please move the condition outside the loop, e.g.
if(skipFirstAndLastSegs)
{
// loop that skips first and last seg
TF_FOR_ALL(itCounts, vertexCounts) {}
}
else
{
// loop that does the opposite.
TF_FOR_ALL(itCounts, vertexCounts) {}
}
and then tidy up the inner loop a little.
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.
The utility functions are copied from HdSt:
I think the code can be kept the same for now and when we need to make necessary change to these functions we can then refine them.
} | ||
v0 = v1; | ||
} | ||
if(wrap) { |
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.
again, testing exactly the same boolean value each iteration within a loop. Send a bit of love to the branch predictor, and move the condition above the loop.
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.
The utility functions are copied from HdSt:
I think the code can be kept the same for now and when we need to make necessary change to these functions we can then refine them.
// Store first vert index incase we are wrapping | ||
const int firstVert = v0; | ||
++ vertexIndex; | ||
for(int i = 1;i < *itCounts; ++i) { |
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.
Please don't dereference an iterator as the terminating condition of a loop. The var exists outside the scope of this method, so now the optimiser will fail to apply any loop optimisations. Take a local copy of the value and use that instead.
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.
The utility functions are copied from HdSt:
I think the code can be kept the same for now and when we need to make necessary change to these functions we can then refine them.
MHWRender::MShaderInstance* _shader{ nullptr }; | ||
|
||
//! Is this object transparent | ||
bool _isTransparent{ false }; |
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.
Move this boolean to be last in the struct. Will avoid 7 bytes of pointless padding.
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.
Fixed with f13a3e1.
const VtArray<int> vertexCounts = topology.GetCurveVertexCounts(); | ||
bool wrap = topology.GetCurveWrap() == HdTokens->periodic; | ||
int vStep; | ||
TfToken basis = topology.GetCurveBasis(); |
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.
const?
std::vector<GfVec4i> indices; | ||
|
||
const VtArray<int> vertexCounts = topology.GetCurveVertexCounts(); | ||
bool wrap = topology.GetCurveWrap() == HdTokens->periodic; |
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.
const?
for(int i = 1;i < *itCounts; ++i) { | ||
v1 = vertexIndex; | ||
++ vertexIndex; | ||
if (!skipFirstAndLastSegs || (i > 1 && i < (*itCounts)-1)) { |
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.
Why are you looping from 1 to *itCounts, and then checking to see if i is in a different range?
doThingWhen(i == 0);
doThingWhen(i == 1);
for(int i = 2, n = *itCounts - 1; i < n; ++i)
{
indices.emplace_back(v0, v1);
}
doThingWhen(i == *itCounts - 1);
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.
It is from HdSt.
v1 = vertexIndex; | ||
++ vertexIndex; | ||
if (!skipFirstAndLastSegs || (i > 1 && i < (*itCounts)-1)) { | ||
indices.push_back(GfVec2i(v0, v1)); |
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.
indices.emplace_back(v0, v1);
Although if you can resize indices to the correct size up front, this code would be an order of magnitude faster than using emplace_back here.
* Reduce unnecessary byte alignment padding. * Reduce unnecessary allocation/deallocation. * More efficient matrix math.
Summary on the good discussion with @robthebloke #228 (comment): About avoiding code dependency or duplication with HdSt, I've discussed with George Elkoura in usd interest group and logged issue PixarAnimationStudios/OpenUSD#1112, which requires to factor out common geometry processing codes from HdSt to a common library and allows other render delegates to link to it. At this point, I don't think it is worthy for us to refine our duplicated code. @kxl-adsk Could we merge this PR please? |
This PR implements the VP2RenderDelegate support for USD curves, as well as some derisking work on tessellation shader approach for curve refinements.
The refactoring change to HdVP2Mesh and HdVP2DrawItem is necessary because the draw item should not be tied with mesh and should be Rprim type agnostic.