-
Notifications
You must be signed in to change notification settings - Fork 407
Use implementation name for OSO #2681
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
Use implementation name for OSO #2681
Conversation
The OSO really is the genoslnetwork implementation - so it makes sense to use that name as the naming structure has already been validated for the genosl generator. To access the implementation we need to change the document caching strategy. We cache the implementation elements in all cases - and only indirect to a nodegraph if present during code generation. If we can measure a performance difference here, then we can add additional caching in the shader generator, but i suspect it won't be measurable under normal circumstances.
ashwinbhat
left a comment
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 looks good to me. The part I'm a little unclear about is how do we handle type based implementations. Does implmentationMap have that data?
|
I actually want to tag @sdromero01 who recently posted this issue. I still stand by this PR and think we should name the OSOs after the corresponding implementation elements, but if people need to retain the ability to control the name of the OSO - I think we could retain that in the tool, if necessary. Let's give it a few more days for them to weigh in before merging. |
|
Hi! thanks for tagging me. I admit I'm not familiar with the implementation naming structure. Could you elaborate on how the generated OSL shaders would be named? Did you mean similar to how the functions in the monolithic OSL shaders made by generateshader.py were named? Currently I'm just using the OSL shader network generator to create OSL shaders with the |
|
As an example here are a few different implementation names
Actually looking more closely at this list,i see the logic I'm using to isn't quite right - so I'll fix that up. But the idea here is to take the I do see the appeal of being able to generate OSOs that match the The reason I'd like the I think maybe the right middle ground here support exporting the OSOs as either name. |
|
I updated the tool so it can emit the OSOs named after the |
source/MaterialXGenOsl/LibsToOso.cpp
Outdated
| i++; | ||
| } | ||
|
|
||
| bool osoNameStrategy_implementation = true; |
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 variable name looks pretty unusual, with a mix of camel case and snake case! Is there a motivation for the unique naming convention?
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.
open to alternatives here...
I'm just remapping a string based enum from the command line args - to allow for future expansion of the public interface - to a more efficient boolean.
I thought the name helped to make it clear that which of the current list of two values we're using for the enum.
In the future if we expand the public command line arg options - then we would need to refactor this internally.
The _ character visually helps separate the variable from its corresponding enumeration value
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.
Since this variable is only referenced once in the code that follows, what would you think of replacing the single variable reference with argOsoNameStrategy == "implementation", which reads clearly on its own?
If a new variable is ultimately needed here, then I'd suggest a camel case name along the lines of osoNameStrategyIsImpl, but given the context, it seems more straightforward just to omit the variable.
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 thought we would prefer to store the result - instead of doing the string comparison inside the loop - but if thats your preference I can make that change. Ultimately we just need to be able to support both modes in a forward looking way.
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's completely up to you, and although this doesn't seem like a big optimization opportunity, it's fine to create the new camel-case variable if you prefer.
source/MaterialXGenOsl/LibsToOso.cpp
Outdated
| } | ||
| else | ||
| { | ||
| // name the node the same as the node definition |
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.
Minor note: Ideally these new comments should start with a capital letter, mirroring the coding style elsewhere in this source file.
jstone-lucasfilm
left a comment
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 looks good to me, thanks @ld-kerley!
efd5fe5
into
AcademySoftwareFoundation:main
|
@ld-kerley , I've logged a regression issue as your change breaks functionality. |
|
replied in your issue... |
Use implementation name when creating the OSO for OSL Network generator.
The OSO really is the genoslnetwork implementation - so it makes sense to use that name as the naming structure has already been validated for the genosl generator.
To access the implementation we need to change the document caching strategy. We cache the implementation elements in all cases - and only indirect to a nodegraph if present during code generation. If we can measure a performance difference here, then we can add additional caching in the shader generator, but i suspect it won't be measurable under normal circumstances.