-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add type information for needed attributes. #1650
Add type information for needed attributes. #1650
Conversation
|
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.
LGTM.
Looks like there are a few formatting issues to fix (look at the logs of the failed clang-format test), and also needs a DCO message attached to the commit. But the code LGTM. |
@curtisblack Ping! -- can you please push an update with the DCO and fixed formatting so I can merge this in time for the monthly patch release this week? |
Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
34872ba
to
3f08988
Compare
Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
…ck/OpenShadingLanguage into getattribute_type_info
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.
LGTM, thanks for fixing.
…n#1650) We can currently query which attribute names and scopes are requested in a shader. This PR extends that idea to also allow querying the attribute types. This now more closely matches the equivalent available queries for user data. For example, this shader: ``` shader Shader { color c; getattribute("user_color", c); string s; getattribute("user_string", s); } ``` allows us to do this: ``` int nattr = 0; if (shadingSys->getattribute(shaderRef.get(), "num_attributes_needed", nattr) && nattr) { // this already works OIIO::ustring* names = nullptr; shadingSys->getattribute(shaderRef.get(), "attributes_needed", OSL::TypeDesc::PTR, &names); // this is the added feature OIIO::TypeDesc* types = nullptr; shadingSys->getattribute(shaderRef.get(), "attribute_types", OSL::TypeDesc::PTR, &types); // nattr: 2 // names: ["user_color", "user_string"] // types: [OIIO::TypeColor, OIIO::TypeString] } ``` The motivation behind this feature is to perform additional type validation at material compile time when determining what primvars can be provided to the shader. One side-effect of this change to be aware of is that, as mentioned in the code comments, if the same name is requested multiple times with different types, it will now be reported multiple times. Hopefully this is not too much of an issue as the same behaviour also occurs when an attribute is requested in multiple scopes, or when user data is requested with multiple types. Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
* Don't insert redundant run layer calls inside a basic block (AcademySoftwareFoundation#1665) * Apply recent run layer call optimization to batched execution (AcademySoftwareFoundation#1669) * Do-over: Make recent run-layer optimizations optional, and fix init ops-related false positive (AcademySoftwareFoundation#1672) * fix for ReParameterization corner case (AcademySoftwareFoundation#1670) * RendererServices API for letting get_texture_handle consider colorspace (AcademySoftwareFoundation#1641) * Set up ray types for testrender (AcademySoftwareFoundation#1648) * testrender: Don't use the cached background map on the first bounce (AcademySoftwareFoundation#1649) * Switch lockgeom to interpolated and interactive (AcademySoftwareFoundation#1662) * Add type information for needed attributes. (AcademySoftwareFoundation#1650) Note that this bump to 1.13.3.x is only for Arnold at this point, and not yet for the platforms, so to make CI go faster I have rigged .spdev.yaml to only build the sparnold versions at this time. Also updated ABI dump files. See merge request spi/dev/3rd-party/osl-feedstock!47
Description
We can currently query which attribute names and scopes are requested in a shader. This PR extends that idea to also allow querying the attribute types. This now more closely matches the equivalent available queries for user data.
For example, this shader:
allows us to do this:
The motivation behind this feature is to perform additional type validation at material compile time when determining what primvars can be provided to the shader.
One side-effect of this change to be aware of is that, as mentioned in the code comments, if the same name is requested multiple times with different types, it will now be reported multiple times. Hopefully this is not too much of an issue as the same behaviour also occurs when an attribute is requested in multiple scopes, or when user data is requested with multiple types.
Tests
I wasn't able to find any existing unit tests for the "attributes_needed" feature to use as a starting point, if they do already exist please let me know and I can make those changes. I did see a spot in testshade where it seemed appropriate to add a usage of this feature.
Checklist: