-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type information for needed attributes. (#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 <[email protected]>
- Loading branch information
1 parent
5c1617f
commit 35aa264
Showing
5 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters