-
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
Fix up mtoh initialization to not create entries for invalid delagates. #292
Conversation
@marsupial Thank you for contributing to maya-usd! I believe this is your first contribution. Can you introduce yourself and/or let me know if you signed the CLA? |
@marsupial is covered by the CLA already signed by Sony Pictures Imageworks. |
@lgritz Perfect, thank you. |
Hi - so, making sure we only create overrides for renderDelegates that "work" totally makes sense - thanks for the PR! However, the logic here becomes a bit more opaque than I'd like. Why do we need to generalize Also, moving the initialization of the renderer descriptions, and registering of the overrides, from Ideally, I think the way I'd like to see this tackled would be to:
The main downside I can see to this approach is that we'd be creating plugins/delegates twice - once to verify they can be made, and then once when Do you think this would work? |
My pleasure...and sorry I didn't respond (but as usual Larry was right on all points!) On the first point I would say, no. Printing some message about failure, sure. But if they failed to load, they should not be accessible in any way, (more details below). On the second, I'm in no way tied to the logic of this, there was just quite a bit of spaghetti to unwind to make it all work, and this was the easiest/fastest way to stop Maya from crashing while trying to preserve the const-ness of the singletons. On how the first ties into the second, and "The main downside I can see to this approach is that we'd be creating plugins/delegates twice", there is a big problem here lurking in the USD plugin-factory system, where failure to load a plugin because dlopen failed, actually creates a very bad state for USD, so you really wanna honor first-time failure is the state you have to operate in. |
I agree that if there's a load failure (either in creating the plugin or delegate), that renderer should never be used (or tried) again. Basically, I was thinking that the pseudologic for
Since
So, as I mentioned again, plugins that FAIL would never be created or tried again. So first-time failure would be honored. Only ones that SUCCEED would potentially get re-created again. Do you think that would potentially be a problem? |
63b5644
to
58f8dad
Compare
Updated to remove the lambdas. There still is an odd patter returning the render-descriptions, which then gets handed off to MtohInitializeRenderGlobals, but with 22.05 there's likely going to have to be more state tracked at the plugin/application level, so keeping it all in one place seems like a win. |
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.
I like the overall approach you've taken here, of essentially caching both the descriptions and settings inside of a single initialization function - ie, MtohInitializeRenderPlugins. This allows us to not have to worry about creating and plugins or delegates twice, without the need for a callback - and also allows us to do some more cleanup of the renderDelegate, which I noticed you added.. thanks!
However, I think this approach can allow for even more streamlining and simplification:
- We're now effectively caching the settings twice - once as a list, in the second member of the static
Storage
inMtohInitializeRenderPlugins
, and once as a dict, in the_rendererAttributes
private global, inrenderGlobals.cpp
. Let's eliminate the need for the second cache,_rendererAttributes
, by having that be created and cached directly byMtohInitializeRenderPlugins
, instead of a simple list. - Then, we just need to add a new function to return a ref to this settings dict - say,
MtohGetRendererSettings
? - that is similar to your implementation ofMtohGetRendererDescriptions
- it just returns the second element ofMtohInitializeRenderPlugins
. - Once we have both
MtohGetRendererDescriptions
andMtohGetRendererSettings
, then we don't need to publicly exposeMtohInitializeRenderPlugins
, and can make it private toutils.cpp
. The fact that both of these are created + cached at the same time is an implementation detail which outsiders don't need to know about.
This overall approach will eliminate the need to return a pair, the second of which we have to caution users not to "use", and generally simplify the outward interface.
Does this make sense? Looking back at that, it's a bit of a wall of text, so if it's confusing, I can just make a commit containing my proposed changes, and show rather than tell.
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 delete the MRenderOverride pointer until it is deregistered.
@marsupial - splitting this discussion out into it's own conversation, for clarity:
Well... there's one valid cache, true. But the old list is still there, just unuseable, and will still be returned by
Hmm... as long as we make the other map accessible (via returning a reference from a new |
Great improvements since the first commit in this PR! I haven't followed very closely all the discussions, what's left to do? (@marsupial @elrond79) |
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.
Awesome, this looks great!
Only one substantive issue left - you removed the implementation and usage of MtohGetRendererPlugins
, but forgot to remove the declaration in the .h!
Otherwise, just noticed one minor style typo (a missing blank line)... and would ideally like to see a comment re: the usage of the unique_ptr
to protect against errors from registerOverride
, as discussed here. But neither of those are enough to block merging by themselves.
Updated. |
We don’t squash on merge in case someone cares about commit/s sha and to potentially prevent duplication for downstream branches.
This is our general rule, but you are free to do it and force push.
|
Actually, I believe there are open PRs dependent on this PR? Then probably you don’t want to squash (or other PRs may need to be redone)
|
I think the other two PR's will conflict after this no matter what (but both should be trivial to resolve). |
Indeed, they will conflict. |
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.
Looks good!
…I_changes MAYA-125923: remove unused getShaderName code
Initialization of the Hydra delegates is a bit awkward and can ultimately lead to invalid entries in the menu. Selecting an -invalid- delegate can wind up crashing depending on what & why they failed.