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

ensure that GL is initialized when mtoh creates the Storm render delegate #1007

Conversation

mattyjams
Copy link
Contributor

I'm not sure how others aren't running into this, but we're seeing all of the newly added mtoh tests crashing because GL/GLEW isn't fully initialized at the point where it discovers the Storm renderer plugin and tries to call GlfContextCaps::InitInstance().

Prior to core USD 21.02, this was handled by calling GlfGlewInit(), but from 21.02 on, the GLEW dependency has been removed, and GarchGLApiLoad() is used instead.

The same pattern of calling GlfGlewInit()/GarchGLApiLoad() before calling GlfContextCaps::InitInstance() can be seen in some of the unit tests in core USD, for example:
https://github.com/PixarAnimationStudios/USD/blob/e9172af0ccea9896990f5ac093c3d6063ac7cab5/pxr/imaging/hdSt/unitTestGLDrawing.cpp#L94

…gate

For core USD prior to 21.02, this is done by initializing GLEW, but for 21.02
and later where the GLEW dependency has been removed, we instead call
GarchGLApiLoad().
@mattyjams mattyjams added the mtoh Related to legacy Maya to Hydra plugin. label Dec 15, 2020
Comment on lines +19 to +21
// We also disable clang-format for this block, since otherwise v10.0.0 fails
// to recognize that "utils.h" is the related header.
// clang-format off
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another clang-format oddity here, but when I added this block of includes and the conditional, clang-format v10.0.0 starts failing to recognize that "utils.h" is the related header for this cpp file, and it tries to put it at the bottom of the "private" header group at line 32. I opted to disable clang-format here rather than absorb that change.

Choose a reason for hiding this comment

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

Do you happen to know if v11.0.0 will has it fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you happen to know if v11.0.0 will has it fixed?

I just built clang v11.0.0 and gave it a try (using the current configuration) and I get the same results. It seems to get tripped up by the conditional that wraps the glew.h #include. If I remove the #if/#else, it correctly figures out that utils.h should stay where it is, just after glew.h but before the other "local" headers.

Comment on lines +39 to +41
#if USD_VERSION_NUM >= 2102
#include <pxr/imaging/garch/glApi.h>
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike GLEW, this garch include does not need to come first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a follow-up chat with the Hydra team about this. They were saying that the newly added GL loader doesn't break the way glew.h does if it's not #include'd first, it's probably still good practice to include it early. I've got a new PR coming shortly with a bunch more instances of this, so I'll revisit this one as part of those changes. I'll also amend the clang-format config so that it includes both glew.h and glApi.h in the first group.

The Hydra team also just made a change to GlfContextCaps::InitInstance() so that it calls GarchGLApiLoad() itself, so we'd then be able to remove the call I had to add here for core USD 21.02+.

Copy link
Contributor

@pmolodo pmolodo left a comment

Choose a reason for hiding this comment

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

Hmm... well, note sure why @mattyjams was encountering this, and I didn't. (Nor Hamed or the pre-flight tests...) However, since it should be fine to call GlfGlewInit more than once, this looks good / makes sense to me.

@kxl-adsk kxl-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Dec 16, 2020
@kxl-adsk
Copy link

Apologies @mattyjams, this somehow pass undetected in our pre-merge validation. I tested again, and you are correct that dev was broken with dev post 20.11.

@kxl-adsk kxl-adsk merged commit 51d22f0 into Autodesk:dev Dec 16, 2020
@mattyjams mattyjams deleted the pr/ensure_GL_is_initialized_when_mtoh_creates_Storm_delegate branch December 16, 2020 16:50
mattyjams added a commit to mattyjams/maya-usd that referenced this pull request Dec 22, 2020
…gate in mtoh

For core USD 21.02, GlfContextCaps::InitInstance() was updated to call
GarchGLApiLoad() itself in the following core USD commit:
PixarAnimationStudios/OpenUSD@4034139

As a result, the call to GarchGLApiLoad() that was added in Autodesk#1007, and the
accompanying include of glApi.h, were made redundant and are no longer
necessary. The call to GlfGlewInit() remains for earlier versions of core USD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mtoh Related to legacy Maya to Hydra plugin. ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants